Detector = {
canvas: !!window.CanvasRenderingContext2D,
webgl: (function() {
try {
return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
} catch (e) {
return false;
}
})(),
workers: !!window.Worker,
fileapi: window.File && window.FileReader && window.FileList && window.Blob,
};
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = (function() {
return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback, element) {
window.setTimeout(callback, 1000 / 60);
};
})();
}
if (typeof JSON !== 'object') {
JSON = {};
}
(function() {
'use strict';
function f(n) {
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function(key) {
return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z' : null;
};
String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function(key) {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap, indent, meta = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"': '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
var c = meta[a];
return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
var i, k, v, length, mind = gap,
partial, value = holder[key];
if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
return String(value);
case 'object':
if (!value) {
return 'null';
}
gap += indent;
partial = [];
if (Object.prototype.toString.apply(value) === '[object Array]') {
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
gap = mind;
return v;
}
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function(value, replacer, space) {
var i;
gap = '';
indent = '';
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
} else if (typeof space === 'string') {
indent = space;
}
rep = replacer;
if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
return str('', {
'': value
});
};
}
if (typeof JSON.parse !== 'function') {
JSON.parse = function(text, reviver) {
var j;
function walk(holder, key) {
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function(a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
j = eval('(' + text + ')');
return typeof reviver === 'function' ? walk({
'': j
}, '') : j;
}
throw new SyntaxError('JSON.parse');
};
}
}());
var Stats = function() {
function w(d, K, n) {
var u, f, c;
for (f = 0; f < 30; f++)
for (u = 0; u < 73; u++) {
c = (u + f * 74) * 4;
d[c] = d[c + 4];
d[c + 1] = d[c + 5];
d[c + 2] = d[c + 6]
}
for (f = 0; f < 30; f++) {
c = (73 + f * 74) * 4;
if (f < K) {
d[c] = b[n].bg.r;
d[c + 1] = b[n].bg.g;
d[c + 2] = b[n].bg.b
} else {
d[c] = b[n].fg.r;
d[c + 1] = b[n].fg.g;
d[c + 2] = b[n].fg.b
}
}
}
var v = 0,
x = 2,
e, y = 0,
l = (new Date).getTime(),
J = l,
z = l,
o = 0,
A = 1E3,
B = 0,
m, g, a, p, C, q = 0,
D = 1E3,
E = 0,
h, i, r, F, s = 0,
G = 1E3,
H = 0,
j, k, t, I, b = {
fps: {
bg: {
r: 16,
g: 16,
b: 48
},
fg: {
r: 0,
g: 255,
b: 255
}
},
ms: {
bg: {
r: 16,
g: 48,
b: 16
},
fg: {
r: 0,
g: 255,
b: 0
}
},
mem: {
bg: {
r: 48,
g: 16,
b: 26
},
fg: {
r: 255,
g: 0,
b: 128
}
}
};
e = document.createElement("div");
e.style.cursor = "pointer";
e.style.width = "80px";
e.style.opacity = "0.9";
e.style.zIndex = "10001";
e.addEventListener("click", function() {
v++;
v == x && (v = 0);
m.style.display = "none";
h.style.display = "none";
j.style.display = "none";
switch (v) {
case 0:
m.style.display = "block";
break;
case 1:
h.style.display = "block";
break;
case 2:
j.style.display = "block"
}
}, false);
m = document.createElement("div");
m.style.backgroundColor = "rgb(" + Math.floor(b.fps.bg.r / 2) + "," + Math.floor(b.fps.bg.g / 2) + "," + Math.floor(b.fps.bg.b / 2) + ")";
m.style.padding = "2px 0px 3px 0px";
e.appendChild(m);
g = document.createElement("div");
g.style.fontFamily = "Helvetica, Arial, sans-serif";
g.style.textAlign = "left";
g.style.fontSize = "9px";
g.style.color = "rgb(" + b.fps.fg.r + "," + b.fps.fg.g + "," + b.fps.fg.b + ")";
g.style.margin = "0px 0px 1px 3px";
g.innerHTML = 'FPS';
m.appendChild(g);
a = document.createElement("canvas");
a.width = 74;
a.height = 30;
a.style.display = "block";
a.style.marginLeft = "3px";
m.appendChild(a);
p = a.getContext("2d");
p.fillStyle = "rgb(" + b.fps.bg.r + "," + b.fps.bg.g + "," + b.fps.bg.b + ")";
p.fillRect(0, 0, a.width, a.height);
C = p.getImageData(0, 0, a.width, a.height);
h = document.createElement("div");
h.style.backgroundColor = "rgb(" + Math.floor(b.ms.bg.r / 2) + "," + Math.floor(b.ms.bg.g / 2) + "," + Math.floor(b.ms.bg.b / 2) + ")";
h.style.padding = "2px 0px 3px 0px";
h.style.display = "none";
e.appendChild(h);
i = document.createElement("div");
i.style.fontFamily = "Helvetica, Arial, sans-serif";
i.style.textAlign = "left";
i.style.fontSize = "9px";
i.style.color = "rgb(" + b.ms.fg.r + "," + b.ms.fg.g + "," + b.ms.fg.b + ")";
i.style.margin = "0px 0px 1px 3px";
i.innerHTML = 'MS';
h.appendChild(i);
a = document.createElement("canvas");
a.width = 74;
a.height = 30;
a.style.display = "block";
a.style.marginLeft = "3px";
h.appendChild(a);
r = a.getContext("2d");
r.fillStyle = "rgb(" + b.ms.bg.r + "," + b.ms.bg.g + "," + b.ms.bg.b + ")";
r.fillRect(0, 0, a.width, a.height);
F = r.getImageData(0, 0, a.width, a.height);
try {
if (performance && performance.memory && performance.memory.totalJSHeapSize) x = 3
} catch (L) {}
j = document.createElement("div");
j.style.backgroundColor = "rgb(" + Math.floor(b.mem.bg.r / 2) + "," + Math.floor(b.mem.bg.g / 2) + "," + Math.floor(b.mem.bg.b / 2) + ")";
j.style.padding = "2px 0px 3px 0px";
j.style.display = "none";
e.appendChild(j);
k = document.createElement("div");
k.style.fontFamily = "Helvetica, Arial, sans-serif";
k.style.textAlign = "left";
k.style.fontSize = "9px";
k.style.color = "rgb(" + b.mem.fg.r + "," + b.mem.fg.g + "," + b.mem.fg.b + ")";
k.style.margin = "0px 0px 1px 3px";
k.innerHTML = 'MEM';
j.appendChild(k);
a = document.createElement("canvas");
a.width = 74;
a.height = 30;
a.style.display = "block";
a.style.marginLeft = "3px";
j.appendChild(a);
t = a.getContext("2d");
t.fillStyle = "#301010";
t.fillRect(0, 0, a.width, a.height);
I = t.getImageData(0, 0, a.width, a.height);
return {
domElement: e,
update: function() {
y++;
l = (new Date).getTime();
q = l - J;
D = Math.min(D, q);
E = Math.max(E, q);
w(F.data, Math.min(30, 30 - q / 200 * 30), "ms");
i.innerHTML = '' + q + " MS (" + D + "-" + E + ")";
r.putImageData(F, 0, 0);
J = l;
if (l > z + 1E3) {
o = Math.round(y * 1E3 / (l - z));
A = Math.min(A, o);
B = Math.max(B, o);
w(C.data, Math.min(30, 30 - o / 100 * 30), "fps");
g.innerHTML = '' + o + " FPS (" + A + "-" + B + ")";
p.putImageData(C, 0, 0);
if (x == 3) {
s = performance.memory.usedJSHeapSize * 9.54E-7;
G = Math.min(G, s);
H = Math.max(H, s);
w(I.data, Math.min(30, 30 - s / 2), "mem");
k.innerHTML = '' + Math.round(s) + " MEM (" + Math.round(G) + "-" + Math.round(H) + ")";
t.putImageData(I, 0, 0)
}
z = l;
y = 0
}
}
}
};
var BinaryFile = function(strData, iDataOffset, iDataLength) {
var data = strData;
var uint8View = null;
var dataOffset = iDataOffset || 0;
var dataLength = 0;
this.getRawData = function() {
return data;
}
if (typeof strData == "object") {
uint8View = new Uint8Array(strData)
dataLength = iDataLength || uint8View.length;
this.getByteAt = function(iOffset) {
return uint8View[iOffset + dataOffset] & 0xFF;
}
} else if (typeof strData == "string") {
dataLength = iDataLength || data.length;
this.getByteAt = function(iOffset) {
return data.charCodeAt(iOffset + dataOffset) & 0xFF;
}
} else if (typeof strData == "unknown") {
dataLength = iDataLength || IEBinary_getLength(data);
this.getByteAt = function(iOffset) {
return IEBinary_getByteAt(data, iOffset + dataOffset);
}
}
this.getLength = function() {
return dataLength;
}
this.getSByteAt = function(iOffset) {
var iByte = this.getByteAt(iOffset);
if (iByte > 127)
return iByte - 256;
else
return iByte;
}
this.getShortAt = function(iOffset, bBigEndian) {
var iShort = bBigEndian ? (this.getByteAt(iOffset) << 8) + this.getByteAt(iOffset + 1) : (this.getByteAt(iOffset + 1) << 8) + this.getByteAt(iOffset)
if (iShort < 0) iShort += 65536;
return iShort;
}
this.getSShortAt = function(iOffset, bBigEndian) {
var iUShort = this.getShortAt(iOffset, bBigEndian);
if (iUShort > 32767)
return iUShort - 65536;
else
return iUShort;
}
this.getLongAt = function(iOffset, bBigEndian) {
var iByte1 = this.getByteAt(iOffset),
iByte2 = this.getByteAt(iOffset + 1),
iByte3 = this.getByteAt(iOffset + 2),
iByte4 = this.getByteAt(iOffset + 3);
var iLong = bBigEndian ? (((((iByte1 << 8) + iByte2) << 8) + iByte3) << 8) + iByte4 : (((((iByte4 << 8) + iByte3) << 8) + iByte2) << 8) + iByte1;
if (iLong < 0) iLong += 4294967296;
return iLong;
}
this.getSLongAt = function(iOffset, bBigEndian) {
var iULong = this.getLongAt(iOffset, bBigEndian);
if (iULong > 2147483647)
return iULong - 4294967296;
else
return iULong;
}
this.getStringAt = function(iOffset, iLength) {
var aStr = [];
for (var i = iOffset, j = 0; i < iOffset + iLength; i++, j++) {
aStr[j] = String.fromCharCode(this.getByteAt(i));
}
return aStr.join("");
}
this.getCharAt = function(iOffset) {
return String.fromCharCode(this.getByteAt(iOffset));
}
this.toBase64 = function() {
return window.btoa(data);
}
this.fromBase64 = function(strBase64) {
data = window.atob(strBase64);
}
}
var ImageInfo = {};
ImageInfo.useRange = false;
ImageInfo.range = 10240;
(function() {
ImageInfo.readInfoFromData = function(data) {
var offset = 0;
if (data.getByteAt(0) == 0xFF && data.getByteAt(1) == 0xD8) {
return readJPEGInfo(data);
}
if (data.getByteAt(0) == 0x89 && data.getStringAt(1, 3) == "PNG") {
return readPNGInfo(data);
}
if (data.getStringAt(0, 3) == "GIF") {
return readGIFInfo(data);
}
if (data.getByteAt(0) == 0x42 && data.getByteAt(1) == 0x4D) {
return readBMPInfo(data);
}
if (data.getByteAt(0) == 0x00 && data.getByteAt(1) == 0x00) {
return readICOInfo(data);
}
return {
format: "UNKNOWN"
};
}
function readPNGInfo(data) {
var w = data.getLongAt(16, true);
var h = data.getLongAt(20, true);
var bpc = data.getByteAt(24);
var ct = data.getByteAt(25);
var bpp = bpc;
if (ct == 4) bpp *= 2;
if (ct == 2) bpp *= 3;
if (ct == 6) bpp *= 4;
var alpha = data.getByteAt(25) >= 4;
return {
format: "PNG",
version: "",
width: w,
height: h,
bpp: bpp,
alpha: alpha,
exif: {}
}
}
function readGIFInfo(data) {
var version = data.getStringAt(3, 3);
var w = data.getShortAt(6);
var h = data.getShortAt(8);
var bpp = ((data.getByteAt(10) >> 4) & 7) + 1;
return {
format: "GIF",
version: version,
width: w,
height: h,
bpp: bpp,
alpha: false,
exif: {}
}
}
function readJPEGInfo(data) {
var w = 0;
var h = 0;
var comps = 0;
var len = data.getLength();
var offset = 2;
while (offset < len) {
var marker = data.getShortAt(offset, true);
offset += 2;
if (marker == 0xFFC0 || marker == 0xFFC2) {
h = data.getShortAt(offset + 3, true);
w = data.getShortAt(offset + 5, true);
comps = data.getByteAt(offset + 7, true)
break;
} else {
offset += data.getShortAt(offset, true)
}
}
var exif = {};
if (typeof EXIF != "undefined" && EXIF.readFromBinaryFile) {
exif = EXIF.readFromBinaryFile(data);
}
return {
format: "JPEG",
version: "",
width: w,
height: h,
bpp: comps * 8,
alpha: false,
exif: exif
}
}
function readBMPInfo(data) {
var w = data.getLongAt(18);
var h = data.getLongAt(22);
var bpp = data.getShortAt(28);
return {
format: "BMP",
version: "",
width: w,
height: h,
bpp: bpp,
alpha: false,
exif: {}
}
}
})();
(function($) {
$.fn.doubletap = function(onDoubleTapCallback, delay) {
var action;
delay = delay == null ? 500 : delay;
$(this).bind('touchend', function(event) {
if (event.originalEvent.touches.length > 0)
return;
var now = new Date().getTime();
var lastTouch = $(this).data('lastTouch') || now + 1;
var delta = now - lastTouch;
clearTimeout(action);
if (delta < 500 && delta > 0) {
if (onDoubleTapCallback != null && typeof onDoubleTapCallback == 'function') {
onDoubleTapCallback(event);
}
} else {
$(this).data('lastTouch', now);
action = setTimeout(function(evt) {
clearTimeout(action);
}, delay, [event]);
}
$(this).data('lastTouch', now);
});
$(this).bind('touchmove', function(event) {
if (event.originalEvent.touches.length > 1)
return;
$(this).data('lastTouch', 0);
});
};
})(jQuery);
var P3dData = new function() {
this.getBlob = function(data, type) {
try {
if (typeof Blob !== 'undefined') {
return new Blob([data], {
type: type
});
}
} catch (e) {
if (e.name !== 'TypeError') {
throw (e);
}
}
var BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder;
var bb = new BlobBuilder();
bb.append(data);
return bb.getBlob(type);
};
this.dataURItoBlob = function(dataURI) {
var byteString;
if (dataURI.split(',')[0].indexOf('base64') >= 0)
byteString = atob(dataURI.split(',')[1]);
else
byteString = unescape(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return this.getBlob(ab, mimeString);
}
this.fileToObjectURL = function(f) {
if (window.URL && window.URL.createObjectURL)
return window.URL.createObjectURL(f);
else if (window.webkitURL && window.webkitURL.createObjectURL)
return window.webkitURL.createObjectURL(f);
else
return;
};
this.revokeObjectURL = function(ourl) {
if (window.URL && window.URL.revokeObjectURL)
window.URL.revokeObjectURL(ourl);
else if (window.webkitURL && window.webkitURL.revokeObjectURL)
window.webkitURL.revokeObjectURL(ourl);
};
this.urlToBlob = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
if (xhr.status != 404) {
callback(this.response);
return this.response
}
};
xhr.send();
};
this.blob_getImageInfo = function(blob, callback) {
var reader = new FileReader();
reader.onload = function(evt) {
var bin = new BinaryFile(evt.target.result, 0, 0);
callback(ImageInfo.readInfoFromData(bin));
};
reader.readAsArrayBuffer(blob);
};
this.getImageInfo = function(url, callback) {
var p3ddata = this;
this.urlToBlob(url, function(blob) {
p3ddata.blob_getImageInfo(blob, callback);
});
};
};
P3d.noninteractive = function(category, type, label, value) {
ga('send', 'event', category, type, label, {
'nonInteraction': 1
});
};
P3d.timer = function(timing_category, timing_var, timing_val, timing_label) {
ga('send', 'timing', timing_category, timing_var, timing_val, timing_label);
}
P3d.uaEnterEmbeddedViewer = function(label) {
P3d.noninteractive('embedded viewer', 'enter', label);
};
P3d.uaEnterViewer = function(label) {
P3d.noninteractive('viewer', 'enter', label);
};
P3d.uaLeaveViewer = function(label, duration) {
P3d.noninteractive('viewer', 'leave', label);
P3d.timer('viewer', 'active', duration, label);
};
P3d.uaLoadEmbeddedModel = function(label) {
P3d.noninteractive('embedded viewer', 'load', label);
};
P3d.uaGalleryScrollToBottom = function(gallery, page) {
P3d.noninteractive(gallery, 'load', 'page: ' + page);
};
P3d.uaAddTag = function(tag) {
P3d.noninteractive('tag', 'add', tag);
};
P3d.uaRemoveTag = function(tag) {
P3d.noninteractive('tag', 'remove', tag);
};
P3d.uaSelectMaterialOption = function(material) {
P3d.noninteractive('material', 'select', material);
};
P3d.uaSelectPreset = function(preset_name) {
P3d.noninteractive('preset', 'select', preset_name);
};
P3d.uaSaveSuccess = function(label) {
P3d.noninteractive('save', 'success', label);
};
P3d.uaSaveError = function(label) {
P3d.noninteractive('save', 'error', label);
};
P3d.uaExcludeToggle = function(label) {
P3d.noninteractive('exclude toggle', 'toggle', label);
};
P3d.uaShowPanel = function(label) {
P3d.noninteractive('panel', 'show', label);
};
P3d.uaClosePanel = function(label) {
P3d.noninteractive('panel', 'close', label);
};
P3d.uaDisplayPopup = function(label) {
P3d.noninteractive('popup', 'display', label);
};
P3d.uaClosePopup = function(label) {
P3d.noninteractive('popup', 'close', label);
};
// three.js - http://github.com/mrdoob/three.js
'use strict';
var THREE = THREE || {
REVISION: "59"
};
self.console = self.console || {
info: function() {},
log: function() {},
debug: function() {},
warn: function() {},
error: function() {}
};
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; d < e; 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 && !self.requestAnimationFrame; ++c) self.requestAnimationFrame = self[b[c] + "RequestAnimationFrame"], self.cancelAnimationFrame = self[b[c] + "CancelAnimationFrame"] || self[b[c] + "CancelRequestAnimationFrame"];
void 0 === self.requestAnimationFrame && void 0 !== self.setTimeout && (self.requestAnimationFrame = function(b) {
var c = Date.now(),
f = Math.max(0, 16 - (c - a)),
g = self.setTimeout(function() {
b(c + f)
}, f);
a = c + f;
return g
});
void 0 === self.cancelAnimationFrame && void 0 !==
self.clearTimeout && (self.cancelAnimationFrame = function(a) {
self.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) {
void 0 !== a && this.set(a);
return this
};
THREE.Color.prototype = {
constructor: THREE.Color,
r: 1,
g: 1,
b: 1,
set: function(a) {
a instanceof THREE.Color ? this.copy(a) : "number" === typeof a ? this.setHex(a) : "string" === typeof a && this.setStyle(a);
return this
},
setHex: function(a) {
a = Math.floor(a);
this.r = (a >> 16 & 255) / 255;
this.g = (a >> 8 & 255) / 255;
this.b = (a & 255) / 255;
return this
},
setRGB: function(a, b, c) {
this.r = a;
this.g = b;
this.b = c;
return this
},
setHSL: function(a, b, c) {
if (0 === b) this.r = this.g = this.b = c;
else {
var d = function(a, b, c) {
0 > c && (c += 1);
1 < c && (c -= 1);
return c < 1 / 6 ? a + 6 * (b - a) *
c : 0.5 > c ? b : c < 2 / 3 ? a + 6 * (b - a) * (2 / 3 - c) : a
},
b = 0.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) {
if (/^rgb\((\d+),(\d+),(\d+)\)$/i.test(a)) return 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;
if (/^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.test(a)) return 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;
if (/^\#([0-9a-f]{6})$/i.test(a)) return a = /^\#([0-9a-f]{6})$/i.exec(a), this.setHex(parseInt(a[1], 16)), this;
if (/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(a)) return 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;
if (/^(\w+)$/i.test(a)) return this.setHex(THREE.ColorKeywords[a]), this
},
copy: function(a) {
this.r = a.r;
this.g = a.g;
this.b =
a.b;
return this
},
copyGammaToLinear: function(a) {
this.r = a.r * a.r;
this.g = a.g * a.g;
this.b = a.b * a.b;
return this
},
copyLinearToGamma: function(a) {
this.r = Math.sqrt(a.r);
this.g = Math.sqrt(a.g);
this.b = Math.sqrt(a.b);
return this
},
convertGammaToLinear: function() {
var a = this.r,
b = this.g,
c = this.b;
this.r = a * a;
this.g = b * b;
this.b = c * c;
return this
},
convertLinearToGamma: function() {
this.r = Math.sqrt(this.r);
this.g = Math.sqrt(this.g);
this.b = Math.sqrt(this.b);
return this
},
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 = this.r,
c = this.g,
d = this.b,
e = Math.max(b, c, d),
f = Math.min(b, c, d),
g, h = (f + e) / 2;
if (f === e) f = g = 0;
else {
var i = e - f,
f = 0.5 >= h ? i / (e + f) : i / (2 - e - f);
switch (e) {
case b:
g = (c - d) / i + (c < d ? 6 : 0);
break;
case c:
g = (d - b) / i + 2;
break;
case d:
g = (b - c) / i + 4
}
g /= 6
}
a.h = g;
a.s = f;
a.l = h;
return 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();
d.h += a;
d.s += b;
d.l += c;
this.setHSL(d.h, d.s, d.l);
return this
},
add: function(a) {
this.r += a.r;
this.g += a.g;
this.b += a.b;
return this
},
addColors: function(a, b) {
this.r = a.r + b.r;
this.g = a.g + b.g;
this.b = a.b + b.b;
return this
},
addScalar: function(a) {
this.r += a;
this.g += a;
this.b += a;
return this
},
multiply: function(a) {
this.r *= a.r;
this.g *= a.g;
this.b *= a.b;
return this
},
multiplyScalar: function(a) {
this.r *= a;
this.g *= a;
this.b *= a;
return this
},
lerp: function(a, b) {
this.r += (a.r - this.r) * b;
this.g += (a.g - this.g) * b;
this.b += (a.b - this.b) * b;
return 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,
_x: 0,
_y: 0,
_z: 0,
_w: 0,
_euler: void 0,
_updateEuler: function() {
void 0 !== this._euler && this._euler.setFromQuaternion(this, void 0, !1)
},
get x() {
return this._x
},
set x(a) {
this._x = a;
this._updateEuler()
},
get y() {
return this._y
},
set y(a) {
this._y = a;
this._updateEuler()
},
get z() {
return this._z
},
set z(a) {
this._z = a;
this._updateEuler()
},
get w() {
return this._w
},
set w(a) {
this._w = a;
this._updateEuler()
},
set: function(a, b, c, d) {
this._x = a;
this._y = b;
this._z = c;
this._w = d;
this._updateEuler();
return this
},
copy: function(a) {
this._x = a._x;
this._y = a._y;
this._z = a._z;
this._w = a._w;
this._updateEuler();
return this
},
setFromEuler: function(a, b) {
void 0 === typeof a.order && console.error("ERROR: Quaternion's .setFromEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.");
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);
void 0 === a.order || "XYZ" === a.order ? (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" === a.order ? (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" === a.order ? (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" === a.order ? (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" === a.order ? (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" === a.order && (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);
!1 !== b && this._updateEuler();
return this
},
setFromAxisAngle: function(a, b) {
var c = b / 2,
d = Math.sin(c);
this._x = a.x * d;
this._y = a.y * d;
this._z = a.z * d;
this._w = Math.cos(c);
this._updateEuler();
return 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],
k = c + f + b;
0 < k ? (c = 0.5 / Math.sqrt(k + 1), this._w = 0.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 = 0.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 = 0.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 = 0.25 * c);
this._updateEuler();
return this
},
inverse: function() {
this.conjugate().normalize();
return this
},
conjugate: function() {
this._x *= -1;
this._y *= -1;
this._z *= -1;
this._updateEuler();
return 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();
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);
return 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,
k = b._w;
this._x = c * k + f * g + d * i - e * h;
this._y = d * k + f * h + e * g - c * i;
this._z = e * k + f * i + c * h - d * g;
this._w = f * k - c * g - d * h - e * i;
this._updateEuler();
return this
},
multiplyVector3: function(a) {
console.warn("DEPRECATED: Quaternion's .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");
return 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;
0 > g ? (this._w = -a._w, this._x = -a._x, this._y = -a._y, this._z = -a._z, g = -g) : this.copy(a);
if (1 <= g) 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);
if (0.001 > Math.abs(i)) return this._w = 0.5 * (f + this._w), this._x = 0.5 * (c + this._x), this._y = 0.5 * (d + this._y), this._z = 0.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._updateEuler();
return this
},
equals: function(a) {
return a._x === this._x && a._y === this._y && a._z ===
this._z && a._w === this._w
},
fromArray: function(a) {
this._x = a[0];
this._y = a[1];
this._z = a[2];
this._w = a[3];
this._updateEuler();
return 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) {
this.x = a;
this.y = b;
return this
},
setX: function(a) {
this.x = a;
return this
},
setY: function(a) {
this.y = a;
return 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) {
this.x = a.x;
this.y = a.y;
return this
},
add: function(a,
b) {
if (void 0 !== b) return 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;
return this
},
addVectors: function(a, b) {
this.x = a.x + b.x;
this.y = a.y + b.y;
return this
},
addScalar: function(a) {
this.x += a;
this.y += a;
return this
},
sub: function(a, b) {
if (void 0 !== b) return 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;
return this
},
subVectors: function(a, b) {
this.x = a.x - b.x;
this.y = a.y - b.y;
return this
},
multiplyScalar: function(a) {
this.x *= a;
this.y *= a;
return this
},
divideScalar: function(a) {
0 !== a ? (a = 1 / a, this.x *= a, this.y *= a) : this.y = this.x = 0;
return this
},
min: function(a) {
this.x > a.x && (this.x = a.x);
this.y > a.y && (this.y = a.y);
return this
},
max: function(a) {
this.x < a.x && (this.x = a.x);
this.y < a.y && (this.y = a.y);
return this
},
clamp: function(a, b) {
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);
return this
},
negate: function() {
return this.multiplyScalar(-1)
},
dot: function(a) {
return this.x * a.x + this.y * a.y
},
lengthSq: function() {
return this.x * this.x + this.y * this.y
},
length: function() {
return Math.sqrt(this.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();
0 !== b && a !== b && this.multiplyScalar(a /
b);
return this
},
lerp: function(a, b) {
this.x += (a.x - this.x) * b;
this.y += (a.y - this.y) * b;
return this
},
equals: function(a) {
return a.x === this.x && a.y === this.y
},
fromArray: function(a) {
this.x = a[0];
this.y = a[1];
return 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) {
this.x = a;
this.y = b;
this.z = c;
return this
},
setX: function(a) {
this.x = a;
return this
},
setY: function(a) {
this.y = a;
return this
},
setZ: function(a) {
this.z = a;
return this
},
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) {
this.x = a.x;
this.y = a.y;
this.z = a.z;
return this
},
add: function(a, b) {
if (void 0 !== b) return 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;
return this
},
addScalar: function(a) {
this.x += a;
this.y += a;
this.z += a;
return this
},
addVectors: function(a, b) {
this.x = a.x + b.x;
this.y = a.y + b.y;
this.z = a.z + b.z;
return this
},
sub: function(a, b) {
if (void 0 !== b) return 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;
return this
},
subVectors: function(a, b) {
this.x = a.x - b.x;
this.y = a.y - b.y;
this.z = a.z - b.z;
return this
},
multiply: function(a, b) {
if (void 0 !== b) return 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;
return this
},
multiplyScalar: function(a) {
this.x *= a;
this.y *= a;
this.z *= a;
return this
},
multiplyVectors: function(a, b) {
this.x = a.x *
b.x;
this.y = a.y * b.y;
this.z = a.z * b.z;
return this
},
applyMatrix3: function(a) {
var b = this.x,
c = this.y,
d = this.z,
a = a.elements;
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;
return this
},
applyMatrix4: function(a) {
var b = this.x,
c = this.y,
d = this.z,
a = a.elements;
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];
return 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]);
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;
return 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,
k = a * d + e * c - f * b,
b = -e * b - f * c - g * d;
this.x = h * a + b * -e + i * -g - k * -f;
this.y = i * a + b * -f + k * -e - h * -g;
this.z = k * a + b * -g + h * -f - i * -e;
return this
},
transformDirection: function(a) {
var b = this.x,
c = this.y,
d = this.z,
a = a.elements;
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();
return this
},
divide: function(a) {
this.x /= a.x;
this.y /= a.y;
this.z /= a.z;
return this
},
divideScalar: function(a) {
0 !== a ? (a = 1 / a, this.x *= a, this.y *= a, this.z *= a) : this.z = this.y = this.x = 0;
return this
},
min: function(a) {
this.x > a.x && (this.x = a.x);
this.y > a.y && (this.y = a.y);
this.z > a.z && (this.z = a.z);
return this
},
max: function(a) {
this.x < a.x && (this.x = a.x);
this.y < a.y && (this.y = a.y);
this.z < a.z && (this.z = a.z);
return this
},
clamp: function(a, b) {
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);
return this
},
negate: function() {
return this.multiplyScalar(-1)
},
dot: function(a) {
return this.x * a.x + this.y * a.y + this.z * a.z
},
lengthSq: function() {
return this.x * this.x + this.y * this.y + this.z * this.z
},
length: function() {
return Math.sqrt(this.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();
0 !== b && a !== b && this.multiplyScalar(a / b);
return this
},
lerp: function(a, b) {
this.x += (a.x - this.x) * b;
this.y += (a.y - this.y) * b;
this.z += (a.z - this.z) * b;
return 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;
this.x = d * a.z - e * a.y;
this.y = e * a.x - c * a.z;
this.z = c * a.y - d * a.x;
return this
},
crossVectors: function(a, b) {
this.x =
a.y * b.z - a.z * b.y;
this.y = a.z * b.x - a.x * b.z;
this.z = a.x * b.y - a.y * b.x;
return this
},
angleTo: function(a) {
a = this.dot(a) / (this.length() * a.length());
return 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() {
console.error("REMOVED: Vector3's setEulerFromRotationMatrix has been removed in favor of Euler.setFromRotationMatrix(), please update your code.")
},
setEulerFromQuaternion: function() {
console.error("REMOVED: Vector3's setEulerFromQuaternion: has been removed in favor of Euler.setFromQuaternion(), please update your code.")
},
getPositionFromMatrix: function(a) {
this.x = a.elements[12];
this.y = a.elements[13];
this.z = a.elements[14];
return this
},
getScaleFromMatrix: function(a) {
var b = this.set(a.elements[0], a.elements[1], a.elements[2]).length(),
c = this.set(a.elements[4], a.elements[5], a.elements[6]).length(),
a = this.set(a.elements[8], a.elements[9], a.elements[10]).length();
this.x = b;
this.y = c;
this.z = a;
return this
},
getColumnFromMatrix: function(a, b) {
var c = 4 * a,
d = b.elements;
this.x = d[c];
this.y = d[c + 1];
this.z = d[c + 2];
return this
},
equals: function(a) {
return a.x === this.x && a.y === this.y && a.z === this.z
},
fromArray: function(a) {
this.x = a[0];
this.y = a[1];
this.z = a[2];
return 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) {
void 0 === typeof b.order && console.error("ERROR: Vector3's .applyEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.");
b = a.setFromEuler(b);
this.applyQuaternion(b);
return this
}
}(),
applyAxisAngle: function() {
var a = new THREE.Quaternion;
return function(b, c) {
var d = a.setFromAxisAngle(b, c);
this.applyQuaternion(d);
return this
}
}(),
projectOnVector: function() {
var a =
new THREE.Vector3;
return function(b) {
a.copy(b).normalize();
b = this.dot(a);
return this.copy(a).multiplyScalar(b)
}
}(),
projectOnPlane: function() {
var a = new THREE.Vector3;
return function(b) {
a.copy(this).projectOnVector(b);
return this.sub(a)
}
}(),
reflect: function() {
var a = new THREE.Vector3;
return function(b) {
a.copy(this).projectOnVector(b).multiplyScalar(2);
return 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) {
this.x = a;
this.y = b;
this.z = c;
this.w = d;
return this
},
setX: function(a) {
this.x = a;
return this
},
setY: function(a) {
this.y = a;
return this
},
setZ: function(a) {
this.z = a;
return this
},
setW: function(a) {
this.w = a;
return 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) {
this.x = a.x;
this.y = a.y;
this.z = a.z;
this.w = void 0 !== a.w ? a.w : 1;
return this
},
add: function(a, b) {
if (void 0 !== b) return 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;
return this
},
addScalar: function(a) {
this.x += a;
this.y += a;
this.z += a;
this.w += a;
return this
},
addVectors: function(a, b) {
this.x = a.x + b.x;
this.y = a.y + b.y;
this.z = a.z + b.z;
this.w = a.w + b.w;
return this
},
sub: function(a, b) {
if (void 0 !== b) return 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;
return this
},
subVectors: function(a, b) {
this.x = a.x - b.x;
this.y = a.y - b.y;
this.z = a.z - b.z;
this.w = a.w - b.w;
return this
},
multiplyScalar: function(a) {
this.x *= a;
this.y *= a;
this.z *= a;
this.w *= a;
return this
},
applyMatrix4: function(a) {
var b = this.x,
c = this.y,
d = this.z,
e = this.w,
a = a.elements;
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;
return this
},
divideScalar: function(a) {
0 !== a ? (a = 1 / a, this.x *= a, this.y *= a, this.z *= a, this.w *= a) : (this.z = this.y = this.x = 0, this.w = 1);
return this
},
setAxisAngleFromQuaternion: function(a) {
this.w = 2 * Math.acos(a.w);
var b = Math.sqrt(1 - a.w * a.w);
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);
return 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 k = a[10];
if (0.01 > Math.abs(d - g) && 0.01 > Math.abs(f - c) && 0.01 > Math.abs(i - b)) {
if (0.1 > Math.abs(d + g) && 0.1 > Math.abs(f + c) && 0.1 > Math.abs(i + b) && 0.1 > Math.abs(e + h + k - 3)) return this.set(1, 0, 0, 0), this;
a = Math.PI;
e = (e + 1) / 2;
h = (h + 1) / 2;
k = (k + 1) / 2;
d = (d + g) / 4;
f = (f + c) / 4;
i = (i + b) / 4;
e > h && e > k ? 0.01 > e ? (b = 0, d = c = 0.707106781) : (b = Math.sqrt(e), c = d / b, d = f / b) : h > k ? 0.01 > h ?
(b = 0.707106781, c = 0, d = 0.707106781) : (c = Math.sqrt(h), b = d / c, d = i / c) : 0.01 > k ? (c = b = 0.707106781, d = 0) : (d = Math.sqrt(k), b = f / d, c = i / d);
this.set(b, c, d, a);
return this
}
a = Math.sqrt((b - i) * (b - i) + (f - c) * (f - c) + (g - d) * (g - d));
0.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 + k - 1) / 2);
return this
},
min: function(a) {
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);
return this
},
max: function(a) {
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);
return this
},
clamp: function(a, b) {
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);
return this
},
negate: function() {
return this.multiplyScalar(-1)
},
dot: function(a) {
return this.x * a.x + this.y * a.y + this.z * a.z + this.w * a.w
},
lengthSq: function() {
return this.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();
0 !== b && a !== b && this.multiplyScalar(a / b);
return this
},
lerp: function(a, b) {
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;
return this
},
equals: function(a) {
return a.x === this.x && a.y === this.y && a.z === this.z &&
a.w === this.w
},
fromArray: function(a) {
this.x = a[0];
this.y = a[1];
this.z = a[2];
this.w = a[3];
return 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.Euler = function(a, b, c, d) {
this._x = a || 0;
this._y = b || 0;
this._z = c || 0;
this._order = d || THREE.Euler.DefaultOrder
};
THREE.Euler.RotationOrders = "XYZ YZX ZXY XZY YXZ ZYX".split(" ");
THREE.Euler.DefaultOrder = "XYZ";
THREE.Euler.prototype = {
constructor: THREE.Euler,
_x: 0,
_y: 0,
_z: 0,
_order: THREE.Euler.DefaultOrder,
_quaternion: void 0,
_updateQuaternion: function() {
void 0 !== this._quaternion && this._quaternion.setFromEuler(this, !1)
},
get x() {
return this._x
},
set x(a) {
this._x = a;
this._updateQuaternion()
},
get y() {
return this._y
},
set y(a) {
this._y = a;
this._updateQuaternion()
},
get z() {
return this._z
},
set z(a) {
this._z = a;
this._updateQuaternion()
},
get order() {
return this._order
},
set order(a) {
this._order = a;
this._updateQuaternion()
},
set: function(a, b, c, d) {
this._x = a;
this._y = b;
this._z = c;
this._order = d || this._order;
this._updateQuaternion();
return this
},
copy: function(a) {
this._x = a._x;
this._y = a._y;
this._z = a._z;
this._order = a._order;
this._updateQuaternion();
return this
},
setFromRotationMatrix: 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],
k = d[9],
l = d[2],
m = d[6],
d = d[10],
b = b || this._order;
"XYZ" === b ? (this._y = Math.asin(c(g)), 0.99999 > Math.abs(g) ? (this._x = Math.atan2(-k, d), this._z =
Math.atan2(-f, e)) : (this._x = Math.atan2(m, i), this._z = 0)) : "YXZ" === b ? (this._x = Math.asin(-c(k)), 0.99999 > Math.abs(k) ? (this._y = Math.atan2(g, d), this._z = Math.atan2(h, i)) : (this._y = Math.atan2(-l, e), this._z = 0)) : "ZXY" === b ? (this._x = Math.asin(c(m)), 0.99999 > Math.abs(m) ? (this._y = Math.atan2(-l, d), this._z = Math.atan2(-f, i)) : (this._y = 0, this._z = Math.atan2(h, e))) : "ZYX" === b ? (this._y = Math.asin(-c(l)), 0.99999 > Math.abs(l) ? (this._x = Math.atan2(m, d), this._z = Math.atan2(h, e)) : (this._x = 0, this._z = Math.atan2(-f, i))) : "YZX" === b ? (this._z =
Math.asin(c(h)), 0.99999 > Math.abs(h) ? (this._x = Math.atan2(-k, i), this._y = Math.atan2(-l, e)) : (this._x = 0, this._y = Math.atan2(g, d))) : "XZY" === b ? (this._z = Math.asin(-c(f)), 0.99999 > Math.abs(f) ? (this._x = Math.atan2(m, i), this._y = Math.atan2(g, e)) : (this._x = Math.atan2(-k, d), this._y = 0)) : console.warn("WARNING: Euler.setFromRotationMatrix() given unsupported order: " + b);
this._order = b;
this._updateQuaternion();
return this
},
setFromQuaternion: function(a, b, c) {
function d(a) {
return Math.min(Math.max(a, -1), 1)
}
var e = a.x * a.x,
f =
a.y * a.y,
g = a.z * a.z,
h = a.w * a.w,
b = b || this._order;
"XYZ" === b ? (this._x = Math.atan2(2 * (a.x * a.w - a.y * a.z), h - e - f + g), this._y = Math.asin(d(2 * (a.x * a.z + a.y * a.w))), this._z = Math.atan2(2 * (a.z * a.w - a.x * a.y), h + e - f - g)) : "YXZ" === b ? (this._x = Math.asin(d(2 * (a.x * a.w - a.y * a.z))), this._y = Math.atan2(2 * (a.x * a.z + a.y * a.w), h - e - f + g), this._z = Math.atan2(2 * (a.x * a.y + a.z * a.w), h - e + f - g)) : "ZXY" === b ? (this._x = Math.asin(d(2 * (a.x * a.w + a.y * a.z))), this._y = Math.atan2(2 * (a.y * a.w - a.z * a.x), h - e - f + g), this._z = Math.atan2(2 * (a.z * a.w - a.x * a.y), h - e + f - g)) : "ZYX" ===
b ? (this._x = Math.atan2(2 * (a.x * a.w + a.z * a.y), h - e - f + g), this._y = Math.asin(d(2 * (a.y * a.w - a.x * a.z))), this._z = Math.atan2(2 * (a.x * a.y + a.z * a.w), h + e - f - g)) : "YZX" === b ? (this._x = Math.atan2(2 * (a.x * a.w - a.z * a.y), h - e + f - g), this._y = Math.atan2(2 * (a.y * a.w - a.x * a.z), h + e - f - g), this._z = Math.asin(d(2 * (a.x * a.y + a.z * a.w)))) : "XZY" === b ? (this._x = Math.atan2(2 * (a.x * a.w + a.y * a.z), h - e + f - g), this._y = Math.atan2(2 * (a.x * a.z + a.y * a.w), h + e - f - g), this._z = Math.asin(d(2 * (a.z * a.w - a.x * a.y)))) : console.warn("WARNING: Euler.setFromQuaternion() given unsupported order: " +
b);
this._order = b;
!1 !== c && this._updateQuaternion();
return this
},
reorder: function() {
var a = new THREE.Quaternion;
return function(b) {
a.setFromEuler(this);
this.setFromQuaternion(a, b)
}
}(),
fromArray: function(a) {
this._x = a[0];
this._y = a[1];
this._z = a[2];
void 0 !== a[3] && (this._order = a[3]);
this._updateQuaternion();
return this
},
toArray: function() {
return [this._x, this._y, this._z, this._order]
},
equals: function(a) {
return a._x === this._x && a._y === this._y && a._z === this._z && a._order === this._order
},
clone: function() {
return new THREE.Euler(this._x,
this._y, this._z, this._order)
}
};
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) {
this.start.copy(a);
this.end.copy(b);
return this
},
copy: function(a) {
this.start.copy(a.start);
this.end.copy(a.end);
return this
},
center: function(a) {
return (a || new THREE.Vector3).addVectors(this.start, this.end).multiplyScalar(0.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;
d && (e = THREE.Math.clamp(e, 0, 1));
return e
}
}(),
closestPointToPoint: function(a, b, c) {
a = this.closestPointToPointParameter(a, b);
c = c || new THREE.Vector3;
return this.delta(c).multiplyScalar(a).add(this.start)
},
applyMatrix4: function(a) {
this.start.applyMatrix4(a);
this.end.applyMatrix4(a);
return 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(Infinity, Infinity);
this.max = void 0 !== b ? b : new THREE.Vector2(-Infinity, -Infinity)
};
THREE.Box2.prototype = {
constructor: THREE.Box2,
set: function(a, b) {
this.min.copy(a);
this.max.copy(b);
return 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; c < d; 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(0.5);
this.min.copy(b).sub(d);
this.max.copy(b).add(d);
return this
}
}(),
copy: function(a) {
this.min.copy(a.min);
this.max.copy(a.max);
return this
},
makeEmpty: function() {
this.min.x = this.min.y = Infinity;
this.max.x = this.max.y = -Infinity;
return 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(0.5)
},
size: function(a) {
return (a || new THREE.Vector2).subVectors(this.max, this.min)
},
expandByPoint: function(a) {
this.min.min(a);
this.max.max(a);
return this
},
expandByVector: function(a) {
this.min.sub(a);
this.max.add(a);
return this
},
expandByScalar: function(a) {
this.min.addScalar(-a);
this.max.addScalar(a);
return 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) {
this.min.max(a.min);
this.max.min(a.max);
return this
},
union: function(a) {
this.min.min(a.min);
this.max.max(a.max);
return this
},
translate: function(a) {
this.min.add(a);
this.max.add(a);
return 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(Infinity, Infinity, Infinity);
this.max = void 0 !== b ? b : new THREE.Vector3(-Infinity, -Infinity, -Infinity)
};
THREE.Box3.prototype = {
constructor: THREE.Box3,
set: function(a, b) {
this.min.copy(a);
this.max.copy(b);
return 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; c < d; 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(0.5);
this.min.copy(b).sub(d);
this.max.copy(b).add(d);
return this
}
}(),
setFromObject: function() {
var a = new THREE.Vector3;
return function(b) {
var c = this;
b.updateMatrixWorld(!0);
this.makeEmpty();
b.traverse(function(b) {
if (void 0 !== b.geometry && void 0 !== b.geometry.vertices)
for (var e = b.geometry.vertices, f = 0, g = e.length; f < g; f++) a.copy(e[f]), a.applyMatrix4(b.matrixWorld), c.expandByPoint(a)
});
return this
}
}(),
copy: function(a) {
this.min.copy(a.min);
this.max.copy(a.max);
return this
},
makeEmpty: function() {
this.min.x = this.min.y = this.min.z = Infinity;
this.max.x = this.max.y = this.max.z = -Infinity;
return 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(0.5)
},
size: function(a) {
return (a || new THREE.Vector3).subVectors(this.max, this.min)
},
expandByPoint: function(a) {
this.min.min(a);
this.max.max(a);
return this
},
expandByVector: function(a) {
this.min.sub(a);
this.max.add(a);
return this
},
expandByScalar: function(a) {
this.min.addScalar(-a);
this.max.addScalar(a);
return 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) {
b = b || new THREE.Sphere;
b.center = this.center();
b.radius = 0.5 * this.size(a).length();
return b
}
}(),
intersect: function(a) {
this.min.max(a.min);
this.max.min(a.max);
return this
},
union: function(a) {
this.min.min(a.min);
this.max.max(a.max);
return 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) {
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);
return this
}
}(),
translate: function(a) {
this.min.add(a);
this.max.add(a);
return 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 k = this.elements;
k[0] = a;
k[3] = b;
k[6] = c;
k[1] = d;
k[4] = e;
k[7] = f;
k[2] = g;
k[5] = h;
k[8] = i;
return this
},
identity: function() {
this.set(1, 0, 0, 0, 1, 0, 0, 0, 1);
return this
},
copy: function(a) {
a = a.elements;
this.set(a[0], a[3], a[6], a[1], a[4], a[7], a[2], a[5], a[8]);
return this
},
multiplyVector3: function(a) {
console.warn("DEPRECATED: Matrix3's .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");
return a.applyMatrix3(this)
},
multiplyVector3Array: function() {
var a = new THREE.Vector3;
return function(b) {
for (var c = 0, d = b.length; c < d; 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;
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;
return 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;
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];
if (0 === c) {
if (b) throw Error("Matrix3.getInverse(): can't invert matrix, determinant is 0");
console.warn("Matrix3.getInverse(): can't invert matrix, determinant is 0");
this.identity();
return this
}
this.multiplyScalar(1 /
c);
return this
},
transpose: function() {
var a, b = this.elements;
a = b[1];
b[1] = b[3];
b[3] = a;
a = b[2];
b[2] = b[6];
b[6] = a;
a = b[5];
b[5] = b[7];
b[7] = a;
return this
},
getNormalMatrix: function(a) {
this.getInverse(a).transpose();
return this
},
transposeIntoArray: function(a) {
var b = this.elements;
a[0] = b[0];
a[1] = b[3];
a[2] = b[6];
a[3] = b[1];
a[4] = b[4];
a[5] = b[7];
a[6] = b[2];
a[7] = b[5];
a[8] = b[8];
return this
},
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, k, l, m, p, q, t, n) {
var r = this.elements = new Float32Array(16);
r[0] = void 0 !== a ? a : 1;
r[4] = b || 0;
r[8] = c || 0;
r[12] = d || 0;
r[1] = e || 0;
r[5] = void 0 !== f ? f : 1;
r[9] = g || 0;
r[13] = h || 0;
r[2] = i || 0;
r[6] = k || 0;
r[10] = void 0 !== l ? l : 1;
r[14] = m || 0;
r[3] = p || 0;
r[7] = q || 0;
r[11] = t || 0;
r[15] = void 0 !== n ? n : 1
};
THREE.Matrix4.prototype = {
constructor: THREE.Matrix4,
set: function(a, b, c, d, e, f, g, h, i, k, l, m, p, q, t, n) {
var r = this.elements;
r[0] = a;
r[4] = b;
r[8] = c;
r[12] = d;
r[1] = e;
r[5] = f;
r[9] = g;
r[13] = h;
r[2] = i;
r[6] = k;
r[10] = l;
r[14] = m;
r[3] = p;
r[7] = q;
r[11] = t;
r[15] = n;
return this
},
identity: function() {
this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
return this
},
copy: function(a) {
this.elements.set(a.elements);
return this
},
extractPosition: function(a) {
console.warn("DEPRECATED: Matrix4's .extractPosition() has been renamed to .copyPosition().");
return this.copyPosition(a)
},
copyPosition: function(a) {
var b = this.elements,
a = a.elements;
b[12] = a[12];
b[13] = a[13];
b[14] = a[14];
return this
},
extractRotation: function() {
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();
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;
return this
}
}(),
makeRotationFromEuler: function(a) {
void 0 ===
typeof a.order && console.error("ERROR: Matrix's .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.");
var b = this.elements,
c = a.x,
d = a.y,
e = a.z,
f = Math.cos(c),
c = Math.sin(c),
g = Math.cos(d),
d = Math.sin(d),
h = Math.cos(e),
e = Math.sin(e);
if (void 0 === a.order || "XYZ" === a.order) {
var a = f * h,
i = f * e,
k = c * h,
l = c * e;
b[0] = g * h;
b[4] = -g * e;
b[8] = d;
b[1] = i + k * d;
b[5] = a - l * d;
b[9] = -c * g;
b[2] = l - a * d;
b[6] = k + i * d;
b[10] = f * g
} else "YXZ" === a.order ? (a = g * h, i = g * e, k = d * h, l = d * e, b[0] = a + l * c, b[4] =
k * c - i, b[8] = f * d, b[1] = f * e, b[5] = f * h, b[9] = -c, b[2] = i * c - k, b[6] = l + a * c, b[10] = f * g) : "ZXY" === a.order ? (a = g * h, i = g * e, k = d * h, l = d * e, b[0] = a - l * c, b[4] = -f * e, b[8] = k + i * c, b[1] = i + k * c, b[5] = f * h, b[9] = l - a * c, b[2] = -f * d, b[6] = c, b[10] = f * g) : "ZYX" === a.order ? (a = f * h, i = f * e, k = c * h, l = c * e, b[0] = g * h, b[4] = k * d - i, b[8] = a * d + l, b[1] = g * e, b[5] = l * d + a, b[9] = i * d - k, b[2] = -d, b[6] = c * g, b[10] = f * g) : "YZX" === a.order ? (a = f * g, i = f * d, k = c * g, l = c * d, b[0] = g * h, b[4] = l - a * e, b[8] = k * e + i, b[1] = e, b[5] = f * h, b[9] = -c * h, b[2] = -d * h, b[6] = i * e + k, b[10] = a - l * e) : "XZY" === a.order && (a = f * g, i = f * d, k =
c * g, l = c * d, b[0] = g * h, b[4] = -e, b[8] = d * h, b[1] = a * e + l, b[5] = f * h, b[9] = i * e - k, b[2] = k * e - i, b[6] = c * h, b[10] = l * e + a);
b[3] = 0;
b[7] = 0;
b[11] = 0;
b[12] = 0;
b[13] = 0;
b[14] = 0;
b[15] = 1;
return this
},
setRotationFromQuaternion: function(a) {
console.warn("DEPRECATED: Matrix4's .setRotationFromQuaternion() has been deprecated in favor of makeRotationFromQuaternion. Please update your code.");
return 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,
k = c * h,
c = c * i,
l = d * h,
d = d * i,
e = e * i,
g = f * g,
h = f * h,
f = f * i;
b[0] = 1 - (l + e);
b[4] = k - f;
b[8] = c + h;
b[1] = k + f;
b[5] = 1 - (a + e);
b[9] = d - g;
b[2] = c - h;
b[6] = d + g;
b[10] = 1 - (a + l);
b[3] = 0;
b[7] = 0;
b[11] = 0;
b[12] = 0;
b[13] = 0;
b[14] = 0;
b[15] = 1;
return 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;
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;
return 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],
k = c[1],
l = c[5],
m = c[9],
p = c[13],
q = c[2],
t = c[6],
n = c[10],
r = c[14],
s = c[3],
v = c[7],
z = c[11],
c = c[15],
H = d[0],
B = d[4],
G = d[8],
I = d[12],
F = d[1],
A = d[5],
N = d[9],
C = d[13],
K = d[2],
M = d[6],
y = d[10],
J = d[14],
w = d[3],
ca = d[7],
D = d[11],
d = d[15];
e[0] = f * H + g * F + h * K + i * w;
e[4] = f * B + g * A + h * M + i * ca;
e[8] = f * G + g * N + h * y + i * D;
e[12] = f * I + g * C + h * J + i * d;
e[1] = k * H + l * F + m * K + p * w;
e[5] = k * B + l * A + m * M + p * ca;
e[9] = k * G + l * N + m * y + p * D;
e[13] = k * I + l * C + m * J + p * d;
e[2] = q * H + t * F + n * K + r * w;
e[6] = q * B + t * A + n * M + r * ca;
e[10] = q * G + t * N + n * y + r * D;
e[14] = q * I + t * C + n * J + r * d;
e[3] = s * H + v * F + z * K + c * w;
e[7] = s * B + v * A + z * M + c * ca;
e[11] = s * G + v * N + z * y + c * D;
e[15] = s * I + v * C + z * J + c * d;
return this
},
multiplyToArray: function(a,
b, c) {
var d = this.elements;
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];
return this
},
multiplyScalar: function(a) {
var b = this.elements;
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;
return this
},
multiplyVector3: function(a) {
console.warn("DEPRECATED: Matrix4's .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.");
return a.applyProjection(this)
},
multiplyVector4: function(a) {
console.warn("DEPRECATED: Matrix4's .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");
return a.applyMatrix4(this)
},
multiplyVector3Array: function() {
var a = new THREE.Vector3;
return function(b) {
for (var c = 0, d = b.length; c < d; 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) {
console.warn("DEPRECATED: Matrix4's .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");
return 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],
k = a[2],
l = a[6],
m = a[10],
p = a[14];
return a[3] * (+e * h * l - d * i * l - e * g * m + c * i * m + d * g * p - c * h * p) + a[7] * (+b * h * p - b * i * m + e * f * m - d * f * p + d * i * k - e * h * k) + a[11] * (+b * i * l - b * g * p - e * f * l + c * f * p + e * g * k - c * i * k) + a[15] * (-d * g * k - b * h * l + b * g * m + d * f * l - c * f *
m + c * h * k)
},
transpose: function() {
var a = this.elements,
b;
b = a[1];
a[1] = a[4];
a[4] = b;
b = a[2];
a[2] = a[8];
a[8] = b;
b = a[6];
a[6] = a[9];
a[9] = b;
b = a[3];
a[3] = a[12];
a[12] = b;
b = a[7];
a[7] = a[13];
a[13] = b;
b = a[11];
a[11] = a[14];
a[14] = b;
return this
},
flattenToArray: function(a) {
var b = this.elements;
a[0] = b[0];
a[1] = b[1];
a[2] = b[2];
a[3] = b[3];
a[4] = b[4];
a[5] = b[5];
a[6] = b[6];
a[7] = b[7];
a[8] = b[8];
a[9] = b[9];
a[10] = b[10];
a[11] = b[11];
a[12] = b[12];
a[13] = b[13];
a[14] = b[14];
a[15] = b[15];
return a
},
flattenToArrayOffset: function(a, b) {
var c = this.elements;
a[b] = c[0];
a[b + 1] = c[1];
a[b + 2] = c[2];
a[b + 3] = c[3];
a[b + 4] = c[4];
a[b + 5] = c[5];
a[b + 6] = c[6];
a[b + 7] = c[7];
a[b + 8] = c[8];
a[b + 9] = c[9];
a[b + 10] = c[10];
a[b + 11] = c[11];
a[b + 12] = c[12];
a[b + 13] = c[13];
a[b + 14] = c[14];
a[b + 15] = c[15];
return a
},
getPosition: function() {
var a = 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;
b[12] = a.x;
b[13] = a.y;
b[14] = a.z;
return 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],
k = d[5],
l = d[9],
m = d[13],
p = d[2],
q = d[6],
t = d[10],
n = d[14],
r = d[3],
s = d[7],
v = d[11],
d = d[15];
c[0] = l * n * s - m * t * s + m * q * v - k * n * v - l * q * d + k * t * d;
c[4] = h * t * s - g * n * s - h * q * v + f * n * v + g * q * d - f * t * d;
c[8] = g * m * s - h * l * s + h * k * v - f * m * v - g * k * d + f * l * d;
c[12] = h * l * q - g * m * q - h * k * t + f * m * t + g * k * n - f * l * n;
c[1] = m * t * r - l * n * r - m * p * v + i * n * v + l * p * d - i * t * d;
c[5] = g * n * r - h * t * r + h * p * v - e * n * v - g * p * d + e * t * d;
c[9] = h * l * r - g * m * r - h * i * v + e * m * v + g * i * d -
e * l * d;
c[13] = g * m * p - h * l * p + h * i * t - e * m * t - g * i * n + e * l * n;
c[2] = k * n * r - m * q * r + m * p * s - i * n * s - k * p * d + i * q * d;
c[6] = h * q * r - f * n * r - h * p * s + e * n * s + f * p * d - e * q * d;
c[10] = f * m * r - h * k * r + h * i * s - e * m * s - f * i * d + e * k * d;
c[14] = h * k * p - f * m * p - h * i * q + e * m * q + f * i * n - e * k * n;
c[3] = l * q * r - k * t * r - l * p * s + i * t * s + k * p * v - i * q * v;
c[7] = f * t * r - g * q * r + g * p * s - e * t * s - f * p * v + e * q * v;
c[11] = g * k * r - f * l * r - g * i * s + e * l * s + f * i * v - e * k * v;
c[15] = f * l * p - g * k * p + g * i * q - e * l * q - f * i * t + e * k * t;
c = e * c[0] + i * c[4] + p * c[8] + r * c[12];
if (0 == c) {
if (b) throw Error("Matrix4.getInverse(): can't invert matrix, determinant is 0");
console.warn("Matrix4.getInverse(): can't invert matrix, determinant is 0");
this.identity();
return this
}
this.multiplyScalar(1 / c);
return 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;
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;
return this
},
getMaxScaleOnAxis: function() {
var a = this.elements;
return Math.sqrt(Math.max(a[0] * a[0] + a[1] * a[1] + a[2] * a[2], Math.max(a[4] * a[4] + a[5] * a[5] + a[6] * a[6], a[8] * a[8] + a[9] * a[9] + a[10] * a[10])))
},
makeTranslation: function(a, b, c) {
this.set(1, 0, 0, a, 0, 1, 0, b, 0, 0, 1, c, 0, 0, 0, 1);
return this
},
makeRotationX: function(a) {
var b = Math.cos(a),
a = Math.sin(a);
this.set(1,
0, 0, 0, 0, b, -a, 0, 0, a, b, 0, 0, 0, 0, 1);
return this
},
makeRotationY: function(a) {
var b = Math.cos(a),
a = Math.sin(a);
this.set(b, 0, a, 0, 0, 1, 0, 0, -a, 0, b, 0, 0, 0, 0, 1);
return this
},
makeRotationZ: function(a) {
var b = Math.cos(a),
a = Math.sin(a);
this.set(b, -a, 0, 0, a, b, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
return this
},
makeRotationAxis: function(a, b) {
var c = Math.cos(b),
d = Math.sin(b),
e = 1 - c,
f = a.x,
g = a.y,
h = a.z,
i = e * f,
k = e * g;
this.set(i * f + c, i * g - d * h, i * h + d * g, 0, i * g + d * h, k * g + c, k * h - d * f, 0, i * h - d * g, k * h + d * f, e * h * h + c, 0, 0, 0, 0, 1);
return this
},
makeScale: function(a, b, c) {
this.set(a,
0, 0, 0, 0, b, 0, 0, 0, 0, c, 0, 0, 0, 0, 1);
return this
},
compose: function(a, b, c) {
this.makeRotationFromQuaternion(b);
this.scale(c);
this.setPosition(a);
return this
},
decompose: function() {
var a = new THREE.Vector3,
b = new THREE.Matrix4;
return function(c, d, e) {
var f = this.elements,
g = a.set(f[0], f[1], f[2]).length(),
h = a.set(f[4], f[5], f[6]).length(),
i = a.set(f[8], f[9], f[10]).length();
c.x = f[12];
c.y = f[13];
c.z = f[14];
b.elements.set(this.elements);
var c = 1 / g,
f = 1 / h,
k = 1 / i;
b.elements[0] *= c;
b.elements[1] *= c;
b.elements[2] *= c;
b.elements[4] *=
f;
b.elements[5] *= f;
b.elements[6] *= f;
b.elements[8] *= k;
b.elements[9] *= k;
b.elements[10] *= k;
d.setFromRotationMatrix(b);
e.x = g;
e.y = h;
e.z = i;
return this
}
}(),
makeFrustum: function(a, b, c, d, e, f) {
var g = this.elements;
g[0] = 2 * e / (b - a);
g[4] = 0;
g[8] = (b + a) / (b - a);
g[12] = 0;
g[1] = 0;
g[5] = 2 * e / (d - c);
g[9] = (d + c) / (d - c);
g[13] = 0;
g[2] = 0;
g[6] = 0;
g[10] = -(f + e) / (f - e);
g[14] = -2 * f * e / (f - e);
g[3] = 0;
g[7] = 0;
g[11] = -1;
g[15] = 0;
return this
},
makePerspective: function(a, b, c, d) {
var a = c * Math.tan(THREE.Math.degToRad(0.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,
k = f - e;
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 / k;
g[14] = -((f + e) / k);
g[3] = 0;
g[7] = 0;
g[11] = 0;
g[15] = 1;
return this
},
fromArray: function(a) {
this.elements.set(a);
return this
},
toArray: function() {
var a = this.elements;
return [a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]]
},
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.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) {
this.origin.copy(a);
this.direction.copy(b);
return this
},
copy: function(a) {
this.origin.copy(a.origin);
this.direction.copy(a.direction);
return 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) {
this.origin.copy(this.at(b, a));
return this
}
}(),
closestPointToPoint: function(a, b) {
var c = b || new THREE.Vector3;
c.subVectors(a, this.origin);
var d = c.dot(this.direction);
return 0 > d ? c.copy(this.origin) : 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);
if (0 > c) return this.origin.distanceTo(b);
a.copy(this.direction).multiplyScalar(c).add(this.origin);
return a.distanceTo(b)
}
}(),
distanceSqToSegment: function(a, b, c, d) {
var e = a.clone().add(b).multiplyScalar(0.5),
f = b.clone().sub(a).normalize(),
g = 0.5 * a.distanceTo(b),
h = this.origin.clone().sub(e),
a = -this.direction.dot(f),
b = h.dot(this.direction),
i = -h.dot(f),
k = h.lengthSq(),
l = Math.abs(1 - a * a),
m, p;
0 <= l ? (h = a * i - b, m = a * b - i, p = g * l, 0 <= h ? m >= -p ? m <= p ? (g = 1 / l, h *= g, m *= g, a = h * (h + a * m + 2 * b) + m * (a * h + m + 2 * i) + k) : (m = g, h = Math.max(0, -(a * m + b)), a = -h * h + m * (m + 2 * i) + k) : (m = -g, h = Math.max(0, -(a * m + b)), a = -h * h + m * (m + 2 * i) + k) : m <= -p ? (h = Math.max(0, -(-a * g + b)), m = 0 < h ? -g : Math.min(Math.max(-g, -i), g), a = -h * h + m * (m + 2 * i) + k) : m <= p ? (h = 0, m = Math.min(Math.max(-g, -i), g), a = m * (m + 2 * i) + k) : (h = Math.max(0, -(a * g + b)), m = 0 < h ? g : Math.min(Math.max(-g, -i), g), a = -h * h + m * (m + 2 * i) + k)) : (m = 0 < a ? -g : g, h = Math.max(0, -(a * m + b)), a = -h * h + m * (m + 2 * i) + k);
c && c.copy(this.direction.clone().multiplyScalar(h).add(this.origin));
d && d.copy(f.clone().multiplyScalar(m).add(e));
return a
},
isIntersectionSphere: function(a) {
return this.distanceToPoint(a.center) <= a.radius
},
isIntersectionPlane: function(a) {
var b = a.distanceToPoint(this.origin);
return 0 === b || 0 > a.normal.dot(this.direction) * b ? !0 : !1
},
distanceToPlane: function(a) {
var b = a.normal.dot(this.direction);
if (0 == b) return 0 == a.distanceToPoint(this.origin) ?
0 : null;
a = -(this.origin.dot(a.normal) + a.constant) / b;
return 0 <= a ? a : null
},
intersectPlane: function(a, b) {
var c = this.distanceToPlane(a);
return null === c ? null : this.at(c, b)
},
applyMatrix4: function(a) {
this.direction.add(this.origin).applyMatrix4(a);
this.origin.applyMatrix4(a);
this.direction.sub(this.origin);
return 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) {
this.center.copy(a);
this.radius = b;
return this
},
setFromPoints: function(a) {
for (var b, c = 0, d = 0, e = a.length; d < e; d++) b = a[d].lengthSq(), c = Math.max(c, b);
this.center.set(0, 0, 0);
this.radius = Math.sqrt(c);
return this
},
copy: function(a) {
this.center.copy(a.center);
this.radius = a.radius;
return 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;
d.copy(a);
c > this.radius * this.radius && (d.sub(this.center).normalize(), d.multiplyScalar(this.radius).add(this.center));
return d
},
getBoundingBox: function(a) {
a = a || new THREE.Box3;
a.set(this.center, this.center);
a.expandByScalar(this.radius);
return a
},
applyMatrix4: function(a) {
this.center.applyMatrix4(a);
this.radius *= a.getMaxScaleOnAxis();
return this
},
translate: function(a) {
this.center.add(a);
return 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;
g[0].copy(a);
g[1].copy(b);
g[2].copy(c);
g[3].copy(d);
g[4].copy(e);
g[5].copy(f);
return 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],
k = c[7],
l = c[8],
m = c[9],
p = c[10],
q = c[11],
t = c[12],
n = c[13],
r = c[14],
c = c[15];
b[0].setComponents(f - a, k - g, q - l, c - t).normalize();
b[1].setComponents(f +
a, k + g, q + l, c + t).normalize();
b[2].setComponents(f + d, k + h, q + m, c + n).normalize();
b[3].setComponents(f - d, k - h, q - m, c - n).normalize();
b[4].setComponents(f - e, k - i, q - p, c - r).normalize();
b[5].setComponents(f + e, k + i, q + p, c + r).normalize();
return this
},
intersectsObject: function() {
var a = new THREE.Vector3;
return function(b) {
var c = b.geometry,
b = b.matrixWorld;
null === c.boundingSphere && c.computeBoundingSphere();
c = -c.boundingSphere.radius * b.getMaxScaleOnAxis();
a.getPositionFromMatrix(b);
for (var b = this.planes, d = 0; 6 > d; d++)
if (b[d].distanceToPoint(a) <
c) 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
},
intersectsBox: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function(c) {
for (var d = this.planes, e = 0; 6 > e; e++) {
var f = d[e];
a.x = 0 < f.normal.x ? c.min.x : c.max.x;
b.x = 0 < f.normal.x ? c.max.x : c.min.x;
a.y = 0 < f.normal.y ? c.min.y : c.max.y;
b.y = 0 < f.normal.y ? c.max.y : c.min.y;
a.z = 0 < f.normal.z ? c.min.z : c.max.z;
b.z = 0 < f.normal.z ? c.max.z : c.min.z;
var g = f.distanceToPoint(a),
f = f.distanceToPoint(b);
if (0 > g && 0 > f) 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) {
this.normal.copy(a);
this.constant = b;
return this
},
setComponents: function(a, b, c, d) {
this.normal.set(a, b, c);
this.constant = d;
return this
},
setFromNormalAndCoplanarPoint: function(a, b) {
this.normal.copy(a);
this.constant = -b.dot(this.normal);
return this
},
setFromCoplanarPoints: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function(c, d, e) {
d = a.subVectors(e, d).cross(b.subVectors(c, d)).normalize();
this.setFromNormalAndCoplanarPoint(d,
c);
return this
}
}(),
copy: function(a) {
this.normal.copy(a.normal);
this.constant = a.constant;
return this
},
normalize: function() {
var a = 1 / this.normal.length();
this.normal.multiplyScalar(a);
this.constant *= a;
return this
},
negate: function() {
this.constant *= -1;
this.normal.negate();
return 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 && 0 < a || 0 > a && 0 < b
},
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);
if (0 == f) {
if (0 == this.distanceToPoint(b.start)) return d.copy(b.start)
} else return f = -(b.start.dot(this.normal) + this.constant) / f, 0 > f || 1 < f ? void 0 : d.copy(e).multiplyScalar(f).add(b.start)
}
}(),
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);
f.applyMatrix4(c);
this.setFromNormalAndCoplanarPoint(e, f);
return this
}
}(),
translate: function(a) {
this.constant -= a.dot(this.normal);
return this
},
equals: function(a) {
return a.normal.equals(this.normal) &&
a.constant == this.constant
},
clone: function() {
return (new THREE.Plane).copy(this)
}
};
THREE.Math = {
PI2: 2 * Math.PI,
generateUUID: function() {
var a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),
b = Array(36),
c = 0,
d;
return function() {
for (var e = 0; 36 > e; e++) 8 == e || 13 == e || 18 == e || 23 == e ? b[e] = "-" : 14 == e ? b[e] = "4" : (2 >= c && (c = 33554432 + 16777216 * Math.random() | 0), d = c & 15, c >>= 4, b[e] = a[19 == e ? d & 3 | 8 : d]);
return b.join("")
}
}(),
clamp: function(a, b, c) {
return a < b ? b : a > c ? c : a
},
clampBottom: function(a, b) {
return a < b ? b : a
},
mapLinear: function(a, b, c, d, e) {
return d + (a - b) * (e - d) / (c - b)
},
smoothstep: function(a,
b, c) {
if (a <= b) return 0;
if (a >= c) return 1;
a = (a - b) / (c - b);
return a * a * (3 - 2 * a)
},
smootherstep: function(a, b, c) {
if (a <= b) return 0;
if (a >= c) return 1;
a = (a - b) / (c - b);
return 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 * (0.5 - Math.random())
},
sign: function(a) {
return 0 > a ? -1 : 0 < a ? 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) {
a = 0.5 * (c - a);
d = 0.5 * (d - b);
return (2 * (b - c) + a + d) * g + (-3 * (b - c) - 2 * a - d) * f + a * e + b
}
this.points = a;
var c = [],
d = {
x: 0,
y: 0,
z: 0
},
e, f, g, h, i, k, l, m, p;
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) {
e = (this.points.length - 1) * a;
f = Math.floor(e);
g = e - f;
c[0] = 0 === f ? f : f - 1;
c[1] = f;
c[2] = f > this.points.length - 2 ? this.points.length - 1 : f + 1;
c[3] = f > this.points.length - 3 ? this.points.length - 1 :
f + 2;
k = this.points[c[0]];
l = this.points[c[1]];
m = this.points[c[2]];
p = this.points[c[3]];
h = g * g;
i = g * h;
d.x = b(k.x, l.x, m.x, p.x, g, h, i);
d.y = b(k.y, l.y, m.y, p.y, g, h, i);
d.z = b(k.z, l.z, m.z, p.z, g, h, i);
return d
};
this.getControlPointsArray = function() {
var a, b, c = this.points.length,
d = [];
for (a = 0; a < c; 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;
h[0] = 0;
a || (a = 100);
c = this.points.length * a;
f.copy(this.points[0]);
for (a = 1; a < c; 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);
h[h.length] = i;
return {
chunks: h,
total: i
}
};
this.reparametrizeByArcLength = function(a) {
var b, c, d, e, f, g, h = [],
i = new THREE.Vector3,
k = this.getLength();
h.push(i.copy(this.points[0]).clone());
for (b = 1; b < this.points.length; b++) {
c = k.chunks[b] - k.chunks[b - 1];
g = Math.ceil(a * c / k.total);
e = (b - 1) / (this.points.length - 1);
f = b / (this.points.length - 1);
for (c = 1; c < g - 1; 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) {
e = e || new THREE.Vector3;
e.subVectors(d, c);
a.subVectors(b, c);
e.cross(a);
b = e.lengthSq();
return 0 < b ? 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),
k = d * i - e * e,
h = h || new THREE.Vector3;
if (0 == k) return h.set(-2, -1, -1);
k = 1 / k;
i = (i * f - e * g) * k;
d = (d * g - e * f) * k;
return h.set(1 - i - d, d, i)
}
}();
THREE.Triangle.containsPoint = function() {
var a = new THREE.Vector3;
return function(b, c, d, e) {
b = THREE.Triangle.barycoordFromPoint(b, c, d, e, a);
return 0 <= b.x && 0 <= b.y && 1 >= b.x + b.y
}
}();
THREE.Triangle.prototype = {
constructor: THREE.Triangle,
set: function(a, b, c) {
this.a.copy(a);
this.b.copy(b);
this.c.copy(c);
return this
},
setFromPointsAndIndices: function(a, b, c, d) {
this.a.copy(a[b]);
this.b.copy(a[c]);
this.c.copy(a[d]);
return this
},
copy: function(a) {
this.a.copy(a.a);
this.b.copy(a.b);
this.c.copy(a.c);
return this
},
area: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function() {
a.subVectors(this.c, this.b);
b.subVectors(this.a, this.b);
return 0.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) {
console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");
return a
};
THREE.UV = function(a, b) {
console.warn("THREE.UV has been DEPRECATED. Use THREE.Vector2 instead.");
return 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 !== self.performance && void 0 !== self.performance.now ? self.performance.now() : Date.now();
this.running = !0
},
stop: function() {
this.getElapsedTime();
this.running = !1
},
getElapsedTime: function() {
this.getDelta();
return this.elapsedTime
},
getDelta: function() {
var a = 0;
this.autoStart && !this.running && this.start();
if (this.running) {
var b = void 0 !== self.performance && void 0 !== self.performance.now ? self.performance.now() : Date.now(),
a = 0.001 * (b - this.oldTime);
this.oldTime = b;
this.elapsedTime += a
}
return a
}
};
THREE.EventDispatcher = function() {};
THREE.EventDispatcher.prototype = {
constructor: THREE.EventDispatcher,
apply: function(a) {
a.addEventListener = THREE.EventDispatcher.prototype.addEventListener;
a.hasEventListener = THREE.EventDispatcher.prototype.hasEventListener;
a.removeEventListener = THREE.EventDispatcher.prototype.removeEventListener;
a.dispatchEvent = THREE.EventDispatcher.prototype.dispatchEvent
},
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; c < d; 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 || Infinity
};
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, k, p) {
if (h instanceof a.Particle) {
f.getPositionFromMatrix(h.matrixWorld);
var q = k.ray.distanceToPoint(f);
if (q > h.scale.x) return p;
p.push({
distance: q,
point: h.position,
face: null,
object: h
})
} else if (h instanceof a.LOD) f.getPositionFromMatrix(h.matrixWorld), q = k.ray.origin.distanceTo(f), i(h.getObjectForDistance(q), k, p);
else if (h instanceof a.Mesh) {
q = h.geometry;
f.getPositionFromMatrix(h.matrixWorld);
null === q.boundingSphere && q.computeBoundingSphere();
b.set(f, q.boundingSphere.radius * h.matrixWorld.getMaxScaleOnAxis());
if (!1 === k.ray.isIntersectionSphere(b)) return p;
var t = q.vertices;
if (q instanceof a.BufferGeometry) {
var n = h.material;
if (void 0 === n || !1 === q.dynamic) return p;
var r = h.material instanceof a.MeshFaceMaterial,
s = !0 === r ? h.material.materials : null,
v = h.material.side,
z, H, B = k.precision;
g.getInverse(h.matrixWorld);
c.copy(k.ray).applyMatrix4(g);
var G, t = !1;
q.attributes.index && (t = !0);
s = new a.Vector3;
G = new a.Vector3;
var I = new a.Vector3;
new a.Vector3;
new a.Vector3;
for (var F = 0; F < q.offsets.length; ++F)
for (var A = q.offsets[F].start, N = q.offsets[F].index, r = A, C = A + q.offsets[F].count; r < C; r += 3)
if (t ? (v = N + q.attributes.index.array[r], z = N + q.attributes.index.array[r + 1], H = N + q.attributes.index.array[r + 2]) : (v = N, z = N + 1, H = N + 2), s.set(q.attributes.position.array[3 *
v], q.attributes.position.array[3 * v + 1], q.attributes.position.array[3 * v + 2]), G.set(q.attributes.position.array[3 * z], q.attributes.position.array[3 * z + 1], q.attributes.position.array[3 * z + 2]), I.set(q.attributes.position.array[3 * H], q.attributes.position.array[3 * H + 1], q.attributes.position.array[3 * H + 2]), d.setFromCoplanarPoints(s, G, I), A = c.distanceToPlane(d), !(A < B) && null !== A) {
v = n.side;
if (v !== a.DoubleSide && (z = c.direction.dot(d.normal), !(v === a.FrontSide ? 0 > z : 0 < z))) continue;
A < k.near || A > k.far || (e = c.at(A, e), !1 !== a.Triangle.containsPoint(e,
s, G, I) && p.push({
distance: A,
point: k.ray.at(A),
face: null,
faceIndex: null,
object: h
}))
}
} else if (q instanceof a.Geometry) {
r = h.material instanceof a.MeshFaceMaterial;
s = !0 === r ? h.material.materials : null;
B = k.precision;
g.getInverse(h.matrixWorld);
c.copy(k.ray).applyMatrix4(g);
I = 0;
for (G = q.faces.length; I < G; I++)
if (F = q.faces[I], n = !0 === r ? s[F.materialIndex] : h.material, void 0 !== n && (d.setFromNormalAndCoplanarPoint(F.normal, t[F.a]), A = c.distanceToPlane(d), !(A < B) && null !== A)) {
v = n.side;
if (v !== a.DoubleSide && (z = c.direction.dot(d.normal), !(v === a.FrontSide ? 0 > z : 0 < z))) continue;
if (!(A < k.near || A > k.far)) {
e = c.at(A, e);
if (F instanceof a.Face3) {
if (v = t[F.a], z = t[F.b], H = t[F.c], !1 === a.Triangle.containsPoint(e, v, z, H)) continue
} else if (F instanceof a.Face4) {
if (v = t[F.a], z = t[F.b], H = t[F.c], n = t[F.d], !1 === a.Triangle.containsPoint(e, v, z, n) && !1 === a.Triangle.containsPoint(e, z, H, n)) continue
} else throw Error("face type not supported");
p.push({
distance: A,
point: k.ray.at(A),
face: F,
faceIndex: I,
object: h
})
}
}
}
} else if (h instanceof a.Line) {
B = k.linePrecision;
B *= B;
q =
h.geometry;
null === q.boundingSphere && q.computeBoundingSphere();
f.getPositionFromMatrix(h.matrixWorld);
b.set(f, q.boundingSphere.radius * h.matrixWorld.getMaxScaleOnAxis());
if (!1 === k.ray.isIntersectionSphere(b)) return p;
g.getInverse(h.matrixWorld);
c.copy(k.ray).applyMatrix4(g);
c.direction.normalize();
t = q.vertices;
n = t.length;
A = new a.Vector3;
v = new a.Vector3;
z = h.type === a.LineStrip ? 1 : 2;
for (r = 0; r < n - 1; r += z) c.distanceSqToSegment(t[r], t[r + 1], v, A) <= B && (q = c.origin.distanceTo(v), k.near <= q && q <= k.far && p.push({
distance: q,
point: A.clone().applyMatrix4(h.matrixWorld),
face: null,
faceIndex: null,
object: h
}))
}
},
k = function(a, b, c) {
for (var a = a.getDescendants(), d = 0, e = a.length; d < e; d++) i(a[d], b, c)
};
a.Raycaster.prototype.precision = 1E-4;
a.Raycaster.prototype.linePrecision = 1;
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 = [];
!0 === b && k(a, this, c);
i(a, this, c);
c.sort(h);
return c
};
a.Raycaster.prototype.intersectObjects =
function(a, b) {
for (var c = [], d = 0, e = a.length; d < e; d++) i(a[d], this, c), !0 === b && k(a[d], this, c);
c.sort(h);
return c
}
})(THREE);
THREE.Object3D = function() {
this.id = THREE.Object3DIdCount++;
this.uuid = THREE.Math.generateUUID();
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.Euler;
this.quaternion = new THREE.Quaternion;
this.scale = new THREE.Vector3(1, 1, 1);
this.rotation._quaternion = this.quaternion;
this.quaternion._euler = this.rotation;
this.renderDepth = null;
this.rotationAutoUpdate = !0;
this.matrix = new THREE.Matrix4;
this.matrixWorld = new THREE.Matrix4;
this.visible = this.matrixWorldNeedsUpdate = this.matrixAutoUpdate = !0;
this.receiveShadow = this.castShadow = !1;
this.frustumCulled = !0;
this.userData = {}
};
THREE.Object3D.prototype = {
constructor: THREE.Object3D,
get eulerOrder() {
console.warn("DEPRECATED: Object3D's .eulerOrder has been moved to Object3D's .rotation.order.");
return this.rotation.order
},
set eulerOrder(a) {
console.warn("DEPRECATED: Object3D's .eulerOrder has been moved to Object3D's .rotation.order.");
this.rotation.order = a
},
get useQuaternion() {
console.warn("DEPRECATED: Object3D's .useQuaternion has been removed. The library now uses quaternions by default.")
},
set useQuaternion(a) {
console.warn("DEPRECATED: Object3D's .useQuaternion has been removed. The library now uses quaternions by default.")
},
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);
this.quaternion.setFromRotationMatrix(a)
}
}(),
setRotationFromAxisAngle: function(a, b) {
this.quaternion.setFromAxisAngle(a, b)
},
setRotationFromEuler: function(a) {
this.quaternion.setFromEuler(a, !0)
},
setRotationFromMatrix: function(a) {
this.quaternion.setFromRotationMatrix(a)
},
setRotationFromQuaternion: function(a) {
this.quaternion.copy(a)
},
rotateOnAxis: function() {
var a = new THREE.Quaternion;
return function(b, c) {
a.setFromAxisAngle(b, c);
this.quaternion.multiply(a);
return this
}
}(),
rotateX: function() {
var a = new THREE.Vector3(1, 0, 0);
return function(b) {
return this.rotateOnAxis(a, b)
}
}(),
rotateY: function() {
var a = new THREE.Vector3(0, 1, 0);
return function(b) {
return this.rotateOnAxis(a, b)
}
}(),
rotateZ: function() {
var a = new THREE.Vector3(0, 0, 1);
return function(b) {
return this.rotateOnAxis(a,
b)
}
}(),
translateOnAxis: function() {
var a = new THREE.Vector3;
return function(b, c) {
a.copy(b);
a.applyQuaternion(this.quaternion);
this.position.add(a.multiplyScalar(c));
return this
}
}(),
translate: function(a, b) {
console.warn("DEPRECATED: Object3D's .translate() has been removed. Use .translateOnAxis( axis, distance ) instead. Note args have been changed.");
return 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);
this.quaternion.setFromRotationMatrix(a)
}
}(),
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;
a.dispatchEvent({
type: "added"
});
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) {
a.parent = void 0;
a.dispatchEvent({
type: "removed"
});
this.children.splice(b, 1);
for (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; b < c; b++) this.children[b].traverse(a)
},
getObjectById: function(a, b) {
for (var c = 0, d = this.children.length; c < d; 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; c < d; 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) {
console.warn("DEPRECATED: Object3D's .getChildByName() has been renamed to .getObjectByName().");
return 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; b < c; b++) this.children[b].getDescendants(a);
return a
},
updateMatrix: function() {
this.matrix.compose(this.position, this.quaternion, this.scale);
this.matrixWorldNeedsUpdate = !0
},
updateMatrixWorld: function(a) {
!0 ===
this.matrixAutoUpdate && this.updateMatrix();
if (!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; b < c; b++) this.children[b].updateMatrixWorld(a)
},
clone: function(a, b) {
void 0 === a && (a = new THREE.Object3D);
void 0 === b && (b = !0);
a.name = this.name;
a.up.copy(this.up);
a.position.copy(this.position);
a.quaternion.copy(this.quaternion);
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.visible = this.visible;
a.castShadow = this.castShadow;
a.receiveShadow = this.receiveShadow;
a.frustumCulled = this.frustumCulled;
a.userData = JSON.parse(JSON.stringify(this.userData));
if (!0 === b)
for (var c = 0; c < this.children.length; c++) a.add(this.children[c].clone());
return a
}
};
THREE.EventDispatcher.prototype.apply(THREE.Object3D.prototype);
THREE.Object3DIdCount = 0;
THREE.Projector = function() {
function a() {
if (i === l) {
var a = new THREE.RenderableVertex;
k.push(a);
l++;
i++;
return a
}
return k[i++]
}
function b(a, b) {
return a.z !== b.z ? b.z - a.z : a.id !== b.id ? a.id - b.id : 0
}
function c(a, b) {
var c = 0,
d = 1,
e = a.z + a.w,
f = b.z + b.w,
g = -a.z + a.w,
h = -b.z + b.w;
if (0 <= e && 0 <= f && 0 <= g && 0 <= h) return !0;
if (0 > e && 0 > f || 0 > g && 0 > h) return !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)));
if (d < c) return !1;
a.lerp(b, c);
b.lerp(a, 1 - d);
return !0
}
var d, e, f = [],
g =
0,
h, i, k = [],
l = 0,
m, p, q = [],
t = 0,
n, r = [],
s = 0,
v, z, H = [],
B = 0,
G, I, F = [],
A = 0,
N = {
objects: [],
sprites: [],
lights: [],
elements: []
},
C = new THREE.Vector3,
K = new THREE.Vector4,
M = new THREE.Box3(new THREE.Vector3(-1, -1, -1), new THREE.Vector3(1, 1, 1)),
y = new THREE.Box3,
J = Array(3),
w = Array(4),
ca = new THREE.Matrix4,
D = new THREE.Matrix4,
qa, Pa = new THREE.Matrix4,
Sa = new THREE.Matrix3,
P = new THREE.Matrix3,
ia = new THREE.Vector3,
Wa = new THREE.Frustum,
L = new THREE.Vector4,
sa = new THREE.Vector4;
this.projectVector = function(a, b) {
b.matrixWorldInverse.getInverse(b.matrixWorld);
D.multiplyMatrices(b.projectionMatrix, b.matrixWorldInverse);
return a.applyProjection(D)
};
this.unprojectVector = function(a, b) {
b.projectionMatrixInverse.getInverse(b.projectionMatrix);
D.multiplyMatrices(b.matrixWorld, b.projectionMatrixInverse);
return a.applyProjection(D)
};
this.pickingRay = function(a, b) {
a.z = -1;
var c = new THREE.Vector3(a.x, a.y, 1);
this.unprojectVector(a, b);
this.unprojectVector(c, b);
c.sub(a).normalize();
return new THREE.Raycaster(a, c)
};
var W = function(a) {
if (e === g) {
var b = new THREE.RenderableObject;
f.push(b);
g++;
e++;
d = b
} else d = f[e++];
d.id = a.id;
d.object = a;
null !== a.renderDepth ? d.z = a.renderDepth : (C.getPositionFromMatrix(a.matrixWorld), C.applyProjection(D), d.z = C.z);
return d
},
ja = function(a) {
if (!1 !== a.visible) {
a instanceof THREE.Light ? N.lights.push(a) : a instanceof THREE.Mesh || a instanceof THREE.Line ? (!1 === a.frustumCulled || !0 === Wa.intersectsObject(a)) && N.objects.push(W(a)) : (a instanceof THREE.Sprite || a instanceof THREE.Particle) && N.sprites.push(W(a));
for (var b = 0, c = a.children.length; b < c; b++) ja(a.children[b])
}
};
this.projectScene = function(d, f, g, l) {
var C = !1,
W, X, fa, T, U, oa, ha, da, xa, Ta, la, ka, Ba;
I = z = n = p = 0;
N.elements.length = 0;
!0 === d.autoUpdate && d.updateMatrixWorld();
void 0 === f.parent && f.updateMatrixWorld();
ca.copy(f.matrixWorldInverse.getInverse(f.matrixWorld));
D.multiplyMatrices(f.projectionMatrix, ca);
P.getNormalMatrix(ca);
Wa.setFromMatrix(D);
e = 0;
N.objects.length = 0;
N.sprites.length = 0;
N.lights.length = 0;
ja(d);
!0 === g && N.objects.sort(b);
d = 0;
for (g = N.objects.length; d < g; d++)
if (da = N.objects[d].object, qa = da.matrixWorld,
i = 0, da instanceof THREE.Mesh) {
xa = da.geometry;
fa = xa.vertices;
Ta = xa.faces;
xa = xa.faceVertexUvs;
Sa.getNormalMatrix(qa);
ka = da.material instanceof THREE.MeshFaceMaterial;
Ba = !0 === ka ? da.material : null;
W = 0;
for (X = fa.length; W < X; W++) {
h = a();
h.positionWorld.copy(fa[W]).applyMatrix4(qa);
h.positionScreen.copy(h.positionWorld).applyMatrix4(D);
var ea = 1 / h.positionScreen.w;
h.positionScreen.x *= ea;
h.positionScreen.y *= ea;
h.positionScreen.z *= ea;
h.visible = !(-1 > h.positionScreen.x || 1 < h.positionScreen.x || -1 > h.positionScreen.y ||
1 < h.positionScreen.y || -1 > h.positionScreen.z || 1 < h.positionScreen.z)
}
fa = 0;
for (W = Ta.length; fa < W; fa++)
if (X = Ta[fa], ea = !0 === ka ? Ba.materials[X.materialIndex] : da.material, void 0 !== ea) {
oa = ea.side;
if (X instanceof THREE.Face3)
if (T = k[X.a], U = k[X.b], ha = k[X.c], J[0] = T.positionScreen, J[1] = U.positionScreen, J[2] = ha.positionScreen, !0 === T.visible || !0 === U.visible || !0 === ha.visible || M.isIntersectionBox(y.setFromPoints(J)))
if (C = 0 > (ha.positionScreen.x - T.positionScreen.x) * (U.positionScreen.y - T.positionScreen.y) - (ha.positionScreen.y -
T.positionScreen.y) * (U.positionScreen.x - T.positionScreen.x), oa === THREE.DoubleSide || C === (oa === THREE.FrontSide)) p === t ? (la = new THREE.RenderableFace3, q.push(la), t++, p++, m = la) : m = q[p++], m.id = da.id, m.v1.copy(T), m.v2.copy(U), m.v3.copy(ha);
else continue;
else continue;
else if (X instanceof THREE.Face4)
if (T = k[X.a], U = k[X.b], ha = k[X.c], la = k[X.d], w[0] = T.positionScreen, w[1] = U.positionScreen, w[2] = ha.positionScreen, w[3] = la.positionScreen, !0 === T.visible || !0 === U.visible || !0 === ha.visible || !0 === la.visible || M.isIntersectionBox(y.setFromPoints(w)))
if (C =
0 > (la.positionScreen.x - T.positionScreen.x) * (U.positionScreen.y - T.positionScreen.y) - (la.positionScreen.y - T.positionScreen.y) * (U.positionScreen.x - T.positionScreen.x) || 0 > (U.positionScreen.x - ha.positionScreen.x) * (la.positionScreen.y - ha.positionScreen.y) - (U.positionScreen.y - ha.positionScreen.y) * (la.positionScreen.x - ha.positionScreen.x), oa === THREE.DoubleSide || C === (oa === THREE.FrontSide)) {
if (n === s) {
var na = new THREE.RenderableFace4;
r.push(na);
s++;
n++;
m = na
} else m = r[n++];
m.id = da.id;
m.v1.copy(T);
m.v2.copy(U);
m.v3.copy(ha);
m.v4.copy(la)
} else continue;
else continue;
m.normalModel.copy(X.normal);
!1 === C && (oa === THREE.BackSide || oa === THREE.DoubleSide) && m.normalModel.negate();
m.normalModel.applyMatrix3(Sa).normalize();
m.normalModelView.copy(m.normalModel).applyMatrix3(P);
m.centroidModel.copy(X.centroid).applyMatrix4(qa);
ha = X.vertexNormals;
T = 0;
for (U = ha.length; T < U; T++) la = m.vertexNormalsModel[T], la.copy(ha[T]), !1 === C && (oa === THREE.BackSide || oa === THREE.DoubleSide) && la.negate(), la.applyMatrix3(Sa).normalize(), m.vertexNormalsModelView[T].copy(la).applyMatrix3(P);
m.vertexNormalsLength = ha.length;
T = 0;
for (U = xa.length; T < U; T++)
if (la = xa[T][fa], void 0 !== la) {
oa = 0;
for (ha = la.length; oa < ha; oa++) m.uvs[T][oa] = la[oa]
}
m.color = X.color;
m.material = ea;
ia.copy(m.centroidModel).applyProjection(D);
m.z = ia.z;
N.elements.push(m)
}
} else if (da instanceof THREE.Line) {
Pa.multiplyMatrices(D, qa);
fa = da.geometry.vertices;
T = a();
T.positionScreen.copy(fa[0]).applyMatrix4(Pa);
Ta = da.type === THREE.LinePieces ? 2 : 1;
W = 1;
for (X = fa.length; W < X; W++) T = a(), T.positionScreen.copy(fa[W]).applyMatrix4(Pa), 0 < (W + 1) %
Ta || (U = k[i - 2], L.copy(T.positionScreen), sa.copy(U.positionScreen), !0 === c(L, sa) && (L.multiplyScalar(1 / L.w), sa.multiplyScalar(1 / sa.w), z === B ? (xa = new THREE.RenderableLine, H.push(xa), B++, z++, v = xa) : v = H[z++], v.id = da.id, v.v1.positionScreen.copy(L), v.v2.positionScreen.copy(sa), v.z = Math.max(L.z, sa.z), v.material = da.material, da.material.vertexColors === THREE.VertexColors && (v.vertexColors[0].copy(da.geometry.colors[W]), v.vertexColors[1].copy(da.geometry.colors[W - 1])), N.elements.push(v)))
}
d = 0;
for (g = N.sprites.length; d <
g; d++) da = N.sprites[d].object, qa = da.matrixWorld, da instanceof THREE.Particle && (K.set(qa.elements[12], qa.elements[13], qa.elements[14], 1), K.applyMatrix4(D), ea = 1 / K.w, K.z *= ea, 0 < K.z && 1 > K.z && (I === A ? (C = new THREE.RenderableParticle, F.push(C), A++, I++, G = C) : G = F[I++], G.id = da.id, G.x = K.x * ea, G.y = K.y * ea, G.z = K.z, G.object = da, G.rotation = da.rotation.z, G.scale.x = da.scale.x * Math.abs(G.x - (K.x + f.projectionMatrix.elements[0]) / (K.w + f.projectionMatrix.elements[12])), G.scale.y = da.scale.y * Math.abs(G.y - (K.y + f.projectionMatrix.elements[5]) /
(K.w + f.projectionMatrix.elements[13])), G.material = da.material, N.elements.push(G)));
!0 === l && N.elements.sort(b);
return N
}
};
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;
b = 0;
for (c = this.vertexNormals.length; b < c; b++) a.vertexNormals[b] = this.vertexNormals[b].clone();
b = 0;
for (c = this.vertexColors.length; b < c; b++) a.vertexColors[b] = this.vertexColors[b].clone();
b = 0;
for (c = this.vertexTangents.length; b < c; 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;
b = 0;
for (c = this.vertexNormals.length; b < c; b++) a.vertexNormals[b] = this.vertexNormals[b].clone();
b = 0;
for (c = this.vertexColors.length; b < c; b++) a.vertexColors[b] = this.vertexColors[b].clone();
b = 0;
for (c = this.vertexTangents.length; b < c; b++) a.vertexTangents[b] = this.vertexTangents[b].clone();
return a
}
};
THREE.Geometry = function() {
this.id = THREE.GeometryIdCount++;
this.uuid = THREE.Math.generateUUID();
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,
applyMatrix: function(a) {
for (var b = (new THREE.Matrix3).getNormalMatrix(a), c = 0, d = this.vertices.length; c < d; c++) this.vertices[c].applyMatrix4(a);
c = 0;
for (d = this.faces.length; c < d; c++) {
var e = this.faces[c];
e.normal.applyMatrix3(b).normalize();
for (var f = 0, g = e.vertexNormals.length; f < g; f++) e.vertexNormals[f].applyMatrix3(b).normalize();
e.centroid.applyMatrix4(a)
}
this.boundingBox instanceof THREE.Box3 && this.computeBoundingBox();
this.boundingSphere instanceof
THREE.Sphere && this.computeBoundingSphere()
},
computeCentroids: function() {
var a, b, c;
a = 0;
for (b = this.faces.length; a < b; 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; c < d; 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) {
e = this.__tmpVertices = Array(this.vertices.length);
b = 0;
for (c = this.vertices.length; b < c; b++) e[b] = new THREE.Vector3;
b = 0;
for (c = this.faces.length; b < c; 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 {
e = this.__tmpVertices;
b = 0;
for (c = this.vertices.length; b < c; b++) e[b].set(0, 0, 0)
}
if (a) {
var f, g, h, i = new THREE.Vector3,
k = new THREE.Vector3,
l = new THREE.Vector3,
m = new THREE.Vector3,
p = new THREE.Vector3;
b = 0;
for (c = this.faces.length; b < c; 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), k.subVectors(a, f), i.cross(k), 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], l.subVectors(h, f), k.subVectors(a, f), l.cross(k), e[d.a].add(l), e[d.b].add(l), e[d.d].add(l), m.subVectors(h, g), p.subVectors(f, g), m.cross(p), e[d.b].add(m), e[d.c].add(m), e[d.d].add(m))
} else {
b = 0;
for (c = this.faces.length; b < c; 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))
}
b = 0;
for (c = this.vertices.length; b < c; b++) e[b].normalize();
b = 0;
for (c = this.faces.length; b < c; 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;
c = 0;
for (d = this.faces.length; c < d; c++) {
e = this.faces[c];
e.__originalFaceNormal ? e.__originalFaceNormal.copy(e.normal) : e.__originalFaceNormal = e.normal.clone();
e.__originalVertexNormals || (e.__originalVertexNormals = []);
a = 0;
for (b = e.vertexNormals.length; a < b; a++) e.__originalVertexNormals[a] ? e.__originalVertexNormals[a].copy(e.vertexNormals[a]) : e.__originalVertexNormals[a] = e.vertexNormals[a].clone()
}
var f = new THREE.Geometry;
f.faces =
this.faces;
a = 0;
for (b = this.morphTargets.length; a < b; a++) {
if (!this.morphNormals[a]) {
this.morphNormals[a] = {};
this.morphNormals[a].faceNormals = [];
this.morphNormals[a].vertexNormals = [];
var g = this.morphNormals[a].faceNormals,
h = this.morphNormals[a].vertexNormals,
i, k;
c = 0;
for (d = this.faces.length; c < d; c++) e = this.faces[c], i = new THREE.Vector3, k = 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
},
g.push(i), h.push(k)
}
g = this.morphNormals[a];
f.vertices = this.morphTargets[a].vertices;
f.computeFaceNormals();
f.computeVertexNormals();
c = 0;
for (d = this.faces.length; c < d; c++) e = this.faces[c], i = g.faceNormals[c], k = g.vertexNormals[c], i.copy(e.normal), e instanceof THREE.Face3 ? (k.a.copy(e.vertexNormals[0]), k.b.copy(e.vertexNormals[1]), k.c.copy(e.vertexNormals[2])) : (k.a.copy(e.vertexNormals[0]), k.b.copy(e.vertexNormals[1]), k.c.copy(e.vertexNormals[2]), k.d.copy(e.vertexNormals[3]))
}
c = 0;
for (d = this.faces.length; c <
d; 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];
k = a.vertices[d];
l = g[e];
m = g[f];
p = g[y];
q = i.x - h.x;
t = k.x - h.x;
n = i.y - h.y;
r = k.y - h.y;
s = i.z - h.z;
v = k.z - h.z;
z = m.x - l.x;
H = p.x - l.x;
B = m.y - l.y;
G = p.y - l.y;
a = z * G - H * B;
a || (z = 0.5, B = H = 1, G = 0.5, a = z * G - H * B);
I = 1 / a;
C.set((G * q - B * t) * I, (G * n - B * r) * I, (G * s - B * v) * I);
K.set((z * t - H * q) * I, (z * r - H * n) * I, (z * v - H * s) * I);
A[b].add(C);
A[c].add(C);
A[d].add(C);
N[b].add(K);
N[c].add(K);
N[d].add(K)
}
var b, c, d, e, f, g, h, i, k, l, m, p, q, t, n, r, s, v, z, H, B, G, I, F, A = [],
N = [],
C = new THREE.Vector3,
K = new THREE.Vector3,
M = new THREE.Vector3,
y = new THREE.Vector3,
J = new THREE.Vector3;
b = 0;
for (c = this.vertices.length; b < c; b++) A[b] = new THREE.Vector3, N[b] = new THREE.Vector3;
b = 0;
for (c = this.faces.length; b < c; 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 w = ["a", "b", "c", "d"];
b = 0;
for (c = this.faces.length; b < c; b++) {
f = this.faces[b];
for (d = 0; d < f.vertexNormals.length; d++) J.copy(f.vertexNormals[d]), e = f[w[d]], F = A[e], M.copy(F), M.sub(J.multiplyScalar(J.dot(F))).normalize(), y.crossVectors(f.vertexNormals[d], F), e = y.dot(N[e]), e = 0 > e ? -1 : 1, 0 == M.x && (0 == M.y && 0 == M.z) && (M.x = 1), f.vertexTangents[d] = new THREE.Vector4(M.x, M.y, M.z, e)
}
this.hasTangents = !0
},
computeLineDistances: function() {
for (var a = 0, b = this.vertices, c = 0, d = b.length; c < d; c++) 0 < c && (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.setFromPoints(this.vertices)
},
mergeVertices: function() {
var a = {},
b = [],
c = [],
d, e = Math.pow(10, 4),
f, g, h, i, k;
this.__tmpVertices = void 0;
f = 0;
for (g = this.vertices.length; f < g; f++) d = this.vertices[f], d = Math.round(d.x * e) + "_" + Math.round(d.y * e) + "_" + Math.round(d.z *
e), void 0 === a[d] ? (a[d] = f, b.push(this.vertices[f]), c[f] = b.length - 1) : c[f] = c[a[d]];
e = [];
f = 0;
for (g = this.faces.length; f < g; f++)
if (a = this.faces[f], a instanceof THREE.Face3) {
a.a = c[a.a];
a.b = c[a.b];
a.c = c[a.c];
h = [a.a, a.b, a.c];
d = -1;
for (i = 0; 3 > i; i++)
if (h[i] == h[(i + 1) % 3]) {
e.push(f);
break
}
} else if (a instanceof THREE.Face4) {
a.a = c[a.a];
a.b = c[a.b];
a.c = c[a.c];
a.d = c[a.d];
h = [a.a, a.b, a.c, a.d];
d = -1;
for (i = 0; 4 > i; i++) h[i] == h[(i + 1) % 4] && (0 <= d && e.push(f), d = i);
if (0 <= d) {
h.splice(d, 1);
var l = new THREE.Face3(h[0], h[1], h[2], a.normal,
a.color, a.materialIndex);
h = 0;
for (i = this.faceVertexUvs.length; h < i; h++)(k = this.faceVertexUvs[h][f]) && k.splice(d, 1);
a.vertexNormals && 0 < a.vertexNormals.length && (l.vertexNormals = a.vertexNormals, l.vertexNormals.splice(d, 1));
a.vertexColors && 0 < a.vertexColors.length && (l.vertexColors = a.vertexColors, l.vertexColors.splice(d, 1));
this.faces[f] = l
}
}
for (f = e.length - 1; 0 <= f; f--) {
this.faces.splice(f, 1);
h = 0;
for (i = this.faceVertexUvs.length; h < i; h++) this.faceVertexUvs[h].splice(f, 1)
}
c = this.vertices.length - b.length;
this.vertices =
b;
return c
},
clone: function() {
for (var a = new THREE.Geometry, b = this.vertices, c = 0, d = b.length; c < d; c++) a.vertices.push(b[c].clone());
b = this.faces;
c = 0;
for (d = b.length; c < d; c++) a.faces.push(b[c].clone());
b = this.faceVertexUvs[0];
c = 0;
for (d = b.length; c < d; c++) {
for (var e = b[c], f = [], g = 0, h = e.length; g < h; 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.EventDispatcher.prototype.apply(THREE.Geometry.prototype);
THREE.GeometryIdCount = 0;
THREE.BufferGeometry = function() {
this.id = THREE.GeometryIdCount++;
this.uuid = THREE.Math.generateUUID();
this.attributes = {};
this.dynamic = !1;
this.offsets = [];
this.boundingSphere = this.boundingBox = null;
this.hasTangents = !1;
this.morphTargets = []
};
THREE.BufferGeometry.prototype = {
constructor: THREE.BufferGeometry,
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 = this.boundingBox,
c, d, e;
3 <= a.length && (b.min.x = b.max.x = a[0], b.min.y = b.max.y = a[1], b.min.z = b.max.z = a[2]);
for (var f = 3, g = a.length; f < g; f += 3) c = a[f], d = a[f + 1], e = a[f + 2], c < b.min.x ? b.min.x = c : c > b.max.x && (b.max.x = c), d < b.min.y ? b.min.y = d : d > b.max.y && (b.max.y = d), e < b.min.z ? b.min.z = e : e > b.max.z && (b.max.z = e)
}
if (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 = 0, d, e, f = 0, g = a.length; f < g; f += 3) b = a[f], d = a[f + 1], e = a[f + 2], b = b * b + d * d + e * e, b > c && (c = b);
this.boundingSphere.radius = Math.sqrt(c)
}
},
computeVertexNormals: function() {
if (this.attributes.position) {
var a, b, c, d;
a = this.attributes.position.array.length;
if (void 0 === this.attributes.normal) this.attributes.normal = {
itemSize: 3,
array: new Float32Array(a)
};
else {
a = 0;
for (b = this.attributes.normal.array.length; a < b; a++) this.attributes.normal.array[a] = 0
}
var e =
this.attributes.position.array,
f = this.attributes.normal.array,
g, h, i, k, l, m, p = new THREE.Vector3,
q = new THREE.Vector3,
t = new THREE.Vector3,
n = new THREE.Vector3,
r = new THREE.Vector3;
if (this.attributes.index) {
var s = this.attributes.index.array,
v = this.offsets;
c = 0;
for (d = v.length; c < d; ++c) {
b = v[c].start;
g = v[c].count;
var z = v[c].index;
a = b;
for (b += g; a < b; a += 3) g = z + s[a], h = z + s[a + 1], i = z + s[a + 2], k = e[3 * g], l = e[3 * g + 1], m = e[3 * g + 2], p.set(k, l, m), k = e[3 * h], l = e[3 * h + 1], m = e[3 * h + 2], q.set(k, l, m), k = e[3 * i], l = e[3 * i + 1], m = e[3 * i + 2], t.set(k, l,
m), n.subVectors(t, q), r.subVectors(p, q), n.cross(r), f[3 * g] += n.x, f[3 * g + 1] += n.y, f[3 * g + 2] += n.z, f[3 * h] += n.x, f[3 * h + 1] += n.y, f[3 * h + 2] += n.z, f[3 * i] += n.x, f[3 * i + 1] += n.y, f[3 * i + 2] += n.z
}
} else {
a = 0;
for (b = e.length; a < b; a += 9) k = e[a], l = e[a + 1], m = e[a + 2], p.set(k, l, m), k = e[a + 3], l = e[a + 4], m = e[a + 5], q.set(k, l, m), k = e[a + 6], l = e[a + 7], m = e[a + 8], t.set(k, l, m), n.subVectors(t, q), r.subVectors(p, q), n.cross(r), f[a] = n.x, f[a + 1] = n.y, f[a + 2] = n.z, f[a + 3] = n.x, f[a + 4] = n.y, f[a + 5] = n.z, f[a + 6] = n.x, f[a + 7] = n.y, f[a + 8] = n.z
}
this.normalizeNormals();
this.normalsNeedUpdate = !0
}
},
normalizeNormals: function() {
for (var a = this.attributes.normal.array, b, c, d, e = 0, f = a.length; e < f; e += 3) b = a[e], c = a[e + 1], d = a[e + 2], b = 1 / Math.sqrt(b * b + c * c + d * d), a[e] *= b, a[e + 1] *= b, a[e + 2] *= b
},
computeTangents: function() {
function a(a) {
Pa.x = d[3 * a];
Pa.y = d[3 * a + 1];
Pa.z = d[3 * a + 2];
Sa.copy(Pa);
ia = h[a];
D.copy(ia);
D.sub(Pa.multiplyScalar(Pa.dot(ia))).normalize();
qa.crossVectors(Sa, ia);
Wa = qa.dot(i[a]);
P = 0 > Wa ? -1 : 1;
g[4 * a] = D.x;
g[4 * a + 1] = D.y;
g[4 * a + 2] = D.z;
g[4 * a + 3] = P
}
if (void 0 === this.attributes.index || void 0 === this.attributes.position ||
void 0 === this.attributes.normal || void 0 === this.attributes.uv) console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");
else {
var b = this.attributes.index.array,
c = this.attributes.position.array,
d = this.attributes.normal.array,
e = this.attributes.uv.array,
f = c.length / 3;
void 0 === this.attributes.tangent && (this.attributes.tangent = {
itemSize: 4,
array: new Float32Array(4 * f)
});
for (var g = this.attributes.tangent.array, h = [], i = [], k = 0; k < f; k++) h[k] = new THREE.Vector3,
i[k] = new THREE.Vector3;
var l, m, p, q, t, n, r, s, v, z, H, B, G, I, F, f = new THREE.Vector3,
k = new THREE.Vector3,
A, N, C, K, M, y, J, w = this.offsets;
C = 0;
for (K = w.length; C < K; ++C) {
N = w[C].start;
M = w[C].count;
var ca = w[C].index;
A = N;
for (N += M; A < N; A += 3) M = ca + b[A], y = ca + b[A + 1], J = ca + b[A + 2], l = c[3 * M], m = c[3 * M + 1], p = c[3 * M + 2], q = c[3 * y], t = c[3 * y + 1], n = c[3 * y + 2], r = c[3 * J], s = c[3 * J + 1], v = c[3 * J + 2], z = e[2 * M], H = e[2 * M + 1], B = e[2 * y], G = e[2 * y + 1], I = e[2 * J], F = e[2 * J + 1], q -= l, l = r - l, t -= m, m = s - m, n -= p, p = v - p, B -= z, z = I - z, G -= H, H = F - H, F = 1 / (B * H - z * G), f.set((H * q - G * l) * F, (H * t - G *
m) * F, (H * n - G * p) * F), k.set((B * l - z * q) * F, (B * m - z * t) * F, (B * p - z * n) * F), h[M].add(f), h[y].add(f), h[J].add(f), i[M].add(k), i[y].add(k), i[J].add(k)
}
var D = new THREE.Vector3,
qa = new THREE.Vector3,
Pa = new THREE.Vector3,
Sa = new THREE.Vector3,
P, ia, Wa;
C = 0;
for (K = w.length; C < K; ++C) {
N = w[C].start;
M = w[C].count;
ca = w[C].index;
A = N;
for (N += M; A < N; A += 3) M = ca + b[A], y = ca + b[A + 1], J = ca + b[A + 2], a(M), a(y), a(J)
}
this.tangentsNeedUpdate = this.hasTangents = !0
}
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
}
};
THREE.EventDispatcher.prototype.apply(THREE.BufferGeometry.prototype);
THREE.Camera = function() {
THREE.Object3D.call(this);
this.matrixWorldInverse = new THREE.Matrix4;
this.projectionMatrix = new THREE.Matrix4;
this.projectionMatrixInverse = new THREE.Matrix4
};
THREE.Camera.prototype = Object.create(THREE.Object3D.prototype);
THREE.Camera.prototype.lookAt = function() {
var a = new THREE.Matrix4;
return function(b) {
a.lookAt(this.position, b, this.up);
this.quaternion.setFromRotationMatrix(a)
}
}();
THREE.OrthographicCamera = function(a, b, c, d, e, f) {
THREE.Camera.call(this);
this.left = a;
this.right = b;
this.top = c;
this.bottom = d;
this.near = void 0 !== e ? e : 0.1;
this.far = void 0 !== f ? f : 2E3;
this.updateProjectionMatrix()
};
THREE.OrthographicCamera.prototype = Object.create(THREE.Camera.prototype);
THREE.OrthographicCamera.prototype.updateProjectionMatrix = function() {
this.projectionMatrix.makeOrthographic(this.left, this.right, this.top, this.bottom, this.near, this.far)
};
THREE.PerspectiveCamera = function(a, b, c, d) {
THREE.Camera.call(this);
this.fov = void 0 !== a ? a : 50;
this.aspect = void 0 !== b ? b : 1;
this.near = void 0 !== c ? c : 0.1;
this.far = void 0 !== d ? d : 2E3;
this.updateProjectionMatrix()
};
THREE.PerspectiveCamera.prototype = Object.create(THREE.Camera.prototype);
THREE.PerspectiveCamera.prototype.setLens = function(a, b) {
void 0 === b && (b = 24);
this.fov = 2 * THREE.Math.radToDeg(Math.atan(b / (2 * a)));
this.updateProjectionMatrix()
};
THREE.PerspectiveCamera.prototype.setViewOffset = function(a, b, c, d, e, f) {
this.fullWidth = a;
this.fullHeight = b;
this.x = c;
this.y = d;
this.width = e;
this.height = f;
this.updateProjectionMatrix()
};
THREE.PerspectiveCamera.prototype.updateProjectionMatrix = function() {
if (this.fullWidth) {
var a = this.fullWidth / this.fullHeight,
b = Math.tan(THREE.Math.degToRad(0.5 * this.fov)) * this.near,
c = -b,
d = a * c,
a = Math.abs(a * b - d),
c = Math.abs(b - c);
this.projectionMatrix.makeFrustum(d + this.x * a / this.fullWidth, d + (this.x + this.width) * a / this.fullWidth, b - (this.y + this.height) * c / this.fullHeight, b - this.y * c / this.fullHeight, this.near, this.far)
} else this.projectionMatrix.makePerspective(this.fov, this.aspect, this.near, this.far)
};
THREE.Light = function(a) {
THREE.Object3D.call(this);
this.color = new THREE.Color(a)
};
THREE.Light.prototype = Object.create(THREE.Object3D.prototype);
THREE.Light.prototype.clone = function(a) {
void 0 === a && (a = new THREE.Light);
THREE.Object3D.prototype.clone.call(this, a);
a.color.copy(this.color);
return a
};
THREE.AmbientLight = function(a) {
THREE.Light.call(this, a)
};
THREE.AmbientLight.prototype = Object.create(THREE.Light.prototype);
THREE.AmbientLight.prototype.clone = function() {
var a = new THREE.AmbientLight;
THREE.Light.prototype.clone.call(this, a);
return a
};
THREE.AreaLight = function(a, b) {
THREE.Light.call(this, a);
this.normal = new THREE.Vector3(0, -1, 0);
this.right = new THREE.Vector3(1, 0, 0);
this.intensity = void 0 !== b ? b : 1;
this.height = this.width = 1;
this.constantAttenuation = 1.5;
this.linearAttenuation = 0.5;
this.quadraticAttenuation = 0.1
};
THREE.AreaLight.prototype = Object.create(THREE.Light.prototype);
THREE.DirectionalLight = function(a, b) {
THREE.Light.call(this, a);
this.position.set(0, 1, 0);
this.target = new THREE.Object3D;
this.intensity = void 0 !== b ? b : 1;
this.onlyShadow = this.castShadow = !1;
this.shadowCameraNear = 50;
this.shadowCameraFar = 5E3;
this.shadowCameraLeft = -500;
this.shadowCameraTop = this.shadowCameraRight = 500;
this.shadowCameraBottom = -500;
this.shadowCameraVisible = !1;
this.shadowBias = 0;
this.shadowDarkness = 0.5;
this.shadowMapHeight = this.shadowMapWidth = 512;
this.shadowCascade = !1;
this.shadowCascadeOffset = new THREE.Vector3(0,
0, -1E3);
this.shadowCascadeCount = 2;
this.shadowCascadeBias = [0, 0, 0];
this.shadowCascadeWidth = [512, 512, 512];
this.shadowCascadeHeight = [512, 512, 512];
this.shadowCascadeNearZ = [-1, 0.99, 0.998];
this.shadowCascadeFarZ = [0.99, 0.998, 1];
this.shadowCascadeArray = [];
this.shadowMatrix = this.shadowCamera = this.shadowMapSize = this.shadowMap = null
};
THREE.DirectionalLight.prototype = Object.create(THREE.Light.prototype);
THREE.DirectionalLight.prototype.clone = function() {
var a = new THREE.DirectionalLight;
THREE.Light.prototype.clone.call(this, a);
a.target = this.target.clone();
a.intensity = this.intensity;
a.castShadow = this.castShadow;
a.onlyShadow = this.onlyShadow;
return a
};
THREE.HemisphereLight = function(a, b, c) {
THREE.Light.call(this, a);
this.position.set(0, 100, 0);
this.groundColor = new THREE.Color(b);
this.intensity = void 0 !== c ? c : 1
};
THREE.HemisphereLight.prototype = Object.create(THREE.Light.prototype);
THREE.HemisphereLight.prototype.clone = function() {
var a = new THREE.PointLight;
THREE.Light.prototype.clone.call(this, a);
a.groundColor.copy(this.groundColor);
a.intensity = this.intensity;
return a
};
THREE.PointLight = function(a, b, c) {
THREE.Light.call(this, a);
this.intensity = void 0 !== b ? b : 1;
this.distance = void 0 !== c ? c : 0
};
THREE.PointLight.prototype = Object.create(THREE.Light.prototype);
THREE.PointLight.prototype.clone = function() {
var a = new THREE.PointLight;
THREE.Light.prototype.clone.call(this, a);
a.intensity = this.intensity;
a.distance = this.distance;
return a
};
THREE.SpotLight = function(a, b, c, d, e) {
THREE.Light.call(this, a);
this.position.set(0, 1, 0);
this.target = new THREE.Object3D;
this.intensity = void 0 !== b ? b : 1;
this.distance = void 0 !== c ? c : 0;
this.angle = void 0 !== d ? d : Math.PI / 3;
this.exponent = void 0 !== e ? e : 10;
this.onlyShadow = this.castShadow = !1;
this.shadowCameraNear = 50;
this.shadowCameraFar = 5E3;
this.shadowCameraFov = 50;
this.shadowCameraVisible = !1;
this.shadowBias = 0;
this.shadowDarkness = 0.5;
this.shadowMapHeight = this.shadowMapWidth = 512;
this.shadowMatrix = this.shadowCamera = this.shadowMapSize =
this.shadowMap = null
};
THREE.SpotLight.prototype = Object.create(THREE.Light.prototype);
THREE.SpotLight.prototype.clone = function() {
var a = new THREE.SpotLight;
THREE.Light.prototype.clone.call(this, a);
a.target = this.target.clone();
a.intensity = this.intensity;
a.distance = this.distance;
a.angle = this.angle;
a.exponent = this.exponent;
a.castShadow = this.castShadow;
a.onlyShadow = this.onlyShadow;
return a
};
THREE.Loader = function(a) {
this.statusDomElement = (this.showStatus = a) ? THREE.Loader.prototype.addStatusElement() : null;
this.onLoadStart = function() {};
this.onLoadProgress = function() {};
this.onLoadComplete = function() {}
};
THREE.Loader.prototype = {
constructor: THREE.Loader,
crossOrigin: "anonymous",
addStatusElement: function() {
var a = document.createElement("div");
a.style.position = "absolute";
a.style.right = "0px";
a.style.top = "0px";
a.style.fontSize = "0.8em";
a.style.textAlign = "left";
a.style.background = "rgba(0,0,0,0.25)";
a.style.color = "#fff";
a.style.width = "120px";
a.style.padding = "0.5em 0.5em 0.5em 0.5em";
a.style.zIndex = 1E3;
a.innerHTML = "Loading ...";
return a
},
updateProgress: function(a) {
var b = "Loaded ",
b = a.total ? b + ((100 * a.loaded /
a.total).toFixed(0) + "%") : b + ((a.loaded / 1E3).toFixed(2) + " KB");
this.statusDomElement.innerHTML = b
},
extractUrlBase: function(a) {
a = a.split("/");
a.pop();
return (1 > a.length ? "." : a.join("/")) + "/"
},
initMaterials: function(a, b) {
for (var c = [], d = 0; d < a.length; ++d) c[d] = THREE.Loader.prototype.createMaterial(a[d], b);
return c
},
needsTangents: function(a) {
for (var b = 0, c = a.length; b < c; b++)
if (a[b] instanceof THREE.ShaderMaterial) return !0;
return !1
},
createMaterial: function(a, b) {
function c(a) {
a = Math.log(a) / Math.LN2;
return Math.floor(a) ==
a
}
function d(a) {
a = Math.log(a) / Math.LN2;
return Math.pow(2, Math.round(a))
}
function e(a, e, f, h, i, k, r) {
var s = /\.dds$/i.test(f),
v = b + "/" + f;
if (s) {
var z = THREE.ImageUtils.loadCompressedTexture(v);
a[e] = z
} else z = document.createElement("canvas"), a[e] = new THREE.Texture(z);
a[e].sourceFile = f;
h && (a[e].repeat.set(h[0], h[1]), 1 !== h[0] && (a[e].wrapS = THREE.RepeatWrapping), 1 !== h[1] && (a[e].wrapT = THREE.RepeatWrapping));
i && a[e].offset.set(i[0], i[1]);
k && (f = {
repeat: THREE.RepeatWrapping,
mirror: THREE.MirroredRepeatWrapping
}, void 0 !==
f[k[0]] && (a[e].wrapS = f[k[0]]), void 0 !== f[k[1]] && (a[e].wrapT = f[k[1]]));
r && (a[e].anisotropy = r);
if (!s) {
var H = a[e],
a = new Image;
a.onload = function() {
if (!c(this.width) || !c(this.height)) {
var a = d(this.width),
b = d(this.height);
H.image.width = a;
H.image.height = b;
H.image.getContext("2d").drawImage(this, 0, 0, a, b)
} else H.image = this;
H.needsUpdate = !0
};
a.crossOrigin = g.crossOrigin;
a.src = v
}
}
function f(a) {
return (255 * a[0] << 16) + (255 * a[1] << 8) + 255 * a[2]
}
var g = this,
h = "MeshLambertMaterial",
i = {
color: 15658734,
opacity: 1,
map: null,
lightMap: null,
normalMap: null,
bumpMap: null,
wireframe: !1
};
if (a.shading) {
var k = a.shading.toLowerCase();
"phong" === k ? h = "MeshPhongMaterial" : "basic" === k && (h = "MeshBasicMaterial")
}
void 0 !== a.blending && void 0 !== THREE[a.blending] && (i.blending = THREE[a.blending]);
if (void 0 !== a.transparent || 1 > a.opacity) i.transparent = a.transparent;
void 0 !== a.depthTest && (i.depthTest = a.depthTest);
void 0 !== a.depthWrite && (i.depthWrite = a.depthWrite);
void 0 !== a.visible && (i.visible = a.visible);
void 0 !== a.flipSided && (i.side = THREE.BackSide);
void 0 !== a.doubleSided && (i.side = THREE.DoubleSide);
void 0 !== a.wireframe && (i.wireframe = a.wireframe);
void 0 !== a.vertexColors && ("face" === a.vertexColors ? i.vertexColors = THREE.FaceColors : a.vertexColors && (i.vertexColors = THREE.VertexColors));
a.colorDiffuse ? i.color = f(a.colorDiffuse) : a.DbgColor && (i.color = a.DbgColor);
a.colorSpecular && (i.specular = f(a.colorSpecular));
a.colorAmbient && (i.ambient = f(a.colorAmbient));
a.transparency && (i.opacity = a.transparency);
a.specularCoef && (i.shininess = a.specularCoef);
a.mapDiffuse &&
b && e(i, "map", a.mapDiffuse, a.mapDiffuseRepeat, a.mapDiffuseOffset, a.mapDiffuseWrap, a.mapDiffuseAnisotropy);
a.mapLight && b && e(i, "lightMap", a.mapLight, a.mapLightRepeat, a.mapLightOffset, a.mapLightWrap, a.mapLightAnisotropy);
a.mapBump && b && e(i, "bumpMap", a.mapBump, a.mapBumpRepeat, a.mapBumpOffset, a.mapBumpWrap, a.mapBumpAnisotropy);
a.mapNormal && b && e(i, "normalMap", a.mapNormal, a.mapNormalRepeat, a.mapNormalOffset, a.mapNormalWrap, a.mapNormalAnisotropy);
a.mapSpecular && b && e(i, "specularMap", a.mapSpecular, a.mapSpecularRepeat,
a.mapSpecularOffset, a.mapSpecularWrap, a.mapSpecularAnisotropy);
a.mapBumpScale && (i.bumpScale = a.mapBumpScale);
a.mapNormal ? (h = THREE.ShaderLib.normalmap, k = THREE.UniformsUtils.clone(h.uniforms), k.tNormal.value = i.normalMap, a.mapNormalFactor && k.uNormalScale.value.set(a.mapNormalFactor, a.mapNormalFactor), i.map && (k.tDiffuse.value = i.map, k.enableDiffuse.value = !0), i.specularMap && (k.tSpecular.value = i.specularMap, k.enableSpecular.value = !0), i.lightMap && (k.tAO.value = i.lightMap, k.enableAO.value = !0), k.uDiffuseColor.value.setHex(i.color),
k.uSpecularColor.value.setHex(i.specular), k.uAmbientColor.value.setHex(i.ambient), k.uShininess.value = i.shininess, void 0 !== i.opacity && (k.uOpacity.value = i.opacity), h = new THREE.ShaderMaterial({
fragmentShader: h.fragmentShader,
vertexShader: h.vertexShader,
uniforms: k,
lights: !0,
fog: !0
}), i.transparent && (h.transparent = !0)) : h = new THREE[h](i);
void 0 !== a.DbgName && (h.name = a.DbgName);
return h
}
};
THREE.XHRLoader = function(a) {
this.manager = void 0 !== a ? a : THREE.DefaultLoadingManager
};
THREE.XHRLoader.prototype = {
constructor: THREE.XHRLoader,
load: function(a, b, c, d) {
var e = this,
f = new XMLHttpRequest;
void 0 !== b && f.addEventListener("load", function(c) {
e.manager.itemEnd(a);
b(c.target.responseText)
}, !1);
void 0 !== c && f.addEventListener("progress", function(a) {
c(a)
}, !1);
void 0 !== d && f.addEventListener("error", function(a) {
d(a)
}, !1);
void 0 !== this.crossOrigin && (f.crossOrigin = this.crossOrigin);
f.open("GET", a, !0);
f.send(null);
e.manager.itemStart(a)
},
setCrossOrigin: function(a) {
this.crossOrigin = a
}
};
THREE.ImageLoader = function(a) {
this.manager = void 0 !== a ? a : THREE.DefaultLoadingManager
};
THREE.ImageLoader.prototype = {
constructor: THREE.ImageLoader,
load: function(a, b, c, d) {
var e = this,
f = document.createElement("img");
void 0 !== b && f.addEventListener("load", function() {
e.manager.itemEnd(a);
b(this)
}, !1);
void 0 !== c && f.addEventListener("progress", function(a) {
c(a)
}, !1);
void 0 !== d && f.addEventListener("error", function(a) {
d(a)
}, !1);
void 0 !== this.crossOrigin && (f.crossOrigin = this.crossOrigin);
f.src = a;
e.manager.itemStart(a)
},
setCrossOrigin: function(a) {
this.crossOrigin = a
}
};
THREE.JSONLoader = function(a) {
THREE.Loader.call(this, a);
this.withCredentials = !1
};
THREE.JSONLoader.prototype = Object.create(THREE.Loader.prototype);
THREE.JSONLoader.prototype.load = function(a, b, c) {
c = c && "string" === typeof c ? c : this.extractUrlBase(a);
this.onLoadStart();
this.loadAjaxJSON(this, a, b, c)
};
THREE.JSONLoader.prototype.loadAjaxJSON = function(a, b, c, d, e) {
var f = new XMLHttpRequest,
g = 0;
f.onreadystatechange = function() {
if (f.readyState === f.DONE)
if (200 === f.status || 0 === f.status) {
if (f.responseText) {
var h = JSON.parse(f.responseText),
h = a.parse(h, d);
c(h.geometry, h.materials)
} else console.warn("THREE.JSONLoader: [" + b + "] seems to be unreachable or file there is empty");
a.onLoadComplete()
} else console.error("THREE.JSONLoader: Couldn't load [" + b + "] [" + f.status + "]");
else f.readyState === f.LOADING ? e && (0 === g &&
(g = f.getResponseHeader("Content-Length")), e({
total: g,
loaded: f.responseText.length
})) : f.readyState === f.HEADERS_RECEIVED && void 0 !== e && (g = f.getResponseHeader("Content-Length"))
};
f.open("GET", b, !0);
f.withCredentials = this.withCredentials;
f.send(null)
};
THREE.JSONLoader.prototype.parse = function(a, b) {
var c = new THREE.Geometry,
d = void 0 !== a.scale ? 1 / a.scale : 1,
e, f, g, h, i, k, l, m, p, q, t, n, r, s, v, z = a.faces;
q = a.vertices;
var H = a.normals,
B = a.colors,
G = 0;
if (void 0 !== a.uvs) {
for (e = 0; e < a.uvs.length; e++) a.uvs[e].length && G++;
for (e = 0; e < G; e++) c.faceUvs[e] = [], c.faceVertexUvs[e] = []
}
h = 0;
for (i = q.length; h < i;) k = new THREE.Vector3, k.x = q[h++] * d, k.y = q[h++] * d, k.z = q[h++] * d, c.vertices.push(k);
h = 0;
for (i = z.length; h < i;) {
q = z[h++];
k = q & 1;
g = q & 2;
e = q & 4;
f = q & 8;
m = q & 16;
l = q & 32;
t = q & 64;
q &= 128;
k ? (n =
new THREE.Face4, n.a = z[h++], n.b = z[h++], n.c = z[h++], n.d = z[h++], k = 4) : (n = new THREE.Face3, n.a = z[h++], n.b = z[h++], n.c = z[h++], k = 3);
g && (g = z[h++], n.materialIndex = g);
g = c.faces.length;
if (e)
for (e = 0; e < G; e++) r = a.uvs[e], p = z[h++], v = r[2 * p], p = r[2 * p + 1], c.faceUvs[e][g] = new THREE.Vector2(v, p);
if (f)
for (e = 0; e < G; e++) {
r = a.uvs[e];
s = [];
for (f = 0; f < k; f++) p = z[h++], v = r[2 * p], p = r[2 * p + 1], s[f] = new THREE.Vector2(v, p);
c.faceVertexUvs[e][g] = s
}
m && (m = 3 * z[h++], f = new THREE.Vector3, f.x = H[m++], f.y = H[m++], f.z = H[m], n.normal = f);
if (l)
for (e = 0; e < k; e++) m =
3 * z[h++], f = new THREE.Vector3, f.x = H[m++], f.y = H[m++], f.z = H[m], n.vertexNormals.push(f);
t && (l = z[h++], l = new THREE.Color(B[l]), n.color = l);
if (q)
for (e = 0; e < k; e++) l = z[h++], l = new THREE.Color(B[l]), n.vertexColors.push(l);
c.faces.push(n)
}
if (a.skinWeights) {
h = 0;
for (i = a.skinWeights.length; h < i; h += 2) z = a.skinWeights[h], H = a.skinWeights[h + 1], c.skinWeights.push(new THREE.Vector4(z, H, 0, 0))
}
if (a.skinIndices) {
h = 0;
for (i = a.skinIndices.length; h < i; h += 2) z = a.skinIndices[h], H = a.skinIndices[h + 1], c.skinIndices.push(new THREE.Vector4(z,
H, 0, 0))
}
c.bones = a.bones;
c.animation = a.animation;
if (void 0 !== a.morphTargets) {
h = 0;
for (i = a.morphTargets.length; h < i; h++) {
c.morphTargets[h] = {};
c.morphTargets[h].name = a.morphTargets[h].name;
c.morphTargets[h].vertices = [];
B = c.morphTargets[h].vertices;
G = a.morphTargets[h].vertices;
z = 0;
for (H = G.length; z < H; z += 3) q = new THREE.Vector3, q.x = G[z] * d, q.y = G[z + 1] * d, q.z = G[z + 2] * d, B.push(q)
}
}
if (void 0 !== a.morphColors) {
h = 0;
for (i = a.morphColors.length; h < i; h++) {
c.morphColors[h] = {};
c.morphColors[h].name = a.morphColors[h].name;
c.morphColors[h].colors = [];
H = c.morphColors[h].colors;
B = a.morphColors[h].colors;
d = 0;
for (z = B.length; d < z; d += 3) G = new THREE.Color(16755200), G.setRGB(B[d], B[d + 1], B[d + 2]), H.push(G)
}
}
c.computeCentroids();
c.computeFaceNormals();
c.computeBoundingSphere();
if (void 0 === a.materials) return {
geometry: c
};
d = this.initMaterials(a.materials, b);
this.needsTangents(d) && c.computeTangents();
return {
geometry: c,
materials: d
}
};
THREE.LoadingManager = function(a, b, c) {
var d = this,
e = 0,
f = 0;
this.onLoad = a;
this.onProgress = b;
this.onError = c;
this.itemStart = function() {
f++
};
this.itemEnd = function(a) {
e++;
if (void 0 !== d.onProgress) d.onProgress(a, e, f);
if (e === f && void 0 !== d.onLoad) d.onLoad()
}
};
THREE.DefaultLoadingManager = new THREE.LoadingManager;
THREE.GeometryLoader = function(a) {
this.manager = void 0 !== a ? a : THREE.DefaultLoadingManager
};
THREE.GeometryLoader.prototype = {
constructor: THREE.GeometryLoader,
load: function(a, b) {
var c = this,
d = new THREE.XHRLoader;
d.setCrossOrigin(this.crossOrigin);
d.load(a, function(a) {
b(c.parse(JSON.parse(a)))
})
},
setCrossOrigin: function(a) {
this.crossOrigin = a
},
parse: function() {}
};
THREE.MaterialLoader = function(a) {
this.manager = void 0 !== a ? a : THREE.DefaultLoadingManager
};
THREE.MaterialLoader.prototype = {
constructor: THREE.MaterialLoader,
load: function(a, b) {
var c = this,
d = new THREE.XHRLoader;
d.setCrossOrigin(this.crossOrigin);
d.load(a, function(a) {
b(c.parse(JSON.parse(a)))
})
},
setCrossOrigin: function(a) {
this.crossOrigin = a
},
parse: function(a) {
var b;
switch (a.type) {
case "MeshBasicMaterial":
b = new THREE.MeshBasicMaterial({
color: a.color,
opacity: a.opacity,
transparent: a.transparent,
wireframe: a.wireframe
});
break;
case "MeshLambertMaterial":
b = new THREE.MeshLambertMaterial({
color: a.color,
ambient: a.ambient,
emissive: a.emissive,
opacity: a.opacity,
transparent: a.transparent,
wireframe: a.wireframe
});
break;
case "MeshPhongMaterial":
b = new THREE.MeshPhongMaterial({
color: a.color,
ambient: a.ambient,
emissive: a.emissive,
specular: a.specular,
shininess: a.shininess,
opacity: a.opacity,
transparent: a.transparent,
wireframe: a.wireframe
});
break;
case "MeshNormalMaterial":
b = new THREE.MeshNormalMaterial({
opacity: a.opacity,
transparent: a.transparent,
wireframe: a.wireframe
});
break;
case "MeshDepthMaterial":
b = new THREE.MeshDepthMaterial({
opacity: a.opacity,
transparent: a.transparent,
wireframe: a.wireframe
})
}
void 0 !== a.vertexColors && (b.vertexColors = a.vertexColors);
return b
}
};
THREE.ObjectLoader = function(a) {
this.manager = void 0 !== a ? a : THREE.DefaultLoadingManager
};
THREE.ObjectLoader.prototype = {
constructor: THREE.ObjectLoader,
load: function(a, b) {
var c = this,
d = new THREE.XHRLoader(c.manager);
d.setCrossOrigin(this.crossOrigin);
d.load(a, function(a) {
b(c.parse(JSON.parse(a)))
})
},
setCrossOrigin: function(a) {
this.crossOrigin = a
},
parse: function(a) {
var b = this.parseGeometries(a.geometries),
c = this.parseMaterials(a.materials);
return this.parseObject(a.object, b, c)
},
parseGeometries: function(a) {
var b = {};
if (void 0 !== a)
for (var c = new THREE.JSONLoader, d = 0, e = a.length; d < e; d++) {
var f,
g = a[d];
switch (g.type) {
case "PlaneGeometry":
f = new THREE.PlaneGeometry(g.width, g.height, g.widthSegments, g.heightSegments);
break;
case "CubeGeometry":
f = new THREE.CubeGeometry(g.width, g.height, g.depth, g.widthSegments, g.heightSegments, g.depthSegments);
break;
case "CylinderGeometry":
f = new THREE.CylinderGeometry(g.radiusTop, g.radiusBottom, g.height, g.radiusSegments, g.heightSegments, g.openEnded);
break;
case "SphereGeometry":
f = new THREE.SphereGeometry(g.radius, g.widthSegments, g.heightSegments, g.phiStart, g.phiLength,
g.thetaStart, g.thetaLength);
break;
case "IcosahedronGeometry":
f = new THREE.IcosahedronGeometry(g.radius, g.detail);
break;
case "TorusGeometry":
f = new THREE.TorusGeometry(g.radius, g.tube, g.radialSegments, g.tubularSegments, g.arc);
break;
case "TorusKnotGeometry":
f = new THREE.TorusKnotGeometry(g.radius, g.tube, g.radialSegments, g.tubularSegments, g.p, g.q, g.heightScale);
break;
case "Geometry":
f = c.parse(g.data).geometry
}
f.uuid = g.uuid;
void 0 !== g.name && (f.name = g.name);
b[g.uuid] = f
}
return b
},
parseMaterials: function(a) {
var b = {};
if (void 0 !== a)
for (var c = new THREE.MaterialLoader, d = 0, e = a.length; d < e; d++) {
var f = a[d],
g = c.parse(f);
g.uuid = f.uuid;
void 0 !== f.name && (g.name = f.name);
b[f.uuid] = g
}
return b
},
parseObject: function() {
var a = new THREE.Matrix4;
return function(b, c, d) {
var e;
switch (b.type) {
case "Scene":
e = new THREE.Scene;
break;
case "PerspectiveCamera":
e = new THREE.PerspectiveCamera(b.fov, b.aspect, b.near, b.far);
break;
case "OrthographicCamera":
e = new THREE.OrthographicCamera(b.left, b.right, b.top, b.bottom, b.near, b.far);
break;
case "AmbientLight":
e =
new THREE.AmbientLight(b.color);
break;
case "DirectionalLight":
e = new THREE.DirectionalLight(b.color, b.intensity);
break;
case "PointLight":
e = new THREE.PointLight(b.color, b.intensity, b.distance);
break;
case "SpotLight":
e = new THREE.SpotLight(b.color, b.intensity, b.distance, b.angle, b.exponent);
break;
case "HemisphereLight":
e = new THREE.HemisphereLight(b.color, b.groundColor, b.intensity);
break;
case "Mesh":
e = c[b.geometry];
var f = d[b.material];
void 0 === e && console.error("THREE.ObjectLoader: Undefined geometry " +
b.geometry);
void 0 === f && console.error("THREE.ObjectLoader: Undefined material " + b.material);
e = new THREE.Mesh(e, f);
break;
default:
e = new THREE.Object3D
}
e.uuid = b.uuid;
void 0 !== b.name && (e.name = b.name);
void 0 !== b.matrix ? (a.fromArray(b.matrix), a.decompose(e.position, e.quaternion, e.scale)) : (void 0 !== b.position && e.position.fromArray(b.position), void 0 !== b.rotation && e.rotation.fromArray(b.rotation), void 0 !== b.scale && e.scale.fromArray(b.scale));
void 0 !== b.visible && (e.visible = b.visible);
void 0 !== b.userData &&
(e.userData = b.userData);
if (void 0 !== b.children)
for (var g in b.children) e.add(this.parseObject(b.children[g], c, d));
return e
}
}()
};
THREE.SceneLoader = function() {
this.onLoadStart = function() {};
this.onLoadProgress = function() {};
this.onLoadComplete = function() {};
this.callbackSync = function() {};
this.callbackProgress = function() {};
this.geometryHandlers = {};
this.hierarchyHandlers = {};
this.addGeometryHandler("ascii", THREE.JSONLoader)
};
THREE.SceneLoader.prototype = {
constructor: THREE.SceneLoader,
load: function(a, b) {
var c = this,
d = new THREE.XHRLoader(c.manager);
d.setCrossOrigin(this.crossOrigin);
d.load(a, function(d) {
c.parse(JSON.parse(d), b, a)
})
},
setCrossOrigin: function(a) {
this.crossOrigin = a
},
addGeometryHandler: function(a, b) {
this.geometryHandlers[a] = {
loaderClass: b
}
},
addHierarchyHandler: function(a, b) {
this.hierarchyHandlers[a] = {
loaderClass: b
}
},
parse: function(a, b, c) {
function d(a, b) {
return "relativeToHTML" == b ? a : p + "/" + a
}
function e() {
f(A.scene,
C.objects)
}
function f(a, b) {
var c, e, g, i, k, l, p;
for (p in b) {
var r = A.objects[p],
s = b[p];
if (void 0 === r) {
if (s.type && s.type in m.hierarchyHandlers) {
if (void 0 === s.loading) {
e = {
type: 1,
url: 1,
material: 1,
position: 1,
rotation: 1,
scale: 1,
visible: 1,
children: 1,
userData: 1,
skin: 1,
morph: 1,
mirroredLoop: 1,
duration: 1
};
g = {};
for (var y in s) y in e || (g[y] = s[y]);
t = A.materials[s.material];
s.loading = !0;
e = m.hierarchyHandlers[s.type].loaderObject;
e.options ? e.load(d(s.url, C.urlBaseType), h(p, a, t, s)) : e.load(d(s.url, C.urlBaseType), h(p,
a, t, s), g)
}
} else if (void 0 !== s.geometry) {
if (q = A.geometries[s.geometry]) {
r = !1;
t = A.materials[s.material];
r = t instanceof THREE.ShaderMaterial;
g = s.position;
i = s.rotation;
k = s.scale;
c = s.matrix;
l = s.quaternion;
s.material || (t = new THREE.MeshFaceMaterial(A.face_materials[s.geometry]));
t instanceof THREE.MeshFaceMaterial && 0 === t.materials.length && (t = new THREE.MeshFaceMaterial(A.face_materials[s.geometry]));
if (t instanceof THREE.MeshFaceMaterial)
for (e = 0; e < t.materials.length; e++) r = r || t.materials[e] instanceof THREE.ShaderMaterial;
r && q.computeTangents();
s.skin ? r = new THREE.SkinnedMesh(q, t) : s.morph ? (r = new THREE.MorphAnimMesh(q, t), void 0 !== s.duration && (r.duration = s.duration), void 0 !== s.time && (r.time = s.time), void 0 !== s.mirroredLoop && (r.mirroredLoop = s.mirroredLoop), t.morphNormals && q.computeMorphNormals()) : r = new THREE.Mesh(q, t);
r.name = p;
c ? (r.matrixAutoUpdate = !1, r.matrix.set(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15])) : (r.position.fromArray(g), l ? r.quaternion.fromArray(l) : r.rotation.fromArray(i),
r.scale.fromArray(k));
r.visible = s.visible;
r.castShadow = s.castShadow;
r.receiveShadow = s.receiveShadow;
a.add(r);
A.objects[p] = r
}
} else "DirectionalLight" === s.type || "PointLight" === s.type || "AmbientLight" === s.type ? (z = void 0 !== s.color ? s.color : 16777215, H = void 0 !== s.intensity ? s.intensity : 1, "DirectionalLight" === s.type ? (g = s.direction, v = new THREE.DirectionalLight(z, H), v.position.fromArray(g), s.target && (N.push({
object: v,
targetName: s.target
}), v.target = null)) : "PointLight" === s.type ? (g = s.position, e = s.distance, v = new THREE.PointLight(z,
H, e), v.position.fromArray(g)) : "AmbientLight" === s.type && (v = new THREE.AmbientLight(z)), a.add(v), v.name = p, A.lights[p] = v, A.objects[p] = v) : "PerspectiveCamera" === s.type || "OrthographicCamera" === s.type ? (g = s.position, i = s.rotation, l = s.quaternion, "PerspectiveCamera" === s.type ? n = new THREE.PerspectiveCamera(s.fov, s.aspect, s.near, s.far) : "OrthographicCamera" === s.type && (n = new THREE.OrthographicCamera(s.left, s.right, s.top, s.bottom, s.near, s.far)), n.name = p, n.position.fromArray(g), void 0 !== l ? n.quaternion.fromArray(l) :
void 0 !== i && n.rotation.fromArray(i), a.add(n), A.cameras[p] = n, A.objects[p] = n) : (g = s.position, i = s.rotation, k = s.scale, l = s.quaternion, r = new THREE.Object3D, r.name = p, r.position.fromArray(g), l ? r.quaternion.fromArray(l) : r.rotation.fromArray(i), r.scale.fromArray(k), r.visible = void 0 !== s.visible ? s.visible : !1, a.add(r), A.objects[p] = r, A.empties[p] = r);
if (r) {
if (void 0 !== s.userData)
for (var B in s.userData) r.userData[B] = s.userData[B];
if (void 0 !== s.groups)
for (e = 0; e < s.groups.length; e++) g = s.groups[e], void 0 === A.groups[g] &&
(A.groups[g] = []), A.groups[g].push(p)
}
}
void 0 !== r && void 0 !== s.children && f(r, s.children)
}
}
function g(a) {
return function(b, c) {
b.name = a;
A.geometries[a] = b;
A.face_materials[a] = c;
e();
B -= 1;
m.onLoadComplete();
k()
}
}
function h(a, b, c, d) {
return function(f) {
var f = f.content ? f.content : f.dae ? f.scene : f,
g = d.rotation,
h = d.quaternion,
i = d.scale;
f.position.fromArray(d.position);
h ? f.quaternion.fromArray(h) : f.rotation.fromArray(g);
f.scale.fromArray(i);
c && f.traverse(function(a) {
a.material = c
});
var l = void 0 !== d.visible ? d.visible :
!0;
f.traverse(function(a) {
a.visible = l
});
b.add(f);
f.name = a;
A.objects[a] = f;
e();
B -= 1;
m.onLoadComplete();
k()
}
}
function i(a) {
return function(b, c) {
b.name = a;
A.geometries[a] = b;
A.face_materials[a] = c
}
}
function k() {
m.callbackProgress({
totalModels: I,
totalTextures: F,
loadedModels: I - B,
loadedTextures: F - G
}, A);
m.onLoadProgress();
if (0 === B && 0 === G) {
for (var a = 0; a < N.length; a++) {
var c = N[a],
d = A.objects[c.targetName];
d ? c.object.target = d : (c.object.target = new THREE.Object3D, A.scene.add(c.object.target));
c.object.target.userData.targetInverse =
c.object
}
b(A)
}
}
function l(a, b) {
b(a);
if (void 0 !== a.children)
for (var c in a.children) l(a.children[c], b)
}
var m = this,
p = THREE.Loader.prototype.extractUrlBase(c),
q, t, n, r, s, v, z, H, B, G, I, F, A, N = [],
C = a,
K;
for (K in this.geometryHandlers) a = this.geometryHandlers[K].loaderClass, this.geometryHandlers[K].loaderObject = new a;
for (K in this.hierarchyHandlers) a = this.hierarchyHandlers[K].loaderClass, this.hierarchyHandlers[K].loaderObject = new a;
G = B = 0;
A = {
scene: new THREE.Scene,
geometries: {},
face_materials: {},
materials: {},
textures: {},
objects: {},
cameras: {},
lights: {},
fogs: {},
empties: {},
groups: {}
};
if (C.transform && (K = C.transform.position, a = C.transform.rotation, c = C.transform.scale, K && A.scene.position.fromArray(K), a && A.scene.rotation.fromArray(a), c && A.scene.scale.fromArray(c), K || a || c)) A.scene.updateMatrix(), A.scene.updateMatrixWorld();
K = function(a) {
return function() {
G -= a;
k();
m.onLoadComplete()
}
};
for (var M in C.fogs) a = C.fogs[M], "linear" === a.type ? r = new THREE.Fog(0, a.near, a.far) : "exp2" === a.type && (r = new THREE.FogExp2(0, a.density)), a = a.color,
r.color.setRGB(a[0], a[1], a[2]), A.fogs[M] = r;
for (var y in C.geometries) r = C.geometries[y], r.type in this.geometryHandlers && (B += 1, m.onLoadStart());
for (var J in C.objects) l(C.objects[J], function(a) {
a.type && a.type in m.hierarchyHandlers && (B += 1, m.onLoadStart())
});
I = B;
for (y in C.geometries)
if (r = C.geometries[y], "cube" === r.type) q = new THREE.CubeGeometry(r.width, r.height, r.depth, r.widthSegments, r.heightSegments, r.depthSegments), q.name = y, A.geometries[y] = q;
else if ("plane" === r.type) q = new THREE.PlaneGeometry(r.width,
r.height, r.widthSegments, r.heightSegments), q.name = y, A.geometries[y] = q;
else if ("sphere" === r.type) q = new THREE.SphereGeometry(r.radius, r.widthSegments, r.heightSegments), q.name = y, A.geometries[y] = q;
else if ("cylinder" === r.type) q = new THREE.CylinderGeometry(r.topRad, r.botRad, r.height, r.radSegs, r.heightSegs), q.name = y, A.geometries[y] = q;
else if ("torus" === r.type) q = new THREE.TorusGeometry(r.radius, r.tube, r.segmentsR, r.segmentsT), q.name = y, A.geometries[y] = q;
else if ("icosahedron" === r.type) q = new THREE.IcosahedronGeometry(r.radius,
r.subdivisions), q.name = y, A.geometries[y] = q;
else if (r.type in this.geometryHandlers) {
J = {};
for (s in r) "type" !== s && "url" !== s && (J[s] = r[s]);
this.geometryHandlers[r.type].loaderObject.load(d(r.url, C.urlBaseType), g(y), J)
} else "embedded" === r.type && (J = C.embeds[r.id], J.metadata = C.metadata, J && (J = this.geometryHandlers.ascii.loaderObject.parse(J, ""), i(y)(J.geometry, J.materials)));
for (var w in C.textures)
if (y = C.textures[w], y.url instanceof Array) {
G += y.url.length;
for (s = 0; s < y.url.length; s++) m.onLoadStart()
} else G +=
1, m.onLoadStart();
F = G;
for (w in C.textures) {
y = C.textures[w];
void 0 !== y.mapping && void 0 !== THREE[y.mapping] && (y.mapping = new THREE[y.mapping]);
if (y.url instanceof Array) {
J = y.url.length;
r = [];
for (s = 0; s < J; s++) r[s] = d(y.url[s], C.urlBaseType);
s = (s = /\.dds$/i.test(r[0])) ? THREE.ImageUtils.loadCompressedTextureCube(r, y.mapping, K(J)) : THREE.ImageUtils.loadTextureCube(r, y.mapping, K(J))
} else s = /\.dds$/i.test(y.url), J = d(y.url, C.urlBaseType), r = K(1), s = s ? THREE.ImageUtils.loadCompressedTexture(J, y.mapping, r) : THREE.ImageUtils.loadTexture(J,
y.mapping, r), void 0 !== THREE[y.minFilter] && (s.minFilter = THREE[y.minFilter]), void 0 !== THREE[y.magFilter] && (s.magFilter = THREE[y.magFilter]), y.anisotropy && (s.anisotropy = y.anisotropy), y.repeat && (s.repeat.set(y.repeat[0], y.repeat[1]), 1 !== y.repeat[0] && (s.wrapS = THREE.RepeatWrapping), 1 !== y.repeat[1] && (s.wrapT = THREE.RepeatWrapping)), y.offset && s.offset.set(y.offset[0], y.offset[1]), y.wrap && (J = {
repeat: THREE.RepeatWrapping,
mirror: THREE.MirroredRepeatWrapping
}, void 0 !== J[y.wrap[0]] && (s.wrapS = J[y.wrap[0]]), void 0 !==
J[y.wrap[1]] && (s.wrapT = J[y.wrap[1]]));
A.textures[w] = s
}
var ca, D;
for (ca in C.materials) {
w = C.materials[ca];
for (D in w.parameters) "envMap" === D || "map" === D || "lightMap" === D || "bumpMap" === D ? w.parameters[D] = A.textures[w.parameters[D]] : "shading" === D ? w.parameters[D] = "flat" === w.parameters[D] ? THREE.FlatShading : THREE.SmoothShading : "side" === D ? w.parameters[D] = "double" == w.parameters[D] ? THREE.DoubleSide : "back" == w.parameters[D] ? THREE.BackSide : THREE.FrontSide : "blending" === D ? w.parameters[D] = w.parameters[D] in THREE ? THREE[w.parameters[D]] :
THREE.NormalBlending : "combine" === D ? w.parameters[D] = w.parameters[D] in THREE ? THREE[w.parameters[D]] : THREE.MultiplyOperation : "vertexColors" === D ? "face" == w.parameters[D] ? w.parameters[D] = THREE.FaceColors : w.parameters[D] && (w.parameters[D] = THREE.VertexColors) : "wrapRGB" === D && (K = w.parameters[D], w.parameters[D] = new THREE.Vector3(K[0], K[1], K[2]));
void 0 !== w.parameters.opacity && 1 > w.parameters.opacity && (w.parameters.transparent = !0);
w.parameters.normalMap ? (K = THREE.ShaderLib.normalmap, y = THREE.UniformsUtils.clone(K.uniforms),
s = w.parameters.color, J = w.parameters.specular, r = w.parameters.ambient, M = w.parameters.shininess, y.tNormal.value = A.textures[w.parameters.normalMap], w.parameters.normalScale && y.uNormalScale.value.set(w.parameters.normalScale[0], w.parameters.normalScale[1]), w.parameters.map && (y.tDiffuse.value = w.parameters.map, y.enableDiffuse.value = !0), w.parameters.envMap && (y.tCube.value = w.parameters.envMap, y.enableReflection.value = !0, y.uReflectivity.value = w.parameters.reflectivity), w.parameters.lightMap && (y.tAO.value = w.parameters.lightMap,
y.enableAO.value = !0), w.parameters.specularMap && (y.tSpecular.value = A.textures[w.parameters.specularMap], y.enableSpecular.value = !0), w.parameters.displacementMap && (y.tDisplacement.value = A.textures[w.parameters.displacementMap], y.enableDisplacement.value = !0, y.uDisplacementBias.value = w.parameters.displacementBias, y.uDisplacementScale.value = w.parameters.displacementScale), y.uDiffuseColor.value.setHex(s), y.uSpecularColor.value.setHex(J), y.uAmbientColor.value.setHex(r), y.uShininess.value = M, w.parameters.opacity &&
(y.uOpacity.value = w.parameters.opacity), t = new THREE.ShaderMaterial({
fragmentShader: K.fragmentShader,
vertexShader: K.vertexShader,
uniforms: y,
lights: !0,
fog: !0
})) : t = new THREE[w.type](w.parameters);
t.name = ca;
A.materials[ca] = t
}
for (ca in C.materials)
if (w = C.materials[ca], w.parameters.materials) {
D = [];
for (s = 0; s < w.parameters.materials.length; s++) D.push(A.materials[w.parameters.materials[s]]);
A.materials[ca].materials = D
}
e();
A.cameras && C.defaults.camera && (A.currentCamera = A.cameras[C.defaults.camera]);
A.fogs &&
C.defaults.fog && (A.scene.fog = A.fogs[C.defaults.fog]);
m.callbackSync(A);
k()
}
};
THREE.TextureLoader = function(a) {
this.manager = void 0 !== a ? a : THREE.DefaultLoadingManager
};
THREE.TextureLoader.prototype = {
constructor: THREE.TextureLoader,
load: function(a, b) {
var c = new THREE.ImageLoader(this.manager);
c.setCrossOrigin(this.crossOrigin);
c.load(a, function(a) {
a = new THREE.Texture(a);
a.needsUpdate = !0;
void 0 !== b && b(a)
})
},
setCrossOrigin: function(a) {
this.crossOrigin = a
}
};
THREE.Material = function() {
this.id = THREE.MaterialIdCount++;
this.uuid = THREE.Math.generateUUID();
this.name = "";
this.side = THREE.FrontSide;
this.opacity = 1;
this.transparent = !1;
this.blending = THREE.NormalBlending;
this.blendSrc = THREE.SrcAlphaFactor;
this.blendDst = THREE.OneMinusSrcAlphaFactor;
this.blendEquation = THREE.AddEquation;
this.depthWrite = this.depthTest = !0;
this.polygonOffset = !1;
this.overdraw = this.alphaTest = this.polygonOffsetUnits = this.polygonOffsetFactor = 0;
this.needsUpdate = this.visible = !0
};
THREE.Material.prototype = {
constructor: THREE.Material,
setValues: function(a) {
if (void 0 !== a)
for (var b in a) {
var c = a[b];
if (void 0 === c) console.warn("THREE.Material: '" + b + "' parameter is undefined.");
else if (b in this) {
var d = this[b];
d instanceof THREE.Color ? d.set(c) : d instanceof THREE.Vector3 && c instanceof THREE.Vector3 ? d.copy(c) : this[b] = "overdraw" == b ? Number(c) : c
}
}
},
clone: function(a) {
void 0 === a && (a = new THREE.Material);
a.name = this.name;
a.side = this.side;
a.opacity = this.opacity;
a.transparent = this.transparent;
a.blending = this.blending;
a.blendSrc = this.blendSrc;
a.blendDst = this.blendDst;
a.blendEquation = this.blendEquation;
a.depthTest = this.depthTest;
a.depthWrite = this.depthWrite;
a.polygonOffset = this.polygonOffset;
a.polygonOffsetFactor = this.polygonOffsetFactor;
a.polygonOffsetUnits = this.polygonOffsetUnits;
a.alphaTest = this.alphaTest;
a.overdraw = this.overdraw;
a.visible = this.visible;
return a
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
}
};
THREE.EventDispatcher.prototype.apply(THREE.Material.prototype);
THREE.MaterialIdCount = 0;
THREE.LineBasicMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.linewidth = 1;
this.linejoin = this.linecap = "round";
this.vertexColors = !1;
this.fog = !0;
this.setValues(a)
};
THREE.LineBasicMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.LineBasicMaterial.prototype.clone = function() {
var a = new THREE.LineBasicMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.linewidth = this.linewidth;
a.linecap = this.linecap;
a.linejoin = this.linejoin;
a.vertexColors = this.vertexColors;
a.fog = this.fog;
return a
};
THREE.LineDashedMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.scale = this.linewidth = 1;
this.dashSize = 3;
this.gapSize = 1;
this.vertexColors = !1;
this.fog = !0;
this.setValues(a)
};
THREE.LineDashedMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.LineDashedMaterial.prototype.clone = function() {
var a = new THREE.LineDashedMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.linewidth = this.linewidth;
a.scale = this.scale;
a.dashSize = this.dashSize;
a.gapSize = this.gapSize;
a.vertexColors = this.vertexColors;
a.fog = this.fog;
return a
};
THREE.MeshBasicMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.envMap = this.specularMap = this.lightMap = this.map = null;
this.combine = THREE.MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;
this.fog = !0;
this.shading = THREE.SmoothShading;
this.wireframe = !1;
this.wireframeLinewidth = 1;
this.wireframeLinejoin = this.wireframeLinecap = "round";
this.vertexColors = THREE.NoColors;
this.morphTargets = this.skinning = !1;
this.setValues(a)
};
THREE.MeshBasicMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.MeshBasicMaterial.prototype.clone = function() {
var a = new THREE.MeshBasicMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.map = this.map;
a.lightMap = this.lightMap;
a.specularMap = this.specularMap;
a.envMap = this.envMap;
a.combine = this.combine;
a.reflectivity = this.reflectivity;
a.refractionRatio = this.refractionRatio;
a.fog = this.fog;
a.shading = this.shading;
a.wireframe = this.wireframe;
a.wireframeLinewidth = this.wireframeLinewidth;
a.wireframeLinecap = this.wireframeLinecap;
a.wireframeLinejoin =
this.wireframeLinejoin;
a.vertexColors = this.vertexColors;
a.skinning = this.skinning;
a.morphTargets = this.morphTargets;
return a
};
THREE.MeshLambertMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.ambient = new THREE.Color(16777215);
this.emissive = new THREE.Color(0);
this.wrapAround = !1;
this.wrapRGB = new THREE.Vector3(1, 1, 1);
this.envMap = this.specularMap = this.lightMap = this.map = null;
this.combine = THREE.MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;
this.fog = !0;
this.shading = THREE.SmoothShading;
this.wireframe = !1;
this.wireframeLinewidth = 1;
this.wireframeLinejoin = this.wireframeLinecap =
"round";
this.vertexColors = THREE.NoColors;
this.morphNormals = this.morphTargets = this.skinning = !1;
this.setValues(a)
};
THREE.MeshLambertMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.MeshLambertMaterial.prototype.clone = function() {
var a = new THREE.MeshLambertMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.ambient.copy(this.ambient);
a.emissive.copy(this.emissive);
a.wrapAround = this.wrapAround;
a.wrapRGB.copy(this.wrapRGB);
a.map = this.map;
a.lightMap = this.lightMap;
a.specularMap = this.specularMap;
a.envMap = this.envMap;
a.combine = this.combine;
a.reflectivity = this.reflectivity;
a.refractionRatio = this.refractionRatio;
a.fog = this.fog;
a.shading = this.shading;
a.wireframe = this.wireframe;
a.wireframeLinewidth = this.wireframeLinewidth;
a.wireframeLinecap = this.wireframeLinecap;
a.wireframeLinejoin = this.wireframeLinejoin;
a.vertexColors = this.vertexColors;
a.skinning = this.skinning;
a.morphTargets = this.morphTargets;
a.morphNormals = this.morphNormals;
return a
};
THREE.MeshPhongMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.ambient = new THREE.Color(16777215);
this.emissive = new THREE.Color(0);
this.specular = new THREE.Color(1118481);
this.shininess = 30;
this.metal = !1;
this.perPixel = !0;
this.wrapAround = !1;
this.wrapRGB = new THREE.Vector3(1, 1, 1);
this.bumpMap = this.lightMap = this.map = null;
this.bumpScale = 1;
this.normalMap = null;
this.normalScale = new THREE.Vector2(1, 1);
this.envMap = this.specularMap = null;
this.combine = THREE.MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;
this.fog = !0;
this.shading = THREE.SmoothShading;
this.wireframe = !1;
this.wireframeLinewidth = 1;
this.wireframeLinejoin = this.wireframeLinecap = "round";
this.vertexColors = THREE.NoColors;
this.morphNormals = this.morphTargets = this.skinning = !1;
this.setValues(a)
};
THREE.MeshPhongMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.MeshPhongMaterial.prototype.clone = function() {
var a = new THREE.MeshPhongMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.ambient.copy(this.ambient);
a.emissive.copy(this.emissive);
a.specular.copy(this.specular);
a.shininess = this.shininess;
a.metal = this.metal;
a.perPixel = this.perPixel;
a.wrapAround = this.wrapAround;
a.wrapRGB.copy(this.wrapRGB);
a.map = this.map;
a.lightMap = this.lightMap;
a.bumpMap = this.bumpMap;
a.bumpScale = this.bumpScale;
a.normalMap = this.normalMap;
a.normalScale.copy(this.normalScale);
a.specularMap = this.specularMap;
a.envMap = this.envMap;
a.combine = this.combine;
a.reflectivity = this.reflectivity;
a.refractionRatio = this.refractionRatio;
a.fog = this.fog;
a.shading = this.shading;
a.wireframe = this.wireframe;
a.wireframeLinewidth = this.wireframeLinewidth;
a.wireframeLinecap = this.wireframeLinecap;
a.wireframeLinejoin = this.wireframeLinejoin;
a.vertexColors = this.vertexColors;
a.skinning = this.skinning;
a.morphTargets = this.morphTargets;
a.morphNormals = this.morphNormals;
return a
};
THREE.MeshDepthMaterial = function(a) {
THREE.Material.call(this);
this.wireframe = !1;
this.wireframeLinewidth = 1;
this.setValues(a)
};
THREE.MeshDepthMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.MeshDepthMaterial.prototype.clone = function() {
var a = new THREE.MeshDepthMaterial;
THREE.Material.prototype.clone.call(this, a);
a.wireframe = this.wireframe;
a.wireframeLinewidth = this.wireframeLinewidth;
return a
};
THREE.MeshNormalMaterial = function(a) {
THREE.Material.call(this, a);
this.shading = THREE.FlatShading;
this.wireframe = !1;
this.wireframeLinewidth = 1;
this.morphTargets = !1;
this.setValues(a)
};
THREE.MeshNormalMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.MeshNormalMaterial.prototype.clone = function() {
var a = new THREE.MeshNormalMaterial;
THREE.Material.prototype.clone.call(this, a);
a.shading = this.shading;
a.wireframe = this.wireframe;
a.wireframeLinewidth = this.wireframeLinewidth;
return a
};
THREE.MeshFaceMaterial = function(a) {
this.materials = a instanceof Array ? a : []
};
THREE.MeshFaceMaterial.prototype.clone = function() {
return new THREE.MeshFaceMaterial(this.materials.slice(0))
};
THREE.ParticleBasicMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.map = null;
this.size = 1;
this.sizeAttenuation = !0;
this.vertexColors = !1;
this.fog = !0;
this.setValues(a)
};
THREE.ParticleBasicMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.ParticleBasicMaterial.prototype.clone = function() {
var a = new THREE.ParticleBasicMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.map = this.map;
a.size = this.size;
a.sizeAttenuation = this.sizeAttenuation;
a.vertexColors = this.vertexColors;
a.fog = this.fog;
return a
};
THREE.ParticleCanvasMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.program = function() {};
this.setValues(a)
};
THREE.ParticleCanvasMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.ParticleCanvasMaterial.prototype.clone = function() {
var a = new THREE.ParticleCanvasMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.program = this.program;
return a
};
THREE.ShaderMaterial = function(a) {
THREE.Material.call(this);
this.vertexShader = this.fragmentShader = "void main() {}";
this.uniforms = {};
this.defines = {};
this.attributes = null;
this.shading = THREE.SmoothShading;
this.linewidth = 1;
this.wireframe = !1;
this.wireframeLinewidth = 1;
this.lights = this.fog = !1;
this.vertexColors = THREE.NoColors;
this.morphNormals = this.morphTargets = this.skinning = !1;
this.setValues(a)
};
THREE.ShaderMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.ShaderMaterial.prototype.clone = function() {
var a = new THREE.ShaderMaterial;
THREE.Material.prototype.clone.call(this, a);
a.fragmentShader = this.fragmentShader;
a.vertexShader = this.vertexShader;
a.uniforms = THREE.UniformsUtils.clone(this.uniforms);
a.attributes = this.attributes;
a.defines = this.defines;
a.shading = this.shading;
a.wireframe = this.wireframe;
a.wireframeLinewidth = this.wireframeLinewidth;
a.fog = this.fog;
a.lights = this.lights;
a.vertexColors = this.vertexColors;
a.skinning = this.skinning;
a.morphTargets =
this.morphTargets;
a.morphNormals = this.morphNormals;
return a
};
THREE.SpriteMaterial = function(a) {
THREE.Material.call(this);
this.color = new THREE.Color(16777215);
this.map = new THREE.Texture;
this.useScreenCoordinates = !0;
this.depthTest = !this.useScreenCoordinates;
this.sizeAttenuation = !this.useScreenCoordinates;
this.scaleByViewport = !this.sizeAttenuation;
this.alignment = THREE.SpriteAlignment.center.clone();
this.fog = !1;
this.uvOffset = new THREE.Vector2(0, 0);
this.uvScale = new THREE.Vector2(1, 1);
this.setValues(a);
a = a || {};
void 0 === a.depthTest && (this.depthTest = !this.useScreenCoordinates);
void 0 === a.sizeAttenuation && (this.sizeAttenuation = !this.useScreenCoordinates);
void 0 === a.scaleByViewport && (this.scaleByViewport = !this.sizeAttenuation)
};
THREE.SpriteMaterial.prototype = Object.create(THREE.Material.prototype);
THREE.SpriteMaterial.prototype.clone = function() {
var a = new THREE.SpriteMaterial;
THREE.Material.prototype.clone.call(this, a);
a.color.copy(this.color);
a.map = this.map;
a.useScreenCoordinates = this.useScreenCoordinates;
a.sizeAttenuation = this.sizeAttenuation;
a.scaleByViewport = this.scaleByViewport;
a.alignment.copy(this.alignment);
a.uvOffset.copy(this.uvOffset);
a.uvScale.copy(this.uvScale);
a.fog = this.fog;
return a
};
THREE.SpriteAlignment = {};
THREE.SpriteAlignment.topLeft = new THREE.Vector2(1, -1);
THREE.SpriteAlignment.topCenter = new THREE.Vector2(0, -1);
THREE.SpriteAlignment.topRight = new THREE.Vector2(-1, -1);
THREE.SpriteAlignment.centerLeft = new THREE.Vector2(1, 0);
THREE.SpriteAlignment.center = new THREE.Vector2(0, 0);
THREE.SpriteAlignment.centerRight = new THREE.Vector2(-1, 0);
THREE.SpriteAlignment.bottomLeft = new THREE.Vector2(1, 1);
THREE.SpriteAlignment.bottomCenter = new THREE.Vector2(0, 1);
THREE.SpriteAlignment.bottomRight = new THREE.Vector2(-1, 1);
THREE.Texture = function(a, b, c, d, e, f, g, h, i) {
this.id = THREE.TextureIdCount++;
this.uuid = THREE.Math.generateUUID();
this.name = "";
this.image = a;
this.mipmaps = [];
this.mapping = void 0 !== b ? b : new THREE.UVMapping;
this.wrapS = void 0 !== c ? c : THREE.ClampToEdgeWrapping;
this.wrapT = void 0 !== d ? d : THREE.ClampToEdgeWrapping;
this.magFilter = void 0 !== e ? e : THREE.LinearFilter;
this.minFilter = void 0 !== f ? f : THREE.LinearMipMapLinearFilter;
this.anisotropy = void 0 !== i ? i : 1;
this.format = void 0 !== g ? g : THREE.RGBAFormat;
this.type = void 0 !== h ? h : THREE.UnsignedByteType;
this.offset = new THREE.Vector2(0, 0);
this.repeat = new THREE.Vector2(1, 1);
this.generateMipmaps = !0;
this.premultiplyAlpha = !1;
this.flipY = !0;
this.unpackAlignment = 4;
this.needsUpdate = !1;
this.onUpdate = null
};
THREE.Texture.prototype = {
constructor: THREE.Texture,
clone: function(a) {
void 0 === a && (a = new THREE.Texture);
a.image = this.image;
a.mipmaps = this.mipmaps.slice(0);
a.mapping = this.mapping;
a.wrapS = this.wrapS;
a.wrapT = this.wrapT;
a.magFilter = this.magFilter;
a.minFilter = this.minFilter;
a.anisotropy = this.anisotropy;
a.format = this.format;
a.type = this.type;
a.offset.copy(this.offset);
a.repeat.copy(this.repeat);
a.generateMipmaps = this.generateMipmaps;
a.premultiplyAlpha = this.premultiplyAlpha;
a.flipY = this.flipY;
a.unpackAlignment =
this.unpackAlignment;
return a
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
}
};
THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype);
THREE.TextureIdCount = 0;
THREE.CompressedTexture = function(a, b, c, d, e, f, g, h, i, k, l) {
THREE.Texture.call(this, null, f, g, h, i, k, d, e, l);
this.image = {
width: b,
height: c
};
this.mipmaps = a;
this.generateMipmaps = !1
};
THREE.CompressedTexture.prototype = Object.create(THREE.Texture.prototype);
THREE.CompressedTexture.prototype.clone = function() {
var a = new THREE.CompressedTexture;
THREE.Texture.prototype.clone.call(this, a);
return a
};
THREE.DataTexture = function(a, b, c, d, e, f, g, h, i, k, l) {
THREE.Texture.call(this, null, f, g, h, i, k, d, e, l);
this.image = {
data: a,
width: b,
height: c
}
};
THREE.DataTexture.prototype = Object.create(THREE.Texture.prototype);
THREE.DataTexture.prototype.clone = function() {
var a = new THREE.DataTexture;
THREE.Texture.prototype.clone.call(this, a);
return a
};
THREE.Particle = function(a) {
THREE.Object3D.call(this);
this.material = a
};
THREE.Particle.prototype = Object.create(THREE.Object3D.prototype);
THREE.Particle.prototype.clone = function(a) {
void 0 === a && (a = new THREE.Particle(this.material));
THREE.Object3D.prototype.clone.call(this, a);
return a
};
THREE.ParticleSystem = function(a, b) {
THREE.Object3D.call(this);
this.geometry = void 0 !== a ? a : new THREE.Geometry;
this.material = void 0 !== b ? b : new THREE.ParticleBasicMaterial({
color: 16777215 * Math.random()
});
this.frustumCulled = this.sortParticles = !1
};
THREE.ParticleSystem.prototype = Object.create(THREE.Object3D.prototype);
THREE.ParticleSystem.prototype.clone = function(a) {
void 0 === a && (a = new THREE.ParticleSystem(this.geometry, this.material));
a.sortParticles = this.sortParticles;
THREE.Object3D.prototype.clone.call(this, a);
return a
};
THREE.Line = function(a, b, c) {
THREE.Object3D.call(this);
this.geometry = void 0 !== a ? a : new THREE.Geometry;
this.material = void 0 !== b ? b : new THREE.LineBasicMaterial({
color: 16777215 * Math.random()
});
this.type = void 0 !== c ? c : THREE.LineStrip
};
THREE.LineStrip = 0;
THREE.LinePieces = 1;
THREE.Line.prototype = Object.create(THREE.Object3D.prototype);
THREE.Line.prototype.clone = function(a) {
void 0 === a && (a = new THREE.Line(this.geometry, this.material, this.type));
THREE.Object3D.prototype.clone.call(this, a);
return a
};
THREE.Mesh = function(a, b) {
THREE.Object3D.call(this);
this.geometry = void 0 !== a ? a : new THREE.Geometry;
this.material = void 0 !== b ? b : new THREE.MeshBasicMaterial({
color: 16777215 * Math.random()
});
this.updateMorphTargets()
};
THREE.Mesh.prototype = Object.create(THREE.Object3D.prototype);
THREE.Mesh.prototype.updateMorphTargets = function() {
if (0 < this.geometry.morphTargets.length) {
this.morphTargetBase = -1;
this.morphTargetForcedOrder = [];
this.morphTargetInfluences = [];
this.morphTargetDictionary = {};
for (var a = 0, b = this.geometry.morphTargets.length; a < b; a++) this.morphTargetInfluences.push(0), this.morphTargetDictionary[this.geometry.morphTargets[a].name] = a
}
};
THREE.Mesh.prototype.getMorphTargetIndexByName = function(a) {
if (void 0 !== this.morphTargetDictionary[a]) return this.morphTargetDictionary[a];
console.log("THREE.Mesh.getMorphTargetIndexByName: morph target " + a + " does not exist. Returning 0.");
return 0
};
THREE.Mesh.prototype.clone = function(a) {
void 0 === a && (a = new THREE.Mesh(this.geometry, this.material));
THREE.Object3D.prototype.clone.call(this, a);
return a
};
THREE.Bone = function(a) {
THREE.Object3D.call(this);
this.skin = a;
this.skinMatrix = new THREE.Matrix4
};
THREE.Bone.prototype = Object.create(THREE.Object3D.prototype);
THREE.Bone.prototype.update = function(a, b) {
this.matrixAutoUpdate && (b |= this.updateMatrix());
if (b || this.matrixWorldNeedsUpdate) a ? this.skinMatrix.multiplyMatrices(a, this.matrix) : this.skinMatrix.copy(this.matrix), this.matrixWorldNeedsUpdate = !1, b = !0;
var c, d = this.children.length;
for (c = 0; c < d; c++) this.children[c].update(this.skinMatrix, b)
};
THREE.SkinnedMesh = function(a, b, c) {
THREE.Mesh.call(this, a, b);
this.useVertexTexture = void 0 !== c ? c : !0;
this.identityMatrix = new THREE.Matrix4;
this.bones = [];
this.boneMatrices = [];
var d, e, f;
if (this.geometry && void 0 !== this.geometry.bones) {
for (a = 0; a < this.geometry.bones.length; a++) c = this.geometry.bones[a], d = c.pos, e = c.rotq, f = c.scl, b = this.addBone(), b.name = c.name, b.position.set(d[0], d[1], d[2]), b.quaternion.set(e[0], e[1], e[2], e[3]), void 0 !== f ? b.scale.set(f[0], f[1], f[2]) : b.scale.set(1, 1, 1);
for (a = 0; a < this.bones.length; a++) c =
this.geometry.bones[a], b = this.bones[a], -1 === c.parent ? this.add(b) : this.bones[c.parent].add(b);
a = this.bones.length;
this.useVertexTexture ? (this.boneTextureHeight = this.boneTextureWidth = a = 256 < a ? 64 : 64 < a ? 32 : 16 < a ? 16 : 8, this.boneMatrices = new Float32Array(4 * this.boneTextureWidth * this.boneTextureHeight), this.boneTexture = new THREE.DataTexture(this.boneMatrices, this.boneTextureWidth, this.boneTextureHeight, THREE.RGBAFormat, THREE.FloatType), this.boneTexture.minFilter = THREE.NearestFilter, this.boneTexture.magFilter =
THREE.NearestFilter, this.boneTexture.generateMipmaps = !1, this.boneTexture.flipY = !1) : this.boneMatrices = new Float32Array(16 * a);
this.pose()
}
};
THREE.SkinnedMesh.prototype = Object.create(THREE.Mesh.prototype);
THREE.SkinnedMesh.prototype.addBone = function(a) {
void 0 === a && (a = new THREE.Bone(this));
this.bones.push(a);
return a
};
THREE.SkinnedMesh.prototype.updateMatrixWorld = function() {
var a = new THREE.Matrix4;
return function(b) {
this.matrixAutoUpdate && this.updateMatrix();
if (this.matrixWorldNeedsUpdate || b) this.parent ? this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix) : this.matrixWorld.copy(this.matrix), this.matrixWorldNeedsUpdate = !1;
for (var b = 0, c = this.children.length; b < c; b++) {
var d = this.children[b];
d instanceof THREE.Bone ? d.update(this.identityMatrix, !1) : d.updateMatrixWorld(!0)
}
if (void 0 == this.boneInverses) {
this.boneInverses = [];
b = 0;
for (c = this.bones.length; b < c; b++) d = new THREE.Matrix4, d.getInverse(this.bones[b].skinMatrix), this.boneInverses.push(d)
}
b = 0;
for (c = this.bones.length; b < c; b++) a.multiplyMatrices(this.bones[b].skinMatrix, this.boneInverses[b]), a.flattenToArrayOffset(this.boneMatrices, 16 * b);
this.useVertexTexture && (this.boneTexture.needsUpdate = !0)
}
}();
THREE.SkinnedMesh.prototype.pose = function() {
this.updateMatrixWorld(!0);
this.normalizeSkinWeights()
};
THREE.SkinnedMesh.prototype.normalizeSkinWeights = function() {
if (this.geometry instanceof THREE.Geometry)
for (var a = 0; a < this.geometry.skinIndices.length; a++) {
var b = this.geometry.skinWeights[a],
c = 1 / b.lengthManhattan();
Infinity !== c ? b.multiplyScalar(c) : b.set(1)
}
};
THREE.SkinnedMesh.prototype.clone = function(a) {
void 0 === a && (a = new THREE.SkinnedMesh(this.geometry, this.material, this.useVertexTexture));
THREE.Mesh.prototype.clone.call(this, a);
return a
};
THREE.MorphAnimMesh = function(a, b) {
THREE.Mesh.call(this, a, b);
this.duration = 1E3;
this.mirroredLoop = !1;
this.currentKeyframe = this.lastKeyframe = this.time = 0;
this.direction = 1;
this.directionBackwards = !1;
this.setFrameRange(0, this.geometry.morphTargets.length - 1)
};
THREE.MorphAnimMesh.prototype = Object.create(THREE.Mesh.prototype);
THREE.MorphAnimMesh.prototype.setFrameRange = function(a, b) {
this.startKeyframe = a;
this.endKeyframe = b;
this.length = this.endKeyframe - this.startKeyframe + 1
};
THREE.MorphAnimMesh.prototype.setDirectionForward = function() {
this.direction = 1;
this.directionBackwards = !1
};
THREE.MorphAnimMesh.prototype.setDirectionBackward = function() {
this.direction = -1;
this.directionBackwards = !0
};
THREE.MorphAnimMesh.prototype.parseAnimations = function() {
var a = this.geometry;
a.animations || (a.animations = {});
for (var b, c = a.animations, d = /([a-z]+)(\d+)/, e = 0, f = a.morphTargets.length; e < f; e++) {
var g = a.morphTargets[e].name.match(d);
if (g && 1 < g.length) {
g = g[1];
c[g] || (c[g] = {
start: Infinity,
end: -Infinity
});
var h = c[g];
e < h.start && (h.start = e);
e > h.end && (h.end = e);
b || (b = g)
}
}
a.firstAnimation = b
};
THREE.MorphAnimMesh.prototype.setAnimationLabel = function(a, b, c) {
this.geometry.animations || (this.geometry.animations = {});
this.geometry.animations[a] = {
start: b,
end: c
}
};
THREE.MorphAnimMesh.prototype.playAnimation = function(a, b) {
var c = this.geometry.animations[a];
c ? (this.setFrameRange(c.start, c.end), this.duration = 1E3 * ((c.end - c.start) / b), this.time = 0) : console.warn("animation[" + a + "] undefined")
};
THREE.MorphAnimMesh.prototype.updateAnimation = function(a) {
var b = this.duration / this.length;
this.time += this.direction * a;
if (this.mirroredLoop) {
if (this.time > this.duration || 0 > this.time) this.direction *= -1, this.time > this.duration && (this.time = this.duration, this.directionBackwards = !0), 0 > this.time && (this.time = 0, this.directionBackwards = !1)
} else this.time %= this.duration, 0 > this.time && (this.time += this.duration);
a = this.startKeyframe + THREE.Math.clamp(Math.floor(this.time / b), 0, this.length - 1);
a !== this.currentKeyframe &&
(this.morphTargetInfluences[this.lastKeyframe] = 0, this.morphTargetInfluences[this.currentKeyframe] = 1, this.morphTargetInfluences[a] = 0, this.lastKeyframe = this.currentKeyframe, this.currentKeyframe = a);
b = this.time % b / b;
this.directionBackwards && (b = 1 - b);
this.morphTargetInfluences[this.currentKeyframe] = b;
this.morphTargetInfluences[this.lastKeyframe] = 1 - b
};
THREE.MorphAnimMesh.prototype.clone = function(a) {
void 0 === a && (a = new THREE.MorphAnimMesh(this.geometry, this.material));
a.duration = this.duration;
a.mirroredLoop = this.mirroredLoop;
a.time = this.time;
a.lastKeyframe = this.lastKeyframe;
a.currentKeyframe = this.currentKeyframe;
a.direction = this.direction;
a.directionBackwards = this.directionBackwards;
THREE.Mesh.prototype.clone.call(this, a);
return a
};
THREE.Ribbon = function(a, b) {
THREE.Object3D.call(this);
this.geometry = a;
this.material = b
};
THREE.Ribbon.prototype = Object.create(THREE.Object3D.prototype);
THREE.Ribbon.prototype.clone = function(a) {
void 0 === a && (a = new THREE.Ribbon(this.geometry, this.material));
THREE.Object3D.prototype.clone.call(this, a);
return a
};
THREE.LOD = function() {
THREE.Object3D.call(this);
this.objects = []
};
THREE.LOD.prototype = Object.create(THREE.Object3D.prototype);
THREE.LOD.prototype.addLevel = function(a, b) {
void 0 === b && (b = 0);
for (var b = Math.abs(b), c = 0; c < this.objects.length && !(b < this.objects[c].distance); c++);
this.objects.splice(c, 0, {
distance: b,
object: a
});
this.add(a)
};
THREE.LOD.prototype.getObjectForDistance = function(a) {
for (var b = 1, c = this.objects.length; b < c && !(a < this.objects[b].distance); b++);
return this.objects[b - 1].object
};
THREE.LOD.prototype.update = function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function(c) {
if (1 < this.objects.length) {
a.getPositionFromMatrix(c.matrixWorld);
b.getPositionFromMatrix(this.matrixWorld);
c = a.distanceTo(b);
this.objects[0].object.visible = !0;
for (var d = 1, e = this.objects.length; d < e; d++)
if (c >= this.objects[d].distance) this.objects[d - 1].object.visible = !1, this.objects[d].object.visible = !0;
else break;
for (; d < e; d++) this.objects[d].object.visible = !1
}
}
}();
THREE.LOD.prototype.clone = function() {};
THREE.Sprite = function(a) {
THREE.Object3D.call(this);
this.material = void 0 !== a ? a : new THREE.SpriteMaterial;
this.rotation3d = this.rotation;
this.rotation = 0
};
THREE.Sprite.prototype = Object.create(THREE.Object3D.prototype);
THREE.Sprite.prototype.updateMatrix = function() {
this.rotation3d.set(0, 0, this.rotation, this.rotation3d.order);
this.quaternion.setFromEuler(this.rotation3d);
this.matrix.compose(this.position, this.quaternion, this.scale);
this.matrixWorldNeedsUpdate = !0
};
THREE.Sprite.prototype.clone = function(a) {
void 0 === a && (a = new THREE.Sprite(this.material));
THREE.Object3D.prototype.clone.call(this, a);
return a
};
THREE.Scene = function() {
THREE.Object3D.call(this);
this.overrideMaterial = this.fog = null;
this.autoUpdate = !0;
this.matrixAutoUpdate = !1;
this.__objects = [];
this.__lights = [];
this.__objectsAdded = [];
this.__objectsRemoved = []
};
THREE.Scene.prototype = Object.create(THREE.Object3D.prototype);
THREE.Scene.prototype.__addObject = function(a) {
if (a instanceof THREE.Light) - 1 === this.__lights.indexOf(a) && this.__lights.push(a), a.target && void 0 === a.target.parent && this.add(a.target);
else if (!(a instanceof THREE.Camera || a instanceof THREE.Bone) && -1 === this.__objects.indexOf(a)) {
this.__objects.push(a);
this.__objectsAdded.push(a);
var b = this.__objectsRemoved.indexOf(a); - 1 !== b && this.__objectsRemoved.splice(b, 1)
}
for (b = 0; b < a.children.length; b++) this.__addObject(a.children[b])
};
THREE.Scene.prototype.__removeObject = function(a) {
if (a instanceof THREE.Light) {
var b = this.__lights.indexOf(a); - 1 !== b && this.__lights.splice(b, 1)
} else a instanceof THREE.Camera || (b = this.__objects.indexOf(a), -1 !== b && (this.__objects.splice(b, 1), this.__objectsRemoved.push(a), b = this.__objectsAdded.indexOf(a), -1 !== b && this.__objectsAdded.splice(b, 1)));
for (b = 0; b < a.children.length; b++) this.__removeObject(a.children[b])
};
THREE.Scene.prototype.clone = function(a) {
void 0 === a && (a = new THREE.Scene);
THREE.Object3D.prototype.clone.call(this, a);
null !== this.fog && (a.fog = this.fog.clone());
null !== this.overrideMaterial && (a.overrideMaterial = this.overrideMaterial.clone());
a.autoUpdate = this.autoUpdate;
a.matrixAutoUpdate = this.matrixAutoUpdate;
return a
};
THREE.Fog = function(a, b, c) {
this.name = "";
this.color = new THREE.Color(a);
this.near = void 0 !== b ? b : 1;
this.far = void 0 !== c ? c : 1E3
};
THREE.Fog.prototype.clone = function() {
return new THREE.Fog(this.color.getHex(), this.near, this.far)
};
THREE.FogExp2 = function(a, b) {
this.name = "";
this.color = new THREE.Color(a);
this.density = void 0 !== b ? b : 2.5E-4
};
THREE.FogExp2.prototype.clone = function() {
return new THREE.FogExp2(this.color.getHex(), this.density)
};
THREE.CanvasRenderer = function(a) {
function b(a, b, c) {
for (var d = 0, e = I.length; d < e; d++) {
var f = I[d];
Lb.copy(f.color);
if (f instanceof THREE.DirectionalLight) {
var g = Ua.getPositionFromMatrix(f.matrixWorld).normalize(),
h = b.dot(g);
0 >= h || (h *= f.intensity, c.add(Lb.multiplyScalar(h)))
} else f instanceof THREE.PointLight && (g = Ua.getPositionFromMatrix(f.matrixWorld), h = b.dot(Ua.subVectors(g, a).normalize()), 0 >= h || (h *= 0 == f.distance ? 1 : 1 - Math.min(a.distanceTo(g) / f.distance, 1), 0 != h && (h *= f.intensity, c.add(Lb.multiplyScalar(h)))))
}
}
function c(a, c, e, l, q, r, V, n) {
H.info.render.vertices += 3;
H.info.render.faces++;
m(n.opacity);
p(n.blending);
Fa = a.positionScreen.x;
Oa = a.positionScreen.y;
X = c.positionScreen.x;
fa = c.positionScreen.y;
T = e.positionScreen.x;
U = e.positionScreen.y;
d(Fa, Oa, X, fa, T, U);
(n instanceof THREE.MeshLambertMaterial || n instanceof THREE.MeshPhongMaterial) && null === n.map ? (Qa.copy(n.color), hb.copy(n.emissive), n.vertexColors === THREE.FaceColors && Qa.multiply(V.color), !1 === n.wireframe && n.shading == THREE.SmoothShading && 3 == V.vertexNormalsLength ?
(Ba.copy(kb), ea.copy(kb), na.copy(kb), b(V.v1.positionWorld, V.vertexNormalsModel[0], Ba), b(V.v2.positionWorld, V.vertexNormalsModel[1], ea), b(V.v3.positionWorld, V.vertexNormalsModel[2], na), Ba.multiply(Qa).add(hb), ea.multiply(Qa).add(hb), na.multiply(Qa).add(hb), Ia.addColors(ea, na).multiplyScalar(0.5), ra = k(Ba, ea, na, Ia), i(Fa, Oa, X, fa, T, U, 0, 0, 1, 0, 0, 1, ra)) : (ka.copy(kb), b(V.centroidModel, V.normalModel, ka), ka.multiply(Qa).add(hb), !0 === n.wireframe ? f(ka, n.wireframeLinewidth, n.wireframeLinecap, n.wireframeLinejoin) :
g(ka))) : n instanceof THREE.MeshBasicMaterial || n instanceof THREE.MeshLambertMaterial || n instanceof THREE.MeshPhongMaterial ? null !== n.map ? n.map.mapping instanceof THREE.UVMapping && (ta = V.uvs[0], h(Fa, Oa, X, fa, T, U, ta[l].x, ta[l].y, ta[q].x, ta[q].y, ta[r].x, ta[r].y, n.map)) : null !== n.envMap ? n.envMap.mapping instanceof THREE.SphericalReflectionMapping && (Ua.copy(V.vertexNormalsModelView[l]), wb = 0.5 * Ua.x + 0.5, Mb = 0.5 * Ua.y + 0.5, Ua.copy(V.vertexNormalsModelView[q]), j = 0.5 * Ua.x + 0.5, Tb = 0.5 * Ua.y + 0.5, Ua.copy(V.vertexNormalsModelView[r]),
Nb = 0.5 * Ua.x + 0.5, xb = 0.5 * Ua.y + 0.5, h(Fa, Oa, X, fa, T, U, wb, Mb, j, Tb, Nb, xb, n.envMap)) : (ka.copy(n.color), n.vertexColors === THREE.FaceColors && ka.multiply(V.color), !0 === n.wireframe ? f(ka, n.wireframeLinewidth, n.wireframeLinecap, n.wireframeLinejoin) : g(ka)) : n instanceof THREE.MeshDepthMaterial ? (vb = sa.near, yb = sa.far, Ba.r = Ba.g = Ba.b = 1 - z(a.positionScreen.z * a.positionScreen.w, vb, yb), ea.r = ea.g = ea.b = 1 - z(c.positionScreen.z * c.positionScreen.w, vb, yb), na.r = na.g = na.b = 1 - z(e.positionScreen.z * e.positionScreen.w, vb, yb), Ia.addColors(ea,
na).multiplyScalar(0.5), ra = k(Ba, ea, na, Ia), i(Fa, Oa, X, fa, T, U, 0, 0, 1, 0, 0, 1, ra)) : n instanceof THREE.MeshNormalMaterial && (n.shading == THREE.FlatShading ? (a = V.normalModelView, ka.setRGB(a.x, a.y, a.z).multiplyScalar(0.5).addScalar(0.5), !0 === n.wireframe ? f(ka, n.wireframeLinewidth, n.wireframeLinecap, n.wireframeLinejoin) : g(ka)) : n.shading == THREE.SmoothShading && (a = V.vertexNormalsModelView[l], Ba.setRGB(a.x, a.y, a.z).multiplyScalar(0.5).addScalar(0.5), a = V.vertexNormalsModelView[q], ea.setRGB(a.x, a.y, a.z).multiplyScalar(0.5).addScalar(0.5),
a = V.vertexNormalsModelView[r], na.setRGB(a.x, a.y, a.z).multiplyScalar(0.5).addScalar(0.5), Ia.addColors(ea, na).multiplyScalar(0.5), ra = k(Ba, ea, na, Ia), i(Fa, Oa, X, fa, T, U, 0, 0, 1, 0, 0, 1, ra)))
}
function d(a, b, c, d, e, f) {
y.beginPath();
y.moveTo(a, b);
y.lineTo(c, d);
y.lineTo(e, f);
y.closePath()
}
function e(a, b, c, d, e, f, g, h) {
y.beginPath();
y.moveTo(a, b);
y.lineTo(c, d);
y.lineTo(e, f);
y.lineTo(g, h);
y.closePath()
}
function f(a, b, c, d) {
q(b);
t(c);
n(d);
r(a.getStyle());
y.stroke();
ua.expandByScalar(2 * b)
}
function g(a) {
s(a.getStyle());
y.fill()
}
function h(a, b, c, d, e, f, h, j, i, k, m, l, p) {
if (!(p instanceof THREE.DataTexture || void 0 === p.image || 0 == p.image.width)) {
if (!0 === p.needsUpdate) {
var n = p.wrapS == THREE.RepeatWrapping,
q = p.wrapT == THREE.RepeatWrapping;
Ab[p.id] = y.createPattern(p.image, !0 === n && !0 === q ? "repeat" : !0 === n && !1 === q ? "repeat-x" : !1 === n && !0 === q ? "repeat-y" : "no-repeat");
p.needsUpdate = !1
}
void 0 === Ab[p.id] ? s("rgba(0,0,0,1)") : s(Ab[p.id]);
var n = p.offset.x / p.repeat.x,
q = p.offset.y / p.repeat.y,
r = p.image.width * p.repeat.x,
t = p.image.height * p.repeat.y,
h = (h + n) * r,
j = (1 - j + q) * t,
c = c - a,
d = d - b,
e = e - a,
f = f - b,
i = (i + n) * r - h,
k = (1 - k + q) * t - j,
m = (m + n) * r - h,
l = (1 - l + q) * t - j,
n = i * l - m * k;
0 === n ? (void 0 === Ub[p.id] && (b = document.createElement("canvas"), b.width = p.image.width, b.height = p.image.height, b = b.getContext("2d"), b.drawImage(p.image, 0, 0), Ub[p.id] = b.getImageData(0, 0, p.image.width, p.image.height).data), b = Ub[p.id], h = 4 * (Math.floor(h) + Math.floor(j) * p.image.width), ka.setRGB(b[h] / 255, b[h + 1] / 255, b[h + 2] / 255), g(ka)) : (n = 1 / n, p = (l * c - k * e) * n, k = (l * d - k * f) * n, c = (i * e - m * c) * n, d = (i * f - m * d) * n, a = a -
p * h - c * j, h = b - k * h - d * j, y.save(), y.transform(p, k, c, d, a, h), y.fill(), y.restore())
}
}
function i(a, b, c, d, e, f, g, h, j, i, k, m, l) {
var p, n;
p = l.width - 1;
n = l.height - 1;
g *= p;
h *= n;
c -= a;
d -= b;
e -= a;
f -= b;
j = j * p - g;
i = i * n - h;
k = k * p - g;
m = m * n - h;
n = 1 / (j * m - k * i);
p = (m * c - i * e) * n;
i = (m * d - i * f) * n;
c = (j * e - k * c) * n;
d = (j * f - k * d) * n;
a = a - p * g - c * h;
b = b - i * g - d * h;
y.save();
y.transform(p, i, c, d, a, b);
y.clip();
y.drawImage(l, 0, 0);
y.restore()
}
function k(a, b, c, d) {
Ja[0] = 255 * a.r | 0;
Ja[1] = 255 * a.g | 0;
Ja[2] = 255 * a.b | 0;
Ja[4] = 255 * b.r | 0;
Ja[5] = 255 * b.g | 0;
Ja[6] = 255 * b.b | 0;
Ja[8] = 255 *
c.r | 0;
Ja[9] = 255 * c.g | 0;
Ja[10] = 255 * c.b | 0;
Ja[12] = 255 * d.r | 0;
Ja[13] = 255 * d.g | 0;
Ja[14] = 255 * d.b | 0;
Vb.putImageData(Hb, 0, 0);
Ib.drawImage(Jb, 0, 0);
return Wb
}
function l(a, b, c) {
var d = b.x - a.x,
e = b.y - a.y,
f = d * d + e * e;
0 !== f && (c /= Math.sqrt(f), d *= c, e *= c, b.x += d, b.y += e, a.x -= d, a.y -= e)
}
function m(a) {
ca !== a && (ca = y.globalAlpha = a)
}
function p(a) {
D !== a && (a === THREE.NormalBlending ? y.globalCompositeOperation = "source-over" : a === THREE.AdditiveBlending ? y.globalCompositeOperation = "lighter" : a === THREE.SubtractiveBlending && (y.globalCompositeOperation =
"darker"), D = a)
}
function q(a) {
Sa !== a && (Sa = y.lineWidth = a)
}
function t(a) {
P !== a && (P = y.lineCap = a)
}
function n(a) {
ia !== a && (ia = y.lineJoin = a)
}
function r(a) {
qa !== a && (qa = y.strokeStyle = a)
}
function s(a) {
Pa !== a && (Pa = y.fillStyle = a)
}
function v(a, b) {
if (Wa !== a || L !== b) y.setLineDash([a, b]), Wa = a, L = b
}
console.log("THREE.CanvasRenderer", THREE.REVISION);
var z = THREE.Math.smoothstep,
a = a || {},
H = this,
B, G, I, F = new THREE.Projector,
A = void 0 !== a.canvas ? a.canvas : document.createElement("canvas"),
N, C, K, M, y = A.getContext("2d"),
J = new THREE.Color(0),
w = 0,
ca = 1,
D = 0,
qa = null,
Pa = null,
Sa = null,
P = null,
ia = null,
Wa = null,
L = 0,
sa, W, ja, pa, Ea, Za = new THREE.RenderableVertex,
ob = new THREE.RenderableVertex,
Fa, Oa, X, fa, T, U, oa, ha, da, xa, Ta, la, ka = new THREE.Color,
Ba = new THREE.Color,
ea = new THREE.Color,
na = new THREE.Color,
Ia = new THREE.Color,
Qa = new THREE.Color,
hb = new THREE.Color,
Lb = new THREE.Color,
Ab = {},
Ub = {},
vb, yb, ra, ta, wb, Mb, j, Tb, Nb, xb, eb = new THREE.Box2,
Ya = new THREE.Box2,
ua = new THREE.Box2,
kb = new THREE.Color,
Xb = new THREE.Color,
Kb = new THREE.Color,
Ua = new THREE.Vector3,
Jb, Vb,
Hb, Ja, Wb, Ib, Eb = 16;
Jb = document.createElement("canvas");
Jb.width = Jb.height = 2;
Vb = Jb.getContext("2d");
Vb.fillStyle = "rgba(0,0,0,1)";
Vb.fillRect(0, 0, 2, 2);
Hb = Vb.getImageData(0, 0, 2, 2);
Ja = Hb.data;
Wb = document.createElement("canvas");
Wb.width = Wb.height = Eb;
Ib = Wb.getContext("2d");
Ib.translate(-Eb / 2, -Eb / 2);
Ib.scale(Eb, Eb);
Eb--;
void 0 === y.setLineDash && (y.setLineDash = void 0 !== y.mozDash ? function(a) {
y.mozDash = null !== a[0] ? a : null
} : function() {});
this.domElement = A;
this.devicePixelRatio = void 0 !== a.devicePixelRatio ? a.devicePixelRatio :
void 0 !== window.devicePixelRatio ? window.devicePixelRatio : 1;
this.sortElements = this.sortObjects = this.autoClear = !0;
this.info = {
render: {
vertices: 0,
faces: 0
}
};
this.supportsVertexTextures = function() {};
this.setFaceCulling = function() {};
this.setSize = function(a, b, c) {
N = a * this.devicePixelRatio;
C = b * this.devicePixelRatio;
K = Math.floor(N / 2);
M = Math.floor(C / 2);
A.width = N;
A.height = C;
1 !== this.devicePixelRatio && !1 !== c && (A.style.width = a + "px", A.style.height = b + "px");
eb.set(new THREE.Vector2(-K, -M), new THREE.Vector2(K, M));
Ya.set(new THREE.Vector2(-K, -M), new THREE.Vector2(K, M));
ca = 1;
D = 0;
ia = P = Sa = Pa = qa = null
};
this.setClearColor = function(a, b) {
J.set(a);
w = void 0 !== b ? b : 1;
Ya.set(new THREE.Vector2(-K, -M), new THREE.Vector2(K, M))
};
this.setClearColorHex = function(a, b) {
console.warn("DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead.");
this.setClearColor(a, b)
};
this.getMaxAnisotropy = function() {
return 0
};
this.clear = function() {
y.setTransform(1, 0, 0, -1, K, M);
!1 === Ya.empty() && (Ya.intersect(eb), Ya.expandByScalar(2), 1 > w && y.clearRect(Ya.min.x |
0, Ya.min.y | 0, Ya.max.x - Ya.min.x | 0, Ya.max.y - Ya.min.y | 0), 0 < w && (p(THREE.NormalBlending), m(1), s("rgba(" + Math.floor(255 * J.r) + "," + Math.floor(255 * J.g) + "," + Math.floor(255 * J.b) + "," + w + ")"), y.fillRect(Ya.min.x | 0, Ya.min.y | 0, Ya.max.x - Ya.min.x | 0, Ya.max.y - Ya.min.y | 0)), Ya.makeEmpty())
};
this.render = function(a, h) {
if (!1 === h instanceof THREE.Camera) console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");
else {
!0 === this.autoClear && this.clear();
y.setTransform(1, 0, 0, -1, K, M);
H.info.render.vertices =
0;
H.info.render.faces = 0;
B = F.projectScene(a, h, this.sortObjects, this.sortElements);
G = B.elements;
I = B.lights;
sa = h;
kb.setRGB(0, 0, 0);
Xb.setRGB(0, 0, 0);
Kb.setRGB(0, 0, 0);
for (var j = 0, A = I.length; j < A; j++) {
var w = I[j],
C = w.color;
w instanceof THREE.AmbientLight ? kb.add(C) : w instanceof THREE.DirectionalLight ? Xb.add(C) : w instanceof THREE.PointLight && Kb.add(C)
}
j = 0;
for (A = G.length; j < A; j++) {
var V = G[j],
w = V.material;
if (!(void 0 === w || !1 === w.visible)) {
ua.makeEmpty();
if (V instanceof THREE.RenderableParticle) {
W = V;
W.x *= K;
W.y *=
M;
C = W;
m(w.opacity);
p(w.blending);
var lb = void 0,
mb = void 0,
tb = void 0,
zb = void 0,
$b = void 0,
Jc = void 0,
Kc = void 0;
w instanceof THREE.ParticleBasicMaterial ? null === w.map ? (tb = V.object.scale.x, zb = V.object.scale.y, tb *= V.scale.x * K, zb *= V.scale.y * M, ua.min.set(C.x - tb, C.y - zb), ua.max.set(C.x + tb, C.y + zb), !1 === eb.isIntersectionBox(ua) ? ua.makeEmpty() : (s(w.color.getStyle()), y.save(), y.translate(C.x, C.y), y.rotate(-V.rotation), y.scale(tb, zb), y.fillRect(-1, -1, 2, 2), y.restore())) : ($b = w.map.image, Jc = $b.width >> 1, Kc = $b.height >>
1, tb = V.scale.x * K, zb = V.scale.y * M, lb = tb * Jc, mb = zb * Kc, ua.min.set(C.x - lb, C.y - mb), ua.max.set(C.x + lb, C.y + mb), !1 === eb.isIntersectionBox(ua) ? ua.makeEmpty() : (y.save(), y.translate(C.x, C.y), y.rotate(-V.rotation), y.scale(tb, -zb), y.translate(-Jc, -Kc), y.drawImage($b, 0, 0), y.restore())) : w instanceof THREE.ParticleCanvasMaterial && (lb = V.scale.x * K, mb = V.scale.y * M, ua.min.set(C.x - lb, C.y - mb), ua.max.set(C.x + lb, C.y + mb), !1 === eb.isIntersectionBox(ua) ? ua.makeEmpty() : (r(w.color.getStyle()), s(w.color.getStyle()), y.save(), y.translate(C.x,
C.y), y.rotate(-V.rotation), y.scale(lb, mb), w.program(y), y.restore()))
} else if (V instanceof THREE.RenderableLine) {
if (W = V.v1, ja = V.v2, W.positionScreen.x *= K, W.positionScreen.y *= M, ja.positionScreen.x *= K, ja.positionScreen.y *= M, ua.setFromPoints([W.positionScreen, ja.positionScreen]), !0 === eb.isIntersectionBox(ua))
if (C = W, lb = ja, m(w.opacity), p(w.blending), y.beginPath(), y.moveTo(C.positionScreen.x, C.positionScreen.y), y.lineTo(lb.positionScreen.x, lb.positionScreen.y), w instanceof THREE.LineBasicMaterial) {
q(w.linewidth);
t(w.linecap);
n(w.linejoin);
if (w.vertexColors !== THREE.VertexColors) r(w.color.getStyle());
else if (mb = V.vertexColors[0].getStyle(), V = V.vertexColors[1].getStyle(), mb === V) r(mb);
else {
try {
var vc = y.createLinearGradient(C.positionScreen.x, C.positionScreen.y, lb.positionScreen.x, lb.positionScreen.y);
vc.addColorStop(0, mb);
vc.addColorStop(1, V)
} catch (fd) {
vc = mb
}
r(vc)
}
y.stroke();
ua.expandByScalar(2 * w.linewidth)
} else w instanceof THREE.LineDashedMaterial && (q(w.linewidth), t(w.linecap), n(w.linejoin), r(w.color.getStyle()),
v(w.dashSize, w.gapSize), y.stroke(), ua.expandByScalar(2 * w.linewidth), v(null, null))
} else if (V instanceof THREE.RenderableFace3) {
W = V.v1;
ja = V.v2;
pa = V.v3;
if (-1 > W.positionScreen.z || 1 < W.positionScreen.z) continue;
if (-1 > ja.positionScreen.z || 1 < ja.positionScreen.z) continue;
if (-1 > pa.positionScreen.z || 1 < pa.positionScreen.z) continue;
W.positionScreen.x *= K;
W.positionScreen.y *= M;
ja.positionScreen.x *= K;
ja.positionScreen.y *= M;
pa.positionScreen.x *= K;
pa.positionScreen.y *= M;
0 < w.overdraw && (l(W.positionScreen, ja.positionScreen,
w.overdraw), l(ja.positionScreen, pa.positionScreen, w.overdraw), l(pa.positionScreen, W.positionScreen, w.overdraw));
ua.setFromPoints([W.positionScreen, ja.positionScreen, pa.positionScreen]);
!0 === eb.isIntersectionBox(ua) && c(W, ja, pa, 0, 1, 2, V, w)
} else if (V instanceof THREE.RenderableFace4) {
W = V.v1;
ja = V.v2;
pa = V.v3;
Ea = V.v4;
if (-1 > W.positionScreen.z || 1 < W.positionScreen.z) continue;
if (-1 > ja.positionScreen.z || 1 < ja.positionScreen.z) continue;
if (-1 > pa.positionScreen.z || 1 < pa.positionScreen.z) continue;
if (-1 > Ea.positionScreen.z ||
1 < Ea.positionScreen.z) continue;
W.positionScreen.x *= K;
W.positionScreen.y *= M;
ja.positionScreen.x *= K;
ja.positionScreen.y *= M;
pa.positionScreen.x *= K;
pa.positionScreen.y *= M;
Ea.positionScreen.x *= K;
Ea.positionScreen.y *= M;
Za.positionScreen.copy(ja.positionScreen);
ob.positionScreen.copy(Ea.positionScreen);
0 < w.overdraw && (l(W.positionScreen, ja.positionScreen, w.overdraw), l(ja.positionScreen, Ea.positionScreen, w.overdraw), l(Ea.positionScreen, W.positionScreen, w.overdraw), l(pa.positionScreen, Za.positionScreen, w.overdraw),
l(pa.positionScreen, ob.positionScreen, w.overdraw));
ua.setFromPoints([W.positionScreen, ja.positionScreen, pa.positionScreen, Ea.positionScreen]);
!0 === eb.isIntersectionBox(ua) && (C = W, lb = ja, mb = pa, tb = Ea, zb = Za, $b = ob, H.info.render.vertices += 4, H.info.render.faces++, m(w.opacity), p(w.blending), void 0 !== w.map && null !== w.map || void 0 !== w.envMap && null !== w.envMap ? (c(C, lb, tb, 0, 1, 3, V, w), c(zb, mb, $b, 1, 2, 3, V, w)) : (Fa = C.positionScreen.x, Oa = C.positionScreen.y, X = lb.positionScreen.x, fa = lb.positionScreen.y, T = mb.positionScreen.x,
U = mb.positionScreen.y, oa = tb.positionScreen.x, ha = tb.positionScreen.y, da = zb.positionScreen.x, xa = zb.positionScreen.y, Ta = $b.positionScreen.x, la = $b.positionScreen.y, w instanceof THREE.MeshLambertMaterial || w instanceof THREE.MeshPhongMaterial ? (Qa.copy(w.color), hb.copy(w.emissive), w.vertexColors === THREE.FaceColors && Qa.multiply(V.color), !1 === w.wireframe && w.shading == THREE.SmoothShading && 4 == V.vertexNormalsLength ? (Ba.copy(kb), ea.copy(kb), na.copy(kb), Ia.copy(kb), b(V.v1.positionWorld, V.vertexNormalsModel[0], Ba),
b(V.v2.positionWorld, V.vertexNormalsModel[1], ea), b(V.v4.positionWorld, V.vertexNormalsModel[3], na), b(V.v3.positionWorld, V.vertexNormalsModel[2], Ia), Ba.multiply(Qa).add(hb), ea.multiply(Qa).add(hb), na.multiply(Qa).add(hb), Ia.multiply(Qa).add(hb), ra = k(Ba, ea, na, Ia), d(Fa, Oa, X, fa, oa, ha), i(Fa, Oa, X, fa, oa, ha, 0, 0, 1, 0, 0, 1, ra), d(da, xa, T, U, Ta, la), i(da, xa, T, U, Ta, la, 1, 0, 1, 1, 0, 1, ra)) : (ka.copy(kb), b(V.centroidModel, V.normalModel, ka), ka.multiply(Qa).add(hb), e(Fa, Oa, X, fa, T, U, oa, ha), !0 === w.wireframe ? f(ka, w.wireframeLinewidth,
w.wireframeLinecap, w.wireframeLinejoin) : g(ka))) : w instanceof THREE.MeshBasicMaterial ? (ka.copy(w.color), w.vertexColors === THREE.FaceColors && ka.multiply(V.color), e(Fa, Oa, X, fa, T, U, oa, ha), !0 === w.wireframe ? f(ka, w.wireframeLinewidth, w.wireframeLinecap, w.wireframeLinejoin) : g(ka)) : w instanceof THREE.MeshNormalMaterial ? (C = void 0, w.shading == THREE.FlatShading ? (C = V.normalModelView, ka.setRGB(C.x, C.y, C.z).multiplyScalar(0.5).addScalar(0.5), e(Fa, Oa, X, fa, T, U, oa, ha), !0 === w.wireframe ? f(ka, w.wireframeLinewidth, w.wireframeLinecap,
w.wireframeLinejoin) : g(ka)) : w.shading == THREE.SmoothShading && (C = V.vertexNormalsModelView[0], Ba.setRGB(C.x, C.y, C.z).multiplyScalar(0.5).addScalar(0.5), C = V.vertexNormalsModelView[1], ea.setRGB(C.x, C.y, C.z).multiplyScalar(0.5).addScalar(0.5), C = V.vertexNormalsModelView[3], na.setRGB(C.x, C.y, C.z).multiplyScalar(0.5).addScalar(0.5), C = V.vertexNormalsModelView[2], Ia.setRGB(C.x, C.y, C.z).multiplyScalar(0.5).addScalar(0.5), ra = k(Ba, ea, na, Ia), d(Fa, Oa, X, fa, oa, ha), i(Fa, Oa, X, fa, oa, ha, 0, 0, 1, 0, 0, 1, ra), d(da, xa, T, U, Ta,
la), i(da, xa, T, U, Ta, la, 1, 0, 1, 1, 0, 1, ra))) : w instanceof THREE.MeshDepthMaterial && (vb = sa.near, yb = sa.far, Ba.r = Ba.g = Ba.b = 1 - z(C.positionScreen.z * C.positionScreen.w, vb, yb), ea.r = ea.g = ea.b = 1 - z(lb.positionScreen.z * lb.positionScreen.w, vb, yb), na.r = na.g = na.b = 1 - z(tb.positionScreen.z * tb.positionScreen.w, vb, yb), Ia.r = Ia.g = Ia.b = 1 - z(mb.positionScreen.z * mb.positionScreen.w, vb, yb), ra = k(Ba, ea, na, Ia), d(Fa, Oa, X, fa, oa, ha), i(Fa, Oa, X, fa, oa, ha, 0, 0, 1, 0, 0, 1, ra), d(da, xa, T, U, Ta, la), i(da, xa, T, U, Ta, la, 1, 0, 1, 1, 0, 1, ra))))
}
Ya.union(ua)
}
}
y.setTransform(1,
0, 0, 1, 0, 0)
}
}
};
THREE.ShaderChunk = {
fog_pars_fragment: "#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",
fog_fragment: "#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
envmap_pars_fragment: "#ifdef USE_ENVMAP\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nuniform bool useRefract;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",
envmap_fragment: "#ifdef USE_ENVMAP\nvec3 reflectVec;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\nif ( useRefract ) {\nreflectVec = refract( cameraToVertex, normal, refractionRatio );\n} else { \nreflectVec = reflect( cameraToVertex, normal );\n}\n#else\nreflectVec = vReflect;\n#endif\n#ifdef DOUBLE_SIDED\nfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\nvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#else\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#endif\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );\n} else if ( combine == 2 ) {\ngl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;\n} else {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );\n}\n#endif",
envmap_pars_vertex: "#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
worldpos_vertex: "#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n#ifdef USE_SKINNING\nvec4 worldPosition = modelMatrix * skinned;\n#endif\n#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );\n#endif\n#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n#endif\n#endif",
envmap_vertex: "#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\nvec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;\nworldNormal = normalize( worldNormal );\nvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\nif ( useRefract ) {\nvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n} else {\nvReflect = reflect( cameraToVertex, worldNormal );\n}\n#endif",
map_particle_pars_fragment: "#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
map_particle_fragment: "#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n#endif",
map_pars_vertex: "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",
map_pars_fragment: "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
map_vertex: "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",
map_fragment: "#ifdef USE_MAP\nvec4 texelColor = texture2D( map, vUv );\n#ifdef GAMMA_INPUT\ntexelColor.xyz *= texelColor.xyz;\n#endif\ngl_FragColor = gl_FragColor * texelColor;\n#endif",
lightmap_pars_fragment: "#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
lightmap_pars_vertex: "#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
lightmap_fragment: "#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",
lightmap_vertex: "#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",
bumpmap_pars_fragment: "#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;\nuniform float bumpScale;\nvec2 dHdxy_fwd() {\nvec2 dSTdx = dFdx( vUv );\nvec2 dSTdy = dFdy( vUv );\nfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\nfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\nfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\nreturn vec2( dBx, dBy );\n}\nvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\nvec3 vSigmaX = dFdx( surf_pos );\nvec3 vSigmaY = dFdy( surf_pos );\nvec3 vN = surf_norm;\nvec3 R1 = cross( vSigmaY, vN );\nvec3 R2 = cross( vN, vSigmaX );\nfloat fDet = dot( vSigmaX, R1 );\nvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\nreturn normalize( abs( fDet ) * surf_norm - vGrad );\n}\n#endif",
normalmap_pars_fragment: "#ifdef USE_NORMALMAP\nuniform sampler2D normalMap;\nuniform vec2 normalScale;\nvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\nvec3 q0 = dFdx( eye_pos.xyz );\nvec3 q1 = dFdy( eye_pos.xyz );\nvec2 st0 = dFdx( vUv.st );\nvec2 st1 = dFdy( vUv.st );\nvec3 S = normalize( q0 * st1.t - q1 * st0.t );\nvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\nvec3 N = normalize( surf_norm );\nvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\nmapN.xy = normalScale * mapN.xy;\nmat3 tsn = mat3( S, T, N );\nreturn normalize( tsn * mapN );\n}\n#endif",
specularmap_pars_fragment: "#ifdef USE_SPECULARMAP\nuniform sampler2D specularMap;\n#endif",
specularmap_fragment: "float specularStrength;\n#ifdef USE_SPECULARMAP\nvec4 texelSpecular = texture2D( specularMap, vUv );\nspecularStrength = texelSpecular.r;\n#else\nspecularStrength = 1.0;\n#endif",
lights_lambert_pars_vertex: "uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif",
lights_lambert_vertex: "vLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\nvLightBack = vec3( 0.0 );\n#endif\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( transformedNormal, dirVector );\nvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\ndirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\ndirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n#ifdef DOUBLE_SIDED\nvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n#endif\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\npointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\npointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef DOUBLE_SIDED\nvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );\nif ( spotEffect > spotLightAngleCos[ i ] ) {\nspotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\nspotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\nspotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;\n#ifdef DOUBLE_SIDED\nvLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\nvec3 lVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( transformedNormal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nfloat hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;\nvLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n#ifdef DOUBLE_SIDED\nvLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );\n#endif\n}\n#endif\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n#endif",
lights_phong_pars_vertex: "#ifndef PHONG_PER_PIXEL\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\nvarying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvarying vec3 vWorldPosition;\n#endif",
lights_phong_vertex: "#ifndef PHONG_PER_PIXEL\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nvSpotLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvWorldPosition = worldPosition.xyz;\n#endif",
lights_phong_pars_fragment: "uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#else\nvarying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvarying vec3 vWorldPosition;\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
lights_phong_fragment: "vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#ifdef DOUBLE_SIDED\nnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n#endif\n#ifdef USE_NORMALMAP\nnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\nnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nvec3 spotDiffuse = vec3( 0.0 );\nvec3 spotSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vSpotLight[ i ].xyz );\nfloat lDistance = vSpotLight[ i ].w;\n#endif\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\nif ( spotEffect > spotLightAngleCos[ i ] ) {\nspotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat spotDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n#else\nfloat spotDiffuseWeight = max( dotProduct, 0.0 );\n#endif\nspotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;\nvec3 spotHalfVector = normalize( lVector + viewPosition );\nfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\nfloat spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, spotHalfVector ), 5.0 );\nspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;\n#else\nspotSpecular += specular * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, dirVector );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n#endif\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nvec3 hemiDiffuse = vec3( 0.0 );\nvec3 hemiSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\nvec3 lVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\nhemiDiffuse += diffuse * hemiColor;\nvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\nfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\nfloat hemiSpecularWeightSky = specularStrength * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );\nvec3 lVectorGround = -lVector;\nvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\nfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\nfloat hemiSpecularWeightGround = specularStrength * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat dotProductGround = dot( normal, lVectorGround );\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );\nvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );\nhemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n#else\nhemiSpecular += specular * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_HEMI_LIGHTS > 0\ntotalDiffuse += hemiDiffuse;\ntotalSpecular += hemiSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#if MAX_SPOT_LIGHTS > 0\ntotalDiffuse += spotDiffuse;\ntotalSpecular += spotSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif",
color_pars_fragment: "#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",
color_fragment: "#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",
color_pars_vertex: "#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",
color_vertex: "#ifdef USE_COLOR\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\n#endif",
skinning_pars_vertex: "#ifdef USE_SKINNING\n#ifdef BONE_TEXTURE\nuniform sampler2D boneTexture;\nmat4 getBoneMatrix( const in float i ) {\nfloat j = i * 4.0;\nfloat x = mod( j, N_BONE_PIXEL_X );\nfloat y = floor( j / N_BONE_PIXEL_X );\nconst float dx = 1.0 / N_BONE_PIXEL_X;\nconst float dy = 1.0 / N_BONE_PIXEL_Y;\ny = dy * ( y + 0.5 );\nvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\nvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\nvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\nvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\nmat4 bone = mat4( v1, v2, v3, v4 );\nreturn bone;\n}\n#else\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\nmat4 getBoneMatrix( const in float i ) {\nmat4 bone = boneGlobalMatrices[ int(i) ];\nreturn bone;\n}\n#endif\n#endif",
skinbase_vertex: "#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix( skinIndex.x );\nmat4 boneMatY = getBoneMatrix( skinIndex.y );\n#endif",
skinning_vertex: "#ifdef USE_SKINNING\n#ifdef USE_MORPHTARGETS\nvec4 skinVertex = vec4( morphed, 1.0 );\n#else\nvec4 skinVertex = vec4( position, 1.0 );\n#endif\nvec4 skinned = boneMatX * skinVertex * skinWeight.x;\nskinned \t += boneMatY * skinVertex * skinWeight.y;\n#endif",
morphtarget_pars_vertex: "#ifdef USE_MORPHTARGETS\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[ 8 ];\n#else\nuniform float morphTargetInfluences[ 4 ];\n#endif\n#endif",
morphtarget_vertex: "#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n#ifndef USE_MORPHNORMALS\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n#endif\nmorphed += position;\n#endif",
default_vertex: "vec4 mvPosition;\n#ifdef USE_SKINNING\nmvPosition = modelViewMatrix * skinned;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )\nmvPosition = modelViewMatrix * vec4( morphed, 1.0 );\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )\nmvPosition = modelViewMatrix * vec4( position, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;",
morphnormal_vertex: "#ifdef USE_MORPHNORMALS\nvec3 morphedNormal = vec3( 0.0 );\nmorphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\nmorphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\nmorphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\nmorphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\nmorphedNormal += normal;\n#endif",
skinnormal_vertex: "#ifdef USE_SKINNING\nmat4 skinMatrix = skinWeight.x * boneMatX;\nskinMatrix \t+= skinWeight.y * boneMatY;\n#ifdef USE_MORPHNORMALS\nvec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n#else\nvec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n#endif\n#endif",
defaultnormal_vertex: "vec3 objectNormal;\n#ifdef USE_SKINNING\nobjectNormal = skinnedNormal.xyz;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )\nobjectNormal = morphedNormal;\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )\nobjectNormal = normal;\n#endif\n#ifdef FLIP_SIDED\nobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;",
shadowmap_pars_fragment: "#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",
shadowmap_fragment: "#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_DEBUG\nvec3 frustumColors[3];\nfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\nfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\nfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n#endif\n#ifdef SHADOWMAP_CASCADE\nint inFrustumCount = 0;\n#endif\nfloat fDepth;\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nbool inFrustum = all( inFrustumVec );\n#ifdef SHADOWMAP_CASCADE\ninFrustumCount += int( inFrustum );\nbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n#else\nbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n#endif\nbool frustumTest = all( frustumTestVec );\nif ( frustumTest ) {\nshadowCoord.z += shadowBias[ i ];\n#if defined( SHADOWMAP_TYPE_PCF )\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\nfloat shadow = 0.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.0 * xPixelOffset;\nfloat dy0 = -1.0 * yPixelOffset;\nfloat dx1 = 1.0 * xPixelOffset;\nfloat dy1 = 1.0 * yPixelOffset;\nmat3 shadowKernel;\nmat3 depthKernel;\ndepthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\ndepthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\ndepthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\ndepthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\ndepthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\ndepthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\ndepthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\ndepthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\ndepthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nvec3 shadowZ = vec3( shadowCoord.z );\nshadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));\nshadowKernel[0] *= vec3(0.25);\nshadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));\nshadowKernel[1] *= vec3(0.25);\nshadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));\nshadowKernel[2] *= vec3(0.25);\nvec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );\nshadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );\nshadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );\nvec4 shadowValues;\nshadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );\nshadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );\nshadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );\nshadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );\nshadow = dot( shadowValues, vec4( 1.0 ) );\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n#ifdef SHADOWMAP_DEBUG\n#ifdef SHADOWMAP_CASCADE\nif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n#else\nif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n#endif\n#endif\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
shadowmap_pars_vertex: "#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",
shadowmap_vertex: "#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n}\n#endif",
alphatest_fragment: "#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",
linear_to_gamma_fragment: "#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"
};
THREE.UniformsUtils = {
merge: function(a) {
var b, c, d, e = {};
for (b = 0; b < a.length; b++)
for (c in d = this.clone(a[b]), d) e[c] = d[c];
return e
},
clone: function(a) {
var b, c, d, e = {};
for (b in a)
for (c in e[b] = {}, a[b]) d = a[b][c], e[b][c] = d instanceof THREE.Color || d instanceof THREE.Vector2 || d instanceof THREE.Vector3 || d instanceof THREE.Vector4 || d instanceof THREE.Matrix4 || d instanceof THREE.Texture ? d.clone() : d instanceof Array ? d.slice() : d;
return e
}
};
THREE.UniformsLib = {
common: {
diffuse: {
type: "c",
value: new THREE.Color(15658734)
},
opacity: {
type: "f",
value: 1
},
map: {
type: "t",
value: null
},
offsetRepeat: {
type: "v4",
value: new THREE.Vector4(0, 0, 1, 1)
},
lightMap: {
type: "t",
value: null
},
specularMap: {
type: "t",
value: null
},
envMap: {
type: "t",
value: null
},
flipEnvMap: {
type: "f",
value: -1
},
useRefract: {
type: "i",
value: 0
},
reflectivity: {
type: "f",
value: 1
},
refractionRatio: {
type: "f",
value: 0.98
},
combine: {
type: "i",
value: 0
},
morphTargetInfluences: {
type: "f",
value: 0
}
},
bump: {
bumpMap: {
type: "t",
value: null
},
bumpScale: {
type: "f",
value: 1
}
},
normalmap: {
normalMap: {
type: "t",
value: null
},
normalScale: {
type: "v2",
value: new THREE.Vector2(1, 1)
}
},
fog: {
fogDensity: {
type: "f",
value: 2.5E-4
},
fogNear: {
type: "f",
value: 1
},
fogFar: {
type: "f",
value: 2E3
},
fogColor: {
type: "c",
value: new THREE.Color(16777215)
}
},
lights: {
ambientLightColor: {
type: "fv",
value: []
},
directionalLightDirection: {
type: "fv",
value: []
},
directionalLightColor: {
type: "fv",
value: []
},
hemisphereLightDirection: {
type: "fv",
value: []
},
hemisphereLightSkyColor: {
type: "fv",
value: []
},
hemisphereLightGroundColor: {
type: "fv",
value: []
},
pointLightColor: {
type: "fv",
value: []
},
pointLightPosition: {
type: "fv",
value: []
},
pointLightDistance: {
type: "fv1",
value: []
},
spotLightColor: {
type: "fv",
value: []
},
spotLightPosition: {
type: "fv",
value: []
},
spotLightDirection: {
type: "fv",
value: []
},
spotLightDistance: {
type: "fv1",
value: []
},
spotLightAngleCos: {
type: "fv1",
value: []
},
spotLightExponent: {
type: "fv1",
value: []
}
},
particle: {
psColor: {
type: "c",
value: new THREE.Color(15658734)
},
opacity: {
type: "f",
value: 1
},
size: {
type: "f",
value: 1
},
scale: {
type: "f",
value: 1
},
map: {
type: "t",
value: null
},
fogDensity: {
type: "f",
value: 2.5E-4
},
fogNear: {
type: "f",
value: 1
},
fogFar: {
type: "f",
value: 2E3
},
fogColor: {
type: "c",
value: new THREE.Color(16777215)
}
},
shadowmap: {
shadowMap: {
type: "tv",
value: []
},
shadowMapSize: {
type: "v2v",
value: []
},
shadowBias: {
type: "fv1",
value: []
},
shadowDarkness: {
type: "fv1",
value: []
},
shadowMatrix: {
type: "m4v",
value: []
}
}
};
THREE.ShaderLib = {
basic: {
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib.common, THREE.UniformsLib.fog, THREE.UniformsLib.shadowmap]),
vertexShader: [THREE.ShaderChunk.map_pars_vertex, THREE.ShaderChunk.lightmap_pars_vertex, THREE.ShaderChunk.envmap_pars_vertex, THREE.ShaderChunk.color_pars_vertex, THREE.ShaderChunk.morphtarget_pars_vertex, THREE.ShaderChunk.skinning_pars_vertex, THREE.ShaderChunk.shadowmap_pars_vertex, "void main() {", THREE.ShaderChunk.map_vertex, THREE.ShaderChunk.lightmap_vertex, THREE.ShaderChunk.color_vertex,
THREE.ShaderChunk.skinbase_vertex, "#ifdef USE_ENVMAP", THREE.ShaderChunk.morphnormal_vertex, THREE.ShaderChunk.skinnormal_vertex, THREE.ShaderChunk.defaultnormal_vertex, "#endif", THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.skinning_vertex, THREE.ShaderChunk.default_vertex, THREE.ShaderChunk.worldpos_vertex, THREE.ShaderChunk.envmap_vertex, THREE.ShaderChunk.shadowmap_vertex, "}"
].join("\n"),
fragmentShader: ["uniform vec3 diffuse;\nuniform float opacity;", THREE.ShaderChunk.color_pars_fragment, THREE.ShaderChunk.map_pars_fragment,
THREE.ShaderChunk.lightmap_pars_fragment, THREE.ShaderChunk.envmap_pars_fragment, THREE.ShaderChunk.fog_pars_fragment, THREE.ShaderChunk.shadowmap_pars_fragment, THREE.ShaderChunk.specularmap_pars_fragment, "void main() {\ngl_FragColor = vec4( diffuse, opacity );", THREE.ShaderChunk.map_fragment, THREE.ShaderChunk.alphatest_fragment, THREE.ShaderChunk.specularmap_fragment, THREE.ShaderChunk.lightmap_fragment, THREE.ShaderChunk.color_fragment, THREE.ShaderChunk.envmap_fragment, THREE.ShaderChunk.shadowmap_fragment,
THREE.ShaderChunk.linear_to_gamma_fragment, THREE.ShaderChunk.fog_fragment, "}"
].join("\n")
},
lambert: {
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib.common, THREE.UniformsLib.fog, THREE.UniformsLib.lights, THREE.UniformsLib.shadowmap, {
ambient: {
type: "c",
value: new THREE.Color(16777215)
},
emissive: {
type: "c",
value: new THREE.Color(0)
},
wrapRGB: {
type: "v3",
value: new THREE.Vector3(1, 1, 1)
}
}]),
vertexShader: ["#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",
THREE.ShaderChunk.map_pars_vertex, THREE.ShaderChunk.lightmap_pars_vertex, THREE.ShaderChunk.envmap_pars_vertex, THREE.ShaderChunk.lights_lambert_pars_vertex, THREE.ShaderChunk.color_pars_vertex, THREE.ShaderChunk.morphtarget_pars_vertex, THREE.ShaderChunk.skinning_pars_vertex, THREE.ShaderChunk.shadowmap_pars_vertex, "void main() {", THREE.ShaderChunk.map_vertex, THREE.ShaderChunk.lightmap_vertex, THREE.ShaderChunk.color_vertex, THREE.ShaderChunk.morphnormal_vertex, THREE.ShaderChunk.skinbase_vertex, THREE.ShaderChunk.skinnormal_vertex,
THREE.ShaderChunk.defaultnormal_vertex, THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.skinning_vertex, THREE.ShaderChunk.default_vertex, THREE.ShaderChunk.worldpos_vertex, THREE.ShaderChunk.envmap_vertex, THREE.ShaderChunk.lights_lambert_vertex, THREE.ShaderChunk.shadowmap_vertex, "}"
].join("\n"),
fragmentShader: ["uniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif", THREE.ShaderChunk.color_pars_fragment, THREE.ShaderChunk.map_pars_fragment, THREE.ShaderChunk.lightmap_pars_fragment,
THREE.ShaderChunk.envmap_pars_fragment, THREE.ShaderChunk.fog_pars_fragment, THREE.ShaderChunk.shadowmap_pars_fragment, THREE.ShaderChunk.specularmap_pars_fragment, "void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );", THREE.ShaderChunk.map_fragment, THREE.ShaderChunk.alphatest_fragment, THREE.ShaderChunk.specularmap_fragment, "#ifdef DOUBLE_SIDED\nif ( gl_FrontFacing )\ngl_FragColor.xyz *= vLightFront;\nelse\ngl_FragColor.xyz *= vLightBack;\n#else\ngl_FragColor.xyz *= vLightFront;\n#endif", THREE.ShaderChunk.lightmap_fragment,
THREE.ShaderChunk.color_fragment, THREE.ShaderChunk.envmap_fragment, THREE.ShaderChunk.shadowmap_fragment, THREE.ShaderChunk.linear_to_gamma_fragment, THREE.ShaderChunk.fog_fragment, "}"
].join("\n")
},
phong: {
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib.common, THREE.UniformsLib.bump, THREE.UniformsLib.normalmap, THREE.UniformsLib.fog, THREE.UniformsLib.lights, THREE.UniformsLib.shadowmap, {
ambient: {
type: "c",
value: new THREE.Color(16777215)
},
emissive: {
type: "c",
value: new THREE.Color(0)
},
specular: {
type: "c",
value: new THREE.Color(1118481)
},
shininess: {
type: "f",
value: 30
},
wrapRGB: {
type: "v3",
value: new THREE.Vector3(1, 1, 1)
}
}]),
vertexShader: ["#define PHONG\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;", THREE.ShaderChunk.map_pars_vertex, THREE.ShaderChunk.lightmap_pars_vertex, THREE.ShaderChunk.envmap_pars_vertex, THREE.ShaderChunk.lights_phong_pars_vertex, THREE.ShaderChunk.color_pars_vertex, THREE.ShaderChunk.morphtarget_pars_vertex, THREE.ShaderChunk.skinning_pars_vertex, THREE.ShaderChunk.shadowmap_pars_vertex,
"void main() {", THREE.ShaderChunk.map_vertex, THREE.ShaderChunk.lightmap_vertex, THREE.ShaderChunk.color_vertex, THREE.ShaderChunk.morphnormal_vertex, THREE.ShaderChunk.skinbase_vertex, THREE.ShaderChunk.skinnormal_vertex, THREE.ShaderChunk.defaultnormal_vertex, "vNormal = normalize( transformedNormal );", THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.skinning_vertex, THREE.ShaderChunk.default_vertex, "vViewPosition = -mvPosition.xyz;", THREE.ShaderChunk.worldpos_vertex, THREE.ShaderChunk.envmap_vertex,
THREE.ShaderChunk.lights_phong_vertex, THREE.ShaderChunk.shadowmap_vertex, "}"
].join("\n"),
fragmentShader: ["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;", THREE.ShaderChunk.color_pars_fragment, THREE.ShaderChunk.map_pars_fragment, THREE.ShaderChunk.lightmap_pars_fragment, THREE.ShaderChunk.envmap_pars_fragment, THREE.ShaderChunk.fog_pars_fragment, THREE.ShaderChunk.lights_phong_pars_fragment, THREE.ShaderChunk.shadowmap_pars_fragment,
THREE.ShaderChunk.bumpmap_pars_fragment, THREE.ShaderChunk.normalmap_pars_fragment, THREE.ShaderChunk.specularmap_pars_fragment, "void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );", THREE.ShaderChunk.map_fragment, THREE.ShaderChunk.alphatest_fragment, THREE.ShaderChunk.specularmap_fragment, THREE.ShaderChunk.lights_phong_fragment, THREE.ShaderChunk.lightmap_fragment, THREE.ShaderChunk.color_fragment, THREE.ShaderChunk.envmap_fragment, THREE.ShaderChunk.shadowmap_fragment, THREE.ShaderChunk.linear_to_gamma_fragment,
THREE.ShaderChunk.fog_fragment, "}"
].join("\n")
},
particle_basic: {
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib.particle, THREE.UniformsLib.shadowmap]),
vertexShader: ["uniform float size;\nuniform float scale;", THREE.ShaderChunk.color_pars_vertex, THREE.ShaderChunk.shadowmap_pars_vertex, "void main() {", THREE.ShaderChunk.color_vertex, "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",
THREE.ShaderChunk.worldpos_vertex, THREE.ShaderChunk.shadowmap_vertex, "}"
].join("\n"),
fragmentShader: ["uniform vec3 psColor;\nuniform float opacity;", THREE.ShaderChunk.color_pars_fragment, THREE.ShaderChunk.map_particle_pars_fragment, THREE.ShaderChunk.fog_pars_fragment, THREE.ShaderChunk.shadowmap_pars_fragment, "void main() {\ngl_FragColor = vec4( psColor, opacity );", THREE.ShaderChunk.map_particle_fragment, THREE.ShaderChunk.alphatest_fragment, THREE.ShaderChunk.color_fragment, THREE.ShaderChunk.shadowmap_fragment,
THREE.ShaderChunk.fog_fragment, "}"
].join("\n")
},
dashed: {
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib.common, THREE.UniformsLib.fog, {
scale: {
type: "f",
value: 1
},
dashSize: {
type: "f",
value: 1
},
totalSize: {
type: "f",
value: 2
}
}]),
vertexShader: ["uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;", THREE.ShaderChunk.color_pars_vertex, "void main() {", THREE.ShaderChunk.color_vertex, "vLineDistance = scale * lineDistance;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
fragmentShader: ["uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;", THREE.ShaderChunk.color_pars_fragment, THREE.ShaderChunk.fog_pars_fragment, "void main() {\nif ( mod( vLineDistance, totalSize ) > dashSize ) {\ndiscard;\n}\ngl_FragColor = vec4( diffuse, opacity );", THREE.ShaderChunk.color_fragment, THREE.ShaderChunk.fog_fragment, "}"].join("\n")
},
depth: {
uniforms: {
mNear: {
type: "f",
value: 1
},
mFar: {
type: "f",
value: 2E3
},
opacity: {
type: "f",
value: 1
}
},
vertexShader: "void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
fragmentShader: "uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}"
},
normal: {
uniforms: {
opacity: {
type: "f",
value: 1
}
},
vertexShader: ["varying vec3 vNormal;", THREE.ShaderChunk.morphtarget_pars_vertex, "void main() {\nvNormal = normalize( normalMatrix * normal );",
THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.default_vertex, "}"
].join("\n"),
fragmentShader: "uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"
},
normalmap: {
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib.fog, THREE.UniformsLib.lights, THREE.UniformsLib.shadowmap, {
enableAO: {
type: "i",
value: 0
},
enableDiffuse: {
type: "i",
value: 0
},
enableSpecular: {
type: "i",
value: 0
},
enableReflection: {
type: "i",
value: 0
},
enableDisplacement: {
type: "i",
value: 0
},
tDisplacement: {
type: "t",
value: null
},
tDiffuse: {
type: "t",
value: null
},
tCube: {
type: "t",
value: null
},
tNormal: {
type: "t",
value: null
},
tSpecular: {
type: "t",
value: null
},
tAO: {
type: "t",
value: null
},
uNormalScale: {
type: "v2",
value: new THREE.Vector2(1, 1)
},
uDisplacementBias: {
type: "f",
value: 0
},
uDisplacementScale: {
type: "f",
value: 1
},
uDiffuseColor: {
type: "c",
value: new THREE.Color(16777215)
},
uSpecularColor: {
type: "c",
value: new THREE.Color(1118481)
},
uAmbientColor: {
type: "c",
value: new THREE.Color(16777215)
},
uShininess: {
type: "f",
value: 30
},
uOpacity: {
type: "f",
value: 1
},
useRefract: {
type: "i",
value: 0
},
uRefractionRatio: {
type: "f",
value: 0.98
},
uReflectivity: {
type: "f",
value: 0.5
},
uOffset: {
type: "v2",
value: new THREE.Vector2(0, 0)
},
uRepeat: {
type: "v2",
value: new THREE.Vector2(1, 1)
},
wrapRGB: {
type: "v3",
value: new THREE.Vector3(1, 1, 1)
}
}]),
fragmentShader: ["uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform vec2 uNormalScale;\nuniform bool useRefract;\nuniform float uRefractionRatio;\nuniform float uReflectivity;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",
THREE.ShaderChunk.shadowmap_pars_fragment, THREE.ShaderChunk.fog_pars_fragment, "void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse ) {\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( tDiffuse, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\n#endif\n}\nif( enableAO ) {\n#ifdef GAMMA_INPUT\nvec4 aoColor = texture2D( tAO, vUv );\naoColor.xyz *= aoColor.xyz;\ngl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\n#endif\n}\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );\nvec3 finalNormal = tsb * normalTex;\n#ifdef FLIP_SIDED\nfinalNormal = -finalNormal;\n#endif\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointVector = lPosition.xyz + vViewPosition.xyz;\nfloat pointDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\npointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );\npointVector = normalize( pointVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\n#endif\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\nvec3 pointHalfVector = normalize( pointVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;\n#else\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nvec3 spotDiffuse = vec3( 0.0 );\nvec3 spotSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 spotVector = lPosition.xyz + vViewPosition.xyz;\nfloat spotDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nspotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );\nspotVector = normalize( spotVector );\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\nif ( spotEffect > spotLightAngleCos[ i ] ) {\nspotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );\n#ifdef WRAP_AROUND\nfloat spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );\nfloat spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );\nvec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n#else\nfloat spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );\n#endif\nspotDiffuse += spotDistance * spotLightColor[ i ] * uDiffuseColor * spotDiffuseWeight * spotEffect;\nvec3 spotHalfVector = normalize( spotVector + viewPosition );\nfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\nfloat spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( spotVector, spotHalfVector ), 5.0 );\nspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;\n#else\nspotSpecular += spotDistance * spotLightColor[ i ] * uSpecularColor * spotSpecularWeight * spotDiffuseWeight * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n#endif\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nvec3 hemiDiffuse = vec3( 0.0 );\nvec3 hemiSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\nvec3 lVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\nhemiDiffuse += uDiffuseColor * hemiColor;\nvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\nfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\nfloat hemiSpecularWeightSky = specularTex.r * max( pow( hemiDotNormalHalfSky, uShininess ), 0.0 );\nvec3 lVectorGround = -lVector;\nvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\nfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\nfloat hemiSpecularWeightGround = specularTex.r * max( pow( hemiDotNormalHalfGround, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat dotProductGround = dot( normal, lVectorGround );\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlickSky = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );\nvec3 schlickGround = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );\nhemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n#else\nhemiSpecular += uSpecularColor * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_HEMI_LIGHTS > 0\ntotalDiffuse += hemiDiffuse;\ntotalSpecular += hemiSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#if MAX_SPOT_LIGHTS > 0\ntotalDiffuse += spotDiffuse;\ntotalSpecular += spotSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor ) + totalSpecular;\n#endif\nif ( enableReflection ) {\nvec3 vReflect;\nvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\nif ( useRefract ) {\nvReflect = refract( cameraToVertex, normal, uRefractionRatio );\n} else {\nvReflect = reflect( cameraToVertex, normal );\n}\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * uReflectivity );\n}",
THREE.ShaderChunk.shadowmap_fragment, THREE.ShaderChunk.linear_to_gamma_fragment, THREE.ShaderChunk.fog_fragment, "}"
].join("\n"),
vertexShader: ["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\nuniform bool enableDisplacement;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",
THREE.ShaderChunk.skinning_pars_vertex, THREE.ShaderChunk.shadowmap_pars_vertex, "void main() {", THREE.ShaderChunk.skinbase_vertex, THREE.ShaderChunk.skinnormal_vertex, "#ifdef USE_SKINNING\nvNormal = normalize( normalMatrix * skinnedNormal.xyz );\nvec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );\nvTangent = normalize( normalMatrix * skinnedTangent.xyz );\n#else\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\n#endif\nvBinormal = normalize( cross( vNormal, vTangent ) * tangent.w );\nvUv = uv * uRepeat + uOffset;\nvec3 displacedPosition;\n#ifdef VERTEX_TEXTURES\nif ( enableDisplacement ) {\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\ndisplacedPosition = position + normalize( normal ) * df;\n} else {\n#ifdef USE_SKINNING\nvec4 skinVertex = vec4( position, 1.0 );\nvec4 skinned = boneMatX * skinVertex * skinWeight.x;\nskinned \t += boneMatY * skinVertex * skinWeight.y;\ndisplacedPosition = skinned.xyz;\n#else\ndisplacedPosition = position;\n#endif\n}\n#else\n#ifdef USE_SKINNING\nvec4 skinVertex = vec4( position, 1.0 );\nvec4 skinned = boneMatX * skinVertex * skinWeight.x;\nskinned \t += boneMatY * skinVertex * skinWeight.y;\ndisplacedPosition = skinned.xyz;\n#else\ndisplacedPosition = position;\n#endif\n#endif\nvec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );\nvec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\nvWorldPosition = worldPosition.xyz;\nvViewPosition = -mvPosition.xyz;\n#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n}\n#endif\n}"
].join("\n")
},
cube: {
uniforms: {
tCube: {
type: "t",
value: null
},
tFlip: {
type: "f",
value: -1
}
},
vertexShader: "varying vec3 vWorldPosition;\nvoid main() {\nvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\nvWorldPosition = worldPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
fragmentShader: "uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\nvoid main() {\ngl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n}"
},
depthRGBA: {
uniforms: {},
vertexShader: [THREE.ShaderChunk.morphtarget_pars_vertex, THREE.ShaderChunk.skinning_pars_vertex, "void main() {", THREE.ShaderChunk.skinbase_vertex, THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.skinning_vertex, THREE.ShaderChunk.default_vertex, "}"].join("\n"),
fragmentShader: "vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"
}
};
THREE.WebGLRenderer = function(a) {
function b(a, b) {
var c = a.vertices.length,
d = b.material;
if (d.attributes) {
void 0 === a.__webglCustomAttributesList && (a.__webglCustomAttributesList = []);
for (var e in d.attributes) {
var f = d.attributes[e];
if (!f.__webglInitialized || f.createUniqueBuffers) {
f.__webglInitialized = !0;
var g = 1;
"v2" === f.type ? g = 2 : "v3" === f.type ? g = 3 : "v4" === f.type ? g = 4 : "c" === f.type && (g = 3);
f.size = g;
f.array = new Float32Array(c * g);
f.buffer = j.createBuffer();
f.buffer.belongsToAttribute = e;
f.needsUpdate = !0
}
a.__webglCustomAttributesList.push(f)
}
}
}
function c(a, b) {
var c = b.geometry,
g = a.faces3,
h = a.faces4,
i = 3 * g.length + 4 * h.length,
k = 1 * g.length + 2 * h.length,
h = 3 * g.length + 4 * h.length,
g = d(b, a),
m = f(g),
l = e(g),
p = g.vertexColors ? g.vertexColors : !1;
a.__vertexArray = new Float32Array(3 * i);
l && (a.__normalArray = new Float32Array(3 * i));
c.hasTangents && (a.__tangentArray = new Float32Array(4 * i));
p && (a.__colorArray = new Float32Array(3 * i));
if (m) {
if (0 < c.faceUvs.length || 0 < c.faceVertexUvs.length) a.__uvArray = new Float32Array(2 * i);
if (1 < c.faceUvs.length || 1 < c.faceVertexUvs.length) a.__uv2Array =
new Float32Array(2 * i)
}
b.geometry.skinWeights.length && b.geometry.skinIndices.length && (a.__skinIndexArray = new Float32Array(4 * i), a.__skinWeightArray = new Float32Array(4 * i));
a.__faceArray = new Uint16Array(3 * k);
a.__lineArray = new Uint16Array(2 * h);
if (a.numMorphTargets) {
a.__morphTargetsArrays = [];
c = 0;
for (m = a.numMorphTargets; c < m; c++) a.__morphTargetsArrays.push(new Float32Array(3 * i))
}
if (a.numMorphNormals) {
a.__morphNormalsArrays = [];
c = 0;
for (m = a.numMorphNormals; c < m; c++) a.__morphNormalsArrays.push(new Float32Array(3 *
i))
}
a.__webglFaceCount = 3 * k;
a.__webglLineCount = 2 * h;
if (g.attributes) {
void 0 === a.__webglCustomAttributesList && (a.__webglCustomAttributesList = []);
for (var n in g.attributes) {
var k = g.attributes[n],
c = {},
q;
for (q in k) c[q] = k[q];
if (!c.__webglInitialized || c.createUniqueBuffers) c.__webglInitialized = !0, h = 1, "v2" === c.type ? h = 2 : "v3" === c.type ? h = 3 : "v4" === c.type ? h = 4 : "c" === c.type && (h = 3), c.size = h, c.array = new Float32Array(i * h), c.buffer = j.createBuffer(), c.buffer.belongsToAttribute = n, k.needsUpdate = !0, c.__original = k;
a.__webglCustomAttributesList.push(c)
}
}
a.__inittedArrays = !0
}
function d(a, b) {
return a.material instanceof THREE.MeshFaceMaterial ? a.material.materials[b.materialIndex] : a.material
}
function e(a) {
return a instanceof THREE.MeshBasicMaterial && !a.envMap || a instanceof THREE.MeshDepthMaterial ? !1 : a && void 0 !== a.shading && a.shading === THREE.SmoothShading ? THREE.SmoothShading : THREE.FlatShading
}
function f(a) {
return a.map || a.lightMap || a.bumpMap || a.normalMap || a.specularMap || a instanceof THREE.ShaderMaterial ? !0 : !1
}
function g(a) {
Ab[a] || (j.enableVertexAttribArray(a), Ab[a] = !0)
}
function h() {
for (var a in Ab) Ab[a] && (j.disableVertexAttribArray(a), Ab[a] = !1)
}
function i(a, b) {
return a.z !== b.z ? b.z - a.z : a.id - b.id
}
function k(a, b) {
return b[0] - a[0]
}
function l(a, b, c) {
if (a.length)
for (var d = 0, e = a.length; d < e; d++) ob = ja = null, Ea = Za = fa = X = xa = da = T = -1, wb = !0, a[d].render(b, c, hb, Lb), ob = ja = null, Ea = Za = fa = X = xa = da = T = -1, wb = !0
}
function m(a, b, c, d, e, f, g, h) {
var j, i, k, m;
b ? (i = a.length - 1, m = b = -1) : (i = 0, b = a.length, m = 1);
for (var l = i; l !== b; l += m)
if (j = a[l], j.render) {
i = j.object;
k = j.buffer;
if (h) j = h;
else {
j = j[c];
if (!j) continue;
g && L.setBlending(j.blending, j.blendEquation, j.blendSrc, j.blendDst);
L.setDepthTest(j.depthTest);
L.setDepthWrite(j.depthWrite);
A(j.polygonOffset, j.polygonOffsetFactor, j.polygonOffsetUnits)
}
L.setMaterialFaces(j);
k instanceof THREE.BufferGeometry ? L.renderBufferDirect(d, e, f, j, k, i) : L.renderBuffer(d, e, f, j, k, i)
}
}
function p(a, b, c, d, e, f, g) {
for (var h, j, i = 0, k = a.length; i < k; i++)
if (h = a[i], j = h.object, j.visible) {
if (g) h = g;
else {
h = h[b];
if (!h) continue;
f && L.setBlending(h.blending, h.blendEquation, h.blendSrc, h.blendDst);
L.setDepthTest(h.depthTest);
L.setDepthWrite(h.depthWrite);
A(h.polygonOffset, h.polygonOffsetFactor, h.polygonOffsetUnits)
}
L.renderImmediateObject(c, d, e, h, j)
}
}
function q(a, d) {
var e, f, g;
if (void 0 === a.__webglInit && (a.__webglInit = !0, a._modelViewMatrix = new THREE.Matrix4, a._normalMatrix = new THREE.Matrix3, void 0 !== a.geometry && void 0 === a.geometry.__webglInit && (a.geometry.__webglInit = !0, a.geometry.addEventListener("dispose", lc)), f = a.geometry, void 0 !== f))
if (f instanceof THREE.BufferGeometry) {
var h, i;
for (h in f.attributes) i =
"index" === h ? j.ELEMENT_ARRAY_BUFFER : j.ARRAY_BUFFER, g = f.attributes[h], void 0 === g.numItems && (g.numItems = g.array.length), g.buffer = j.createBuffer(), j.bindBuffer(i, g.buffer), j.bufferData(i, g.array, j.STATIC_DRAW)
} else if (a instanceof THREE.Mesh) {
if (void 0 === f.geometryGroups) {
h = f;
var k, m, l, p, n, q = {},
r = h.morphTargets.length,
s = h.morphNormals.length;
h.geometryGroups = {};
i = 0;
for (k = h.faces.length; i < k; i++) m = h.faces[i], l = m.materialIndex, void 0 === q[l] && (q[l] = {
hash: l,
counter: 0
}), n = q[l].hash + "_" + q[l].counter, void 0 ===
h.geometryGroups[n] && (h.geometryGroups[n] = {
faces3: [],
faces4: [],
materialIndex: l,
vertices: 0,
numMorphTargets: r,
numMorphNormals: s
}), p = m instanceof THREE.Face3 ? 3 : 4, 65535 < h.geometryGroups[n].vertices + p && (q[l].counter += 1, n = q[l].hash + "_" + q[l].counter, void 0 === h.geometryGroups[n] && (h.geometryGroups[n] = {
faces3: [],
faces4: [],
materialIndex: l,
vertices: 0,
numMorphTargets: r,
numMorphNormals: s
})), m instanceof THREE.Face3 ? h.geometryGroups[n].faces3.push(i) : h.geometryGroups[n].faces4.push(i), h.geometryGroups[n].vertices +=
p;
h.geometryGroupsList = [];
for (g in h.geometryGroups) h.geometryGroups[g].id = Fa++, h.geometryGroupsList.push(h.geometryGroups[g])
}
for (e in f.geometryGroups)
if (g = f.geometryGroups[e], !g.__webglVertexBuffer) {
h = g;
h.__webglVertexBuffer = j.createBuffer();
h.__webglNormalBuffer = j.createBuffer();
h.__webglTangentBuffer = j.createBuffer();
h.__webglColorBuffer = j.createBuffer();
h.__webglUVBuffer = j.createBuffer();
h.__webglUV2Buffer = j.createBuffer();
h.__webglSkinIndicesBuffer = j.createBuffer();
h.__webglSkinWeightsBuffer =
j.createBuffer();
h.__webglFaceBuffer = j.createBuffer();
h.__webglLineBuffer = j.createBuffer();
k = i = void 0;
if (h.numMorphTargets) {
h.__webglMorphTargetsBuffers = [];
i = 0;
for (k = h.numMorphTargets; i < k; i++) h.__webglMorphTargetsBuffers.push(j.createBuffer())
}
if (h.numMorphNormals) {
h.__webglMorphNormalsBuffers = [];
i = 0;
for (k = h.numMorphNormals; i < k; i++) h.__webglMorphNormalsBuffers.push(j.createBuffer())
}
L.info.memory.geometries++;
c(g, a);
f.verticesNeedUpdate = !0;
f.morphTargetsNeedUpdate = !0;
f.elementsNeedUpdate = !0;
f.uvsNeedUpdate = !0;
f.normalsNeedUpdate = !0;
f.tangentsNeedUpdate = !0;
f.colorsNeedUpdate = !0
}
} else a instanceof THREE.Ribbon ? f.__webglVertexBuffer || (g = f, g.__webglVertexBuffer = j.createBuffer(), g.__webglColorBuffer = j.createBuffer(), g.__webglNormalBuffer = j.createBuffer(), L.info.memory.geometries++, g = f, h = g.vertices.length, g.__vertexArray = new Float32Array(3 * h), g.__colorArray = new Float32Array(3 * h), g.__normalArray = new Float32Array(3 * h), g.__webglVertexCount = h, b(g, a), f.verticesNeedUpdate = !0, f.colorsNeedUpdate = !0, f.normalsNeedUpdate = !0) : a instanceof THREE.Line ? f.__webglVertexBuffer || (g = f, g.__webglVertexBuffer = j.createBuffer(), g.__webglColorBuffer = j.createBuffer(), g.__webglLineDistanceBuffer = j.createBuffer(), L.info.memory.geometries++, g = f, h = g.vertices.length, g.__vertexArray = new Float32Array(3 * h), g.__colorArray = new Float32Array(3 * h), g.__lineDistanceArray = new Float32Array(1 * h), g.__webglLineCount = h, b(g, a), f.verticesNeedUpdate = !0, f.colorsNeedUpdate = !0, f.lineDistancesNeedUpdate = !0) : a instanceof THREE.ParticleSystem && !f.__webglVertexBuffer &&
(g = f, g.__webglVertexBuffer = j.createBuffer(), g.__webglColorBuffer = j.createBuffer(), L.info.memory.geometries++, g = f, h = g.vertices.length, g.__vertexArray = new Float32Array(3 * h), g.__colorArray = new Float32Array(3 * h), g.__sortArray = [], g.__webglParticleCount = h, b(g, a), f.verticesNeedUpdate = !0, f.colorsNeedUpdate = !0);
if (void 0 === a.__webglActive) {
if (a instanceof THREE.Mesh)
if (f = a.geometry, f instanceof THREE.BufferGeometry) t(d.__webglObjects, f, a);
else {
if (f instanceof THREE.Geometry)
for (e in f.geometryGroups) g = f.geometryGroups[e],
t(d.__webglObjects, g, a)
} else a instanceof THREE.Ribbon || a instanceof THREE.Line || a instanceof THREE.ParticleSystem ? (f = a.geometry, t(d.__webglObjects, f, a)) : a instanceof THREE.ImmediateRenderObject || a.immediateRenderCallback ? d.__webglObjectsImmediate.push({
id: null,
object: a,
opaque: null,
transparent: null,
z: 0
}) : a instanceof THREE.Sprite ? d.__webglSprites.push(a) : a instanceof THREE.LensFlare && d.__webglFlares.push(a);
a.__webglActive = !0
}
}
function t(a, b, c) {
a.push({
id: null,
buffer: b,
object: c,
opaque: null,
transparent: null,
z: 0
})
}
function n(a) {
for (var b in a.attributes)
if (a.attributes[b].needsUpdate) return !0;
return !1
}
function r(a) {
for (var b in a.attributes) a.attributes[b].needsUpdate = !1
}
function s(a, b) {
a instanceof THREE.Mesh || a instanceof THREE.ParticleSystem || a instanceof THREE.Ribbon || a instanceof THREE.Line ? v(b.__webglObjects, a) : a instanceof THREE.Sprite ? z(b.__webglSprites, a) : a instanceof THREE.LensFlare ? z(b.__webglFlares, a) : (a instanceof THREE.ImmediateRenderObject || a.immediateRenderCallback) && v(b.__webglObjectsImmediate,
a);
delete a.__webglActive
}
function v(a, b) {
for (var c = a.length - 1; 0 <= c; c--) a[c].object === b && a.splice(c, 1)
}
function z(a, b) {
for (var c = a.length - 1; 0 <= c; c--) a[c] === b && a.splice(c, 1)
}
function H(a, b, c, d, e) {
Oa = 0;
d.needsUpdate && (d.program && uc(d), L.initMaterial(d, b, c, e), d.needsUpdate = !1);
d.morphTargets && !e.__webglMorphTargetInfluences && (e.__webglMorphTargetInfluences = new Float32Array(L.maxMorphTargets));
var f = !1,
g = d.program,
h = g.uniforms,
i = d.uniforms;
g !== ja && (j.useProgram(g), ja = g, f = !0);
d.id !== Ea && (Ea = d.id, f = !0);
if (f || a !== ob) j.uniformMatrix4fv(h.projectionMatrix, !1, a.projectionMatrix.elements), a !== ob && (ob = a);
if (d.skinning)
if (Jb && e.useVertexTexture) {
if (null !== h.boneTexture) {
var k = B();
j.uniform1i(h.boneTexture, k);
L.setTexture(e.boneTexture, k)
}
} else null !== h.boneGlobalMatrices && j.uniformMatrix4fv(h.boneGlobalMatrices, !1, e.boneMatrices);
if (f) {
c && d.fog && (i.fogColor.value = c.color, c instanceof THREE.Fog ? (i.fogNear.value = c.near, i.fogFar.value = c.far) : c instanceof THREE.FogExp2 && (i.fogDensity.value = c.density));
if (d instanceof THREE.MeshPhongMaterial || d instanceof THREE.MeshLambertMaterial || d.lights) {
if (wb) {
for (var m, l = k = 0, p = 0, n, q, r, s = Mb, t = s.directional.colors, v = s.directional.positions, z = s.point.colors, y = s.point.positions, A = s.point.distances, C = s.spot.colors, H = s.spot.positions, F = s.spot.distances, E = s.spot.directions, N = s.spot.anglesCos, W = s.spot.exponents, O = s.hemi.skyColors, M = s.hemi.groundColors, D = s.hemi.positions, P = 0, T = 0, X = 0, pa = 0, ca = 0, R = 0, S = 0, Q = 0, aa = m = 0, c = r = aa = 0, f = b.length; c < f; c++) m = b[c], m.onlyShadow || (n = m.color, q = m.intensity,
r = m.distance, m instanceof THREE.AmbientLight ? m.visible && (L.gammaInput ? (k += n.r * n.r, l += n.g * n.g, p += n.b * n.b) : (k += n.r, l += n.g, p += n.b)) : m instanceof THREE.DirectionalLight ? (ca += 1, m.visible && (ta.getPositionFromMatrix(m.matrixWorld), ra.getPositionFromMatrix(m.target.matrixWorld), ta.sub(ra), ta.normalize(), 0 === ta.x && 0 === ta.y && 0 === ta.z || (m = 3 * P, v[m] = ta.x, v[m + 1] = ta.y, v[m + 2] = ta.z, L.gammaInput ? G(t, m, n, q * q) : I(t, m, n, q), P += 1))) : m instanceof THREE.PointLight ? (R += 1, m.visible && (aa = 3 * T, L.gammaInput ? G(z, aa, n, q * q) : I(z, aa,
n, q), ra.getPositionFromMatrix(m.matrixWorld), y[aa] = ra.x, y[aa + 1] = ra.y, y[aa + 2] = ra.z, A[T] = r, T += 1)) : m instanceof THREE.SpotLight ? (S += 1, m.visible && (aa = 3 * X, L.gammaInput ? G(C, aa, n, q * q) : I(C, aa, n, q), ra.getPositionFromMatrix(m.matrixWorld), H[aa] = ra.x, H[aa + 1] = ra.y, H[aa + 2] = ra.z, F[X] = r, ta.copy(ra), ra.getPositionFromMatrix(m.target.matrixWorld), ta.sub(ra), ta.normalize(), E[aa] = ta.x, E[aa + 1] = ta.y, E[aa + 2] = ta.z, N[X] = Math.cos(m.angle), W[X] = m.exponent, X += 1)) : m instanceof THREE.HemisphereLight && (Q += 1, m.visible && (ta.getPositionFromMatrix(m.matrixWorld),
ta.normalize(), 0 === ta.x && 0 === ta.y && 0 === ta.z || (r = 3 * pa, D[r] = ta.x, D[r + 1] = ta.y, D[r + 2] = ta.z, n = m.color, m = m.groundColor, L.gammaInput ? (q *= q, G(O, r, n, q), G(M, r, m, q)) : (I(O, r, n, q), I(M, r, m, q)), pa += 1))));
c = 3 * P;
for (f = Math.max(t.length, 3 * ca); c < f; c++) t[c] = 0;
c = 3 * T;
for (f = Math.max(z.length, 3 * R); c < f; c++) z[c] = 0;
c = 3 * X;
for (f = Math.max(C.length, 3 * S); c < f; c++) C[c] = 0;
c = 3 * pa;
for (f = Math.max(O.length, 3 * Q); c < f; c++) O[c] = 0;
c = 3 * pa;
for (f = Math.max(M.length, 3 * Q); c < f; c++) M[c] = 0;
s.directional.length = P;
s.point.length = T;
s.spot.length = X;
s.hemi.length =
pa;
s.ambient[0] = k;
s.ambient[1] = l;
s.ambient[2] = p;
wb = !1
}
c = Mb;
i.ambientLightColor.value = c.ambient;
i.directionalLightColor.value = c.directional.colors;
i.directionalLightDirection.value = c.directional.positions;
i.pointLightColor.value = c.point.colors;
i.pointLightPosition.value = c.point.positions;
i.pointLightDistance.value = c.point.distances;
i.spotLightColor.value = c.spot.colors;
i.spotLightPosition.value = c.spot.positions;
i.spotLightDistance.value = c.spot.distances;
i.spotLightDirection.value = c.spot.directions;
i.spotLightAngleCos.value = c.spot.anglesCos;
i.spotLightExponent.value = c.spot.exponents;
i.hemisphereLightSkyColor.value = c.hemi.skyColors;
i.hemisphereLightGroundColor.value = c.hemi.groundColors;
i.hemisphereLightDirection.value = c.hemi.positions
}
if (d instanceof THREE.MeshBasicMaterial || d instanceof THREE.MeshLambertMaterial || d instanceof THREE.MeshPhongMaterial) {
i.opacity.value = d.opacity;
L.gammaInput ? i.diffuse.value.copyGammaToLinear(d.color) : i.diffuse.value = d.color;
i.map.value = d.map;
i.lightMap.value = d.lightMap;
i.specularMap.value = d.specularMap;
d.bumpMap && (i.bumpMap.value = d.bumpMap, i.bumpScale.value = d.bumpScale);
d.normalMap && (i.normalMap.value = d.normalMap, i.normalScale.value.copy(d.normalScale));
var U;
d.map ? U = d.map : d.specularMap ? U = d.specularMap : d.normalMap ? U = d.normalMap : d.bumpMap && (U = d.bumpMap);
void 0 !== U && (c = U.offset, U = U.repeat, i.offsetRepeat.value.set(c.x, c.y, U.x, U.y));
i.envMap.value = d.envMap;
i.flipEnvMap.value = d.envMap instanceof THREE.WebGLRenderTargetCube ? 1 : -1;
i.reflectivity.value = d.reflectivity;
i.refractionRatio.value =
d.refractionRatio;
i.combine.value = d.combine;
i.useRefract.value = d.envMap && d.envMap.mapping instanceof THREE.CubeRefractionMapping
}
d instanceof THREE.LineBasicMaterial ? (i.diffuse.value = d.color, i.opacity.value = d.opacity) : d instanceof THREE.LineDashedMaterial ? (i.diffuse.value = d.color, i.opacity.value = d.opacity, i.dashSize.value = d.dashSize, i.totalSize.value = d.dashSize + d.gapSize, i.scale.value = d.scale) : d instanceof THREE.ParticleBasicMaterial ? (i.psColor.value = d.color, i.opacity.value = d.opacity, i.size.value =
d.size, i.scale.value = w.height / 2, i.map.value = d.map) : d instanceof THREE.MeshPhongMaterial ? (i.shininess.value = d.shininess, L.gammaInput ? (i.ambient.value.copyGammaToLinear(d.ambient), i.emissive.value.copyGammaToLinear(d.emissive), i.specular.value.copyGammaToLinear(d.specular)) : (i.ambient.value = d.ambient, i.emissive.value = d.emissive, i.specular.value = d.specular), d.wrapAround && i.wrapRGB.value.copy(d.wrapRGB)) : d instanceof THREE.MeshLambertMaterial ? (L.gammaInput ? (i.ambient.value.copyGammaToLinear(d.ambient),
i.emissive.value.copyGammaToLinear(d.emissive)) : (i.ambient.value = d.ambient, i.emissive.value = d.emissive), d.wrapAround && i.wrapRGB.value.copy(d.wrapRGB)) : d instanceof THREE.MeshDepthMaterial ? (i.mNear.value = a.near, i.mFar.value = a.far, i.opacity.value = d.opacity) : d instanceof THREE.MeshNormalMaterial && (i.opacity.value = d.opacity);
if (e.receiveShadow && !d._shadowPass && i.shadowMatrix) {
c = U = 0;
for (f = b.length; c < f; c++)
if (k = b[c], k.castShadow && (k instanceof THREE.SpotLight || k instanceof THREE.DirectionalLight && !k.shadowCascade)) i.shadowMap.value[U] =
k.shadowMap, i.shadowMapSize.value[U] = k.shadowMapSize, i.shadowMatrix.value[U] = k.shadowMatrix, i.shadowDarkness.value[U] = k.shadowDarkness, i.shadowBias.value[U] = k.shadowBias, U++
}
b = d.uniformsList;
i = 0;
for (U = b.length; i < U; i++)
if (f = g.uniforms[b[i][1]])
if (c = b[i][0], l = c.type, k = c.value, "i" === l) j.uniform1i(f, k);
else if ("f" === l) j.uniform1f(f, k);
else if ("v2" === l) j.uniform2f(f, k.x, k.y);
else if ("v3" === l) j.uniform3f(f, k.x, k.y, k.z);
else if ("v4" === l) j.uniform4f(f, k.x, k.y, k.z, k.w);
else if ("c" === l) j.uniform3f(f, k.r, k.g,
k.b);
else if ("iv1" === l) j.uniform1iv(f, k);
else if ("iv" === l) j.uniform3iv(f, k);
else if ("fv1" === l) j.uniform1fv(f, k);
else if ("fv" === l) j.uniform3fv(f, k);
else if ("v2v" === l) {
void 0 === c._array && (c._array = new Float32Array(2 * k.length));
l = 0;
for (p = k.length; l < p; l++) s = 2 * l, c._array[s] = k[l].x, c._array[s + 1] = k[l].y;
j.uniform2fv(f, c._array)
} else if ("v3v" === l) {
void 0 === c._array && (c._array = new Float32Array(3 * k.length));
l = 0;
for (p = k.length; l < p; l++) s = 3 * l, c._array[s] = k[l].x, c._array[s + 1] = k[l].y, c._array[s + 2] = k[l].z;
j.uniform3fv(f,
c._array)
} else if ("v4v" === l) {
void 0 === c._array && (c._array = new Float32Array(4 * k.length));
l = 0;
for (p = k.length; l < p; l++) s = 4 * l, c._array[s] = k[l].x, c._array[s + 1] = k[l].y, c._array[s + 2] = k[l].z, c._array[s + 3] = k[l].w;
j.uniform4fv(f, c._array)
} else if ("m4" === l) void 0 === c._array && (c._array = new Float32Array(16)), k.flattenToArray(c._array), j.uniformMatrix4fv(f, !1, c._array);
else if ("m4v" === l) {
void 0 === c._array && (c._array = new Float32Array(16 * k.length));
l = 0;
for (p = k.length; l < p; l++) k[l].flattenToArrayOffset(c._array, 16 *
l);
j.uniformMatrix4fv(f, !1, c._array)
} else if ("t" === l) {
if (s = k, k = B(), j.uniform1i(f, k), s)
if (s.image instanceof Array && 6 === s.image.length) {
if (c = s, f = k, 6 === c.image.length)
if (c.needsUpdate) {
c.image.__webglTextureCube || (c.addEventListener("dispose", hc), c.image.__webglTextureCube = j.createTexture(), L.info.memory.textures++);
j.activeTexture(j.TEXTURE0 + f);
j.bindTexture(j.TEXTURE_CUBE_MAP, c.image.__webglTextureCube);
j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL, c.flipY);
f = c instanceof THREE.CompressedTexture;
k = [];
for (l =
0; 6 > l; l++) L.autoScaleCubemaps && !f ? (p = k, s = l, t = c.image[l], z = Xb, t.width <= z && t.height <= z || (y = Math.max(t.width, t.height), v = Math.floor(t.width * z / y), z = Math.floor(t.height * z / y), y = document.createElement("canvas"), y.width = v, y.height = z, y.getContext("2d").drawImage(t, 0, 0, t.width, t.height, 0, 0, v, z), t = y), p[s] = t) : k[l] = c.image[l];
l = k[0];
p = 0 === (l.width & l.width - 1) && 0 === (l.height & l.height - 1);
s = J(c.format);
t = J(c.type);
K(j.TEXTURE_CUBE_MAP, c, p);
for (l = 0; 6 > l; l++)
if (f) {
z = k[l].mipmaps;
y = 0;
for (A = z.length; y < A; y++) v = z[y], j.compressedTexImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X +
l, y, s, v.width, v.height, 0, v.data)
} else j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X + l, 0, s, s, t, k[l]);
c.generateMipmaps && p && j.generateMipmap(j.TEXTURE_CUBE_MAP);
c.needsUpdate = !1;
if (c.onUpdate) c.onUpdate()
} else j.activeTexture(j.TEXTURE0 + f), j.bindTexture(j.TEXTURE_CUBE_MAP, c.image.__webglTextureCube)
} else s instanceof THREE.WebGLRenderTargetCube ? (c = s, j.activeTexture(j.TEXTURE0 + k), j.bindTexture(j.TEXTURE_CUBE_MAP, c.__webglTexture)) : L.setTexture(s, k)
} else if ("tv" === l) {
void 0 === c._array && (c._array = []);
l = 0;
for (p = c.value.length; l < p; l++) c._array[l] = B();
j.uniform1iv(f, c._array);
l = 0;
for (p = c.value.length; l < p; l++) s = c.value[l], k = c._array[l], s && L.setTexture(s, k)
} else console.warn("THREE.WebGLRenderer: Unknown uniform type: " + l);
if ((d instanceof THREE.ShaderMaterial || d instanceof THREE.MeshPhongMaterial || d.envMap) && null !== h.cameraPosition) ra.getPositionFromMatrix(a.matrixWorld), j.uniform3f(h.cameraPosition, ra.x, ra.y, ra.z);
(d instanceof THREE.MeshPhongMaterial || d instanceof THREE.MeshLambertMaterial || d instanceof THREE.ShaderMaterial || d.skinning) && null !== h.viewMatrix && j.uniformMatrix4fv(h.viewMatrix, !1, a.matrixWorldInverse.elements)
}
j.uniformMatrix4fv(h.modelViewMatrix, !1, e._modelViewMatrix.elements);
h.normalMatrix && j.uniformMatrix3fv(h.normalMatrix, !1, e._normalMatrix.elements);
null !== h.modelMatrix && j.uniformMatrix4fv(h.modelMatrix, !1, e.matrixWorld.elements);
return g
}
function B() {
var a = Oa;
a >= ua && console.warn("WebGLRenderer: trying to use " + a + " texture units while this GPU supports only " + ua);
Oa += 1;
return a
}
function G(a, b, c, d) {
a[b] = c.r * c.r * d;
a[b + 1] = c.g * c.g * d;
a[b + 2] = c.b * c.b * d
}
function I(a, b, c, d) {
a[b] = c.r * d;
a[b + 1] = c.g * d;
a[b + 2] = c.b * d
}
function F(a) {
a !== Ba && (j.lineWidth(a), Ba = a)
}
function A(a, b, c) {
Ta !== a && (a ? j.enable(j.POLYGON_OFFSET_FILL) : j.disable(j.POLYGON_OFFSET_FILL), Ta = a);
if (a && (la !== b || ka !== c)) j.polygonOffset(b, c), la = b, ka = c
}
function N(a) {
for (var a = a.split("\n"), b = 0, c = a.length; b < c; b++) a[b] = b + 1 + ": " + a[b];
return a.join("\n")
}
function C(a, b) {
var c;
"fragment" === a ? c = j.createShader(j.FRAGMENT_SHADER) : "vertex" ===
a && (c = j.createShader(j.VERTEX_SHADER));
j.shaderSource(c, b);
j.compileShader(c);
return !j.getShaderParameter(c, j.COMPILE_STATUS) ? (console.error(j.getShaderInfoLog(c)), console.error(N(b)), null) : c
}
function K(a, b, c) {
c ? (j.texParameteri(a, j.TEXTURE_WRAP_S, J(b.wrapS)), j.texParameteri(a, j.TEXTURE_WRAP_T, J(b.wrapT)), j.texParameteri(a, j.TEXTURE_MAG_FILTER, J(b.magFilter)), j.texParameteri(a, j.TEXTURE_MIN_FILTER, J(b.minFilter))) : (j.texParameteri(a, j.TEXTURE_WRAP_S, j.CLAMP_TO_EDGE), j.texParameteri(a, j.TEXTURE_WRAP_T,
j.CLAMP_TO_EDGE), j.texParameteri(a, j.TEXTURE_MAG_FILTER, y(b.magFilter)), j.texParameteri(a, j.TEXTURE_MIN_FILTER, y(b.minFilter)));
if (xb && b.type !== THREE.FloatType && (1 < b.anisotropy || b.__oldAnisotropy)) j.texParameterf(a, xb.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(b.anisotropy, Kb)), b.__oldAnisotropy = b.anisotropy
}
function M(a, b) {
j.bindRenderbuffer(j.RENDERBUFFER, a);
b.depthBuffer && !b.stencilBuffer ? (j.renderbufferStorage(j.RENDERBUFFER, j.DEPTH_COMPONENT16, b.width, b.height), j.framebufferRenderbuffer(j.FRAMEBUFFER,
j.DEPTH_ATTACHMENT, j.RENDERBUFFER, a)) : b.depthBuffer && b.stencilBuffer ? (j.renderbufferStorage(j.RENDERBUFFER, j.DEPTH_STENCIL, b.width, b.height), j.framebufferRenderbuffer(j.FRAMEBUFFER, j.DEPTH_STENCIL_ATTACHMENT, j.RENDERBUFFER, a)) : j.renderbufferStorage(j.RENDERBUFFER, j.RGBA4, b.width, b.height)
}
function y(a) {
return a === THREE.NearestFilter || a === THREE.NearestMipMapNearestFilter || a === THREE.NearestMipMapLinearFilter ? j.NEAREST : j.LINEAR
}
function J(a) {
if (a === THREE.RepeatWrapping) return j.REPEAT;
if (a === THREE.ClampToEdgeWrapping) return j.CLAMP_TO_EDGE;
if (a === THREE.MirroredRepeatWrapping) return j.MIRRORED_REPEAT;
if (a === THREE.NearestFilter) return j.NEAREST;
if (a === THREE.NearestMipMapNearestFilter) return j.NEAREST_MIPMAP_NEAREST;
if (a === THREE.NearestMipMapLinearFilter) return j.NEAREST_MIPMAP_LINEAR;
if (a === THREE.LinearFilter) return j.LINEAR;
if (a === THREE.LinearMipMapNearestFilter) return j.LINEAR_MIPMAP_NEAREST;
if (a === THREE.LinearMipMapLinearFilter) return j.LINEAR_MIPMAP_LINEAR;
if (a === THREE.UnsignedByteType) return j.UNSIGNED_BYTE;
if (a === THREE.UnsignedShort4444Type) return j.UNSIGNED_SHORT_4_4_4_4;
if (a === THREE.UnsignedShort5551Type) return j.UNSIGNED_SHORT_5_5_5_1;
if (a === THREE.UnsignedShort565Type) return j.UNSIGNED_SHORT_5_6_5;
if (a === THREE.ByteType) return j.BYTE;
if (a === THREE.ShortType) return j.SHORT;
if (a === THREE.UnsignedShortType) return j.UNSIGNED_SHORT;
if (a === THREE.IntType) return j.INT;
if (a === THREE.UnsignedIntType) return j.UNSIGNED_INT;
if (a === THREE.FloatType) return j.FLOAT;
if (a === THREE.AlphaFormat) return j.ALPHA;
if (a === THREE.RGBFormat) return j.RGB;
if (a === THREE.RGBAFormat) return j.RGBA;
if (a ===
THREE.LuminanceFormat) return j.LUMINANCE;
if (a === THREE.LuminanceAlphaFormat) return j.LUMINANCE_ALPHA;
if (a === THREE.AddEquation) return j.FUNC_ADD;
if (a === THREE.SubtractEquation) return j.FUNC_SUBTRACT;
if (a === THREE.ReverseSubtractEquation) return j.FUNC_REVERSE_SUBTRACT;
if (a === THREE.ZeroFactor) return j.ZERO;
if (a === THREE.OneFactor) return j.ONE;
if (a === THREE.SrcColorFactor) return j.SRC_COLOR;
if (a === THREE.OneMinusSrcColorFactor) return j.ONE_MINUS_SRC_COLOR;
if (a === THREE.SrcAlphaFactor) return j.SRC_ALPHA;
if (a ===
THREE.OneMinusSrcAlphaFactor) return j.ONE_MINUS_SRC_ALPHA;
if (a === THREE.DstAlphaFactor) return j.DST_ALPHA;
if (a === THREE.OneMinusDstAlphaFactor) return j.ONE_MINUS_DST_ALPHA;
if (a === THREE.DstColorFactor) return j.DST_COLOR;
if (a === THREE.OneMinusDstColorFactor) return j.ONE_MINUS_DST_COLOR;
if (a === THREE.SrcAlphaSaturateFactor) return j.SRC_ALPHA_SATURATE;
if (void 0 !== eb) {
if (a === THREE.RGB_S3TC_DXT1_Format) return eb.COMPRESSED_RGB_S3TC_DXT1_EXT;
if (a === THREE.RGBA_S3TC_DXT1_Format) return eb.COMPRESSED_RGBA_S3TC_DXT1_EXT;
if (a === THREE.RGBA_S3TC_DXT3_Format) return eb.COMPRESSED_RGBA_S3TC_DXT3_EXT;
if (a === THREE.RGBA_S3TC_DXT5_Format) return eb.COMPRESSED_RGBA_S3TC_DXT5_EXT
}
return 0
}
console.log("THREE.WebGLRenderer", THREE.REVISION);
var a = a || {},
w = void 0 !== a.canvas ? a.canvas : document.createElement("canvas"),
ca = void 0 !== a.precision ? a.precision : "highp",
D = void 0 !== a.alpha ? a.alpha : !0,
qa = void 0 !== a.premultipliedAlpha ? a.premultipliedAlpha : !0,
Pa = void 0 !== a.antialias ? a.antialias : !1,
Sa = void 0 !== a.stencil ? a.stencil : !0,
P = void 0 !== a.preserveDrawingBuffer ?
a.preserveDrawingBuffer : !1,
ia = new THREE.Color(0),
Wa = 0;
void 0 !== a.clearColor && (console.warn("DEPRECATED: clearColor in WebGLRenderer constructor parameters is being removed. Use .setClearColor() instead."), ia.setHex(a.clearColor));
void 0 !== a.clearAlpha && (console.warn("DEPRECATED: clearAlpha in WebGLRenderer constructor parameters is being removed. Use .setClearColor() instead."), Wa = a.clearAlpha);
this.domElement = w;
this.context = null;
this.devicePixelRatio = void 0 !== a.devicePixelRatio ? a.devicePixelRatio :
void 0 !== window.devicePixelRatio ? window.devicePixelRatio : 1;
this.autoUpdateObjects = this.sortObjects = this.autoClearStencil = this.autoClearDepth = this.autoClearColor = this.autoClear = !0;
this.shadowMapEnabled = this.physicallyBasedShading = this.gammaOutput = this.gammaInput = !1;
this.shadowMapAutoUpdate = !0;
this.shadowMapType = THREE.PCFShadowMap;
this.shadowMapCullFace = THREE.CullFaceFront;
this.shadowMapCascade = this.shadowMapDebug = !1;
this.maxMorphTargets = 8;
this.maxMorphNormals = 4;
this.autoScaleCubemaps = !0;
this.renderPluginsPre = [];
this.renderPluginsPost = [];
this.info = {
memory: {
programs: 0,
geometries: 0,
textures: 0
},
render: {
calls: 0,
vertices: 0,
faces: 0,
points: 0
}
};
var L = this,
sa = [],
W = 0,
ja = null,
pa = null,
Ea = -1,
Za = null,
ob = null,
Fa = 0,
Oa = 0,
X = -1,
fa = -1,
T = -1,
U = -1,
oa = -1,
ha = -1,
da = -1,
xa = -1,
Ta = null,
la = null,
ka = null,
Ba = null,
ea = 0,
na = 0,
Ia = 0,
Qa = 0,
hb = 0,
Lb = 0,
Ab = {},
Ub = new THREE.Frustum,
vb = new THREE.Matrix4,
yb = new THREE.Matrix4,
ra = new THREE.Vector3,
ta = new THREE.Vector3,
wb = !0,
Mb = {
ambient: [0, 0, 0],
directional: {
length: 0,
colors: [],
positions: []
},
point: {
length: 0,
colors: [],
positions: [],
distances: []
},
spot: {
length: 0,
colors: [],
positions: [],
distances: [],
directions: [],
anglesCos: [],
exponents: []
},
hemi: {
length: 0,
skyColors: [],
groundColors: [],
positions: []
}
},
j, Tb, Nb, xb, eb;
try {
if (!(j = w.getContext("experimental-webgl", {
alpha: D,
premultipliedAlpha: qa,
antialias: Pa,
stencil: Sa,
preserveDrawingBuffer: P
}))) throw "Error creating WebGL context.";
} catch (Ya) {
console.error(Ya)
}
Tb = j.getExtension("OES_texture_float");
j.getExtension("OES_texture_float_linear");
Nb = j.getExtension("OES_standard_derivatives");
xb = j.getExtension("EXT_texture_filter_anisotropic") || j.getExtension("MOZ_EXT_texture_filter_anisotropic") || j.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
eb = j.getExtension("WEBGL_compressed_texture_s3tc") || j.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || j.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
Tb || console.log("THREE.WebGLRenderer: Float textures not supported.");
Nb || console.log("THREE.WebGLRenderer: Standard derivatives not supported.");
xb || console.log("THREE.WebGLRenderer: Anisotropic texture filtering not supported.");
eb || console.log("THREE.WebGLRenderer: S3TC compressed textures not supported.");
void 0 === j.getShaderPrecisionFormat && (j.getShaderPrecisionFormat = function() {
return {
rangeMin: 1,
rangeMax: 1,
precision: 1
}
});
j.clearColor(0, 0, 0, 1);
j.clearDepth(1);
j.clearStencil(0);
j.enable(j.DEPTH_TEST);
j.depthFunc(j.LEQUAL);
j.frontFace(j.CCW);
j.cullFace(j.BACK);
j.enable(j.CULL_FACE);
j.enable(j.BLEND);
j.blendEquation(j.FUNC_ADD);
j.blendFunc(j.SRC_ALPHA, j.ONE_MINUS_SRC_ALPHA);
j.clearColor(ia.r, ia.g, ia.b, Wa);
this.context = j;
var ua = j.getParameter(j.MAX_TEXTURE_IMAGE_UNITS),
kb = j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
j.getParameter(j.MAX_TEXTURE_SIZE);
var Xb = j.getParameter(j.MAX_CUBE_MAP_TEXTURE_SIZE),
Kb = xb ? j.getParameter(xb.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
Ua = 0 < kb,
Jb = Ua && Tb;
eb && j.getParameter(j.COMPRESSED_TEXTURE_FORMATS);
var Vb = j.getShaderPrecisionFormat(j.VERTEX_SHADER, j.HIGH_FLOAT),
Hb = j.getShaderPrecisionFormat(j.VERTEX_SHADER, j.MEDIUM_FLOAT);
j.getShaderPrecisionFormat(j.VERTEX_SHADER, j.LOW_FLOAT);
var Ja =
j.getShaderPrecisionFormat(j.FRAGMENT_SHADER, j.HIGH_FLOAT),
Wb = j.getShaderPrecisionFormat(j.FRAGMENT_SHADER, j.MEDIUM_FLOAT);
j.getShaderPrecisionFormat(j.FRAGMENT_SHADER, j.LOW_FLOAT);
j.getShaderPrecisionFormat(j.VERTEX_SHADER, j.HIGH_INT);
j.getShaderPrecisionFormat(j.VERTEX_SHADER, j.MEDIUM_INT);
j.getShaderPrecisionFormat(j.VERTEX_SHADER, j.LOW_INT);
j.getShaderPrecisionFormat(j.FRAGMENT_SHADER, j.HIGH_INT);
j.getShaderPrecisionFormat(j.FRAGMENT_SHADER, j.MEDIUM_INT);
j.getShaderPrecisionFormat(j.FRAGMENT_SHADER,
j.LOW_INT);
var Ib = 0 < Vb.precision && 0 < Ja.precision,
Eb = 0 < Hb.precision && 0 < Wb.precision;
"highp" === ca && !Ib && (Eb ? (ca = "mediump", console.warn("WebGLRenderer: highp not supported, using mediump")) : (ca = "lowp", console.warn("WebGLRenderer: highp and mediump not supported, using lowp")));
"mediump" === ca && !Eb && (ca = "lowp", console.warn("WebGLRenderer: mediump not supported, using lowp"));
this.getContext = function() {
return j
};
this.supportsVertexTextures = function() {
return Ua
};
this.supportsFloatTextures = function() {
return Tb
};
this.supportsStandardDerivatives = function() {
return Nb
};
this.supportsCompressedTextureS3TC = function() {
return eb
};
this.getMaxAnisotropy = function() {
return Kb
};
this.getPrecision = function() {
return ca
};
this.setSize = function(a, b, c) {
w.width = a * this.devicePixelRatio;
w.height = b * this.devicePixelRatio;
1 !== this.devicePixelRatio && !1 !== c && (w.style.width = a + "px", w.style.height = b + "px");
this.setViewport(0, 0, w.width, w.height)
};
this.setViewport = function(a, b, c, d) {
ea = void 0 !== a ? a : 0;
na = void 0 !== b ? b : 0;
Ia = void 0 !== c ? c : w.width;
Qa = void 0 !== d ? d : w.height;
j.viewport(ea, na, Ia, Qa)
};
this.setScissor = function(a, b, c, d) {
j.scissor(a, b, c, d)
};
this.enableScissorTest = function(a) {
a ? j.enable(j.SCISSOR_TEST) : j.disable(j.SCISSOR_TEST)
};
this.setClearColor = function(a, b) {
ia.set(a);
Wa = void 0 !== b ? b : 1;
j.clearColor(ia.r, ia.g, ia.b, Wa)
};
this.setClearColorHex = function(a, b) {
console.warn("DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead.");
this.setClearColor(a, b)
};
this.getClearColor = function() {
return ia
};
this.getClearAlpha =
function() {
return Wa
};
this.clear = function(a, b, c) {
var d = 0;
if (void 0 === a || a) d |= j.COLOR_BUFFER_BIT;
if (void 0 === b || b) d |= j.DEPTH_BUFFER_BIT;
if (void 0 === c || c) d |= j.STENCIL_BUFFER_BIT;
j.clear(d)
};
this.clearTarget = function(a, b, c, d) {
this.setRenderTarget(a);
this.clear(b, c, d)
};
this.addPostPlugin = function(a) {
a.init(this);
this.renderPluginsPost.push(a)
};
this.addPrePlugin = function(a) {
a.init(this);
this.renderPluginsPre.push(a)
};
this.updateShadowMap = function(a, b) {
ja = null;
Ea = Za = xa = da = T = -1;
wb = !0;
fa = X = -1;
this.shadowMapPlugin.update(a,
b)
};
var lc = function(a) {
a = a.target;
a.removeEventListener("dispose", lc);
a.__webglInit = void 0;
if (a instanceof THREE.BufferGeometry) {
var b = a.attributes,
c;
for (c in b) void 0 !== b[c].buffer && j.deleteBuffer(b[c].buffer);
L.info.memory.geometries--
} else if (void 0 !== a.geometryGroups)
for (b in a.geometryGroups) {
c = a.geometryGroups[b];
if (void 0 !== c.numMorphTargets)
for (var d = 0, e = c.numMorphTargets; d < e; d++) j.deleteBuffer(c.__webglMorphTargetsBuffers[d]);
if (void 0 !== c.numMorphNormals) {
d = 0;
for (e = c.numMorphNormals; d < e; d++) j.deleteBuffer(c.__webglMorphNormalsBuffers[d])
}
tc(c)
} else tc(a)
},
hc = function(a) {
a = a.target;
a.removeEventListener("dispose", hc);
a.image && a.image.__webglTextureCube ? j.deleteTexture(a.image.__webglTextureCube) : a.__webglInit && (a.__webglInit = !1, j.deleteTexture(a.__webglTexture));
L.info.memory.textures--
},
mc = function(a) {
a = a.target;
a.removeEventListener("dispose", mc);
if (a && a.__webglTexture)
if (j.deleteTexture(a.__webglTexture), a instanceof THREE.WebGLRenderTargetCube)
for (var b = 0; 6 > b; b++) j.deleteFramebuffer(a.__webglFramebuffer[b]), j.deleteRenderbuffer(a.__webglRenderbuffer[b]);
else j.deleteFramebuffer(a.__webglFramebuffer), j.deleteRenderbuffer(a.__webglRenderbuffer);
L.info.memory.textures--
},
nc = function(a) {
a = a.target;
a.removeEventListener("dispose", nc);
uc(a)
},
tc = function(a) {
void 0 !== a.__webglVertexBuffer && j.deleteBuffer(a.__webglVertexBuffer);
void 0 !== a.__webglNormalBuffer && j.deleteBuffer(a.__webglNormalBuffer);
void 0 !== a.__webglTangentBuffer && j.deleteBuffer(a.__webglTangentBuffer);
void 0 !== a.__webglColorBuffer && j.deleteBuffer(a.__webglColorBuffer);
void 0 !== a.__webglUVBuffer &&
j.deleteBuffer(a.__webglUVBuffer);
void 0 !== a.__webglUV2Buffer && j.deleteBuffer(a.__webglUV2Buffer);
void 0 !== a.__webglSkinIndicesBuffer && j.deleteBuffer(a.__webglSkinIndicesBuffer);
void 0 !== a.__webglSkinWeightsBuffer && j.deleteBuffer(a.__webglSkinWeightsBuffer);
void 0 !== a.__webglFaceBuffer && j.deleteBuffer(a.__webglFaceBuffer);
void 0 !== a.__webglLineBuffer && j.deleteBuffer(a.__webglLineBuffer);
void 0 !== a.__webglLineDistanceBuffer && j.deleteBuffer(a.__webglLineDistanceBuffer);
if (void 0 !== a.__webglCustomAttributesList)
for (var b in a.__webglCustomAttributesList) j.deleteBuffer(a.__webglCustomAttributesList[b].buffer);
L.info.memory.geometries--
},
uc = function(a) {
var b = a.program;
if (void 0 !== b) {
a.program = void 0;
var c, d, e = !1,
a = 0;
for (c = sa.length; a < c; a++)
if (d = sa[a], d.program === b) {
d.usedTimes--;
0 === d.usedTimes && (e = !0);
break
}
if (!0 === e) {
e = [];
a = 0;
for (c = sa.length; a < c; a++) d = sa[a], d.program !== b && e.push(d);
sa = e;
j.deleteProgram(b);
L.info.memory.programs--
}
}
};
this.renderBufferImmediate = function(a, b, c) {
a.hasPositions && !a.__webglVertexBuffer && (a.__webglVertexBuffer = j.createBuffer());
a.hasNormals && !a.__webglNormalBuffer && (a.__webglNormalBuffer =
j.createBuffer());
a.hasUvs && !a.__webglUvBuffer && (a.__webglUvBuffer = j.createBuffer());
a.hasColors && !a.__webglColorBuffer && (a.__webglColorBuffer = j.createBuffer());
a.hasPositions && (j.bindBuffer(j.ARRAY_BUFFER, a.__webglVertexBuffer), j.bufferData(j.ARRAY_BUFFER, a.positionArray, j.DYNAMIC_DRAW), j.enableVertexAttribArray(b.attributes.position), j.vertexAttribPointer(b.attributes.position, 3, j.FLOAT, !1, 0, 0));
if (a.hasNormals) {
j.bindBuffer(j.ARRAY_BUFFER, a.__webglNormalBuffer);
if (c.shading === THREE.FlatShading) {
var d,
e, f, g, h, i, k, l, m, p, n, q = 3 * a.count;
for (n = 0; n < q; n += 9) p = a.normalArray, d = p[n], e = p[n + 1], f = p[n + 2], g = p[n + 3], i = p[n + 4], l = p[n + 5], h = p[n + 6], k = p[n + 7], m = p[n + 8], d = (d + g + h) / 3, e = (e + i + k) / 3, f = (f + l + m) / 3, p[n] = d, p[n + 1] = e, p[n + 2] = f, p[n + 3] = d, p[n + 4] = e, p[n + 5] = f, p[n + 6] = d, p[n + 7] = e, p[n + 8] = f
}
j.bufferData(j.ARRAY_BUFFER, a.normalArray, j.DYNAMIC_DRAW);
j.enableVertexAttribArray(b.attributes.normal);
j.vertexAttribPointer(b.attributes.normal, 3, j.FLOAT, !1, 0, 0)
}
a.hasUvs && c.map && (j.bindBuffer(j.ARRAY_BUFFER, a.__webglUvBuffer), j.bufferData(j.ARRAY_BUFFER,
a.uvArray, j.DYNAMIC_DRAW), j.enableVertexAttribArray(b.attributes.uv), j.vertexAttribPointer(b.attributes.uv, 2, j.FLOAT, !1, 0, 0));
a.hasColors && c.vertexColors !== THREE.NoColors && (j.bindBuffer(j.ARRAY_BUFFER, a.__webglColorBuffer), j.bufferData(j.ARRAY_BUFFER, a.colorArray, j.DYNAMIC_DRAW), j.enableVertexAttribArray(b.attributes.color), j.vertexAttribPointer(b.attributes.color, 3, j.FLOAT, !1, 0, 0));
j.drawArrays(j.TRIANGLES, 0, a.count);
a.count = 0
};
this.renderBufferDirect = function(a, b, c, d, e, f) {
if (!1 !== d.visible) {
var i,
k, l, m;
i = H(a, b, c, d, f);
b = i.attributes;
a = e.attributes;
c = !1;
i = 16777215 * e.id + 2 * i.id + (d.wireframe ? 1 : 0);
i !== Za && (Za = i, c = !0);
c && h();
if (f instanceof THREE.Mesh)
if (d = a.index) {
e = e.offsets;
1 < e.length && (c = !0);
for (var f = 0, p = e.length; f < p; f++) {
var n = e[f].index;
if (c) {
for (k in a) "index" !== k && (l = b[k], i = a[k], m = i.itemSize, 0 <= l && (j.bindBuffer(j.ARRAY_BUFFER, i.buffer), g(l), j.vertexAttribPointer(l, m, j.FLOAT, !1, 0, 4 * n * m)));
j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, d.buffer)
}
j.drawElements(j.TRIANGLES, e[f].count, j.UNSIGNED_SHORT,
2 * e[f].start);
L.info.render.calls++;
L.info.render.vertices += e[f].count;
L.info.render.faces += e[f].count / 3
}
} else {
if (c)
for (k in a) "index" !== k && (l = b[k], i = a[k], m = i.itemSize, 0 <= l && (j.bindBuffer(j.ARRAY_BUFFER, i.buffer), g(l), j.vertexAttribPointer(l, m, j.FLOAT, !1, 0, 0)));
a = e.attributes.position;
j.drawArrays(j.TRIANGLES, 0, a.numItems / 3);
L.info.render.calls++;
L.info.render.vertices += a.numItems / 3;
L.info.render.faces += a.numItems / 3 / 3
} else if (f instanceof THREE.ParticleSystem) {
if (c) {
for (k in a) l = b[k], i = a[k], m = i.itemSize,
0 <= l && (j.bindBuffer(j.ARRAY_BUFFER, i.buffer), g(l), j.vertexAttribPointer(l, m, j.FLOAT, !1, 0, 0));
a = a.position;
j.drawArrays(j.POINTS, 0, a.numItems / 3);
L.info.render.calls++;
L.info.render.points += a.numItems / 3
}
} else if (f instanceof THREE.Line && c) {
for (k in a) l = b[k], i = a[k], m = i.itemSize, 0 <= l && (j.bindBuffer(j.ARRAY_BUFFER, i.buffer), g(l), j.vertexAttribPointer(l, m, j.FLOAT, !1, 0, 0));
k = f.type === THREE.LineStrip ? j.LINE_STRIP : j.LINES;
F(d.linewidth);
a = a.position;
j.drawArrays(k, 0, a.numItems / 3);
L.info.render.calls++;
L.info.render.points +=
a.numItems
}
}
};
this.renderBuffer = function(a, b, c, d, e, f) {
if (!1 !== d.visible) {
var i, l, c = H(a, b, c, d, f),
a = c.attributes,
b = !1,
c = 16777215 * e.id + 2 * c.id + (d.wireframe ? 1 : 0);
c !== Za && (Za = c, b = !0);
b && h();
if (!d.morphTargets && 0 <= a.position) b && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglVertexBuffer), g(a.position), j.vertexAttribPointer(a.position, 3, j.FLOAT, !1, 0, 0));
else if (f.morphTargetBase) {
c = d.program.attributes; - 1 !== f.morphTargetBase && 0 <= c.position ? (j.bindBuffer(j.ARRAY_BUFFER, e.__webglMorphTargetsBuffers[f.morphTargetBase]),
g(c.position), j.vertexAttribPointer(c.position, 3, j.FLOAT, !1, 0, 0)) : 0 <= c.position && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglVertexBuffer), g(c.position), j.vertexAttribPointer(c.position, 3, j.FLOAT, !1, 0, 0));
if (f.morphTargetForcedOrder.length) {
var m = 0;
l = f.morphTargetForcedOrder;
for (i = f.morphTargetInfluences; m < d.numSupportedMorphTargets && m < l.length;) 0 <= c["morphTarget" + m] && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglMorphTargetsBuffers[l[m]]), g(c["morphTarget" + m]), j.vertexAttribPointer(c["morphTarget" + m], 3, j.FLOAT, !1, 0, 0)), 0 <= c["morphNormal" + m] && d.morphNormals && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglMorphNormalsBuffers[l[m]]), g(c["morphNormal" + m]), j.vertexAttribPointer(c["morphNormal" + m], 3, j.FLOAT, !1, 0, 0)), f.__webglMorphTargetInfluences[m] = i[l[m]], m++
} else {
l = [];
i = f.morphTargetInfluences;
var p, n = i.length;
for (p = 0; p < n; p++) m = i[p], 0 < m && l.push([m, p]);
l.length > d.numSupportedMorphTargets ? (l.sort(k), l.length = d.numSupportedMorphTargets) : l.length > d.numSupportedMorphNormals ? l.sort(k) : 0 === l.length && l.push([0, 0]);
for (m = 0; m <
d.numSupportedMorphTargets;) l[m] ? (p = l[m][1], 0 <= c["morphTarget" + m] && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglMorphTargetsBuffers[p]), g(c["morphTarget" + m]), j.vertexAttribPointer(c["morphTarget" + m], 3, j.FLOAT, !1, 0, 0)), 0 <= c["morphNormal" + m] && d.morphNormals && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglMorphNormalsBuffers[p]), g(c["morphNormal" + m]), j.vertexAttribPointer(c["morphNormal" + m], 3, j.FLOAT, !1, 0, 0)), f.__webglMorphTargetInfluences[m] = i[p]) : f.__webglMorphTargetInfluences[m] = 0, m++
}
null !== d.program.uniforms.morphTargetInfluences &&
j.uniform1fv(d.program.uniforms.morphTargetInfluences, f.__webglMorphTargetInfluences)
}
if (b) {
if (e.__webglCustomAttributesList) {
i = 0;
for (l = e.__webglCustomAttributesList.length; i < l; i++) c = e.__webglCustomAttributesList[i], 0 <= a[c.buffer.belongsToAttribute] && (j.bindBuffer(j.ARRAY_BUFFER, c.buffer), g(a[c.buffer.belongsToAttribute]), j.vertexAttribPointer(a[c.buffer.belongsToAttribute], c.size, j.FLOAT, !1, 0, 0))
}
0 <= a.color && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglColorBuffer), g(a.color), j.vertexAttribPointer(a.color,
3, j.FLOAT, !1, 0, 0));
0 <= a.normal && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglNormalBuffer), g(a.normal), j.vertexAttribPointer(a.normal, 3, j.FLOAT, !1, 0, 0));
0 <= a.tangent && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglTangentBuffer), g(a.tangent), j.vertexAttribPointer(a.tangent, 4, j.FLOAT, !1, 0, 0));
0 <= a.uv && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglUVBuffer), g(a.uv), j.vertexAttribPointer(a.uv, 2, j.FLOAT, !1, 0, 0));
0 <= a.uv2 && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglUV2Buffer), g(a.uv2), j.vertexAttribPointer(a.uv2, 2, j.FLOAT, !1, 0, 0));
d.skinning && (0 <= a.skinIndex && 0 <= a.skinWeight) && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglSkinIndicesBuffer), g(a.skinIndex), j.vertexAttribPointer(a.skinIndex, 4, j.FLOAT, !1, 0, 0), j.bindBuffer(j.ARRAY_BUFFER, e.__webglSkinWeightsBuffer), g(a.skinWeight), j.vertexAttribPointer(a.skinWeight, 4, j.FLOAT, !1, 0, 0));
0 <= a.lineDistance && (j.bindBuffer(j.ARRAY_BUFFER, e.__webglLineDistanceBuffer), g(a.lineDistance), j.vertexAttribPointer(a.lineDistance, 1, j.FLOAT, !1, 0, 0))
}
f instanceof THREE.Mesh ? (d.wireframe ? (F(d.wireframeLinewidth),
b && j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, e.__webglLineBuffer), j.drawElements(j.LINES, e.__webglLineCount, j.UNSIGNED_SHORT, 0)) : (b && j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, e.__webglFaceBuffer), j.drawElements(j.TRIANGLES, e.__webglFaceCount, j.UNSIGNED_SHORT, 0)), L.info.render.calls++, L.info.render.vertices += e.__webglFaceCount, L.info.render.faces += e.__webglFaceCount / 3) : f instanceof THREE.Line ? (f = f.type === THREE.LineStrip ? j.LINE_STRIP : j.LINES, F(d.linewidth), j.drawArrays(f, 0, e.__webglLineCount), L.info.render.calls++) :
f instanceof THREE.ParticleSystem ? (j.drawArrays(j.POINTS, 0, e.__webglParticleCount), L.info.render.calls++, L.info.render.points += e.__webglParticleCount) : f instanceof THREE.Ribbon && (j.drawArrays(j.TRIANGLE_STRIP, 0, e.__webglVertexCount), L.info.render.calls++)
}
};
this.render = function(a, b, c, d) {
if (!1 === b instanceof THREE.Camera) console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
else {
var e, f, g, h, k = a.__lights,
n = a.fog;
Ea = -1;
wb = !0;
!0 === a.autoUpdate && a.updateMatrixWorld();
void 0 === b.parent && b.updateMatrixWorld();
b.matrixWorldInverse.getInverse(b.matrixWorld);
vb.multiplyMatrices(b.projectionMatrix, b.matrixWorldInverse);
Ub.setFromMatrix(vb);
this.autoUpdateObjects && this.initWebGLObjects(a);
l(this.renderPluginsPre, a, b);
L.info.render.calls = 0;
L.info.render.vertices = 0;
L.info.render.faces = 0;
L.info.render.points = 0;
this.setRenderTarget(c);
(this.autoClear || d) && this.clear(this.autoClearColor, this.autoClearDepth, this.autoClearStencil);
h = a.__webglObjects;
d = 0;
for (e = h.length; d < e; d++)
if (f =
h[d], g = f.object, f.id = d, f.render = !1, g.visible && (!(g instanceof THREE.Mesh || g instanceof THREE.ParticleSystem) || !g.frustumCulled || Ub.intersectsObject(g))) {
var q = g;
q._modelViewMatrix.multiplyMatrices(b.matrixWorldInverse, q.matrixWorld);
q._normalMatrix.getNormalMatrix(q._modelViewMatrix);
var q = f,
r = q.buffer,
s = void 0,
t = s = void 0,
t = q.object.material;
if (t instanceof THREE.MeshFaceMaterial) s = r.materialIndex, s = t.materials[s], s.transparent ? (q.transparent = s, q.opaque = null) : (q.opaque = s, q.transparent = null);
else if (s =
t) s.transparent ? (q.transparent = s, q.opaque = null) : (q.opaque = s, q.transparent = null);
f.render = !0;
!0 === this.sortObjects && (null !== g.renderDepth ? f.z = g.renderDepth : (ra.getPositionFromMatrix(g.matrixWorld), ra.applyProjection(vb), f.z = ra.z))
}
this.sortObjects && h.sort(i);
h = a.__webglObjectsImmediate;
d = 0;
for (e = h.length; d < e; d++) f = h[d], g = f.object, g.visible && (g._modelViewMatrix.multiplyMatrices(b.matrixWorldInverse, g.matrixWorld), g._normalMatrix.getNormalMatrix(g._modelViewMatrix), g = f.object.material, g.transparent ?
(f.transparent = g, f.opaque = null) : (f.opaque = g, f.transparent = null));
a.overrideMaterial ? (d = a.overrideMaterial, this.setBlending(d.blending, d.blendEquation, d.blendSrc, d.blendDst), this.setDepthTest(d.depthTest), this.setDepthWrite(d.depthWrite), A(d.polygonOffset, d.polygonOffsetFactor, d.polygonOffsetUnits), m(a.__webglObjects, !1, "", b, k, n, !0, d), p(a.__webglObjectsImmediate, "", b, k, n, !1, d)) : (d = null, this.setBlending(THREE.NoBlending), m(a.__webglObjects, !0, "opaque", b, k, n, !1, d), p(a.__webglObjectsImmediate, "opaque",
b, k, n, !1, d), m(a.__webglObjects, !1, "transparent", b, k, n, !0, d), p(a.__webglObjectsImmediate, "transparent", b, k, n, !0, d));
l(this.renderPluginsPost, a, b);
c && (c.generateMipmaps && c.minFilter !== THREE.NearestFilter && c.minFilter !== THREE.LinearFilter) && (c instanceof THREE.WebGLRenderTargetCube ? (j.bindTexture(j.TEXTURE_CUBE_MAP, c.__webglTexture), j.generateMipmap(j.TEXTURE_CUBE_MAP), j.bindTexture(j.TEXTURE_CUBE_MAP, null)) : (j.bindTexture(j.TEXTURE_2D, c.__webglTexture), j.generateMipmap(j.TEXTURE_2D), j.bindTexture(j.TEXTURE_2D,
null)));
this.setDepthTest(!0);
this.setDepthWrite(!0)
}
};
this.renderImmediateObject = function(a, b, c, d, e) {
var f = H(a, b, c, d, e);
Za = -1;
L.setMaterialFaces(d);
e.immediateRenderCallback ? e.immediateRenderCallback(f, j, Ub) : e.render(function(a) {
L.renderBufferImmediate(a, f, d)
})
};
this.initWebGLObjects = function(a) {
a.__webglObjects || (a.__webglObjects = [], a.__webglObjectsImmediate = [], a.__webglSprites = [], a.__webglFlares = []);
for (; a.__objectsAdded.length;) q(a.__objectsAdded[0], a), a.__objectsAdded.splice(0, 1);
for (; a.__objectsRemoved.length;) s(a.__objectsRemoved[0],
a), a.__objectsRemoved.splice(0, 1);
for (var b = 0, g = a.__webglObjects.length; b < g; b++) {
var h = a.__webglObjects[b].object;
void 0 === h.__webglInit && (void 0 !== h.__webglActive && s(h, a), q(h, a));
var i = h,
l = i.geometry,
m = void 0,
p = void 0,
t = void 0;
if (l instanceof THREE.BufferGeometry) {
var v = j.DYNAMIC_DRAW,
z = !l.dynamic,
w = l.attributes,
y = void 0,
A = void 0;
for (y in w) A = w[y], A.needsUpdate && ("index" === y ? (j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, A.buffer), j.bufferData(j.ELEMENT_ARRAY_BUFFER, A.array, v)) : (j.bindBuffer(j.ARRAY_BUFFER,
A.buffer), j.bufferData(j.ARRAY_BUFFER, A.array, v)), A.needsUpdate = !1), z && !A.dynamic && (A.array = null)
} else if (i instanceof THREE.Mesh) {
for (var C = 0, H = l.geometryGroupsList.length; C < H; C++)
if (m = l.geometryGroupsList[C], t = d(i, m), l.buffersNeedUpdate && c(m, i), p = t.attributes && n(t), l.verticesNeedUpdate || l.morphTargetsNeedUpdate || l.elementsNeedUpdate || l.uvsNeedUpdate || l.normalsNeedUpdate || l.colorsNeedUpdate || l.tangentsNeedUpdate || p) {
var B = m,
F = i,
G = j.DYNAMIC_DRAW,
I = !l.dynamic,
J = t;
if (B.__inittedArrays) {
var K = e(J),
L =
J.vertexColors ? J.vertexColors : !1,
N = f(J),
M = K === THREE.SmoothShading,
E = void 0,
D = void 0,
W = void 0,
O = void 0,
P = void 0,
T = void 0,
X = void 0,
ja = void 0,
U = void 0,
pa = void 0,
ca = void 0,
R = void 0,
S = void 0,
Q = void 0,
aa = void 0,
da = void 0,
fa = void 0,
Fa = void 0,
ia = void 0,
ea = void 0,
ha = void 0,
Ea = void 0,
Oa = void 0,
ka = void 0,
oa = void 0,
la = void 0,
ta = void 0,
na = void 0,
qa = void 0,
sa = void 0,
Ba = void 0,
ua = void 0,
Za = void 0,
xa = void 0,
Pa = void 0,
ya = void 0,
Ya = void 0,
Ia = void 0,
ob = void 0,
Wa = void 0,
bb = void 0,
eb = void 0,
$a = void 0,
ab = void 0,
Sa = void 0,
Qa = void 0,
Ra = 0,
Xa = 0,
Ta = 0,
Ua = 0,
Ja = 0,
ib = 0,
Ca = 0,
nb = 0,
Va = 0,
Z = 0,
ga = 0,
x = 0,
za = void 0,
cb = B.__vertexArray,
hb = B.__uvArray,
kb = B.__uv2Array,
Bb = B.__normalArray,
Ka = B.__tangentArray,
db = B.__colorArray,
La = B.__skinIndexArray,
Ma = B.__skinWeightArray,
wb = B.__morphTargetsArrays,
xb = B.__morphNormalsArrays,
Ab = B.__webglCustomAttributesList,
u = void 0,
Ob = B.__faceArray,
ub = B.__lineArray,
pb = F.geometry,
Jb = pb.elementsNeedUpdate,
Eb = pb.uvsNeedUpdate,
Tb = pb.normalsNeedUpdate,
Ub = pb.tangentsNeedUpdate,
Vb = pb.colorsNeedUpdate,
Wb = pb.morphTargetsNeedUpdate,
dc = pb.vertices,
va = B.faces3,
wa = B.faces4,
jb = pb.faces,
Lb = pb.faceVertexUvs[0],
Nb = pb.faceVertexUvs[1],
ec = pb.skinIndices,
ac = pb.skinWeights,
bc = pb.morphTargets,
Ib = pb.morphNormals;
if (pb.verticesNeedUpdate) {
E = 0;
for (D = va.length; E < D; E++) O = jb[va[E]], R = dc[O.a], S = dc[O.b], Q = dc[O.c], cb[Xa] = R.x, cb[Xa + 1] = R.y, cb[Xa + 2] = R.z, cb[Xa + 3] = S.x, cb[Xa + 4] = S.y, cb[Xa + 5] = S.z, cb[Xa + 6] = Q.x, cb[Xa + 7] = Q.y, cb[Xa + 8] = Q.z, Xa += 9;
E = 0;
for (D = wa.length; E < D; E++) O = jb[wa[E]], R = dc[O.a], S = dc[O.b], Q = dc[O.c], aa = dc[O.d], cb[Xa] = R.x, cb[Xa + 1] = R.y, cb[Xa + 2] =
R.z, cb[Xa + 3] = S.x, cb[Xa + 4] = S.y, cb[Xa + 5] = S.z, cb[Xa + 6] = Q.x, cb[Xa + 7] = Q.y, cb[Xa + 8] = Q.z, cb[Xa + 9] = aa.x, cb[Xa + 10] = aa.y, cb[Xa + 11] = aa.z, Xa += 12;
j.bindBuffer(j.ARRAY_BUFFER, B.__webglVertexBuffer);
j.bufferData(j.ARRAY_BUFFER, cb, G)
}
if (Wb) {
bb = 0;
for (eb = bc.length; bb < eb; bb++) {
E = ga = 0;
for (D = va.length; E < D; E++) Sa = va[E], O = jb[Sa], R = bc[bb].vertices[O.a], S = bc[bb].vertices[O.b], Q = bc[bb].vertices[O.c], $a = wb[bb], $a[ga] = R.x, $a[ga + 1] = R.y, $a[ga + 2] = R.z, $a[ga + 3] = S.x, $a[ga + 4] = S.y, $a[ga + 5] = S.z, $a[ga + 6] = Q.x, $a[ga + 7] = Q.y, $a[ga + 8] = Q.z,
J.morphNormals && (M ? (Qa = Ib[bb].vertexNormals[Sa], ea = Qa.a, ha = Qa.b, Ea = Qa.c) : Ea = ha = ea = Ib[bb].faceNormals[Sa], ab = xb[bb], ab[ga] = ea.x, ab[ga + 1] = ea.y, ab[ga + 2] = ea.z, ab[ga + 3] = ha.x, ab[ga + 4] = ha.y, ab[ga + 5] = ha.z, ab[ga + 6] = Ea.x, ab[ga + 7] = Ea.y, ab[ga + 8] = Ea.z), ga += 9;
E = 0;
for (D = wa.length; E < D; E++) Sa = wa[E], O = jb[Sa], R = bc[bb].vertices[O.a], S = bc[bb].vertices[O.b], Q = bc[bb].vertices[O.c], aa = bc[bb].vertices[O.d], $a = wb[bb], $a[ga] = R.x, $a[ga + 1] = R.y, $a[ga + 2] = R.z, $a[ga + 3] = S.x, $a[ga + 4] = S.y, $a[ga + 5] = S.z, $a[ga + 6] = Q.x, $a[ga + 7] = Q.y, $a[ga +
8] = Q.z, $a[ga + 9] = aa.x, $a[ga + 10] = aa.y, $a[ga + 11] = aa.z, J.morphNormals && (M ? (Qa = Ib[bb].vertexNormals[Sa], ea = Qa.a, ha = Qa.b, Ea = Qa.c, Oa = Qa.d) : Oa = Ea = ha = ea = Ib[bb].faceNormals[Sa], ab = xb[bb], ab[ga] = ea.x, ab[ga + 1] = ea.y, ab[ga + 2] = ea.z, ab[ga + 3] = ha.x, ab[ga + 4] = ha.y, ab[ga + 5] = ha.z, ab[ga + 6] = Ea.x, ab[ga + 7] = Ea.y, ab[ga + 8] = Ea.z, ab[ga + 9] = Oa.x, ab[ga + 10] = Oa.y, ab[ga + 11] = Oa.z), ga += 12;
j.bindBuffer(j.ARRAY_BUFFER, B.__webglMorphTargetsBuffers[bb]);
j.bufferData(j.ARRAY_BUFFER, wb[bb], G);
J.morphNormals && (j.bindBuffer(j.ARRAY_BUFFER, B.__webglMorphNormalsBuffers[bb]),
j.bufferData(j.ARRAY_BUFFER, xb[bb], G))
}
}
if (ac.length) {
E = 0;
for (D = va.length; E < D; E++) O = jb[va[E]], na = ac[O.a], qa = ac[O.b], sa = ac[O.c], Ma[Z] = na.x, Ma[Z + 1] = na.y, Ma[Z + 2] = na.z, Ma[Z + 3] = na.w, Ma[Z + 4] = qa.x, Ma[Z + 5] = qa.y, Ma[Z + 6] = qa.z, Ma[Z + 7] = qa.w, Ma[Z + 8] = sa.x, Ma[Z + 9] = sa.y, Ma[Z + 10] = sa.z, Ma[Z + 11] = sa.w, ua = ec[O.a], Za = ec[O.b], xa = ec[O.c], La[Z] = ua.x, La[Z + 1] = ua.y, La[Z + 2] = ua.z, La[Z + 3] = ua.w, La[Z + 4] = Za.x, La[Z + 5] = Za.y, La[Z + 6] = Za.z, La[Z + 7] = Za.w, La[Z + 8] = xa.x, La[Z + 9] = xa.y, La[Z + 10] = xa.z, La[Z + 11] = xa.w, Z += 12;
E = 0;
for (D = wa.length; E < D; E++) O =
jb[wa[E]], na = ac[O.a], qa = ac[O.b], sa = ac[O.c], Ba = ac[O.d], Ma[Z] = na.x, Ma[Z + 1] = na.y, Ma[Z + 2] = na.z, Ma[Z + 3] = na.w, Ma[Z + 4] = qa.x, Ma[Z + 5] = qa.y, Ma[Z + 6] = qa.z, Ma[Z + 7] = qa.w, Ma[Z + 8] = sa.x, Ma[Z + 9] = sa.y, Ma[Z + 10] = sa.z, Ma[Z + 11] = sa.w, Ma[Z + 12] = Ba.x, Ma[Z + 13] = Ba.y, Ma[Z + 14] = Ba.z, Ma[Z + 15] = Ba.w, ua = ec[O.a], Za = ec[O.b], xa = ec[O.c], Pa = ec[O.d], La[Z] = ua.x, La[Z + 1] = ua.y, La[Z + 2] = ua.z, La[Z + 3] = ua.w, La[Z + 4] = Za.x, La[Z + 5] = Za.y, La[Z + 6] = Za.z, La[Z + 7] = Za.w, La[Z + 8] = xa.x, La[Z + 9] = xa.y, La[Z + 10] = xa.z, La[Z + 11] = xa.w, La[Z + 12] = Pa.x, La[Z + 13] = Pa.y, La[Z + 14] =
Pa.z, La[Z + 15] = Pa.w, Z += 16;
0 < Z && (j.bindBuffer(j.ARRAY_BUFFER, B.__webglSkinIndicesBuffer), j.bufferData(j.ARRAY_BUFFER, La, G), j.bindBuffer(j.ARRAY_BUFFER, B.__webglSkinWeightsBuffer), j.bufferData(j.ARRAY_BUFFER, Ma, G))
}
if (Vb && L) {
E = 0;
for (D = va.length; E < D; E++) O = jb[va[E]], X = O.vertexColors, ja = O.color, 3 === X.length && L === THREE.VertexColors ? (ka = X[0], oa = X[1], la = X[2]) : la = oa = ka = ja, db[Va] = ka.r, db[Va + 1] = ka.g, db[Va + 2] = ka.b, db[Va + 3] = oa.r, db[Va + 4] = oa.g, db[Va + 5] = oa.b, db[Va + 6] = la.r, db[Va + 7] = la.g, db[Va + 8] = la.b, Va += 9;
E = 0;
for (D =
wa.length; E < D; E++) O = jb[wa[E]], X = O.vertexColors, ja = O.color, 4 === X.length && L === THREE.VertexColors ? (ka = X[0], oa = X[1], la = X[2], ta = X[3]) : ta = la = oa = ka = ja, db[Va] = ka.r, db[Va + 1] = ka.g, db[Va + 2] = ka.b, db[Va + 3] = oa.r, db[Va + 4] = oa.g, db[Va + 5] = oa.b, db[Va + 6] = la.r, db[Va + 7] = la.g, db[Va + 8] = la.b, db[Va + 9] = ta.r, db[Va + 10] = ta.g, db[Va + 11] = ta.b, Va += 12;
0 < Va && (j.bindBuffer(j.ARRAY_BUFFER, B.__webglColorBuffer), j.bufferData(j.ARRAY_BUFFER, db, G))
}
if (Ub && pb.hasTangents) {
E = 0;
for (D = va.length; E < D; E++) O = jb[va[E]], U = O.vertexTangents, da = U[0],
fa = U[1], Fa = U[2], Ka[Ca] = da.x, Ka[Ca + 1] = da.y, Ka[Ca + 2] = da.z, Ka[Ca + 3] = da.w, Ka[Ca + 4] = fa.x, Ka[Ca + 5] = fa.y, Ka[Ca + 6] = fa.z, Ka[Ca + 7] = fa.w, Ka[Ca + 8] = Fa.x, Ka[Ca + 9] = Fa.y, Ka[Ca + 10] = Fa.z, Ka[Ca + 11] = Fa.w, Ca += 12;
E = 0;
for (D = wa.length; E < D; E++) O = jb[wa[E]], U = O.vertexTangents, da = U[0], fa = U[1], Fa = U[2], ia = U[3], Ka[Ca] = da.x, Ka[Ca + 1] = da.y, Ka[Ca + 2] = da.z, Ka[Ca + 3] = da.w, Ka[Ca + 4] = fa.x, Ka[Ca + 5] = fa.y, Ka[Ca + 6] = fa.z, Ka[Ca + 7] = fa.w, Ka[Ca + 8] = Fa.x, Ka[Ca + 9] = Fa.y, Ka[Ca + 10] = Fa.z, Ka[Ca + 11] = Fa.w, Ka[Ca + 12] = ia.x, Ka[Ca + 13] = ia.y, Ka[Ca + 14] = ia.z, Ka[Ca +
15] = ia.w, Ca += 16;
j.bindBuffer(j.ARRAY_BUFFER, B.__webglTangentBuffer);
j.bufferData(j.ARRAY_BUFFER, Ka, G)
}
if (Tb && K) {
E = 0;
for (D = va.length; E < D; E++)
if (O = jb[va[E]], P = O.vertexNormals, T = O.normal, 3 === P.length && M)
for (ya = 0; 3 > ya; ya++) Ia = P[ya], Bb[ib] = Ia.x, Bb[ib + 1] = Ia.y, Bb[ib + 2] = Ia.z, ib += 3;
else
for (ya = 0; 3 > ya; ya++) Bb[ib] = T.x, Bb[ib + 1] = T.y, Bb[ib + 2] = T.z, ib += 3;
E = 0;
for (D = wa.length; E < D; E++)
if (O = jb[wa[E]], P = O.vertexNormals, T = O.normal, 4 === P.length && M)
for (ya = 0; 4 > ya; ya++) Ia = P[ya], Bb[ib] = Ia.x, Bb[ib + 1] = Ia.y, Bb[ib + 2] = Ia.z, ib +=
3;
else
for (ya = 0; 4 > ya; ya++) Bb[ib] = T.x, Bb[ib + 1] = T.y, Bb[ib + 2] = T.z, ib += 3;
j.bindBuffer(j.ARRAY_BUFFER, B.__webglNormalBuffer);
j.bufferData(j.ARRAY_BUFFER, Bb, G)
}
if (Eb && Lb && N) {
E = 0;
for (D = va.length; E < D; E++)
if (W = va[E], pa = Lb[W], void 0 !== pa)
for (ya = 0; 3 > ya; ya++) ob = pa[ya], hb[Ta] = ob.x, hb[Ta + 1] = ob.y, Ta += 2;
E = 0;
for (D = wa.length; E < D; E++)
if (W = wa[E], pa = Lb[W], void 0 !== pa)
for (ya = 0; 4 > ya; ya++) ob = pa[ya], hb[Ta] = ob.x, hb[Ta + 1] = ob.y, Ta += 2;
0 < Ta && (j.bindBuffer(j.ARRAY_BUFFER, B.__webglUVBuffer), j.bufferData(j.ARRAY_BUFFER, hb, G))
}
if (Eb &&
Nb && N) {
E = 0;
for (D = va.length; E < D; E++)
if (W = va[E], ca = Nb[W], void 0 !== ca)
for (ya = 0; 3 > ya; ya++) Wa = ca[ya], kb[Ua] = Wa.x, kb[Ua + 1] = Wa.y, Ua += 2;
E = 0;
for (D = wa.length; E < D; E++)
if (W = wa[E], ca = Nb[W], void 0 !== ca)
for (ya = 0; 4 > ya; ya++) Wa = ca[ya], kb[Ua] = Wa.x, kb[Ua + 1] = Wa.y, Ua += 2;
0 < Ua && (j.bindBuffer(j.ARRAY_BUFFER, B.__webglUV2Buffer), j.bufferData(j.ARRAY_BUFFER, kb, G))
}
if (Jb) {
E = 0;
for (D = va.length; E < D; E++) Ob[Ja] = Ra, Ob[Ja + 1] = Ra + 1, Ob[Ja + 2] = Ra + 2, Ja += 3, ub[nb] = Ra, ub[nb + 1] = Ra + 1, ub[nb + 2] = Ra, ub[nb + 3] = Ra + 2, ub[nb + 4] = Ra + 1, ub[nb + 5] = Ra + 2, nb += 6,
Ra += 3;
E = 0;
for (D = wa.length; E < D; E++) Ob[Ja] = Ra, Ob[Ja + 1] = Ra + 1, Ob[Ja + 2] = Ra + 3, Ob[Ja + 3] = Ra + 1, Ob[Ja + 4] = Ra + 2, Ob[Ja + 5] = Ra + 3, Ja += 6, ub[nb] = Ra, ub[nb + 1] = Ra + 1, ub[nb + 2] = Ra, ub[nb + 3] = Ra + 3, ub[nb + 4] = Ra + 1, ub[nb + 5] = Ra + 2, ub[nb + 6] = Ra + 2, ub[nb + 7] = Ra + 3, nb += 8, Ra += 4;
j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, B.__webglFaceBuffer);
j.bufferData(j.ELEMENT_ARRAY_BUFFER, Ob, G);
j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, B.__webglLineBuffer);
j.bufferData(j.ELEMENT_ARRAY_BUFFER, ub, G)
}
if (Ab) {
ya = 0;
for (Ya = Ab.length; ya < Ya; ya++)
if (u = Ab[ya], u.__original.needsUpdate) {
x =
0;
if (1 === u.size)
if (void 0 === u.boundTo || "vertices" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) O = jb[va[E]], u.array[x] = u.value[O.a], u.array[x + 1] = u.value[O.b], u.array[x + 2] = u.value[O.c], x += 3;
E = 0;
for (D = wa.length; E < D; E++) O = jb[wa[E]], u.array[x] = u.value[O.a], u.array[x + 1] = u.value[O.b], u.array[x + 2] = u.value[O.c], u.array[x + 3] = u.value[O.d], x += 4
} else {
if ("faces" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) za = u.value[va[E]], u.array[x] = za, u.array[x + 1] = za, u.array[x + 2] = za, x += 3;
E = 0;
for (D = wa.length; E < D; E++) za = u.value[wa[E]],
u.array[x] = za, u.array[x + 1] = za, u.array[x + 2] = za, u.array[x + 3] = za, x += 4
}
} else if (2 === u.size)
if (void 0 === u.boundTo || "vertices" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) O = jb[va[E]], R = u.value[O.a], S = u.value[O.b], Q = u.value[O.c], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = S.x, u.array[x + 3] = S.y, u.array[x + 4] = Q.x, u.array[x + 5] = Q.y, x += 6;
E = 0;
for (D = wa.length; E < D; E++) O = jb[wa[E]], R = u.value[O.a], S = u.value[O.b], Q = u.value[O.c], aa = u.value[O.d], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = S.x, u.array[x + 3] = S.y, u.array[x +
4] = Q.x, u.array[x + 5] = Q.y, u.array[x + 6] = aa.x, u.array[x + 7] = aa.y, x += 8
} else {
if ("faces" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) Q = S = R = za = u.value[va[E]], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = S.x, u.array[x + 3] = S.y, u.array[x + 4] = Q.x, u.array[x + 5] = Q.y, x += 6;
E = 0;
for (D = wa.length; E < D; E++) aa = Q = S = R = za = u.value[wa[E]], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = S.x, u.array[x + 3] = S.y, u.array[x + 4] = Q.x, u.array[x + 5] = Q.y, u.array[x + 6] = aa.x, u.array[x + 7] = aa.y, x += 8
}
} else if (3 === u.size) {
var Y;
Y = "c" === u.type ? ["r", "g", "b"] : ["x", "y", "z"];
if (void 0 === u.boundTo || "vertices" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) O = jb[va[E]], R = u.value[O.a], S = u.value[O.b], Q = u.value[O.c], u.array[x] = R[Y[0]], u.array[x + 1] = R[Y[1]], u.array[x + 2] = R[Y[2]], u.array[x + 3] = S[Y[0]], u.array[x + 4] = S[Y[1]], u.array[x + 5] = S[Y[2]], u.array[x + 6] = Q[Y[0]], u.array[x + 7] = Q[Y[1]], u.array[x + 8] = Q[Y[2]], x += 9;
E = 0;
for (D = wa.length; E < D; E++) O = jb[wa[E]], R = u.value[O.a], S = u.value[O.b], Q = u.value[O.c], aa = u.value[O.d], u.array[x] = R[Y[0]], u.array[x + 1] = R[Y[1]], u.array[x + 2] = R[Y[2]], u.array[x +
3] = S[Y[0]], u.array[x + 4] = S[Y[1]], u.array[x + 5] = S[Y[2]], u.array[x + 6] = Q[Y[0]], u.array[x + 7] = Q[Y[1]], u.array[x + 8] = Q[Y[2]], u.array[x + 9] = aa[Y[0]], u.array[x + 10] = aa[Y[1]], u.array[x + 11] = aa[Y[2]], x += 12
} else if ("faces" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) Q = S = R = za = u.value[va[E]], u.array[x] = R[Y[0]], u.array[x + 1] = R[Y[1]], u.array[x + 2] = R[Y[2]], u.array[x + 3] = S[Y[0]], u.array[x + 4] = S[Y[1]], u.array[x + 5] = S[Y[2]], u.array[x + 6] = Q[Y[0]], u.array[x + 7] = Q[Y[1]], u.array[x + 8] = Q[Y[2]], x += 9;
E = 0;
for (D = wa.length; E < D; E++) aa = Q = S = R = za =
u.value[wa[E]], u.array[x] = R[Y[0]], u.array[x + 1] = R[Y[1]], u.array[x + 2] = R[Y[2]], u.array[x + 3] = S[Y[0]], u.array[x + 4] = S[Y[1]], u.array[x + 5] = S[Y[2]], u.array[x + 6] = Q[Y[0]], u.array[x + 7] = Q[Y[1]], u.array[x + 8] = Q[Y[2]], u.array[x + 9] = aa[Y[0]], u.array[x + 10] = aa[Y[1]], u.array[x + 11] = aa[Y[2]], x += 12
} else if ("faceVertices" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) za = u.value[va[E]], R = za[0], S = za[1], Q = za[2], u.array[x] = R[Y[0]], u.array[x + 1] = R[Y[1]], u.array[x + 2] = R[Y[2]], u.array[x + 3] = S[Y[0]], u.array[x + 4] = S[Y[1]], u.array[x + 5] = S[Y[2]],
u.array[x + 6] = Q[Y[0]], u.array[x + 7] = Q[Y[1]], u.array[x + 8] = Q[Y[2]], x += 9;
E = 0;
for (D = wa.length; E < D; E++) za = u.value[wa[E]], R = za[0], S = za[1], Q = za[2], aa = za[3], u.array[x] = R[Y[0]], u.array[x + 1] = R[Y[1]], u.array[x + 2] = R[Y[2]], u.array[x + 3] = S[Y[0]], u.array[x + 4] = S[Y[1]], u.array[x + 5] = S[Y[2]], u.array[x + 6] = Q[Y[0]], u.array[x + 7] = Q[Y[1]], u.array[x + 8] = Q[Y[2]], u.array[x + 9] = aa[Y[0]], u.array[x + 10] = aa[Y[1]], u.array[x + 11] = aa[Y[2]], x += 12
}
} else if (4 === u.size)
if (void 0 === u.boundTo || "vertices" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) O =
jb[va[E]], R = u.value[O.a], S = u.value[O.b], Q = u.value[O.c], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = R.z, u.array[x + 3] = R.w, u.array[x + 4] = S.x, u.array[x + 5] = S.y, u.array[x + 6] = S.z, u.array[x + 7] = S.w, u.array[x + 8] = Q.x, u.array[x + 9] = Q.y, u.array[x + 10] = Q.z, u.array[x + 11] = Q.w, x += 12;
E = 0;
for (D = wa.length; E < D; E++) O = jb[wa[E]], R = u.value[O.a], S = u.value[O.b], Q = u.value[O.c], aa = u.value[O.d], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = R.z, u.array[x + 3] = R.w, u.array[x + 4] = S.x, u.array[x + 5] = S.y, u.array[x + 6] = S.z, u.array[x + 7] = S.w, u.array[x +
8] = Q.x, u.array[x + 9] = Q.y, u.array[x + 10] = Q.z, u.array[x + 11] = Q.w, u.array[x + 12] = aa.x, u.array[x + 13] = aa.y, u.array[x + 14] = aa.z, u.array[x + 15] = aa.w, x += 16
} else if ("faces" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) Q = S = R = za = u.value[va[E]], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = R.z, u.array[x + 3] = R.w, u.array[x + 4] = S.x, u.array[x + 5] = S.y, u.array[x + 6] = S.z, u.array[x + 7] = S.w, u.array[x + 8] = Q.x, u.array[x + 9] = Q.y, u.array[x + 10] = Q.z, u.array[x + 11] = Q.w, x += 12;
E = 0;
for (D = wa.length; E < D; E++) aa = Q = S = R = za = u.value[wa[E]], u.array[x] = R.x,
u.array[x + 1] = R.y, u.array[x + 2] = R.z, u.array[x + 3] = R.w, u.array[x + 4] = S.x, u.array[x + 5] = S.y, u.array[x + 6] = S.z, u.array[x + 7] = S.w, u.array[x + 8] = Q.x, u.array[x + 9] = Q.y, u.array[x + 10] = Q.z, u.array[x + 11] = Q.w, u.array[x + 12] = aa.x, u.array[x + 13] = aa.y, u.array[x + 14] = aa.z, u.array[x + 15] = aa.w, x += 16
} else if ("faceVertices" === u.boundTo) {
E = 0;
for (D = va.length; E < D; E++) za = u.value[va[E]], R = za[0], S = za[1], Q = za[2], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = R.z, u.array[x + 3] = R.w, u.array[x + 4] = S.x, u.array[x + 5] = S.y, u.array[x + 6] = S.z, u.array[x +
7] = S.w, u.array[x + 8] = Q.x, u.array[x + 9] = Q.y, u.array[x + 10] = Q.z, u.array[x + 11] = Q.w, x += 12;
E = 0;
for (D = wa.length; E < D; E++) za = u.value[wa[E]], R = za[0], S = za[1], Q = za[2], aa = za[3], u.array[x] = R.x, u.array[x + 1] = R.y, u.array[x + 2] = R.z, u.array[x + 3] = R.w, u.array[x + 4] = S.x, u.array[x + 5] = S.y, u.array[x + 6] = S.z, u.array[x + 7] = S.w, u.array[x + 8] = Q.x, u.array[x + 9] = Q.y, u.array[x + 10] = Q.z, u.array[x + 11] = Q.w, u.array[x + 12] = aa.x, u.array[x + 13] = aa.y, u.array[x + 14] = aa.z, u.array[x + 15] = aa.w, x += 16
}
j.bindBuffer(j.ARRAY_BUFFER, u.buffer);
j.bufferData(j.ARRAY_BUFFER,
u.array, G)
}
}
I && (delete B.__inittedArrays, delete B.__colorArray, delete B.__normalArray, delete B.__tangentArray, delete B.__uvArray, delete B.__uv2Array, delete B.__faceArray, delete B.__vertexArray, delete B.__lineArray, delete B.__skinIndexArray, delete B.__skinWeightArray)
}
}
l.verticesNeedUpdate = !1;
l.morphTargetsNeedUpdate = !1;
l.elementsNeedUpdate = !1;
l.uvsNeedUpdate = !1;
l.normalsNeedUpdate = !1;
l.colorsNeedUpdate = !1;
l.tangentsNeedUpdate = !1;
l.buffersNeedUpdate = !1;
t.attributes && r(t)
} else if (i instanceof THREE.Ribbon) {
t =
d(i, l);
p = t.attributes && n(t);
if (l.verticesNeedUpdate || l.colorsNeedUpdate || l.normalsNeedUpdate || p) {
var Cb = l,
Mb = j.DYNAMIC_DRAW,
Hb = void 0,
Kb = void 0,
oc = void 0,
Xb = void 0,
Aa = void 0,
wc = void 0,
xc = void 0,
yc = void 0,
hc = void 0,
fb = void 0,
ic = void 0,
Ga = void 0,
qb = void 0,
lc = Cb.vertices,
mc = Cb.colors,
nc = Cb.normals,
tc = lc.length,
uc = mc.length,
Yc = nc.length,
zc = Cb.__vertexArray,
Ac = Cb.__colorArray,
Bc = Cb.__normalArray,
Zc = Cb.colorsNeedUpdate,
$c = Cb.normalsNeedUpdate,
Lc = Cb.__webglCustomAttributesList;
if (Cb.verticesNeedUpdate) {
for (Hb =
0; Hb < tc; Hb++) Xb = lc[Hb], Aa = 3 * Hb, zc[Aa] = Xb.x, zc[Aa + 1] = Xb.y, zc[Aa + 2] = Xb.z;
j.bindBuffer(j.ARRAY_BUFFER, Cb.__webglVertexBuffer);
j.bufferData(j.ARRAY_BUFFER, zc, Mb)
}
if (Zc) {
for (Kb = 0; Kb < uc; Kb++) wc = mc[Kb], Aa = 3 * Kb, Ac[Aa] = wc.r, Ac[Aa + 1] = wc.g, Ac[Aa + 2] = wc.b;
j.bindBuffer(j.ARRAY_BUFFER, Cb.__webglColorBuffer);
j.bufferData(j.ARRAY_BUFFER, Ac, Mb)
}
if ($c) {
for (oc = 0; oc < Yc; oc++) xc = nc[oc], Aa = 3 * oc, Bc[Aa] = xc.x, Bc[Aa + 1] = xc.y, Bc[Aa + 2] = xc.z;
j.bindBuffer(j.ARRAY_BUFFER, Cb.__webglNormalBuffer);
j.bufferData(j.ARRAY_BUFFER, Bc, Mb)
}
if (Lc) {
yc =
0;
for (hc = Lc.length; yc < hc; yc++)
if (Ga = Lc[yc], Ga.needsUpdate && (void 0 === Ga.boundTo || "vertices" === Ga.boundTo)) {
Aa = 0;
ic = Ga.value.length;
if (1 === Ga.size)
for (fb = 0; fb < ic; fb++) Ga.array[fb] = Ga.value[fb];
else if (2 === Ga.size)
for (fb = 0; fb < ic; fb++) qb = Ga.value[fb], Ga.array[Aa] = qb.x, Ga.array[Aa + 1] = qb.y, Aa += 2;
else if (3 === Ga.size)
if ("c" === Ga.type)
for (fb = 0; fb < ic; fb++) qb = Ga.value[fb], Ga.array[Aa] = qb.r, Ga.array[Aa + 1] = qb.g, Ga.array[Aa + 2] = qb.b, Aa += 3;
else
for (fb = 0; fb < ic; fb++) qb = Ga.value[fb], Ga.array[Aa] = qb.x, Ga.array[Aa + 1] =
qb.y, Ga.array[Aa + 2] = qb.z, Aa += 3;
else if (4 === Ga.size)
for (fb = 0; fb < ic; fb++) qb = Ga.value[fb], Ga.array[Aa] = qb.x, Ga.array[Aa + 1] = qb.y, Ga.array[Aa + 2] = qb.z, Ga.array[Aa + 3] = qb.w, Aa += 4;
j.bindBuffer(j.ARRAY_BUFFER, Ga.buffer);
j.bufferData(j.ARRAY_BUFFER, Ga.array, Mb)
}
}
}
l.verticesNeedUpdate = !1;
l.colorsNeedUpdate = !1;
l.normalsNeedUpdate = !1;
t.attributes && r(t)
} else if (i instanceof THREE.Line) {
t = d(i, l);
p = t.attributes && n(t);
if (l.verticesNeedUpdate || l.colorsNeedUpdate || l.lineDistancesNeedUpdate || p) {
var Db = l,
Cc = j.DYNAMIC_DRAW,
pc = void 0,
qc = void 0,
rc = void 0,
Dc = void 0,
Na = void 0,
Ec = void 0,
Qc = Db.vertices,
Rc = Db.colors,
Sc = Db.lineDistances,
ad = Qc.length,
bd = Rc.length,
cd = Sc.length,
Fc = Db.__vertexArray,
Gc = Db.__colorArray,
Tc = Db.__lineDistanceArray,
dd = Db.colorsNeedUpdate,
ed = Db.lineDistancesNeedUpdate,
Mc = Db.__webglCustomAttributesList,
Hc = void 0,
Uc = void 0,
gb = void 0,
jc = void 0,
rb = void 0,
Ha = void 0;
if (Db.verticesNeedUpdate) {
for (pc = 0; pc < ad; pc++) Dc = Qc[pc], Na = 3 * pc, Fc[Na] = Dc.x, Fc[Na + 1] = Dc.y, Fc[Na + 2] = Dc.z;
j.bindBuffer(j.ARRAY_BUFFER, Db.__webglVertexBuffer);
j.bufferData(j.ARRAY_BUFFER, Fc, Cc)
}
if (dd) {
for (qc = 0; qc < bd; qc++) Ec = Rc[qc], Na = 3 * qc, Gc[Na] = Ec.r, Gc[Na + 1] = Ec.g, Gc[Na + 2] = Ec.b;
j.bindBuffer(j.ARRAY_BUFFER, Db.__webglColorBuffer);
j.bufferData(j.ARRAY_BUFFER, Gc, Cc)
}
if (ed) {
for (rc = 0; rc < cd; rc++) Tc[rc] = Sc[rc];
j.bindBuffer(j.ARRAY_BUFFER, Db.__webglLineDistanceBuffer);
j.bufferData(j.ARRAY_BUFFER, Tc, Cc)
}
if (Mc) {
Hc = 0;
for (Uc = Mc.length; Hc < Uc; Hc++)
if (Ha = Mc[Hc], Ha.needsUpdate && (void 0 === Ha.boundTo || "vertices" === Ha.boundTo)) {
Na = 0;
jc = Ha.value.length;
if (1 === Ha.size)
for (gb =
0; gb < jc; gb++) Ha.array[gb] = Ha.value[gb];
else if (2 === Ha.size)
for (gb = 0; gb < jc; gb++) rb = Ha.value[gb], Ha.array[Na] = rb.x, Ha.array[Na + 1] = rb.y, Na += 2;
else if (3 === Ha.size)
if ("c" === Ha.type)
for (gb = 0; gb < jc; gb++) rb = Ha.value[gb], Ha.array[Na] = rb.r, Ha.array[Na + 1] = rb.g, Ha.array[Na + 2] = rb.b, Na += 3;
else
for (gb = 0; gb < jc; gb++) rb = Ha.value[gb], Ha.array[Na] = rb.x, Ha.array[Na + 1] = rb.y, Ha.array[Na + 2] = rb.z, Na += 3;
else if (4 === Ha.size)
for (gb = 0; gb < jc; gb++) rb = Ha.value[gb], Ha.array[Na] = rb.x, Ha.array[Na + 1] = rb.y, Ha.array[Na + 2] = rb.z, Ha.array[Na +
3] = rb.w, Na += 4;
j.bindBuffer(j.ARRAY_BUFFER, Ha.buffer);
j.bufferData(j.ARRAY_BUFFER, Ha.array, Cc)
}
}
}
l.verticesNeedUpdate = !1;
l.colorsNeedUpdate = !1;
l.lineDistancesNeedUpdate = !1;
t.attributes && r(t)
} else if (i instanceof THREE.ParticleSystem) {
t = d(i, l);
p = t.attributes && n(t);
if (l.verticesNeedUpdate || l.colorsNeedUpdate || i.sortParticles || p) {
var Pb = l,
Nc = j.DYNAMIC_DRAW,
sc = i,
sb = void 0,
Qb = void 0,
Rb = void 0,
ba = void 0,
Sb = void 0,
cc = void 0,
Ic = Pb.vertices,
Oc = Ic.length,
Pc = Pb.colors,
Vc = Pc.length,
fc = Pb.__vertexArray,
gc = Pb.__colorArray,
Yb = Pb.__sortArray,
Wc = Pb.verticesNeedUpdate,
Xc = Pb.colorsNeedUpdate,
Zb = Pb.__webglCustomAttributesList,
Fb = void 0,
kc = void 0,
ma = void 0,
Gb = void 0,
Da = void 0,
$ = void 0;
if (sc.sortParticles) {
yb.copy(vb);
yb.multiply(sc.matrixWorld);
for (sb = 0; sb < Oc; sb++) Rb = Ic[sb], ra.copy(Rb), ra.applyProjection(yb), Yb[sb] = [ra.z, sb];
Yb.sort(k);
for (sb = 0; sb < Oc; sb++) Rb = Ic[Yb[sb][1]], ba = 3 * sb, fc[ba] = Rb.x, fc[ba + 1] = Rb.y, fc[ba + 2] = Rb.z;
for (Qb = 0; Qb < Vc; Qb++) ba = 3 * Qb, cc = Pc[Yb[Qb][1]], gc[ba] = cc.r, gc[ba + 1] = cc.g, gc[ba + 2] = cc.b;
if (Zb) {
Fb = 0;
for (kc =
Zb.length; Fb < kc; Fb++)
if ($ = Zb[Fb], void 0 === $.boundTo || "vertices" === $.boundTo)
if (ba = 0, Gb = $.value.length, 1 === $.size)
for (ma = 0; ma < Gb; ma++) Sb = Yb[ma][1], $.array[ma] = $.value[Sb];
else if (2 === $.size)
for (ma = 0; ma < Gb; ma++) Sb = Yb[ma][1], Da = $.value[Sb], $.array[ba] = Da.x, $.array[ba + 1] = Da.y, ba += 2;
else if (3 === $.size)
if ("c" === $.type)
for (ma = 0; ma < Gb; ma++) Sb = Yb[ma][1], Da = $.value[Sb], $.array[ba] = Da.r, $.array[ba + 1] = Da.g, $.array[ba + 2] = Da.b, ba += 3;
else
for (ma = 0; ma < Gb; ma++) Sb = Yb[ma][1], Da = $.value[Sb], $.array[ba] = Da.x, $.array[ba +
1] = Da.y, $.array[ba + 2] = Da.z, ba += 3;
else if (4 === $.size)
for (ma = 0; ma < Gb; ma++) Sb = Yb[ma][1], Da = $.value[Sb], $.array[ba] = Da.x, $.array[ba + 1] = Da.y, $.array[ba + 2] = Da.z, $.array[ba + 3] = Da.w, ba += 4
}
} else {
if (Wc)
for (sb = 0; sb < Oc; sb++) Rb = Ic[sb], ba = 3 * sb, fc[ba] = Rb.x, fc[ba + 1] = Rb.y, fc[ba + 2] = Rb.z;
if (Xc)
for (Qb = 0; Qb < Vc; Qb++) cc = Pc[Qb], ba = 3 * Qb, gc[ba] = cc.r, gc[ba + 1] = cc.g, gc[ba + 2] = cc.b;
if (Zb) {
Fb = 0;
for (kc = Zb.length; Fb < kc; Fb++)
if ($ = Zb[Fb], $.needsUpdate && (void 0 === $.boundTo || "vertices" === $.boundTo))
if (Gb = $.value.length, ba = 0, 1 === $.size)
for (ma =
0; ma < Gb; ma++) $.array[ma] = $.value[ma];
else if (2 === $.size)
for (ma = 0; ma < Gb; ma++) Da = $.value[ma], $.array[ba] = Da.x, $.array[ba + 1] = Da.y, ba += 2;
else if (3 === $.size)
if ("c" === $.type)
for (ma = 0; ma < Gb; ma++) Da = $.value[ma], $.array[ba] = Da.r, $.array[ba + 1] = Da.g, $.array[ba + 2] = Da.b, ba += 3;
else
for (ma = 0; ma < Gb; ma++) Da = $.value[ma], $.array[ba] = Da.x, $.array[ba + 1] = Da.y, $.array[ba + 2] = Da.z, ba += 3;
else if (4 === $.size)
for (ma = 0; ma < Gb; ma++) Da = $.value[ma], $.array[ba] = Da.x, $.array[ba + 1] = Da.y, $.array[ba + 2] = Da.z, $.array[ba + 3] = Da.w, ba += 4
}
}
if (Wc ||
sc.sortParticles) j.bindBuffer(j.ARRAY_BUFFER, Pb.__webglVertexBuffer), j.bufferData(j.ARRAY_BUFFER, fc, Nc);
if (Xc || sc.sortParticles) j.bindBuffer(j.ARRAY_BUFFER, Pb.__webglColorBuffer), j.bufferData(j.ARRAY_BUFFER, gc, Nc);
if (Zb) {
Fb = 0;
for (kc = Zb.length; Fb < kc; Fb++)
if ($ = Zb[Fb], $.needsUpdate || sc.sortParticles) j.bindBuffer(j.ARRAY_BUFFER, $.buffer), j.bufferData(j.ARRAY_BUFFER, $.array, Nc)
}
}
l.verticesNeedUpdate = !1;
l.colorsNeedUpdate = !1;
t.attributes && r(t)
}
}
};
this.initMaterial = function(a, b, c, d) {
var e, f, g, h;
a.addEventListener("dispose",
nc);
var i, k, l, m, p;
a instanceof THREE.MeshDepthMaterial ? p = "depth" : a instanceof THREE.MeshNormalMaterial ? p = "normal" : a instanceof THREE.MeshBasicMaterial ? p = "basic" : a instanceof THREE.MeshLambertMaterial ? p = "lambert" : a instanceof THREE.MeshPhongMaterial ? p = "phong" : a instanceof THREE.LineBasicMaterial ? p = "basic" : a instanceof THREE.LineDashedMaterial ? p = "dashed" : a instanceof THREE.ParticleBasicMaterial && (p = "particle_basic");
if (p) {
var n = THREE.ShaderLib[p];
a.uniforms = THREE.UniformsUtils.clone(n.uniforms);
a.vertexShader =
n.vertexShader;
a.fragmentShader = n.fragmentShader
}
var q = e = 0,
r = 0;
f = n = 0;
for (var s = b.length; f < s; f++) g = b[f], g.onlyShadow || (g instanceof THREE.DirectionalLight && e++, g instanceof THREE.PointLight && q++, g instanceof THREE.SpotLight && r++, g instanceof THREE.HemisphereLight && n++);
f = q;
g = r;
h = n;
r = n = 0;
for (q = b.length; r < q; r++) s = b[r], s.castShadow && (s instanceof THREE.SpotLight && n++, s instanceof THREE.DirectionalLight && !s.shadowCascade && n++);
m = n;
Jb && d && d.useVertexTexture ? l = 1024 : (b = j.getParameter(j.MAX_VERTEX_UNIFORM_VECTORS),
b = Math.floor((b - 20) / 4), void 0 !== d && d instanceof THREE.SkinnedMesh && (b = Math.min(d.bones.length, b), b < d.bones.length && console.warn("WebGLRenderer: too many bones - " + d.bones.length + ", this GPU supports just " + b + " (try OpenGL instead of ANGLE)")), l = b);
a: {
var r = a.fragmentShader,
q = a.vertexShader,
n = a.uniforms,
b = a.attributes,
s = a.defines,
c = {
map: !!a.map,
envMap: !!a.envMap,
lightMap: !!a.lightMap,
bumpMap: !!a.bumpMap,
normalMap: !!a.normalMap,
specularMap: !!a.specularMap,
vertexColors: a.vertexColors,
fog: c,
useFog: a.fog,
fogExp: c instanceof THREE.FogExp2,
sizeAttenuation: a.sizeAttenuation,
skinning: a.skinning,
maxBones: l,
useVertexTexture: Jb && d && d.useVertexTexture,
boneTextureWidth: d && d.boneTextureWidth,
boneTextureHeight: d && d.boneTextureHeight,
morphTargets: a.morphTargets,
morphNormals: a.morphNormals,
maxMorphTargets: this.maxMorphTargets,
maxMorphNormals: this.maxMorphNormals,
maxDirLights: e,
maxPointLights: f,
maxSpotLights: g,
maxHemiLights: h,
maxShadows: m,
shadowMapEnabled: this.shadowMapEnabled && d.receiveShadow,
shadowMapType: this.shadowMapType,
shadowMapDebug: this.shadowMapDebug,
shadowMapCascade: this.shadowMapCascade,
alphaTest: a.alphaTest,
metal: a.metal,
perPixel: a.perPixel,
wrapAround: a.wrapAround,
doubleSided: a.side === THREE.DoubleSide,
flipSided: a.side === THREE.BackSide
},
t, v, z, d = [];
p ? d.push(p) : (d.push(r), d.push(q));
for (v in s) d.push(v), d.push(s[v]);
for (t in c) d.push(t), d.push(c[t]);
p = d.join();
t = 0;
for (v = sa.length; t < v; t++)
if (d = sa[t], d.code === p) {
d.usedTimes++;
k = d.program;
break a
}
t = "SHADOWMAP_TYPE_BASIC";
c.shadowMapType === THREE.PCFShadowMap ? t = "SHADOWMAP_TYPE_PCF" :
c.shadowMapType === THREE.PCFSoftShadowMap && (t = "SHADOWMAP_TYPE_PCF_SOFT");
v = [];
for (z in s) d = s[z], !1 !== d && (d = "#define " + z + " " + d, v.push(d));
d = v.join("\n");
z = j.createProgram();
v = ["precision " + ca + " float;", d, Ua ? "#define VERTEX_TEXTURES" : "", L.gammaInput ? "#define GAMMA_INPUT" : "", L.gammaOutput ? "#define GAMMA_OUTPUT" : "", L.physicallyBasedShading ? "#define PHYSICALLY_BASED_SHADING" : "", "#define MAX_DIR_LIGHTS " + c.maxDirLights, "#define MAX_POINT_LIGHTS " + c.maxPointLights, "#define MAX_SPOT_LIGHTS " + c.maxSpotLights,
"#define MAX_HEMI_LIGHTS " + c.maxHemiLights, "#define MAX_SHADOWS " + c.maxShadows, "#define MAX_BONES " + c.maxBones, c.map ? "#define USE_MAP" : "", c.envMap ? "#define USE_ENVMAP" : "", c.lightMap ? "#define USE_LIGHTMAP" : "", c.bumpMap ? "#define USE_BUMPMAP" : "", c.normalMap ? "#define USE_NORMALMAP" : "", c.specularMap ? "#define USE_SPECULARMAP" : "", c.vertexColors ? "#define USE_COLOR" : "", c.skinning ? "#define USE_SKINNING" : "", c.useVertexTexture ? "#define BONE_TEXTURE" : "", c.boneTextureWidth ? "#define N_BONE_PIXEL_X " + c.boneTextureWidth.toFixed(1) :
"", c.boneTextureHeight ? "#define N_BONE_PIXEL_Y " + c.boneTextureHeight.toFixed(1) : "", c.morphTargets ? "#define USE_MORPHTARGETS" : "", c.morphNormals ? "#define USE_MORPHNORMALS" : "", c.perPixel ? "#define PHONG_PER_PIXEL" : "", c.wrapAround ? "#define WRAP_AROUND" : "", c.doubleSided ? "#define DOUBLE_SIDED" : "", c.flipSided ? "#define FLIP_SIDED" : "", c.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", c.shadowMapEnabled ? "#define " + t : "", c.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "", c.shadowMapCascade ? "#define SHADOWMAP_CASCADE" :
"", c.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", "uniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"
].join("\n");
t = ["precision " + ca + " float;", c.bumpMap || c.normalMap ? "#extension GL_OES_standard_derivatives : enable" : "", d, "#define MAX_DIR_LIGHTS " + c.maxDirLights, "#define MAX_POINT_LIGHTS " + c.maxPointLights, "#define MAX_SPOT_LIGHTS " + c.maxSpotLights, "#define MAX_HEMI_LIGHTS " + c.maxHemiLights, "#define MAX_SHADOWS " + c.maxShadows, c.alphaTest ? "#define ALPHATEST " + c.alphaTest : "", L.gammaInput ? "#define GAMMA_INPUT" : "", L.gammaOutput ? "#define GAMMA_OUTPUT" : "", L.physicallyBasedShading ? "#define PHYSICALLY_BASED_SHADING" :
"", c.useFog && c.fog ? "#define USE_FOG" : "", c.useFog && c.fogExp ? "#define FOG_EXP2" : "", c.map ? "#define USE_MAP" : "", c.envMap ? "#define USE_ENVMAP" : "", c.lightMap ? "#define USE_LIGHTMAP" : "", c.bumpMap ? "#define USE_BUMPMAP" : "", c.normalMap ? "#define USE_NORMALMAP" : "", c.specularMap ? "#define USE_SPECULARMAP" : "", c.vertexColors ? "#define USE_COLOR" : "", c.metal ? "#define METAL" : "", c.perPixel ? "#define PHONG_PER_PIXEL" : "", c.wrapAround ? "#define WRAP_AROUND" : "", c.doubleSided ? "#define DOUBLE_SIDED" : "", c.flipSided ? "#define FLIP_SIDED" :
"", c.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", c.shadowMapEnabled ? "#define " + t : "", c.shadowMapDebug ? "#define SHADOWMAP_DEBUG" : "", c.shadowMapCascade ? "#define SHADOWMAP_CASCADE" : "", "uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"
].join("\n");
v = C("vertex", v + q);
t = C("fragment", t + r);
j.attachShader(z, v);
j.attachShader(z, t);
j.linkProgram(z);
j.getProgramParameter(z, j.LINK_STATUS) || console.error("Could not initialise shader\nVALIDATE_STATUS: " + j.getProgramParameter(z, j.VALIDATE_STATUS) + ", gl error [" +
j.getError() + "]");
j.deleteShader(t);
j.deleteShader(v);
z.uniforms = {};
z.attributes = {};
var w;
t = "viewMatrix modelViewMatrix projectionMatrix normalMatrix modelMatrix cameraPosition morphTargetInfluences".split(" ");
c.useVertexTexture ? t.push("boneTexture") : t.push("boneGlobalMatrices");
for (w in n) t.push(w);
w = t;
t = 0;
for (v = w.length; t < v; t++) n = w[t], z.uniforms[n] = j.getUniformLocation(z, n);
t = "position normal uv uv2 tangent color skinIndex skinWeight lineDistance".split(" ");
for (w = 0; w < c.maxMorphTargets; w++) t.push("morphTarget" +
w);
for (w = 0; w < c.maxMorphNormals; w++) t.push("morphNormal" + w);
for (k in b) t.push(k);
k = t;
w = 0;
for (b = k.length; w < b; w++) t = k[w], z.attributes[t] = j.getAttribLocation(z, t);
z.id = W++;
sa.push({
program: z,
code: p,
usedTimes: 1
});
L.info.memory.programs = sa.length;
k = z
}
a.program = k;
w = a.program.attributes;
if (a.morphTargets) {
a.numSupportedMorphTargets = 0;
b = "morphTarget";
for (k = 0; k < this.maxMorphTargets; k++) z = b + k, 0 <= w[z] && a.numSupportedMorphTargets++
}
if (a.morphNormals) {
a.numSupportedMorphNormals = 0;
b = "morphNormal";
for (k = 0; k < this.maxMorphNormals; k++) z =
b + k, 0 <= w[z] && a.numSupportedMorphNormals++
}
a.uniformsList = [];
for (i in a.uniforms) a.uniformsList.push([a.uniforms[i], i])
};
this.setFaceCulling = function(a, b) {
a === THREE.CullFaceNone ? j.disable(j.CULL_FACE) : (b === THREE.FrontFaceDirectionCW ? j.frontFace(j.CW) : j.frontFace(j.CCW), a === THREE.CullFaceBack ? j.cullFace(j.BACK) : a === THREE.CullFaceFront ? j.cullFace(j.FRONT) : j.cullFace(j.FRONT_AND_BACK), j.enable(j.CULL_FACE))
};
this.setMaterialFaces = function(a) {
var b = a.side === THREE.DoubleSide,
a = a.side === THREE.BackSide;
X !==
b && (b ? j.disable(j.CULL_FACE) : j.enable(j.CULL_FACE), X = b);
fa !== a && (a ? j.frontFace(j.CW) : j.frontFace(j.CCW), fa = a)
};
this.setDepthTest = function(a) {
da !== a && (a ? j.enable(j.DEPTH_TEST) : j.disable(j.DEPTH_TEST), da = a)
};
this.setDepthWrite = function(a) {
xa !== a && (j.depthMask(a), xa = a)
};
this.setBlending = function(a, b, c, d) {
a !== T && (a === THREE.NoBlending ? j.disable(j.BLEND) : a === THREE.AdditiveBlending ? (j.enable(j.BLEND), j.blendEquation(j.FUNC_ADD), j.blendFunc(j.SRC_ALPHA, j.ONE)) : a === THREE.SubtractiveBlending ? (j.enable(j.BLEND),
j.blendEquation(j.FUNC_ADD), j.blendFunc(j.ZERO, j.ONE_MINUS_SRC_COLOR)) : a === THREE.MultiplyBlending ? (j.enable(j.BLEND), j.blendEquation(j.FUNC_ADD), j.blendFunc(j.ZERO, j.SRC_COLOR)) : a === THREE.CustomBlending ? j.enable(j.BLEND) : (j.enable(j.BLEND), j.blendEquationSeparate(j.FUNC_ADD, j.FUNC_ADD), j.blendFuncSeparate(j.SRC_ALPHA, j.ONE_MINUS_SRC_ALPHA, j.ONE, j.ONE_MINUS_SRC_ALPHA)), T = a);
if (a === THREE.CustomBlending) {
if (b !== U && (j.blendEquation(J(b)), U = b), c !== oa || d !== ha) j.blendFunc(J(c), J(d)), oa = c, ha = d
} else ha = oa =
U = null
};
this.setTexture = function(a, b) {
if (a.needsUpdate) {
a.__webglInit || (a.__webglInit = !0, a.addEventListener("dispose", hc), a.__webglTexture = j.createTexture(), L.info.memory.textures++);
j.activeTexture(j.TEXTURE0 + b);
j.bindTexture(j.TEXTURE_2D, a.__webglTexture);
j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL, a.flipY);
j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL, a.premultiplyAlpha);
j.pixelStorei(j.UNPACK_ALIGNMENT, a.unpackAlignment);
var c = a.image,
d = 0 === (c.width & c.width - 1) && 0 === (c.height & c.height - 1),
e = J(a.format),
f = J(a.type);
K(j.TEXTURE_2D, a, d);
var g = a.mipmaps;
if (a instanceof THREE.DataTexture)
if (0 < g.length && d) {
for (var h = 0, i = g.length; h < i; h++) c = g[h], j.texImage2D(j.TEXTURE_2D, h, e, c.width, c.height, 0, e, f, c.data);
a.generateMipmaps = !1
} else j.texImage2D(j.TEXTURE_2D, 0, e, c.width, c.height, 0, e, f, c.data);
else if (a instanceof THREE.CompressedTexture) {
h = 0;
for (i = g.length; h < i; h++) c = g[h], j.compressedTexImage2D(j.TEXTURE_2D, h, e, c.width, c.height, 0, c.data)
} else if (0 < g.length && d) {
h = 0;
for (i = g.length; h < i; h++) c = g[h], j.texImage2D(j.TEXTURE_2D,
h, e, e, f, c);
a.generateMipmaps = !1
} else j.texImage2D(j.TEXTURE_2D, 0, e, e, f, a.image);
a.generateMipmaps && d && j.generateMipmap(j.TEXTURE_2D);
a.needsUpdate = !1;
if (a.onUpdate) a.onUpdate()
} else j.activeTexture(j.TEXTURE0 + b), j.bindTexture(j.TEXTURE_2D, a.__webglTexture)
};
this.setRenderTarget = function(a) {
var b = a instanceof THREE.WebGLRenderTargetCube;
if (a && !a.__webglFramebuffer) {
void 0 === a.depthBuffer && (a.depthBuffer = !0);
void 0 === a.stencilBuffer && (a.stencilBuffer = !0);
a.addEventListener("dispose", mc);
a.__webglTexture =
j.createTexture();
L.info.memory.textures++;
var c = 0 === (a.width & a.width - 1) && 0 === (a.height & a.height - 1),
d = J(a.format),
e = J(a.type);
if (b) {
a.__webglFramebuffer = [];
a.__webglRenderbuffer = [];
j.bindTexture(j.TEXTURE_CUBE_MAP, a.__webglTexture);
K(j.TEXTURE_CUBE_MAP, a, c);
for (var f = 0; 6 > f; f++) {
a.__webglFramebuffer[f] = j.createFramebuffer();
a.__webglRenderbuffer[f] = j.createRenderbuffer();
j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X + f, 0, d, a.width, a.height, 0, d, e, null);
var g = a,
h = j.TEXTURE_CUBE_MAP_POSITIVE_X + f;
j.bindFramebuffer(j.FRAMEBUFFER,
a.__webglFramebuffer[f]);
j.framebufferTexture2D(j.FRAMEBUFFER, j.COLOR_ATTACHMENT0, h, g.__webglTexture, 0);
M(a.__webglRenderbuffer[f], a)
}
c && j.generateMipmap(j.TEXTURE_CUBE_MAP)
} else a.__webglFramebuffer = j.createFramebuffer(), a.__webglRenderbuffer = a.shareDepthFrom ? a.shareDepthFrom.__webglRenderbuffer : j.createRenderbuffer(), j.bindTexture(j.TEXTURE_2D, a.__webglTexture), K(j.TEXTURE_2D, a, c), j.texImage2D(j.TEXTURE_2D, 0, d, a.width, a.height, 0, d, e, null), d = j.TEXTURE_2D, j.bindFramebuffer(j.FRAMEBUFFER, a.__webglFramebuffer),
j.framebufferTexture2D(j.FRAMEBUFFER, j.COLOR_ATTACHMENT0, d, a.__webglTexture, 0), a.shareDepthFrom ? a.depthBuffer && !a.stencilBuffer ? j.framebufferRenderbuffer(j.FRAMEBUFFER, j.DEPTH_ATTACHMENT, j.RENDERBUFFER, a.__webglRenderbuffer) : a.depthBuffer && a.stencilBuffer && j.framebufferRenderbuffer(j.FRAMEBUFFER, j.DEPTH_STENCIL_ATTACHMENT, j.RENDERBUFFER, a.__webglRenderbuffer) : M(a.__webglRenderbuffer, a), c && j.generateMipmap(j.TEXTURE_2D);
b ? j.bindTexture(j.TEXTURE_CUBE_MAP, null) : j.bindTexture(j.TEXTURE_2D, null);
j.bindRenderbuffer(j.RENDERBUFFER,
null);
j.bindFramebuffer(j.FRAMEBUFFER, null)
}
a ? (b = b ? a.__webglFramebuffer[a.activeCubeFace] : a.__webglFramebuffer, c = a.width, a = a.height, e = d = 0) : (b = null, c = Ia, a = Qa, d = ea, e = na);
b !== pa && (j.bindFramebuffer(j.FRAMEBUFFER, b), j.viewport(d, e, c, a), pa = b);
hb = c;
Lb = a
};
this.shadowMapPlugin = new THREE.ShadowMapPlugin;
this.addPrePlugin(this.shadowMapPlugin);
this.addPostPlugin(new THREE.SpritePlugin);
this.addPostPlugin(new THREE.LensFlarePlugin)
};
THREE.WebGLRenderTarget = function(a, b, c) {
this.width = a;
this.height = b;
c = c || {};
this.wrapS = void 0 !== c.wrapS ? c.wrapS : THREE.ClampToEdgeWrapping;
this.wrapT = void 0 !== c.wrapT ? c.wrapT : THREE.ClampToEdgeWrapping;
this.magFilter = void 0 !== c.magFilter ? c.magFilter : THREE.LinearFilter;
this.minFilter = void 0 !== c.minFilter ? c.minFilter : THREE.LinearMipMapLinearFilter;
this.anisotropy = void 0 !== c.anisotropy ? c.anisotropy : 1;
this.offset = new THREE.Vector2(0, 0);
this.repeat = new THREE.Vector2(1, 1);
this.format = void 0 !== c.format ? c.format :
THREE.RGBAFormat;
this.type = void 0 !== c.type ? c.type : THREE.UnsignedByteType;
this.depthBuffer = void 0 !== c.depthBuffer ? c.depthBuffer : !0;
this.stencilBuffer = void 0 !== c.stencilBuffer ? c.stencilBuffer : !0;
this.generateMipmaps = !0;
this.shareDepthFrom = null
};
THREE.WebGLRenderTarget.prototype = {
constructor: THREE.WebGLRenderTarget,
clone: function() {
var a = new THREE.WebGLRenderTarget(this.width, this.height);
a.wrapS = this.wrapS;
a.wrapT = this.wrapT;
a.magFilter = this.magFilter;
a.minFilter = this.minFilter;
a.anisotropy = this.anisotropy;
a.offset.copy(this.offset);
a.repeat.copy(this.repeat);
a.format = this.format;
a.type = this.type;
a.depthBuffer = this.depthBuffer;
a.stencilBuffer = this.stencilBuffer;
a.generateMipmaps = this.generateMipmaps;
a.shareDepthFrom = this.shareDepthFrom;
return a
},
dispose: function() {
this.dispatchEvent({
type: "dispose"
})
}
};
THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);
THREE.WebGLRenderTargetCube = function(a, b, c) {
THREE.WebGLRenderTarget.call(this, a, b, c);
this.activeCubeFace = 0
};
THREE.WebGLRenderTargetCube.prototype = Object.create(THREE.WebGLRenderTarget.prototype);
THREE.RenderableVertex = function() {
this.positionWorld = new THREE.Vector3;
this.positionScreen = new THREE.Vector4;
this.visible = !0
};
THREE.RenderableVertex.prototype.copy = function(a) {
this.positionWorld.copy(a.positionWorld);
this.positionScreen.copy(a.positionScreen)
};
THREE.RenderableFace3 = function() {
this.id = 0;
this.v1 = new THREE.RenderableVertex;
this.v2 = new THREE.RenderableVertex;
this.v3 = new THREE.RenderableVertex;
this.centroidModel = new THREE.Vector3;
this.normalModel = new THREE.Vector3;
this.normalModelView = new THREE.Vector3;
this.vertexNormalsLength = 0;
this.vertexNormalsModel = [new THREE.Vector3, new THREE.Vector3, new THREE.Vector3];
this.vertexNormalsModelView = [new THREE.Vector3, new THREE.Vector3, new THREE.Vector3];
this.material = this.color = null;
this.uvs = [
[]
];
this.z =
0
};
THREE.RenderableFace4 = function() {
this.id = 0;
this.v1 = new THREE.RenderableVertex;
this.v2 = new THREE.RenderableVertex;
this.v3 = new THREE.RenderableVertex;
this.v4 = new THREE.RenderableVertex;
this.centroidModel = new THREE.Vector3;
this.normalModel = new THREE.Vector3;
this.normalModelView = new THREE.Vector3;
this.vertexNormalsLength = 0;
this.vertexNormalsModel = [new THREE.Vector3, new THREE.Vector3, new THREE.Vector3, new THREE.Vector3];
this.vertexNormalsModelView = [new THREE.Vector3, new THREE.Vector3, new THREE.Vector3,
new THREE.Vector3
];
this.material = this.color = null;
this.uvs = [
[]
];
this.z = 0
};
THREE.RenderableObject = function() {
this.id = 0;
this.object = null;
this.z = 0
};
THREE.RenderableParticle = function() {
this.id = 0;
this.object = null;
this.z = this.y = this.x = 0;
this.rotation = null;
this.scale = new THREE.Vector2;
this.material = null
};
THREE.RenderableLine = function() {
this.id = 0;
this.v1 = new THREE.RenderableVertex;
this.v2 = new THREE.RenderableVertex;
this.vertexColors = [new THREE.Color, new THREE.Color];
this.material = null;
this.z = 0
};
THREE.GeometryUtils = {
merge: function(a, b, c) {
var d, e, f = a.vertices.length,
g = b instanceof THREE.Mesh ? b.geometry : b,
h = a.vertices,
i = g.vertices,
k = a.faces,
l = g.faces,
a = a.faceVertexUvs[0],
g = g.faceVertexUvs[0];
void 0 === c && (c = 0);
b instanceof THREE.Mesh && (b.matrixAutoUpdate && b.updateMatrix(), d = b.matrix, e = (new THREE.Matrix3).getNormalMatrix(d));
for (var b = 0, m = i.length; b < m; b++) {
var p = i[b].clone();
d && p.applyMatrix4(d);
h.push(p)
}
b = 0;
for (m = l.length; b < m; b++) {
var p = l[b],
q, t, n = p.vertexNormals,
r = p.vertexColors;
p instanceof
THREE.Face3 ? q = new THREE.Face3(p.a + f, p.b + f, p.c + f) : p instanceof THREE.Face4 && (q = new THREE.Face4(p.a + f, p.b + f, p.c + f, p.d + f));
q.normal.copy(p.normal);
e && q.normal.applyMatrix3(e).normalize();
h = 0;
for (i = n.length; h < i; h++) t = n[h].clone(), e && t.applyMatrix3(e).normalize(), q.vertexNormals.push(t);
q.color.copy(p.color);
h = 0;
for (i = r.length; h < i; h++) t = r[h], q.vertexColors.push(t.clone());
q.materialIndex = p.materialIndex + c;
q.centroid.copy(p.centroid);
d && q.centroid.applyMatrix4(d);
k.push(q)
}
b = 0;
for (m = g.length; b < m; b++) {
c =
g[b];
d = [];
h = 0;
for (i = c.length; h < i; h++) d.push(new THREE.Vector2(c[h].x, c[h].y));
a.push(d)
}
},
removeMaterials: function(a, b) {
for (var c = {}, d = 0, e = b.length; d < e; d++) c[b[d]] = !0;
for (var f, g = [], d = 0, e = a.faces.length; d < e; d++) f = a.faces[d], f.materialIndex in c || g.push(f);
a.faces = g
},
randomPointInTriangle: function() {
var a = new THREE.Vector3;
return function(b, c, d) {
var e = new THREE.Vector3,
f = THREE.Math.random16(),
g = THREE.Math.random16();
1 < f + g && (f = 1 - f, g = 1 - g);
var h = 1 - f - g;
e.copy(b);
e.multiplyScalar(f);
a.copy(c);
a.multiplyScalar(g);
e.add(a);
a.copy(d);
a.multiplyScalar(h);
e.add(a);
return e
}
}(),
randomPointInFace: function(a, b, c) {
var d, e, f;
if (a instanceof THREE.Face3) return d = b.vertices[a.a], e = b.vertices[a.b], f = b.vertices[a.c], THREE.GeometryUtils.randomPointInTriangle(d, e, f);
if (a instanceof THREE.Face4) {
d = b.vertices[a.a];
e = b.vertices[a.b];
f = b.vertices[a.c];
var b = b.vertices[a.d],
g;
c ? a._area1 && a._area2 ? (c = a._area1, g = a._area2) : (c = THREE.GeometryUtils.triangleArea(d, e, b), g = THREE.GeometryUtils.triangleArea(e, f, b), a._area1 = c, a._area2 = g) :
(c = THREE.GeometryUtils.triangleArea(d, e, b), g = THREE.GeometryUtils.triangleArea(e, f, b));
return THREE.Math.random16() * (c + g) < c ? THREE.GeometryUtils.randomPointInTriangle(d, e, b) : THREE.GeometryUtils.randomPointInTriangle(e, f, b)
}
},
randomPointsInGeometry: function(a, b) {
function c(a) {
function b(c, d) {
if (d < c) return c;
var e = c + Math.floor((d - c) / 2);
return k[e] > a ? b(c, e - 1) : k[e] < a ? b(e + 1, d) : e
}
return b(0, k.length - 1)
}
var d, e, f = a.faces,
g = a.vertices,
h = f.length,
i = 0,
k = [],
l, m, p, q;
for (e = 0; e < h; e++) d = f[e], d instanceof THREE.Face3 ?
(l = g[d.a], m = g[d.b], p = g[d.c], d._area = THREE.GeometryUtils.triangleArea(l, m, p)) : d instanceof THREE.Face4 && (l = g[d.a], m = g[d.b], p = g[d.c], q = g[d.d], d._area1 = THREE.GeometryUtils.triangleArea(l, m, q), d._area2 = THREE.GeometryUtils.triangleArea(m, p, q), d._area = d._area1 + d._area2), i += d._area, k[e] = i;
d = [];
for (e = 0; e < b; e++) g = THREE.Math.random16() * i, g = c(g), d[e] = THREE.GeometryUtils.randomPointInFace(f[g], a, !0);
return d
},
triangleArea: function() {
var a = new THREE.Vector3,
b = new THREE.Vector3;
return function(c, d, e) {
a.subVectors(d,
c);
b.subVectors(e, c);
a.cross(b);
return 0.5 * a.length()
}
}(),
center: function(a) {
a.computeBoundingBox();
var b = a.boundingBox,
c = new THREE.Vector3;
c.addVectors(b.min, b.max);
c.multiplyScalar(-0.5);
a.applyMatrix((new THREE.Matrix4).makeTranslation(c.x, c.y, c.z));
a.computeBoundingBox();
return c
},
triangulateQuads: function(a) {
var b, c, d, e, f = [],
g = [],
h = [];
b = 0;
for (c = a.faceUvs.length; b < c; b++) g[b] = [];
b = 0;
for (c = a.faceVertexUvs.length; b < c; b++) h[b] = [];
b = 0;
for (c = a.faces.length; b < c; b++)
if (d = a.faces[b], d instanceof THREE.Face4) {
e =
d.a;
var i = d.b,
k = d.c,
l = d.d,
m = new THREE.Face3,
p = new THREE.Face3;
m.color.copy(d.color);
p.color.copy(d.color);
m.materialIndex = d.materialIndex;
p.materialIndex = d.materialIndex;
m.a = e;
m.b = i;
m.c = l;
p.a = i;
p.b = k;
p.c = l;
4 === d.vertexColors.length && (m.vertexColors[0] = d.vertexColors[0].clone(), m.vertexColors[1] = d.vertexColors[1].clone(), m.vertexColors[2] = d.vertexColors[3].clone(), p.vertexColors[0] = d.vertexColors[1].clone(), p.vertexColors[1] = d.vertexColors[2].clone(), p.vertexColors[2] = d.vertexColors[3].clone());
f.push(m,
p);
d = 0;
for (e = a.faceVertexUvs.length; d < e; d++) a.faceVertexUvs[d].length && (m = a.faceVertexUvs[d][b], i = m[1], k = m[2], l = m[3], m = [m[0].clone(), i.clone(), l.clone()], i = [i.clone(), k.clone(), l.clone()], h[d].push(m, i));
d = 0;
for (e = a.faceUvs.length; d < e; d++) a.faceUvs[d].length && (i = a.faceUvs[d][b], g[d].push(i, i))
} else {
f.push(d);
d = 0;
for (e = a.faceUvs.length; d < e; d++) g[d].push(a.faceUvs[d][b]);
d = 0;
for (e = a.faceVertexUvs.length; d < e; d++) h[d].push(a.faceVertexUvs[d][b])
}
a.faces = f;
a.faceUvs = g;
a.faceVertexUvs = h;
a.computeCentroids();
a.computeFaceNormals();
a.computeVertexNormals();
a.hasTangents && a.computeTangents()
},
setMaterialIndex: function(a, b, c, d) {
a = a.faces;
d = d || a.length - 1;
for (c = c || 0; c <= d; c++) a[c].materialIndex = b
}
};
THREE.ImageUtils = {
crossOrigin: "anonymous",
loadTexture: function(a, b, c) {
var d = new Image,
e = new THREE.Texture(d, b),
b = new THREE.ImageLoader;
b.crossOrigin = this.crossOrigin;
b.load(a, function(a) {
e.image = a;
e.needsUpdate = !0;
c && c(e)
});
e.sourceFile = a;
return e
},
loadCompressedTexture: function(a, b, c, d) {
var e = new THREE.CompressedTexture;
e.mapping = b;
var f = new XMLHttpRequest;
f.onload = function() {
var a = THREE.ImageUtils.parseDDS(f.response, !0);
e.format = a.format;
e.mipmaps = a.mipmaps;
e.image.width = a.width;
e.image.height =
a.height;
e.generateMipmaps = !1;
e.needsUpdate = !0;
c && c(e)
};
f.onerror = d;
f.open("GET", a, !0);
f.responseType = "arraybuffer";
f.send(null);
return e
},
loadTextureCube: function(a, b, c, d) {
var e = [];
e.loadCount = 0;
var f = new THREE.Texture;
f.image = e;
void 0 !== b && (f.mapping = b);
f.flipY = !1;
for (var b = 0, g = a.length; b < g; ++b) {
var h = new Image;
e[b] = h;
h.onload = function() {
e.loadCount += 1;
6 === e.loadCount && (f.needsUpdate = !0, c && c(f))
};
h.onerror = d;
h.crossOrigin = this.crossOrigin;
h.src = a[b]
}
return f
},
loadCompressedTextureCube: function(a,
b, c, d) {
var e = [];
e.loadCount = 0;
var f = new THREE.CompressedTexture;
f.image = e;
void 0 !== b && (f.mapping = b);
f.flipY = !1;
f.generateMipmaps = !1;
b = function(a, b) {
return function() {
var d = THREE.ImageUtils.parseDDS(a.response, !0);
b.format = d.format;
b.mipmaps = d.mipmaps;
b.width = d.width;
b.height = d.height;
e.loadCount += 1;
6 === e.loadCount && (f.format = d.format, f.needsUpdate = !0, c && c(f))
}
};
if (a instanceof Array)
for (var g = 0, h = a.length; g < h; ++g) {
var i = {};
e[g] = i;
var k = new XMLHttpRequest;
k.onload = b(k, i);
k.onerror = d;
i = a[g];
k.open("GET",
i, !0);
k.responseType = "arraybuffer";
k.send(null)
} else k = new XMLHttpRequest, k.onload = function() {
var a = THREE.ImageUtils.parseDDS(k.response, !0);
if (a.isCubemap) {
for (var b = a.mipmaps.length / a.mipmapCount, d = 0; d < b; d++) {
e[d] = {
mipmaps: []
};
for (var g = 0; g < a.mipmapCount; g++) e[d].mipmaps.push(a.mipmaps[d * a.mipmapCount + g]), e[d].format = a.format, e[d].width = a.width, e[d].height = a.height
}
f.format = a.format;
f.needsUpdate = !0;
c && c(f)
}
}, k.onerror = d, k.open("GET", a, !0), k.responseType = "arraybuffer", k.send(null);
return f
},
parseDDS: function(a,
b) {
function c(a) {
return a.charCodeAt(0) + (a.charCodeAt(1) << 8) + (a.charCodeAt(2) << 16) + (a.charCodeAt(3) << 24)
}
var d = {
mipmaps: [],
width: 0,
height: 0,
format: null,
mipmapCount: 1
},
e = c("DXT1"),
f = c("DXT3"),
g = c("DXT5"),
h = new Int32Array(a, 0, 31);
if (542327876 !== h[0]) return console.error("ImageUtils.parseDDS(): Invalid magic number in DDS header"), d;
if (!h[20] & 4) return console.error("ImageUtils.parseDDS(): Unsupported format, must contain a FourCC code"), d;
var i = h[21];
switch (i) {
case e:
e = 8;
d.format = THREE.RGB_S3TC_DXT1_Format;
break;
case f:
e = 16;
d.format = THREE.RGBA_S3TC_DXT3_Format;
break;
case g:
e = 16;
d.format = THREE.RGBA_S3TC_DXT5_Format;
break;
default:
return console.error("ImageUtils.parseDDS(): Unsupported FourCC code: ", String.fromCharCode(i & 255, i >> 8 & 255, i >> 16 & 255, i >> 24 & 255)), d
}
d.mipmapCount = 1;
h[2] & 131072 && !1 !== b && (d.mipmapCount = Math.max(1, h[7]));
d.isCubemap = h[28] & 512 ? !0 : !1;
d.width = h[4];
d.height = h[3];
for (var h = h[1] + 4, f = d.width, g = d.height, i = d.isCubemap ? 6 : 1, k = 0; k < i; k++) {
for (var l = 0; l < d.mipmapCount; l++) {
var m = Math.max(4, f) /
4 * Math.max(4, g) / 4 * e,
p = {
data: new Uint8Array(a, h, m),
width: f,
height: g
};
d.mipmaps.push(p);
h += m;
f = Math.max(0.5 * f, 1);
g = Math.max(0.5 * g, 1)
}
f = d.width;
g = d.height
}
return d
},
getNormalMap: function(a, b) {
var c = function(a) {
var b = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
return [a[0] / b, a[1] / b, a[2] / b]
},
b = b | 1,
d = a.width,
e = a.height,
f = document.createElement("canvas");
f.width = d;
f.height = e;
var g = f.getContext("2d");
g.drawImage(a, 0, 0);
for (var h = g.getImageData(0, 0, d, e).data, i = g.createImageData(d, e), k = i.data, l = 0; l < d; l++)
for (var m =
0; m < e; m++) {
var p = 0 > m - 1 ? 0 : m - 1,
q = m + 1 > e - 1 ? e - 1 : m + 1,
t = 0 > l - 1 ? 0 : l - 1,
n = l + 1 > d - 1 ? d - 1 : l + 1,
r = [],
s = [0, 0, h[4 * (m * d + l)] / 255 * b];
r.push([-1, 0, h[4 * (m * d + t)] / 255 * b]);
r.push([-1, -1, h[4 * (p * d + t)] / 255 * b]);
r.push([0, -1, h[4 * (p * d + l)] / 255 * b]);
r.push([1, -1, h[4 * (p * d + n)] / 255 * b]);
r.push([1, 0, h[4 * (m * d + n)] / 255 * b]);
r.push([1, 1, h[4 * (q * d + n)] / 255 * b]);
r.push([0, 1, h[4 * (q * d + l)] / 255 * b]);
r.push([-1, 1, h[4 * (q * d + t)] / 255 * b]);
p = [];
t = r.length;
for (q = 0; q < t; q++) {
var n = r[q],
v = r[(q + 1) % t],
n = [n[0] - s[0], n[1] - s[1], n[2] - s[2]],
v = [v[0] - s[0], v[1] - s[1], v[2] - s[2]];
p.push(c([n[1] * v[2] - n[2] * v[1], n[2] * v[0] - n[0] * v[2], n[0] * v[1] - n[1] * v[0]]))
}
r = [0, 0, 0];
for (q = 0; q < p.length; q++) r[0] += p[q][0], r[1] += p[q][1], r[2] += p[q][2];
r[0] /= p.length;
r[1] /= p.length;
r[2] /= p.length;
s = 4 * (m * d + l);
k[s] = 255 * ((r[0] + 1) / 2) | 0;
k[s + 1] = 255 * ((r[1] + 1) / 2) | 0;
k[s + 2] = 255 * r[2] | 0;
k[s + 3] = 255
}
g.putImageData(i, 0, 0);
return f
},
generateDataTexture: function(a, b, c) {
for (var d = a * b, e = new Uint8Array(3 * d), f = Math.floor(255 * c.r), g = Math.floor(255 * c.g), c = Math.floor(255 * c.b), h = 0; h < d; h++) e[3 * h] = f, e[3 * h + 1] = g, e[3 * h + 2] = c;
a = new THREE.DataTexture(e,
a, b, THREE.RGBFormat);
a.needsUpdate = !0;
return a
}
};
THREE.SceneUtils = {
createMultiMaterialObject: function(a, b) {
for (var c = new THREE.Object3D, d = 0, e = b.length; d < e; d++) c.add(new THREE.Mesh(a, b[d]));
return c
},
detach: function(a, b, c) {
a.applyMatrix(b.matrixWorld);
b.remove(a);
c.add(a)
},
attach: function(a, b, c) {
var d = new THREE.Matrix4;
d.getInverse(c.matrixWorld);
a.applyMatrix(d);
b.remove(a);
c.add(a)
}
};
THREE.FontUtils = {
faces: {},
face: "helvetiker",
weight: "normal",
style: "normal",
size: 150,
divisions: 10,
getFace: function() {
return this.faces[this.face][this.weight][this.style]
},
loadFace: function(a) {
var b = a.familyName.toLowerCase();
this.faces[b] = this.faces[b] || {};
this.faces[b][a.cssFontWeight] = this.faces[b][a.cssFontWeight] || {};
this.faces[b][a.cssFontWeight][a.cssFontStyle] = a;
return this.faces[b][a.cssFontWeight][a.cssFontStyle] = a
},
drawText: function(a) {
for (var b = this.getFace(), c = this.size / b.resolution, d =
0, e = String(a).split(""), f = e.length, g = [], a = 0; a < f; a++) {
var h = new THREE.Path,
h = this.extractGlyphPoints(e[a], b, c, d, h),
d = d + h.offset;
g.push(h.path)
}
return {
paths: g,
offset: d / 2
}
},
extractGlyphPoints: function(a, b, c, d, e) {
var f = [],
g, h, i, k, l, m, p, q, t, n, r, s = b.glyphs[a] || b.glyphs["?"];
if (s) {
if (s.o) {
b = s._cachedOutline || (s._cachedOutline = s.o.split(" "));
k = b.length;
for (a = 0; a < k;) switch (i = b[a++], i) {
case "m":
i = b[a++] * c + d;
l = b[a++] * c;
e.moveTo(i, l);
break;
case "l":
i = b[a++] * c + d;
l = b[a++] * c;
e.lineTo(i, l);
break;
case "q":
i = b[a++] *
c + d;
l = b[a++] * c;
q = b[a++] * c + d;
t = b[a++] * c;
e.quadraticCurveTo(q, t, i, l);
if (g = f[f.length - 1]) {
m = g.x;
p = g.y;
g = 1;
for (h = this.divisions; g <= h; g++) {
var v = g / h;
THREE.Shape.Utils.b2(v, m, q, i);
THREE.Shape.Utils.b2(v, p, t, l)
}
}
break;
case "b":
if (i = b[a++] * c + d, l = b[a++] * c, q = b[a++] * c + d, t = b[a++] * -c, n = b[a++] * c + d, r = b[a++] * -c, e.bezierCurveTo(i, l, q, t, n, r), g = f[f.length - 1]) {
m = g.x;
p = g.y;
g = 1;
for (h = this.divisions; g <= h; g++) v = g / h, THREE.Shape.Utils.b3(v, m, q, n, i), THREE.Shape.Utils.b3(v, p, t, r, l)
}
}
}
return {
offset: s.ha * c,
path: e
}
}
}
};
THREE.FontUtils.generateShapes = function(a, b) {
var b = b || {},
c = void 0 !== b.curveSegments ? b.curveSegments : 4,
d = void 0 !== b.font ? b.font : "helvetiker",
e = void 0 !== b.weight ? b.weight : "normal",
f = void 0 !== b.style ? b.style : "normal";
THREE.FontUtils.size = void 0 !== b.size ? b.size : 100;
THREE.FontUtils.divisions = c;
THREE.FontUtils.face = d;
THREE.FontUtils.weight = e;
THREE.FontUtils.style = f;
c = THREE.FontUtils.drawText(a).paths;
d = [];
e = 0;
for (f = c.length; e < f; e++) Array.prototype.push.apply(d, c[e].toShapes());
return d
};
(function(a) {
var b = function(a) {
for (var b = a.length, e = 0, f = b - 1, g = 0; g < b; f = g++) e += a[f].x * a[g].y - a[g].x * a[f].y;
return 0.5 * e
};
a.Triangulate = function(a, d) {
var e = a.length;
if (3 > e) return null;
var f = [],
g = [],
h = [],
i, k, l;
if (0 < b(a))
for (k = 0; k < e; k++) g[k] = k;
else
for (k = 0; k < e; k++) g[k] = e - 1 - k;
var m = 2 * e;
for (k = e - 1; 2 < e;) {
if (0 >= m--) {
console.log("Warning, unable to triangulate polygon!");
break
}
i = k;
e <= i && (i = 0);
k = i + 1;
e <= k && (k = 0);
l = k + 1;
e <= l && (l = 0);
var p;
a: {
var q = p = void 0,
t = void 0,
n = void 0,
r = void 0,
s = void 0,
v = void 0,
z = void 0,
H =
void 0,
q = a[g[i]].x,
t = a[g[i]].y,
n = a[g[k]].x,
r = a[g[k]].y,
s = a[g[l]].x,
v = a[g[l]].y;
if (1E-10 > (n - q) * (v - t) - (r - t) * (s - q)) p = !1;
else {
var B = void 0,
G = void 0,
I = void 0,
F = void 0,
A = void 0,
N = void 0,
C = void 0,
K = void 0,
M = void 0,
y = void 0,
M = K = C = H = z = void 0,
B = s - n,
G = v - r,
I = q - s,
F = t - v,
A = n - q,
N = r - t;
for (p = 0; p < e; p++)
if (!(p === i || p === k || p === l))
if (z = a[g[p]].x, H = a[g[p]].y, C = z - q, K = H - t, M = z - n, y = H - r, z -= s, H -= v, M = B * y - G * M, C = A * K - N * C, K = I * H - F * z, 0 <= M && 0 <= K && 0 <= C) {
p = !1;
break a
}
p = !0
}
}
if (p) {
f.push([a[g[i]], a[g[k]], a[g[l]]]);
h.push([g[i], g[k], g[l]]);
i = k;
for (l = k + 1; l < e; i++, l++) g[i] = g[l];
e--;
m = 2 * e
}
}
return d ? h : f
};
a.Triangulate.area = b;
return a
})(THREE.FontUtils);
self._typeface_js = {
faces: THREE.FontUtils.faces,
loadFace: THREE.FontUtils.loadFace
};
THREE.typeface_js = self._typeface_js;
THREE.Curve = function() {};
THREE.Curve.prototype.getPoint = function() {
console.log("Warning, getPoint() not implemented!");
return null
};
THREE.Curve.prototype.getPointAt = function(a) {
a = this.getUtoTmapping(a);
return this.getPoint(a)
};
THREE.Curve.prototype.getPoints = function(a) {
a || (a = 5);
var b, c = [];
for (b = 0; b <= a; b++) c.push(this.getPoint(b / a));
return c
};
THREE.Curve.prototype.getSpacedPoints = function(a) {
a || (a = 5);
var b, c = [];
for (b = 0; b <= a; b++) c.push(this.getPointAt(b / a));
return c
};
THREE.Curve.prototype.getLength = function() {
var a = this.getLengths();
return a[a.length - 1]
};
THREE.Curve.prototype.getLengths = function(a) {
a || (a = this.__arcLengthDivisions ? this.__arcLengthDivisions : 200);
if (this.cacheArcLengths && this.cacheArcLengths.length == a + 1 && !this.needsUpdate) return this.cacheArcLengths;
this.needsUpdate = !1;
var b = [],
c, d = this.getPoint(0),
e, f = 0;
b.push(0);
for (e = 1; e <= a; e++) c = this.getPoint(e / a), f += c.distanceTo(d), b.push(f), d = c;
return this.cacheArcLengths = b
};
THREE.Curve.prototype.updateArcLengths = function() {
this.needsUpdate = !0;
this.getLengths()
};
THREE.Curve.prototype.getUtoTmapping = function(a, b) {
var c = this.getLengths(),
d = 0,
e = c.length,
f;
f = b ? b : a * c[e - 1];
for (var g = 0, h = e - 1, i; g <= h;)
if (d = Math.floor(g + (h - g) / 2), i = c[d] - f, 0 > i) g = d + 1;
else if (0 < i) h = d - 1;
else {
h = d;
break
}
d = h;
if (c[d] == f) return d / (e - 1);
g = c[d];
return c = (d + (f - g) / (c[d + 1] - g)) / (e - 1)
};
THREE.Curve.prototype.getTangent = function(a) {
var b = a - 1E-4,
a = a + 1E-4;
0 > b && (b = 0);
1 < a && (a = 1);
b = this.getPoint(b);
return this.getPoint(a).clone().sub(b).normalize()
};
THREE.Curve.prototype.getTangentAt = function(a) {
a = this.getUtoTmapping(a);
return this.getTangent(a)
};
THREE.Curve.Utils = {
tangentQuadraticBezier: function(a, b, c, d) {
return 2 * (1 - a) * (c - b) + 2 * a * (d - c)
},
tangentCubicBezier: function(a, b, c, d, e) {
return -3 * b * (1 - a) * (1 - a) + 3 * c * (1 - a) * (1 - a) - 6 * a * c * (1 - a) + 6 * a * d * (1 - a) - 3 * a * a * d + 3 * a * a * e
},
tangentSpline: function(a) {
return 6 * a * a - 6 * a + (3 * a * a - 4 * a + 1) + (-6 * a * a + 6 * a) + (3 * a * a - 2 * a)
},
interpolate: function(a, b, c, d, e) {
var a = 0.5 * (c - a),
d = 0.5 * (d - b),
f = e * e;
return (2 * b - 2 * c + a + d) * e * f + (-3 * b + 3 * c - 2 * a - d) * f + a * e + b
}
};
THREE.Curve.create = function(a, b) {
a.prototype = Object.create(THREE.Curve.prototype);
a.prototype.getPoint = b;
return a
};
THREE.CurvePath = function() {
this.curves = [];
this.bends = [];
this.autoClose = !1
};
THREE.CurvePath.prototype = Object.create(THREE.Curve.prototype);
THREE.CurvePath.prototype.add = function(a) {
this.curves.push(a)
};
THREE.CurvePath.prototype.checkConnection = function() {};
THREE.CurvePath.prototype.closePath = function() {
var a = this.curves[0].getPoint(0),
b = this.curves[this.curves.length - 1].getPoint(1);
a.equals(b) || this.curves.push(new THREE.LineCurve(b, a))
};
THREE.CurvePath.prototype.getPoint = function(a) {
for (var b = a * this.getLength(), c = this.getCurveLengths(), a = 0; a < c.length;) {
if (c[a] >= b) return b = c[a] - b, a = this.curves[a], b = 1 - b / a.getLength(), a.getPointAt(b);
a++
}
return null
};
THREE.CurvePath.prototype.getLength = function() {
var a = this.getCurveLengths();
return a[a.length - 1]
};
THREE.CurvePath.prototype.getCurveLengths = function() {
if (this.cacheLengths && this.cacheLengths.length == this.curves.length) return this.cacheLengths;
var a = [],
b = 0,
c, d = this.curves.length;
for (c = 0; c < d; c++) b += this.curves[c].getLength(), a.push(b);
return this.cacheLengths = a
};
THREE.CurvePath.prototype.getBoundingBox = function() {
var a = this.getPoints(),
b, c, d, e, f, g;
b = c = Number.NEGATIVE_INFINITY;
e = f = Number.POSITIVE_INFINITY;
var h, i, k, l, m = a[0] instanceof THREE.Vector3;
l = m ? new THREE.Vector3 : new THREE.Vector2;
i = 0;
for (k = a.length; i < k; i++) h = a[i], h.x > b ? b = h.x : h.x < e && (e = h.x), h.y > c ? c = h.y : h.y < f && (f = h.y), m && (h.z > d ? d = h.z : h.z < g && (g = h.z)), l.add(h);
a = {
minX: e,
minY: f,
maxX: b,
maxY: c,
centroid: l.divideScalar(k)
};
m && (a.maxZ = d, a.minZ = g);
return a
};
THREE.CurvePath.prototype.createPointsGeometry = function(a) {
a = this.getPoints(a, !0);
return this.createGeometry(a)
};
THREE.CurvePath.prototype.createSpacedPointsGeometry = function(a) {
a = this.getSpacedPoints(a, !0);
return this.createGeometry(a)
};
THREE.CurvePath.prototype.createGeometry = function(a) {
for (var b = new THREE.Geometry, c = 0; c < a.length; c++) b.vertices.push(new THREE.Vector3(a[c].x, a[c].y, a[c].z || 0));
return b
};
THREE.CurvePath.prototype.addWrapPath = function(a) {
this.bends.push(a)
};
THREE.CurvePath.prototype.getTransformedPoints = function(a, b) {
var c = this.getPoints(a),
d, e;
b || (b = this.bends);
d = 0;
for (e = b.length; d < e; d++) c = this.getWrapPoints(c, b[d]);
return c
};
THREE.CurvePath.prototype.getTransformedSpacedPoints = function(a, b) {
var c = this.getSpacedPoints(a),
d, e;
b || (b = this.bends);
d = 0;
for (e = b.length; d < e; d++) c = this.getWrapPoints(c, b[d]);
return c
};
THREE.CurvePath.prototype.getWrapPoints = function(a, b) {
var c = this.getBoundingBox(),
d, e, f, g, h, i;
d = 0;
for (e = a.length; d < e; d++) f = a[d], g = f.x, h = f.y, i = g / c.maxX, i = b.getUtoTmapping(i, g), g = b.getPoint(i), h = b.getNormalVector(i).multiplyScalar(h), f.x = g.x + h.x, f.y = g.y + h.y;
return a
};
THREE.Gyroscope = function() {
THREE.Object3D.call(this)
};
THREE.Gyroscope.prototype = Object.create(THREE.Object3D.prototype);
THREE.Gyroscope.prototype.updateMatrixWorld = function(a) {
this.matrixAutoUpdate && this.updateMatrix();
if (this.matrixWorldNeedsUpdate || a) this.parent ? (this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorld.decompose(this.translationWorld, this.quaternionWorld, this.scaleWorld), this.matrix.decompose(this.translationObject, this.quaternionObject, this.scaleObject), this.matrixWorld.compose(this.translationWorld, this.quaternionObject, this.scaleWorld)) : this.matrixWorld.copy(this.matrix),
this.matrixWorldNeedsUpdate = !1, a = !0;
for (var b = 0, c = this.children.length; b < c; b++) this.children[b].updateMatrixWorld(a)
};
THREE.Gyroscope.prototype.translationWorld = new THREE.Vector3;
THREE.Gyroscope.prototype.translationObject = new THREE.Vector3;
THREE.Gyroscope.prototype.quaternionWorld = new THREE.Quaternion;
THREE.Gyroscope.prototype.quaternionObject = new THREE.Quaternion;
THREE.Gyroscope.prototype.scaleWorld = new THREE.Vector3;
THREE.Gyroscope.prototype.scaleObject = new THREE.Vector3;
THREE.Path = function(a) {
THREE.CurvePath.call(this);
this.actions = [];
a && this.fromPoints(a)
};
THREE.Path.prototype = Object.create(THREE.CurvePath.prototype);
THREE.PathActions = {
MOVE_TO: "moveTo",
LINE_TO: "lineTo",
QUADRATIC_CURVE_TO: "quadraticCurveTo",
BEZIER_CURVE_TO: "bezierCurveTo",
CSPLINE_THRU: "splineThru",
ARC: "arc",
ELLIPSE: "ellipse"
};
THREE.Path.prototype.fromPoints = function(a) {
this.moveTo(a[0].x, a[0].y);
for (var b = 1, c = a.length; b < c; b++) this.lineTo(a[b].x, a[b].y)
};
THREE.Path.prototype.moveTo = function(a, b) {
var c = Array.prototype.slice.call(arguments);
this.actions.push({
action: THREE.PathActions.MOVE_TO,
args: c
})
};
THREE.Path.prototype.lineTo = function(a, b) {
var c = Array.prototype.slice.call(arguments),
d = this.actions[this.actions.length - 1].args,
d = new THREE.LineCurve(new THREE.Vector2(d[d.length - 2], d[d.length - 1]), new THREE.Vector2(a, b));
this.curves.push(d);
this.actions.push({
action: THREE.PathActions.LINE_TO,
args: c
})
};
THREE.Path.prototype.quadraticCurveTo = function(a, b, c, d) {
var e = Array.prototype.slice.call(arguments),
f = this.actions[this.actions.length - 1].args,
f = new THREE.QuadraticBezierCurve(new THREE.Vector2(f[f.length - 2], f[f.length - 1]), new THREE.Vector2(a, b), new THREE.Vector2(c, d));
this.curves.push(f);
this.actions.push({
action: THREE.PathActions.QUADRATIC_CURVE_TO,
args: e
})
};
THREE.Path.prototype.bezierCurveTo = function(a, b, c, d, e, f) {
var g = Array.prototype.slice.call(arguments),
h = this.actions[this.actions.length - 1].args,
h = new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length - 2], h[h.length - 1]), new THREE.Vector2(a, b), new THREE.Vector2(c, d), new THREE.Vector2(e, f));
this.curves.push(h);
this.actions.push({
action: THREE.PathActions.BEZIER_CURVE_TO,
args: g
})
};
THREE.Path.prototype.splineThru = function(a) {
var b = Array.prototype.slice.call(arguments),
c = this.actions[this.actions.length - 1].args,
c = [new THREE.Vector2(c[c.length - 2], c[c.length - 1])];
Array.prototype.push.apply(c, a);
c = new THREE.SplineCurve(c);
this.curves.push(c);
this.actions.push({
action: THREE.PathActions.CSPLINE_THRU,
args: b
})
};
THREE.Path.prototype.arc = function(a, b, c, d, e, f) {
var g = this.actions[this.actions.length - 1].args;
this.absarc(a + g[g.length - 2], b + g[g.length - 1], c, d, e, f)
};
THREE.Path.prototype.absarc = function(a, b, c, d, e, f) {
this.absellipse(a, b, c, c, d, e, f)
};
THREE.Path.prototype.ellipse = function(a, b, c, d, e, f, g) {
var h = this.actions[this.actions.length - 1].args;
this.absellipse(a + h[h.length - 2], b + h[h.length - 1], c, d, e, f, g)
};
THREE.Path.prototype.absellipse = function(a, b, c, d, e, f, g) {
var h = Array.prototype.slice.call(arguments),
i = new THREE.EllipseCurve(a, b, c, d, e, f, g);
this.curves.push(i);
i = i.getPoint(g ? 1 : 0);
h.push(i.x);
h.push(i.y);
this.actions.push({
action: THREE.PathActions.ELLIPSE,
args: h
})
};
THREE.Path.prototype.getSpacedPoints = function(a) {
a || (a = 40);
for (var b = [], c = 0; c < a; c++) b.push(this.getPoint(c / a));
return b
};
THREE.Path.prototype.getPoints = function(a, b) {
if (this.useSpacedPoints) return console.log("tata"), this.getSpacedPoints(a, b);
var a = a || 12,
c = [],
d, e, f, g, h, i, k, l, m, p, q, t, n;
d = 0;
for (e = this.actions.length; d < e; d++) switch (f = this.actions[d], g = f.action, f = f.args, g) {
case THREE.PathActions.MOVE_TO:
c.push(new THREE.Vector2(f[0], f[1]));
break;
case THREE.PathActions.LINE_TO:
c.push(new THREE.Vector2(f[0], f[1]));
break;
case THREE.PathActions.QUADRATIC_CURVE_TO:
h = f[2];
i = f[3];
m = f[0];
p = f[1];
0 < c.length ? (g = c[c.length - 1], q = g.x,
t = g.y) : (g = this.actions[d - 1].args, q = g[g.length - 2], t = g[g.length - 1]);
for (f = 1; f <= a; f++) n = f / a, g = THREE.Shape.Utils.b2(n, q, m, h), n = THREE.Shape.Utils.b2(n, t, p, i), c.push(new THREE.Vector2(g, n));
break;
case THREE.PathActions.BEZIER_CURVE_TO:
h = f[4];
i = f[5];
m = f[0];
p = f[1];
k = f[2];
l = f[3];
0 < c.length ? (g = c[c.length - 1], q = g.x, t = g.y) : (g = this.actions[d - 1].args, q = g[g.length - 2], t = g[g.length - 1]);
for (f = 1; f <= a; f++) n = f / a, g = THREE.Shape.Utils.b3(n, q, m, k, h), n = THREE.Shape.Utils.b3(n, t, p, l, i), c.push(new THREE.Vector2(g, n));
break;
case THREE.PathActions.CSPLINE_THRU:
g =
this.actions[d - 1].args;
n = [new THREE.Vector2(g[g.length - 2], g[g.length - 1])];
g = a * f[0].length;
n = n.concat(f[0]);
n = new THREE.SplineCurve(n);
for (f = 1; f <= g; f++) c.push(n.getPointAt(f / g));
break;
case THREE.PathActions.ARC:
h = f[0];
i = f[1];
p = f[2];
k = f[3];
g = f[4];
m = !!f[5];
q = g - k;
t = 2 * a;
for (f = 1; f <= t; f++) n = f / t, m || (n = 1 - n), n = k + n * q, g = h + p * Math.cos(n), n = i + p * Math.sin(n), c.push(new THREE.Vector2(g, n));
break;
case THREE.PathActions.ELLIPSE:
h = f[0];
i = f[1];
p = f[2];
l = f[3];
k = f[4];
g = f[5];
m = !!f[6];
q = g - k;
t = 2 * a;
for (f = 1; f <= t; f++) n = f / t, m ||
(n = 1 - n), n = k + n * q, g = h + p * Math.cos(n), n = i + l * Math.sin(n), c.push(new THREE.Vector2(g, n))
}
d = c[c.length - 1];
1E-10 > Math.abs(d.x - c[0].x) && 1E-10 > Math.abs(d.y - c[0].y) && c.splice(c.length - 1, 1);
b && c.push(c[0]);
return c
};
THREE.Path.prototype.toShapes = function(a) {
var b, c, d, e, f = [],
g = new THREE.Path;
b = 0;
for (c = this.actions.length; b < c; b++) d = this.actions[b], e = d.args, d = d.action, d == THREE.PathActions.MOVE_TO && 0 != g.actions.length && (f.push(g), g = new THREE.Path), g[d].apply(g, e);
0 != g.actions.length && f.push(g);
if (0 == f.length) return [];
var h;
e = [];
if (1 == f.length) return d = f[0], h = new THREE.Shape, h.actions = d.actions, h.curves = d.curves, e.push(h), e;
b = !THREE.Shape.Utils.isClockWise(f[0].getPoints());
if (a ? !b : b) {
h = new THREE.Shape;
b = 0;
for (c =
f.length; b < c; b++) d = f[b], g = THREE.Shape.Utils.isClockWise(d.getPoints()), (g = a ? !g : g) ? (h.actions = d.actions, h.curves = d.curves, e.push(h), h = new THREE.Shape) : h.holes.push(d)
} else {
h = void 0;
b = 0;
for (c = f.length; b < c; b++) d = f[b], g = THREE.Shape.Utils.isClockWise(d.getPoints()), (g = a ? !g : g) ? (h && e.push(h), h = new THREE.Shape, h.actions = d.actions, h.curves = d.curves) : h.holes.push(d);
e.push(h)
}
return e
};
THREE.Shape = function() {
THREE.Path.apply(this, arguments);
this.holes = []
};
THREE.Shape.prototype = Object.create(THREE.Path.prototype);
THREE.Shape.prototype.extrude = function(a) {
return new THREE.ExtrudeGeometry(this, a)
};
THREE.Shape.prototype.makeGeometry = function(a) {
return new THREE.ShapeGeometry(this, a)
};
THREE.Shape.prototype.getPointsHoles = function(a) {
var b, c = this.holes.length,
d = [];
for (b = 0; b < c; b++) d[b] = this.holes[b].getTransformedPoints(a, this.bends);
return d
};
THREE.Shape.prototype.getSpacedPointsHoles = function(a) {
var b, c = this.holes.length,
d = [];
for (b = 0; b < c; b++) d[b] = this.holes[b].getTransformedSpacedPoints(a, this.bends);
return d
};
THREE.Shape.prototype.extractAllPoints = function(a) {
return {
shape: this.getTransformedPoints(a),
holes: this.getPointsHoles(a)
}
};
THREE.Shape.prototype.extractPoints = function(a) {
return this.useSpacedPoints ? this.extractAllSpacedPoints(a) : this.extractAllPoints(a)
};
THREE.Shape.prototype.extractAllSpacedPoints = function(a) {
return {
shape: this.getTransformedSpacedPoints(a),
holes: this.getSpacedPointsHoles(a)
}
};
THREE.Shape.Utils = {
removeHoles: function(a, b) {
var c = a.concat(),
d = c.concat(),
e, f, g, h, i, k, l, m, p, q, t = [];
for (i = 0; i < b.length; i++) {
k = b[i];
Array.prototype.push.apply(d, k);
f = Number.POSITIVE_INFINITY;
for (e = 0; e < k.length; e++) {
p = k[e];
q = [];
for (m = 0; m < c.length; m++) l = c[m], l = p.distanceToSquared(l), q.push(l), l < f && (f = l, g = e, h = m)
}
e = 0 <= h - 1 ? h - 1 : c.length - 1;
f = 0 <= g - 1 ? g - 1 : k.length - 1;
var n = [k[g], c[h], c[e]];
m = THREE.FontUtils.Triangulate.area(n);
var r = [k[g], k[f], c[h]];
p = THREE.FontUtils.Triangulate.area(r);
q = h;
l = g;
h += 1;
g += -1;
0 >
h && (h += c.length);
h %= c.length;
0 > g && (g += k.length);
g %= k.length;
e = 0 <= h - 1 ? h - 1 : c.length - 1;
f = 0 <= g - 1 ? g - 1 : k.length - 1;
n = [k[g], c[h], c[e]];
n = THREE.FontUtils.Triangulate.area(n);
r = [k[g], k[f], c[h]];
r = THREE.FontUtils.Triangulate.area(r);
m + p > n + r && (h = q, g = l, 0 > h && (h += c.length), h %= c.length, 0 > g && (g += k.length), g %= k.length, e = 0 <= h - 1 ? h - 1 : c.length - 1, f = 0 <= g - 1 ? g - 1 : k.length - 1);
m = c.slice(0, h);
p = c.slice(h);
q = k.slice(g);
l = k.slice(0, g);
f = [k[g], k[f], c[h]];
t.push([k[g], c[h], c[e]]);
t.push(f);
c = m.concat(q).concat(l).concat(p)
}
return {
shape: c,
isolatedPts: t,
allpoints: d
}
},
triangulateShape: function(a, b) {
var c = THREE.Shape.Utils.removeHoles(a, b),
d = c.allpoints,
e = c.isolatedPts,
c = THREE.FontUtils.Triangulate(c.shape, !1),
f, g, h, i, k = {};
f = 0;
for (g = d.length; f < g; f++) i = d[f].x + ":" + d[f].y, void 0 !== k[i] && console.log("Duplicate point", i), k[i] = f;
f = 0;
for (g = c.length; f < g; f++) {
h = c[f];
for (d = 0; 3 > d; d++) i = h[d].x + ":" + h[d].y, i = k[i], void 0 !== i && (h[d] = i)
}
f = 0;
for (g = e.length; f < g; f++) {
h = e[f];
for (d = 0; 3 > d; d++) i = h[d].x + ":" + h[d].y, i = k[i], void 0 !== i && (h[d] = i)
}
return c.concat(e)
},
isClockWise: function(a) {
return 0 > THREE.FontUtils.Triangulate.area(a)
},
b2p0: function(a, b) {
var c = 1 - a;
return c * c * b
},
b2p1: function(a, b) {
return 2 * (1 - a) * a * b
},
b2p2: function(a, b) {
return a * a * b
},
b2: function(a, b, c, d) {
return this.b2p0(a, b) + this.b2p1(a, c) + this.b2p2(a, d)
},
b3p0: function(a, b) {
var c = 1 - a;
return c * c * c * b
},
b3p1: function(a, b) {
var c = 1 - a;
return 3 * c * c * a * b
},
b3p2: function(a, b) {
return 3 * (1 - a) * a * a * b
},
b3p3: function(a, b) {
return a * a * a * b
},
b3: function(a, b, c, d, e) {
return this.b3p0(a, b) + this.b3p1(a, c) + this.b3p2(a, d) +
this.b3p3(a, e)
}
};
THREE.LineCurve = function(a, b) {
this.v1 = a;
this.v2 = b
};
THREE.LineCurve.prototype = Object.create(THREE.Curve.prototype);
THREE.LineCurve.prototype.getPoint = function(a) {
var b = this.v2.clone().sub(this.v1);
b.multiplyScalar(a).add(this.v1);
return b
};
THREE.LineCurve.prototype.getPointAt = function(a) {
return this.getPoint(a)
};
THREE.LineCurve.prototype.getTangent = function() {
return this.v2.clone().sub(this.v1).normalize()
};
THREE.QuadraticBezierCurve = function(a, b, c) {
this.v0 = a;
this.v1 = b;
this.v2 = c
};
THREE.QuadraticBezierCurve.prototype = Object.create(THREE.Curve.prototype);
THREE.QuadraticBezierCurve.prototype.getPoint = function(a) {
var b;
b = THREE.Shape.Utils.b2(a, this.v0.x, this.v1.x, this.v2.x);
a = THREE.Shape.Utils.b2(a, this.v0.y, this.v1.y, this.v2.y);
return new THREE.Vector2(b, a)
};
THREE.QuadraticBezierCurve.prototype.getTangent = function(a) {
var b;
b = THREE.Curve.Utils.tangentQuadraticBezier(a, this.v0.x, this.v1.x, this.v2.x);
a = THREE.Curve.Utils.tangentQuadraticBezier(a, this.v0.y, this.v1.y, this.v2.y);
b = new THREE.Vector2(b, a);
b.normalize();
return b
};
THREE.CubicBezierCurve = function(a, b, c, d) {
this.v0 = a;
this.v1 = b;
this.v2 = c;
this.v3 = d
};
THREE.CubicBezierCurve.prototype = Object.create(THREE.Curve.prototype);
THREE.CubicBezierCurve.prototype.getPoint = function(a) {
var b;
b = THREE.Shape.Utils.b3(a, this.v0.x, this.v1.x, this.v2.x, this.v3.x);
a = THREE.Shape.Utils.b3(a, this.v0.y, this.v1.y, this.v2.y, this.v3.y);
return new THREE.Vector2(b, a)
};
THREE.CubicBezierCurve.prototype.getTangent = function(a) {
var b;
b = THREE.Curve.Utils.tangentCubicBezier(a, this.v0.x, this.v1.x, this.v2.x, this.v3.x);
a = THREE.Curve.Utils.tangentCubicBezier(a, this.v0.y, this.v1.y, this.v2.y, this.v3.y);
b = new THREE.Vector2(b, a);
b.normalize();
return b
};
THREE.SplineCurve = function(a) {
this.points = void 0 == a ? [] : a
};
THREE.SplineCurve.prototype = Object.create(THREE.Curve.prototype);
THREE.SplineCurve.prototype.getPoint = function(a) {
var b = new THREE.Vector2,
c = [],
d = this.points,
e;
e = (d.length - 1) * a;
a = Math.floor(e);
e -= a;
c[0] = 0 == a ? a : a - 1;
c[1] = a;
c[2] = a > d.length - 2 ? d.length - 1 : a + 1;
c[3] = a > d.length - 3 ? d.length - 1 : a + 2;
b.x = THREE.Curve.Utils.interpolate(d[c[0]].x, d[c[1]].x, d[c[2]].x, d[c[3]].x, e);
b.y = THREE.Curve.Utils.interpolate(d[c[0]].y, d[c[1]].y, d[c[2]].y, d[c[3]].y, e);
return b
};
THREE.EllipseCurve = function(a, b, c, d, e, f, g) {
this.aX = a;
this.aY = b;
this.xRadius = c;
this.yRadius = d;
this.aStartAngle = e;
this.aEndAngle = f;
this.aClockwise = g
};
THREE.EllipseCurve.prototype = Object.create(THREE.Curve.prototype);
THREE.EllipseCurve.prototype.getPoint = function(a) {
var b = this.aEndAngle - this.aStartAngle;
this.aClockwise || (a = 1 - a);
b = this.aStartAngle + a * b;
a = this.aX + this.xRadius * Math.cos(b);
b = this.aY + this.yRadius * Math.sin(b);
return new THREE.Vector2(a, b)
};
THREE.ArcCurve = function(a, b, c, d, e, f) {
THREE.EllipseCurve.call(this, a, b, c, c, d, e, f)
};
THREE.ArcCurve.prototype = Object.create(THREE.EllipseCurve.prototype);
THREE.LineCurve3 = THREE.Curve.create(function(a, b) {
this.v1 = a;
this.v2 = b
}, function(a) {
var b = new THREE.Vector3;
b.subVectors(this.v2, this.v1);
b.multiplyScalar(a);
b.add(this.v1);
return b
});
THREE.QuadraticBezierCurve3 = THREE.Curve.create(function(a, b, c) {
this.v0 = a;
this.v1 = b;
this.v2 = c
}, function(a) {
var b, c;
b = THREE.Shape.Utils.b2(a, this.v0.x, this.v1.x, this.v2.x);
c = THREE.Shape.Utils.b2(a, this.v0.y, this.v1.y, this.v2.y);
a = THREE.Shape.Utils.b2(a, this.v0.z, this.v1.z, this.v2.z);
return new THREE.Vector3(b, c, a)
});
THREE.CubicBezierCurve3 = THREE.Curve.create(function(a, b, c, d) {
this.v0 = a;
this.v1 = b;
this.v2 = c;
this.v3 = d
}, function(a) {
var b, c;
b = THREE.Shape.Utils.b3(a, this.v0.x, this.v1.x, this.v2.x, this.v3.x);
c = THREE.Shape.Utils.b3(a, this.v0.y, this.v1.y, this.v2.y, this.v3.y);
a = THREE.Shape.Utils.b3(a, this.v0.z, this.v1.z, this.v2.z, this.v3.z);
return new THREE.Vector3(b, c, a)
});
THREE.SplineCurve3 = THREE.Curve.create(function(a) {
this.points = void 0 == a ? [] : a
}, function(a) {
var b = new THREE.Vector3,
c = [],
d = this.points,
e, a = (d.length - 1) * a;
e = Math.floor(a);
a -= e;
c[0] = 0 == e ? e : e - 1;
c[1] = e;
c[2] = e > d.length - 2 ? d.length - 1 : e + 1;
c[3] = e > d.length - 3 ? d.length - 1 : e + 2;
e = d[c[0]];
var f = d[c[1]],
g = d[c[2]],
c = d[c[3]];
b.x = THREE.Curve.Utils.interpolate(e.x, f.x, g.x, c.x, a);
b.y = THREE.Curve.Utils.interpolate(e.y, f.y, g.y, c.y, a);
b.z = THREE.Curve.Utils.interpolate(e.z, f.z, g.z, c.z, a);
return b
});
THREE.ClosedSplineCurve3 = THREE.Curve.create(function(a) {
this.points = void 0 == a ? [] : a
}, function(a) {
var b = new THREE.Vector3,
c = [],
d = this.points,
e;
e = (d.length - 0) * a;
a = Math.floor(e);
e -= a;
a += 0 < a ? 0 : (Math.floor(Math.abs(a) / d.length) + 1) * d.length;
c[0] = (a - 1) % d.length;
c[1] = a % d.length;
c[2] = (a + 1) % d.length;
c[3] = (a + 2) % d.length;
b.x = THREE.Curve.Utils.interpolate(d[c[0]].x, d[c[1]].x, d[c[2]].x, d[c[3]].x, e);
b.y = THREE.Curve.Utils.interpolate(d[c[0]].y, d[c[1]].y, d[c[2]].y, d[c[3]].y, e);
b.z = THREE.Curve.Utils.interpolate(d[c[0]].z,
d[c[1]].z, d[c[2]].z, d[c[3]].z, e);
return b
});
THREE.AnimationHandler = function() {
var a = [],
b = {},
c = {
update: function(b) {
for (var c = 0; c < a.length; c++) a[c].update(b)
},
addToUpdate: function(b) {
-1 === a.indexOf(b) && a.push(b)
},
removeFromUpdate: function(b) {
b = a.indexOf(b); - 1 !== b && a.splice(b, 1)
},
add: function(a) {
void 0 !== b[a.name] && console.log("THREE.AnimationHandler.add: Warning! " + a.name + " already exists in library. Overwriting.");
b[a.name] = a;
if (!0 !== a.initialized) {
for (var c = 0; c < a.hierarchy.length; c++) {
for (var d = 0; d < a.hierarchy[c].keys.length; d++)
if (0 > a.hierarchy[c].keys[d].time &&
(a.hierarchy[c].keys[d].time = 0), void 0 !== a.hierarchy[c].keys[d].rot && !(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)) {
var h = a.hierarchy[c].keys[d].rot;
a.hierarchy[c].keys[d].rot = new THREE.Quaternion(h[0], h[1], h[2], h[3])
}
if (a.hierarchy[c].keys.length && void 0 !== a.hierarchy[c].keys[0].morphTargets) {
h = {};
for (d = 0; d < a.hierarchy[c].keys.length; d++)
for (var i = 0; i < a.hierarchy[c].keys[d].morphTargets.length; i++) {
var k = a.hierarchy[c].keys[d].morphTargets[i];
h[k] = -1
}
a.hierarchy[c].usedMorphTargets = h;
for (d = 0; d < a.hierarchy[c].keys.length; d++) {
var l = {};
for (k in h) {
for (i = 0; i < a.hierarchy[c].keys[d].morphTargets.length; i++)
if (a.hierarchy[c].keys[d].morphTargets[i] === k) {
l[k] = a.hierarchy[c].keys[d].morphTargetsInfluences[i];
break
}
i === a.hierarchy[c].keys[d].morphTargets.length && (l[k] = 0)
}
a.hierarchy[c].keys[d].morphTargetsInfluences = l
}
}
for (d = 1; d < a.hierarchy[c].keys.length; d++) a.hierarchy[c].keys[d].time === a.hierarchy[c].keys[d - 1].time && (a.hierarchy[c].keys.splice(d, 1), d--);
for (d = 0; d < a.hierarchy[c].keys.length; d++) a.hierarchy[c].keys[d].index =
d
}
d = parseInt(a.length * a.fps, 10);
a.JIT = {};
a.JIT.hierarchy = [];
for (c = 0; c < a.hierarchy.length; c++) a.JIT.hierarchy.push(Array(d));
a.initialized = !0
}
},
get: function(a) {
if ("string" === typeof a) {
if (b[a]) return b[a];
console.log("THREE.AnimationHandler.get: Couldn't find animation " + a);
return null
}
},
parse: function(a) {
var b = [];
if (a instanceof THREE.SkinnedMesh)
for (var c = 0; c < a.bones.length; c++) b.push(a.bones[c]);
else d(a, b);
return b
}
},
d = function(a, b) {
b.push(a);
for (var c = 0; c < a.children.length; c++) d(a.children[c],
b)
};
c.LINEAR = 0;
c.CATMULLROM = 1;
c.CATMULLROM_FORWARD = 2;
return c
}();
THREE.Animation = function(a, b, c) {
this.root = a;
this.data = THREE.AnimationHandler.get(b);
this.hierarchy = THREE.AnimationHandler.parse(a);
this.currentTime = 0;
this.timeScale = 1;
this.isPlaying = !1;
this.loop = this.isPaused = !0;
this.interpolationType = void 0 !== c ? c : THREE.AnimationHandler.LINEAR;
this.points = [];
this.target = new THREE.Vector3
};
THREE.Animation.prototype.play = function(a, b) {
if (!1 === this.isPlaying) {
this.isPlaying = !0;
this.loop = void 0 !== a ? a : !0;
this.currentTime = void 0 !== b ? b : 0;
var c, d = this.hierarchy.length,
e;
for (c = 0; c < d; c++) {
e = this.hierarchy[c];
e.matrixAutoUpdate = !0;
void 0 === e.animationCache && (e.animationCache = {}, e.animationCache.prevKey = {
pos: 0,
rot: 0,
scl: 0
}, e.animationCache.nextKey = {
pos: 0,
rot: 0,
scl: 0
}, e.animationCache.originalMatrix = e instanceof THREE.Bone ? e.skinMatrix : e.matrix);
var f = e.animationCache.prevKey;
e = e.animationCache.nextKey;
f.pos = this.data.hierarchy[c].keys[0];
f.rot = this.data.hierarchy[c].keys[0];
f.scl = this.data.hierarchy[c].keys[0];
e.pos = this.getNextKeyWith("pos", c, 1);
e.rot = this.getNextKeyWith("rot", c, 1);
e.scl = this.getNextKeyWith("scl", c, 1)
}
this.update(0)
}
this.isPaused = !1;
THREE.AnimationHandler.addToUpdate(this)
};
THREE.Animation.prototype.pause = function() {
!0 === this.isPaused ? THREE.AnimationHandler.addToUpdate(this) : THREE.AnimationHandler.removeFromUpdate(this);
this.isPaused = !this.isPaused
};
THREE.Animation.prototype.stop = function() {
this.isPaused = this.isPlaying = !1;
THREE.AnimationHandler.removeFromUpdate(this)
};
THREE.Animation.prototype.update = function(a) {
if (!1 !== this.isPlaying) {
var b = ["pos", "rot", "scl"],
c, d, e, f, g, h, i, k, l;
l = this.currentTime += a * this.timeScale;
k = this.currentTime %= this.data.length;
parseInt(Math.min(k * this.data.fps, this.data.length * this.data.fps), 10);
for (var m = 0, p = this.hierarchy.length; m < p; m++) {
a = this.hierarchy[m];
i = a.animationCache;
for (var q = 0; 3 > q; q++) {
c = b[q];
g = i.prevKey[c];
h = i.nextKey[c];
if (h.time <= l) {
if (k < l)
if (this.loop) {
g = this.data.hierarchy[m].keys[0];
for (h = this.getNextKeyWith(c, m, 1); h.time <
k;) g = h, h = this.getNextKeyWith(c, m, h.index + 1)
} else {
this.stop();
return
} else {
do g = h, h = this.getNextKeyWith(c, m, h.index + 1); while (h.time < k)
}
i.prevKey[c] = g;
i.nextKey[c] = h
}
a.matrixAutoUpdate = !0;
a.matrixWorldNeedsUpdate = !0;
d = (k - g.time) / (h.time - g.time);
e = g[c];
f = h[c];
if (0 > d || 1 < d) console.log("THREE.Animation.update: Warning! Scale out of bounds:" + d + " on bone " + m), d = 0 > d ? 0 : 1;
if ("pos" === c)
if (c = a.position, this.interpolationType === THREE.AnimationHandler.LINEAR) c.x = e[0] + (f[0] - e[0]) * d, c.y = e[1] + (f[1] - e[1]) * d, c.z = e[2] +
(f[2] - e[2]) * d;
else {
if (this.interpolationType === THREE.AnimationHandler.CATMULLROM || this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD) this.points[0] = this.getPrevKeyWith("pos", m, g.index - 1).pos, this.points[1] = e, this.points[2] = f, this.points[3] = this.getNextKeyWith("pos", m, h.index + 1).pos, d = 0.33 * d + 0.33, e = this.interpolateCatmullRom(this.points, d), c.x = e[0], c.y = e[1], c.z = e[2], this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD && (d = this.interpolateCatmullRom(this.points, 1.01 * d),
this.target.set(d[0], d[1], d[2]), this.target.sub(c), this.target.y = 0, this.target.normalize(), d = Math.atan2(this.target.x, this.target.z), a.rotation.set(0, d, 0))
} else "rot" === c ? THREE.Quaternion.slerp(e, f, a.quaternion, d) : "scl" === c && (c = a.scale, c.x = e[0] + (f[0] - e[0]) * d, c.y = e[1] + (f[1] - e[1]) * d, c.z = e[2] + (f[2] - e[2]) * d)
}
}
}
};
THREE.Animation.prototype.interpolateCatmullRom = function(a, b) {
var c = [],
d = [],
e, f, g, h, i, k;
e = (a.length - 1) * b;
f = Math.floor(e);
e -= f;
c[0] = 0 === f ? f : f - 1;
c[1] = f;
c[2] = f > a.length - 2 ? f : f + 1;
c[3] = f > a.length - 3 ? f : f + 2;
f = a[c[0]];
h = a[c[1]];
i = a[c[2]];
k = a[c[3]];
c = e * e;
g = e * c;
d[0] = this.interpolate(f[0], h[0], i[0], k[0], e, c, g);
d[1] = this.interpolate(f[1], h[1], i[1], k[1], e, c, g);
d[2] = this.interpolate(f[2], h[2], i[2], k[2], e, c, g);
return d
};
THREE.Animation.prototype.interpolate = function(a, b, c, d, e, f, g) {
a = 0.5 * (c - a);
d = 0.5 * (d - b);
return (2 * (b - c) + a + d) * g + (-3 * (b - c) - 2 * a - d) * f + a * e + b
};
THREE.Animation.prototype.getNextKeyWith = function(a, b, c) {
for (var d = this.data.hierarchy[b].keys, c = this.interpolationType === THREE.AnimationHandler.CATMULLROM || this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ? c < d.length - 1 ? c : d.length - 1 : c % d.length; c < d.length; c++)
if (void 0 !== d[c][a]) return d[c];
return this.data.hierarchy[b].keys[0]
};
THREE.Animation.prototype.getPrevKeyWith = function(a, b, c) {
for (var d = this.data.hierarchy[b].keys, c = this.interpolationType === THREE.AnimationHandler.CATMULLROM || this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ? 0 < c ? c : 0 : 0 <= c ? c : c + d.length; 0 <= c; c--)
if (void 0 !== d[c][a]) return d[c];
return this.data.hierarchy[b].keys[d.length - 1]
};
THREE.KeyFrameAnimation = function(a, b, c) {
this.root = a;
this.data = THREE.AnimationHandler.get(b);
this.hierarchy = THREE.AnimationHandler.parse(a);
this.currentTime = 0;
this.timeScale = 0.001;
this.isPlaying = !1;
this.loop = this.isPaused = !0;
this.JITCompile = void 0 !== c ? c : !0;
a = 0;
for (b = this.hierarchy.length; a < b; a++) {
var c = this.data.hierarchy[a].sids,
d = this.hierarchy[a];
if (this.data.hierarchy[a].keys.length && c) {
for (var e = 0; e < c.length; e++) {
var f = c[e],
g = this.getNextKeyWith(f, a, 0);
g && g.apply(f)
}
d.matrixAutoUpdate = !1;
this.data.hierarchy[a].node.updateMatrix();
d.matrixWorldNeedsUpdate = !0
}
}
};
THREE.KeyFrameAnimation.prototype.play = function(a, b) {
if (!this.isPlaying) {
this.isPlaying = !0;
this.loop = void 0 !== a ? a : !0;
this.currentTime = void 0 !== b ? b : 0;
this.startTimeMs = b;
this.startTime = 1E7;
this.endTime = -this.startTime;
var c, d = this.hierarchy.length,
e, f;
for (c = 0; c < d; c++) e = this.hierarchy[c], f = this.data.hierarchy[c], void 0 === f.animationCache && (f.animationCache = {}, f.animationCache.prevKey = null, f.animationCache.nextKey = null, f.animationCache.originalMatrix = e instanceof THREE.Bone ? e.skinMatrix : e.matrix), e = this.data.hierarchy[c].keys,
e.length && (f.animationCache.prevKey = e[0], f.animationCache.nextKey = e[1], this.startTime = Math.min(e[0].time, this.startTime), this.endTime = Math.max(e[e.length - 1].time, this.endTime));
this.update(0)
}
this.isPaused = !1;
THREE.AnimationHandler.addToUpdate(this)
};
THREE.KeyFrameAnimation.prototype.pause = function() {
this.isPaused ? THREE.AnimationHandler.addToUpdate(this) : THREE.AnimationHandler.removeFromUpdate(this);
this.isPaused = !this.isPaused
};
THREE.KeyFrameAnimation.prototype.stop = function() {
this.isPaused = this.isPlaying = !1;
THREE.AnimationHandler.removeFromUpdate(this);
for (var a = 0; a < this.data.hierarchy.length; a++) {
var b = this.hierarchy[a],
c = this.data.hierarchy[a];
if (void 0 !== c.animationCache) {
var d = c.animationCache.originalMatrix;
b instanceof THREE.Bone ? (d.copy(b.skinMatrix), b.skinMatrix = d) : (d.copy(b.matrix), b.matrix = d);
delete c.animationCache
}
}
};
THREE.KeyFrameAnimation.prototype.update = function(a) {
if (this.isPlaying) {
var b, c, d, e, f = this.data.JIT.hierarchy,
g, h, i;
h = this.currentTime += a * this.timeScale;
g = this.currentTime %= this.data.length;
g < this.startTimeMs && (g = this.currentTime = this.startTimeMs + g);
e = parseInt(Math.min(g * this.data.fps, this.data.length * this.data.fps), 10);
if ((i = g < h) && !this.loop) {
for (var a = 0, k = this.hierarchy.length; a < k; a++) {
var l = this.data.hierarchy[a].keys,
f = this.data.hierarchy[a].sids;
d = l.length - 1;
e = this.hierarchy[a];
if (l.length) {
for (l =
0; l < f.length; l++) g = f[l], (h = this.getPrevKeyWith(g, a, d)) && h.apply(g);
this.data.hierarchy[a].node.updateMatrix();
e.matrixWorldNeedsUpdate = !0
}
}
this.stop()
} else if (!(g < this.startTime)) {
a = 0;
for (k = this.hierarchy.length; a < k; a++) {
d = this.hierarchy[a];
b = this.data.hierarchy[a];
var l = b.keys,
m = b.animationCache;
if (this.JITCompile && void 0 !== f[a][e]) d instanceof THREE.Bone ? (d.skinMatrix = f[a][e], d.matrixWorldNeedsUpdate = !1) : (d.matrix = f[a][e], d.matrixWorldNeedsUpdate = !0);
else if (l.length) {
this.JITCompile && m && (d instanceof THREE.Bone ? d.skinMatrix = m.originalMatrix : d.matrix = m.originalMatrix);
b = m.prevKey;
c = m.nextKey;
if (b && c) {
if (c.time <= h) {
if (i && this.loop) {
b = l[0];
for (c = l[1]; c.time < g;) b = c, c = l[b.index + 1]
} else if (!i)
for (var p = l.length - 1; c.time < g && c.index !== p;) b = c, c = l[b.index + 1];
m.prevKey = b;
m.nextKey = c
}
c.time >= g ? b.interpolate(c, g) : b.interpolate(c, c.time)
}
this.data.hierarchy[a].node.updateMatrix();
d.matrixWorldNeedsUpdate = !0
}
}
if (this.JITCompile && void 0 === f[0][e]) {
this.hierarchy[0].updateMatrixWorld(!0);
for (a = 0; a < this.hierarchy.length; a++) f[a][e] =
this.hierarchy[a] instanceof THREE.Bone ? this.hierarchy[a].skinMatrix.clone() : this.hierarchy[a].matrix.clone()
}
}
}
};
THREE.KeyFrameAnimation.prototype.getNextKeyWith = function(a, b, c) {
b = this.data.hierarchy[b].keys;
for (c %= b.length; c < b.length; c++)
if (b[c].hasTarget(a)) return b[c];
return b[0]
};
THREE.KeyFrameAnimation.prototype.getPrevKeyWith = function(a, b, c) {
b = this.data.hierarchy[b].keys;
for (c = 0 <= c ? c : c + b.length; 0 <= c; c--)
if (b[c].hasTarget(a)) return b[c];
return b[b.length - 1]
};
THREE.CubeCamera = function(a, b, c) {
THREE.Object3D.call(this);
var d = new THREE.PerspectiveCamera(90, 1, a, b);
d.up.set(0, -1, 0);
d.lookAt(new THREE.Vector3(1, 0, 0));
this.add(d);
var e = new THREE.PerspectiveCamera(90, 1, a, b);
e.up.set(0, -1, 0);
e.lookAt(new THREE.Vector3(-1, 0, 0));
this.add(e);
var f = new THREE.PerspectiveCamera(90, 1, a, b);
f.up.set(0, 0, 1);
f.lookAt(new THREE.Vector3(0, 1, 0));
this.add(f);
var g = new THREE.PerspectiveCamera(90, 1, a, b);
g.up.set(0, 0, -1);
g.lookAt(new THREE.Vector3(0, -1, 0));
this.add(g);
var h = new THREE.PerspectiveCamera(90,
1, a, b);
h.up.set(0, -1, 0);
h.lookAt(new THREE.Vector3(0, 0, 1));
this.add(h);
var i = new THREE.PerspectiveCamera(90, 1, a, b);
i.up.set(0, -1, 0);
i.lookAt(new THREE.Vector3(0, 0, -1));
this.add(i);
this.renderTarget = new THREE.WebGLRenderTargetCube(c, c, {
format: THREE.RGBFormat,
magFilter: THREE.LinearFilter,
minFilter: THREE.LinearFilter
});
this.updateCubeMap = function(a, b) {
var c = this.renderTarget,
p = c.generateMipmaps;
c.generateMipmaps = !1;
c.activeCubeFace = 0;
a.render(b, d, c);
c.activeCubeFace = 1;
a.render(b, e, c);
c.activeCubeFace =
2;
a.render(b, f, c);
c.activeCubeFace = 3;
a.render(b, g, c);
c.activeCubeFace = 4;
a.render(b, h, c);
c.generateMipmaps = p;
c.activeCubeFace = 5;
a.render(b, i, c)
}
};
THREE.CubeCamera.prototype = Object.create(THREE.Object3D.prototype);
THREE.CombinedCamera = function(a, b, c, d, e, f, g) {
THREE.Camera.call(this);
this.fov = c;
this.left = -a / 2;
this.right = a / 2;
this.top = b / 2;
this.bottom = -b / 2;
this.cameraO = new THREE.OrthographicCamera(a / -2, a / 2, b / 2, b / -2, f, g);
this.cameraP = new THREE.PerspectiveCamera(c, a / b, d, e);
this.zoom = 1;
this.toPerspective()
};
THREE.CombinedCamera.prototype = Object.create(THREE.Camera.prototype);
THREE.CombinedCamera.prototype.toPerspective = function() {
this.near = this.cameraP.near;
this.far = this.cameraP.far;
this.cameraP.fov = this.fov / this.zoom;
this.cameraP.updateProjectionMatrix();
this.projectionMatrix = this.cameraP.projectionMatrix;
this.inPerspectiveMode = !0;
this.inOrthographicMode = !1
};
THREE.CombinedCamera.prototype.toOrthographic = function() {
var a = this.cameraP.aspect,
b = (this.cameraP.near + this.cameraP.far) / 2,
b = Math.tan(this.fov / 2) * b,
a = 2 * b * a / 2,
b = b / this.zoom,
a = a / this.zoom;
this.cameraO.left = -a;
this.cameraO.right = a;
this.cameraO.top = b;
this.cameraO.bottom = -b;
this.cameraO.updateProjectionMatrix();
this.near = this.cameraO.near;
this.far = this.cameraO.far;
this.projectionMatrix = this.cameraO.projectionMatrix;
this.inPerspectiveMode = !1;
this.inOrthographicMode = !0
};
THREE.CombinedCamera.prototype.setSize = function(a, b) {
this.cameraP.aspect = a / b;
this.left = -a / 2;
this.right = a / 2;
this.top = b / 2;
this.bottom = -b / 2
};
THREE.CombinedCamera.prototype.setFov = function(a) {
this.fov = a;
this.inPerspectiveMode ? this.toPerspective() : this.toOrthographic()
};
THREE.CombinedCamera.prototype.updateProjectionMatrix = function() {
this.inPerspectiveMode ? this.toPerspective() : (this.toPerspective(), this.toOrthographic())
};
THREE.CombinedCamera.prototype.setLens = function(a, b) {
void 0 === b && (b = 24);
var c = 2 * THREE.Math.radToDeg(Math.atan(b / (2 * a)));
this.setFov(c);
return c
};
THREE.CombinedCamera.prototype.setZoom = function(a) {
this.zoom = a;
this.inPerspectiveMode ? this.toPerspective() : this.toOrthographic()
};
THREE.CombinedCamera.prototype.toFrontView = function() {
this.rotation.x = 0;
this.rotation.y = 0;
this.rotation.z = 0;
this.rotationAutoUpdate = !1
};
THREE.CombinedCamera.prototype.toBackView = function() {
this.rotation.x = 0;
this.rotation.y = Math.PI;
this.rotation.z = 0;
this.rotationAutoUpdate = !1
};
THREE.CombinedCamera.prototype.toLeftView = function() {
this.rotation.x = 0;
this.rotation.y = -Math.PI / 2;
this.rotation.z = 0;
this.rotationAutoUpdate = !1
};
THREE.CombinedCamera.prototype.toRightView = function() {
this.rotation.x = 0;
this.rotation.y = Math.PI / 2;
this.rotation.z = 0;
this.rotationAutoUpdate = !1
};
THREE.CombinedCamera.prototype.toTopView = function() {
this.rotation.x = -Math.PI / 2;
this.rotation.y = 0;
this.rotation.z = 0;
this.rotationAutoUpdate = !1
};
THREE.CombinedCamera.prototype.toBottomView = function() {
this.rotation.x = Math.PI / 2;
this.rotation.y = 0;
this.rotation.z = 0;
this.rotationAutoUpdate = !1
};
THREE.CircleGeometry = function(a, b, c, d) {
THREE.Geometry.call(this);
var a = a || 50,
c = void 0 !== c ? c : 0,
d = void 0 !== d ? d : 2 * Math.PI,
b = void 0 !== b ? Math.max(3, b) : 8,
e, f = [];
e = new THREE.Vector3;
var g = new THREE.Vector2(0.5, 0.5);
this.vertices.push(e);
f.push(g);
for (e = 0; e <= b; e++) {
var h = new THREE.Vector3,
i = c + e / b * d;
h.x = a * Math.cos(i);
h.y = a * Math.sin(i);
this.vertices.push(h);
f.push(new THREE.Vector2((h.x / a + 1) / 2, (h.y / a + 1) / 2))
}
c = new THREE.Vector3(0, 0, 1);
for (e = 1; e <= b; e++) this.faces.push(new THREE.Face3(e, e + 1, 0, [c, c, c])), this.faceVertexUvs[0].push([f[e],
f[e + 1], g
]);
this.computeCentroids();
this.computeFaceNormals();
this.boundingSphere = new THREE.Sphere(new THREE.Vector3, a)
};
THREE.CircleGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.CubeGeometry = function(a, b, c, d, e, f) {
function g(a, b, c, d, e, f, g, n) {
var r, s = h.widthSegments,
v = h.heightSegments,
z = e / 2,
H = f / 2,
B = h.vertices.length;
if ("x" === a && "y" === b || "y" === a && "x" === b) r = "z";
else if ("x" === a && "z" === b || "z" === a && "x" === b) r = "y", v = h.depthSegments;
else if ("z" === a && "y" === b || "y" === a && "z" === b) r = "x", s = h.depthSegments;
var G = s + 1,
I = v + 1,
F = e / s,
A = f / v,
N = new THREE.Vector3;
N[r] = 0 < g ? 1 : -1;
for (e = 0; e < I; e++)
for (f = 0; f < G; f++) {
var C = new THREE.Vector3;
C[a] = (f * F - z) * c;
C[b] = (e * A - H) * d;
C[r] = g;
h.vertices.push(C)
}
for (e =
0; e < v; e++)
for (f = 0; f < s; f++) a = new THREE.Face4(f + G * e + B, f + G * (e + 1) + B, f + 1 + G * (e + 1) + B, f + 1 + G * e + B), a.normal.copy(N), a.vertexNormals.push(N.clone(), N.clone(), N.clone(), N.clone()), a.materialIndex = n, h.faces.push(a), h.faceVertexUvs[0].push([new THREE.Vector2(f / s, 1 - e / v), new THREE.Vector2(f / s, 1 - (e + 1) / v), new THREE.Vector2((f + 1) / s, 1 - (e + 1) / v), new THREE.Vector2((f + 1) / s, 1 - e / v)])
}
THREE.Geometry.call(this);
var h = this;
this.width = a;
this.height = b;
this.depth = c;
this.widthSegments = d || 1;
this.heightSegments = e || 1;
this.depthSegments =
f || 1;
a = this.width / 2;
b = this.height / 2;
c = this.depth / 2;
g("z", "y", -1, -1, this.depth, this.height, a, 0);
g("z", "y", 1, -1, this.depth, this.height, -a, 1);
g("x", "z", 1, 1, this.width, this.depth, b, 2);
g("x", "z", 1, -1, this.width, this.depth, -b, 3);
g("x", "y", 1, -1, this.width, this.height, c, 4);
g("x", "y", -1, -1, this.width, this.height, -c, 5);
this.computeCentroids();
this.mergeVertices()
};
THREE.CubeGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.CylinderGeometry = function(a, b, c, d, e, f) {
THREE.Geometry.call(this);
this.radiusTop = a = void 0 !== a ? a : 20;
this.radiusBottom = b = void 0 !== b ? b : 20;
this.height = c = void 0 !== c ? c : 100;
this.radialSegments = d = d || 8;
this.heightSegments = e = e || 1;
this.openEnded = f = void 0 !== f ? f : !1;
var g = c / 2,
h, i, k = [],
l = [];
for (i = 0; i <= e; i++) {
var m = [],
p = [],
q = i / e,
t = q * (b - a) + a;
for (h = 0; h <= d; h++) {
var n = h / d,
r = new THREE.Vector3;
r.x = t * Math.sin(2 * n * Math.PI);
r.y = -q * c + g;
r.z = t * Math.cos(2 * n * Math.PI);
this.vertices.push(r);
m.push(this.vertices.length - 1);
p.push(new THREE.Vector2(n,
1 - q))
}
k.push(m);
l.push(p)
}
c = (b - a) / c;
for (h = 0; h < d; h++) {
0 !== a ? (m = this.vertices[k[0][h]].clone(), p = this.vertices[k[0][h + 1]].clone()) : (m = this.vertices[k[1][h]].clone(), p = this.vertices[k[1][h + 1]].clone());
m.setY(Math.sqrt(m.x * m.x + m.z * m.z) * c).normalize();
p.setY(Math.sqrt(p.x * p.x + p.z * p.z) * c).normalize();
for (i = 0; i < e; i++) {
var q = k[i][h],
t = k[i + 1][h],
n = k[i + 1][h + 1],
r = k[i][h + 1],
s = m.clone(),
v = m.clone(),
z = p.clone(),
H = p.clone(),
B = l[i][h].clone(),
G = l[i + 1][h].clone(),
I = l[i + 1][h + 1].clone(),
F = l[i][h + 1].clone();
this.faces.push(new THREE.Face4(q,
t, n, r, [s, v, z, H]));
this.faceVertexUvs[0].push([B, G, I, F])
}
}
if (!1 === f && 0 < a) {
this.vertices.push(new THREE.Vector3(0, g, 0));
for (h = 0; h < d; h++) q = k[0][h], t = k[0][h + 1], n = this.vertices.length - 1, s = new THREE.Vector3(0, 1, 0), v = new THREE.Vector3(0, 1, 0), z = new THREE.Vector3(0, 1, 0), B = l[0][h].clone(), G = l[0][h + 1].clone(), I = new THREE.Vector2(G.u, 0), this.faces.push(new THREE.Face3(q, t, n, [s, v, z])), this.faceVertexUvs[0].push([B, G, I])
}
if (!1 === f && 0 < b) {
this.vertices.push(new THREE.Vector3(0, -g, 0));
for (h = 0; h < d; h++) q = k[i][h + 1],
t = k[i][h], n = this.vertices.length - 1, s = new THREE.Vector3(0, -1, 0), v = new THREE.Vector3(0, -1, 0), z = new THREE.Vector3(0, -1, 0), B = l[i][h + 1].clone(), G = l[i][h].clone(), I = new THREE.Vector2(G.u, 1), this.faces.push(new THREE.Face3(q, t, n, [s, v, z])), this.faceVertexUvs[0].push([B, G, I])
}
this.computeCentroids();
this.computeFaceNormals()
};
THREE.CylinderGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.ExtrudeGeometry = function(a, b) {
"undefined" !== typeof a && (THREE.Geometry.call(this), a = a instanceof Array ? a : [a], this.shapebb = a[a.length - 1].getBoundingBox(), this.addShapeList(a, b), this.computeCentroids(), this.computeFaceNormals())
};
THREE.ExtrudeGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.ExtrudeGeometry.prototype.addShapeList = function(a, b) {
for (var c = a.length, d = 0; d < c; d++) this.addShape(a[d], b)
};
THREE.ExtrudeGeometry.prototype.addShape = function(a, b) {
function c(a, b, c) {
b || console.log("die");
return b.clone().multiplyScalar(c).add(a)
}
function d(a, b, c) {
var d = THREE.ExtrudeGeometry.__v1,
e = THREE.ExtrudeGeometry.__v2,
f = THREE.ExtrudeGeometry.__v3,
g = THREE.ExtrudeGeometry.__v4,
h = THREE.ExtrudeGeometry.__v5,
i = THREE.ExtrudeGeometry.__v6;
d.set(a.x - b.x, a.y - b.y);
e.set(a.x - c.x, a.y - c.y);
d = d.normalize();
e = e.normalize();
f.set(-d.y, d.x);
g.set(e.y, -e.x);
h.copy(a).add(f);
i.copy(a).add(g);
if (h.equals(i)) return g.clone();
h.copy(b).add(f);
i.copy(c).add(g);
f = d.dot(g);
g = i.sub(h).dot(g);
0 === f && (console.log("Either infinite or no solutions!"), 0 === g ? console.log("Its finite solutions.") : console.log("Too bad, no solutions."));
g /= f;
return 0 > g ? (b = Math.atan2(b.y - a.y, b.x - a.x), a = Math.atan2(c.y - a.y, c.x - a.x), b > a && (a += 2 * Math.PI), c = (b + a) / 2, a = -Math.cos(c), c = -Math.sin(c), new THREE.Vector2(a, c)) : d.multiplyScalar(g).add(h).sub(a).clone()
}
function e(c, d) {
var e, f;
for (P = c.length; 0 <= --P;) {
e = P;
f = P - 1;
0 > f && (f = c.length - 1);
for (var g = 0, h = q + 2 * l,
g = 0; g < h; g++) {
var i = qa * g,
k = qa * (g + 1),
m = d + e + i,
i = d + f + i,
p = d + f + k,
k = d + e + k,
n = c,
r = g,
s = h,
t = e,
w = f,
m = m + K,
i = i + K,
p = p + K,
k = k + K;
C.faces.push(new THREE.Face4(m, i, p, k, null, null, v));
m = z.generateSideWallUV(C, a, n, b, m, i, p, k, r, s, t, w);
C.faceVertexUvs[0].push(m)
}
}
}
function f(a, b, c) {
C.vertices.push(new THREE.Vector3(a, b, c))
}
function g(c, d, e, f) {
c += K;
d += K;
e += K;
C.faces.push(new THREE.Face3(c, d, e, null, null, s));
c = f ? z.generateBottomUV(C, a, b, c, d, e) : z.generateTopUV(C, a, b, c, d, e);
C.faceVertexUvs[0].push(c)
}
var h = void 0 !== b.amount ? b.amount :
100,
i = void 0 !== b.bevelThickness ? b.bevelThickness : 6,
k = void 0 !== b.bevelSize ? b.bevelSize : i - 2,
l = void 0 !== b.bevelSegments ? b.bevelSegments : 3,
m = void 0 !== b.bevelEnabled ? b.bevelEnabled : !0,
p = void 0 !== b.curveSegments ? b.curveSegments : 12,
q = void 0 !== b.steps ? b.steps : 1,
t = b.extrudePath,
n, r = !1,
s = b.material,
v = b.extrudeMaterial,
z = void 0 !== b.UVGenerator ? b.UVGenerator : THREE.ExtrudeGeometry.WorldUVGenerator,
H, B, G, I;
t && (n = t.getSpacedPoints(q), r = !0, m = !1, H = void 0 !== b.frames ? b.frames : new THREE.TubeGeometry.FrenetFrames(t, q, !1), B = new THREE.Vector3, G = new THREE.Vector3, I = new THREE.Vector3);
m || (k = i = l = 0);
var F, A, N, C = this,
K = this.vertices.length,
p = a.extractPoints(p),
M = p.shape,
p = p.holes;
if (t = !THREE.Shape.Utils.isClockWise(M)) {
M = M.reverse();
A = 0;
for (N = p.length; A < N; A++) F = p[A], THREE.Shape.Utils.isClockWise(F) && (p[A] = F.reverse());
t = !1
}
var y = THREE.Shape.Utils.triangulateShape(M, p),
t = M;
A = 0;
for (N = p.length; A < N; A++) F = p[A], M = M.concat(F);
var J, w, ca, D, qa = M.length,
Pa = y.length,
Sa = [],
P = 0,
ia = t.length;
J = ia - 1;
for (w = P + 1; P < ia; P++, J++, w++) J === ia &&
(J = 0), w === ia && (w = 0), Sa[P] = d(t[P], t[J], t[w]);
var Wa = [],
L, sa = Sa.concat();
A = 0;
for (N = p.length; A < N; A++) {
F = p[A];
L = [];
P = 0;
ia = F.length;
J = ia - 1;
for (w = P + 1; P < ia; P++, J++, w++) J === ia && (J = 0), w === ia && (w = 0), L[P] = d(F[P], F[J], F[w]);
Wa.push(L);
sa = sa.concat(L)
}
for (J = 0; J < l; J++) {
F = J / l;
ca = i * (1 - F);
w = k * Math.sin(F * Math.PI / 2);
P = 0;
for (ia = t.length; P < ia; P++) D = c(t[P], Sa[P], w), f(D.x, D.y, -ca);
A = 0;
for (N = p.length; A < N; A++) {
F = p[A];
L = Wa[A];
P = 0;
for (ia = F.length; P < ia; P++) D = c(F[P], L[P], w), f(D.x, D.y, -ca)
}
}
w = k;
for (P = 0; P < qa; P++) D = m ? c(M[P], sa[P],
w) : M[P], r ? (G.copy(H.normals[0]).multiplyScalar(D.x), B.copy(H.binormals[0]).multiplyScalar(D.y), I.copy(n[0]).add(G).add(B), f(I.x, I.y, I.z)) : f(D.x, D.y, 0);
for (F = 1; F <= q; F++)
for (P = 0; P < qa; P++) D = m ? c(M[P], sa[P], w) : M[P], r ? (G.copy(H.normals[F]).multiplyScalar(D.x), B.copy(H.binormals[F]).multiplyScalar(D.y), I.copy(n[F]).add(G).add(B), f(I.x, I.y, I.z)) : f(D.x, D.y, h / q * F);
for (J = l - 1; 0 <= J; J--) {
F = J / l;
ca = i * (1 - F);
w = k * Math.sin(F * Math.PI / 2);
P = 0;
for (ia = t.length; P < ia; P++) D = c(t[P], Sa[P], w), f(D.x, D.y, h + ca);
A = 0;
for (N = p.length; A <
N; A++) {
F = p[A];
L = Wa[A];
P = 0;
for (ia = F.length; P < ia; P++) D = c(F[P], L[P], w), r ? f(D.x, D.y + n[q - 1].y, n[q - 1].x + ca) : f(D.x, D.y, h + ca)
}
}
if (m) {
i = 0 * qa;
for (P = 0; P < Pa; P++) h = y[P], g(h[2] + i, h[1] + i, h[0] + i, !0);
i = qa * (q + 2 * l);
for (P = 0; P < Pa; P++) h = y[P], g(h[0] + i, h[1] + i, h[2] + i, !1)
} else {
for (P = 0; P < Pa; P++) h = y[P], g(h[2], h[1], h[0], !0);
for (P = 0; P < Pa; P++) h = y[P], g(h[0] + qa * q, h[1] + qa * q, h[2] + qa * q, !1)
}
h = 0;
e(t, h);
h += t.length;
A = 0;
for (N = p.length; A < N; A++) F = p[A], e(F, h), h += F.length
};
THREE.ExtrudeGeometry.WorldUVGenerator = {
generateTopUV: function(a, b, c, d, e, f) {
b = a.vertices[e].x;
e = a.vertices[e].y;
c = a.vertices[f].x;
f = a.vertices[f].y;
return [new THREE.Vector2(a.vertices[d].x, a.vertices[d].y), new THREE.Vector2(b, e), new THREE.Vector2(c, f)]
},
generateBottomUV: function(a, b, c, d, e, f) {
return this.generateTopUV(a, b, c, d, e, f)
},
generateSideWallUV: function(a, b, c, d, e, f, g, h) {
var b = a.vertices[e].x,
c = a.vertices[e].y,
e = a.vertices[e].z,
d = a.vertices[f].x,
i = a.vertices[f].y,
f = a.vertices[f].z,
k = a.vertices[g].x,
l = a.vertices[g].y,
g = a.vertices[g].z,
m = a.vertices[h].x,
p = a.vertices[h].y,
a = a.vertices[h].z;
return 0.01 > Math.abs(c - i) ? [new THREE.Vector2(b, 1 - e), new THREE.Vector2(d, 1 - f), new THREE.Vector2(k, 1 - g), new THREE.Vector2(m, 1 - a)] : [new THREE.Vector2(c, 1 - e), new THREE.Vector2(i, 1 - f), new THREE.Vector2(l, 1 - g), new THREE.Vector2(p, 1 - a)]
}
};
THREE.ExtrudeGeometry.__v1 = new THREE.Vector2;
THREE.ExtrudeGeometry.__v2 = new THREE.Vector2;
THREE.ExtrudeGeometry.__v3 = new THREE.Vector2;
THREE.ExtrudeGeometry.__v4 = new THREE.Vector2;
THREE.ExtrudeGeometry.__v5 = new THREE.Vector2;
THREE.ExtrudeGeometry.__v6 = new THREE.Vector2;
THREE.ShapeGeometry = function(a, b) {
THREE.Geometry.call(this);
!1 === a instanceof Array && (a = [a]);
this.shapebb = a[a.length - 1].getBoundingBox();
this.addShapeList(a, b);
this.computeCentroids();
this.computeFaceNormals()
};
THREE.ShapeGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.ShapeGeometry.prototype.addShapeList = function(a, b) {
for (var c = 0, d = a.length; c < d; c++) this.addShape(a[c], b);
return this
};
THREE.ShapeGeometry.prototype.addShape = function(a, b) {
void 0 === b && (b = {});
var c = b.material,
d = void 0 === b.UVGenerator ? THREE.ExtrudeGeometry.WorldUVGenerator : b.UVGenerator,
e, f, g, h = this.vertices.length;
e = a.extractPoints(void 0 !== b.curveSegments ? b.curveSegments : 12);
var i = e.shape,
k = e.holes;
if (!THREE.Shape.Utils.isClockWise(i)) {
i = i.reverse();
e = 0;
for (f = k.length; e < f; e++) g = k[e], THREE.Shape.Utils.isClockWise(g) && (k[e] = g.reverse())
}
var l = THREE.Shape.Utils.triangulateShape(i, k);
e = 0;
for (f = k.length; e < f; e++) g = k[e],
i = i.concat(g);
k = i.length;
f = l.length;
for (e = 0; e < k; e++) g = i[e], this.vertices.push(new THREE.Vector3(g.x, g.y, 0));
for (e = 0; e < f; e++) k = l[e], i = k[0] + h, g = k[1] + h, k = k[2] + h, this.faces.push(new THREE.Face3(i, g, k, null, null, c)), this.faceVertexUvs[0].push(d.generateBottomUV(this, a, b, i, g, k))
};
THREE.LatheGeometry = function(a, b, c, d) {
THREE.Geometry.call(this);
for (var b = b || 12, c = c || 0, d = d || 2 * Math.PI, e = 1 / (a.length - 1), f = 1 / b, g = 0, h = b; g <= h; g++)
for (var i = c + g * f * d, k = Math.cos(i), l = Math.sin(i), i = 0, m = a.length; i < m; i++) {
var p = a[i],
q = new THREE.Vector3;
q.x = k * p.x - l * p.y;
q.y = l * p.x + k * p.y;
q.z = p.z;
this.vertices.push(q)
}
c = a.length;
g = 0;
for (h = b; g < h; g++) {
i = 0;
for (m = a.length - 1; i < m; i++) d = b = i + c * g, l = b + c, k = b + 1 + c, this.faces.push(new THREE.Face4(d, l, k, b + 1)), k = g * f, b = i * e, d = k + f, l = b + e, this.faceVertexUvs[0].push([new THREE.Vector2(k,
b), new THREE.Vector2(d, b), new THREE.Vector2(d, l), new THREE.Vector2(k, l)])
}
this.mergeVertices();
this.computeCentroids();
this.computeFaceNormals();
this.computeVertexNormals()
};
THREE.LatheGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.PlaneGeometry = function(a, b, c, d) {
THREE.Geometry.call(this);
this.width = a;
this.height = b;
this.widthSegments = c || 1;
this.heightSegments = d || 1;
for (var c = a / 2, e = b / 2, d = this.widthSegments, f = this.heightSegments, g = d + 1, h = f + 1, i = this.width / d, k = this.height / f, l = new THREE.Vector3(0, 0, 1), a = 0; a < h; a++)
for (b = 0; b < g; b++) this.vertices.push(new THREE.Vector3(b * i - c, -(a * k - e), 0));
for (a = 0; a < f; a++)
for (b = 0; b < d; b++) c = new THREE.Face4(b + g * a, b + g * (a + 1), b + 1 + g * (a + 1), b + 1 + g * a), c.normal.copy(l), c.vertexNormals.push(l.clone(), l.clone(),
l.clone(), l.clone()), this.faces.push(c), this.faceVertexUvs[0].push([new THREE.Vector2(b / d, 1 - a / f), new THREE.Vector2(b / d, 1 - (a + 1) / f), new THREE.Vector2((b + 1) / d, 1 - (a + 1) / f), new THREE.Vector2((b + 1) / d, 1 - a / f)]);
this.computeCentroids()
};
THREE.PlaneGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.RingGeometry = function(a, b, c, d, e, f) {
THREE.Geometry.call(this);
for (var a = a || 0, b = b || 50, e = void 0 !== e ? e : 0, f = void 0 !== f ? f : 2 * Math.PI, c = void 0 !== c ? Math.max(3, c) : 8, d = void 0 !== d ? Math.max(3, d) : 8, g = [], h = a, i = (b - a) / d, a = 0; a <= d; a++) {
for (b = 0; b <= c; b++) {
var k = new THREE.Vector3,
l = e + b / c * f;
k.x = h * Math.cos(l);
k.y = h * Math.sin(l);
this.vertices.push(k);
g.push(new THREE.Vector2((k.x / h + 1) / 2, -(k.y / h + 1) / 2 + 1))
}
h += i
}
e = new THREE.Vector3(0, 0, 1);
for (a = 0; a < d; a++) {
f = a * c;
for (b = 0; b <= c; b++) {
var l = b + f,
i = l + a,
k = l + c + a,
m = l + c + 1 + a;
this.faces.push(new THREE.Face3(i,
k, m, [e, e, e]));
this.faceVertexUvs[0].push([g[i], g[k], g[m]]);
i = l + a;
k = l + c + 1 + a;
m = l + 1 + a;
this.faces.push(new THREE.Face3(i, k, m, [e, e, e]));
this.faceVertexUvs[0].push([g[i], g[k], g[m]])
}
}
this.computeCentroids();
this.computeFaceNormals();
this.boundingSphere = new THREE.Sphere(new THREE.Vector3, h)
};
THREE.RingGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.SphereGeometry = function(a, b, c, d, e, f, g) {
THREE.Geometry.call(this);
this.radius = a = a || 50;
this.widthSegments = b = Math.max(3, Math.floor(b) || 8);
this.heightSegments = c = Math.max(2, Math.floor(c) || 6);
this.phiStart = d = void 0 !== d ? d : 0;
this.phiLength = e = void 0 !== e ? e : 2 * Math.PI;
this.thetaStart = f = void 0 !== f ? f : 0;
this.thetaLength = g = void 0 !== g ? g : Math.PI;
var h, i, k = [],
l = [];
for (i = 0; i <= c; i++) {
var m = [],
p = [];
for (h = 0; h <= b; h++) {
var q = h / b,
t = i / c,
n = new THREE.Vector3;
n.x = -a * Math.cos(d + q * e) * Math.sin(f + t * g);
n.y = a * Math.cos(f + t * g);
n.z = a * Math.sin(d + q * e) * Math.sin(f + t * g);
this.vertices.push(n);
m.push(this.vertices.length - 1);
p.push(new THREE.Vector2(q, 1 - t))
}
k.push(m);
l.push(p)
}
for (i = 0; i < this.heightSegments; i++)
for (h = 0; h < this.widthSegments; h++) {
var b = k[i][h + 1],
c = k[i][h],
d = k[i + 1][h],
e = k[i + 1][h + 1],
f = this.vertices[b].clone().normalize(),
g = this.vertices[c].clone().normalize(),
m = this.vertices[d].clone().normalize(),
p = this.vertices[e].clone().normalize(),
q = l[i][h + 1].clone(),
t = l[i][h].clone(),
n = l[i + 1][h].clone(),
r = l[i + 1][h + 1].clone();
Math.abs(this.vertices[b].y) ===
this.radius ? (this.faces.push(new THREE.Face3(b, d, e, [f, m, p])), this.faceVertexUvs[0].push([q, n, r])) : Math.abs(this.vertices[d].y) === this.radius ? (this.faces.push(new THREE.Face3(b, c, d, [f, g, m])), this.faceVertexUvs[0].push([q, t, n])) : (this.faces.push(new THREE.Face4(b, c, d, e, [f, g, m, p])), this.faceVertexUvs[0].push([q, t, n, r]))
}
this.computeCentroids();
this.computeFaceNormals();
this.boundingSphere = new THREE.Sphere(new THREE.Vector3, a)
};
THREE.SphereGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.TextGeometry = function(a, b) {
var b = b || {},
c = THREE.FontUtils.generateShapes(a, b);
b.amount = void 0 !== b.height ? b.height : 50;
void 0 === b.bevelThickness && (b.bevelThickness = 10);
void 0 === b.bevelSize && (b.bevelSize = 8);
void 0 === b.bevelEnabled && (b.bevelEnabled = !1);
THREE.ExtrudeGeometry.call(this, c, b)
};
THREE.TextGeometry.prototype = Object.create(THREE.ExtrudeGeometry.prototype);
THREE.TorusGeometry = function(a, b, c, d, e) {
THREE.Geometry.call(this);
this.radius = a || 100;
this.tube = b || 40;
this.radialSegments = c || 8;
this.tubularSegments = d || 6;
this.arc = e || 2 * Math.PI;
e = new THREE.Vector3;
a = [];
b = [];
for (c = 0; c <= this.radialSegments; c++)
for (d = 0; d <= this.tubularSegments; d++) {
var f = d / this.tubularSegments * this.arc,
g = 2 * c / this.radialSegments * Math.PI;
e.x = this.radius * Math.cos(f);
e.y = this.radius * Math.sin(f);
var h = new THREE.Vector3;
h.x = (this.radius + this.tube * Math.cos(g)) * Math.cos(f);
h.y = (this.radius + this.tube *
Math.cos(g)) * Math.sin(f);
h.z = this.tube * Math.sin(g);
this.vertices.push(h);
a.push(new THREE.Vector2(d / this.tubularSegments, c / this.radialSegments));
b.push(h.clone().sub(e).normalize())
}
for (c = 1; c <= this.radialSegments; c++)
for (d = 1; d <= this.tubularSegments; d++) {
var e = (this.tubularSegments + 1) * c + d - 1,
f = (this.tubularSegments + 1) * (c - 1) + d - 1,
g = (this.tubularSegments + 1) * (c - 1) + d,
h = (this.tubularSegments + 1) * c + d,
i = new THREE.Face4(e, f, g, h, [b[e], b[f], b[g], b[h]]);
i.normal.add(b[e]);
i.normal.add(b[f]);
i.normal.add(b[g]);
i.normal.add(b[h]);
i.normal.normalize();
this.faces.push(i);
this.faceVertexUvs[0].push([a[e].clone(), a[f].clone(), a[g].clone(), a[h].clone()])
}
this.computeCentroids()
};
THREE.TorusGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.TorusKnotGeometry = function(a, b, c, d, e, f, g) {
function h(a, b, c, d, e) {
var f = Math.cos(a),
g = Math.sin(a),
a = b / c * a,
b = Math.cos(a),
f = 0.5 * (d * (2 + b)) * f,
g = 0.5 * d * (2 + b) * g,
d = 0.5 * e * d * Math.sin(a);
return new THREE.Vector3(f, g, d)
}
THREE.Geometry.call(this);
this.radius = a || 100;
this.tube = b || 40;
this.radialSegments = c || 64;
this.tubularSegments = d || 8;
this.p = e || 2;
this.q = f || 3;
this.heightScale = g || 1;
this.grid = Array(this.radialSegments);
c = new THREE.Vector3;
d = new THREE.Vector3;
e = new THREE.Vector3;
for (a = 0; a < this.radialSegments; ++a) {
this.grid[a] =
Array(this.tubularSegments);
b = 2 * (a / this.radialSegments) * this.p * Math.PI;
f = h(b, this.q, this.p, this.radius, this.heightScale);
b = h(b + 0.01, this.q, this.p, this.radius, this.heightScale);
c.subVectors(b, f);
d.addVectors(b, f);
e.crossVectors(c, d);
d.crossVectors(e, c);
e.normalize();
d.normalize();
for (b = 0; b < this.tubularSegments; ++b) {
var i = 2 * (b / this.tubularSegments) * Math.PI,
g = -this.tube * Math.cos(i),
i = this.tube * Math.sin(i),
k = new THREE.Vector3;
k.x = f.x + g * d.x + i * e.x;
k.y = f.y + g * d.y + i * e.y;
k.z = f.z + g * d.z + i * e.z;
this.grid[a][b] =
this.vertices.push(k) - 1
}
}
for (a = 0; a < this.radialSegments; ++a)
for (b = 0; b < this.tubularSegments; ++b) {
var e = (a + 1) % this.radialSegments,
f = (b + 1) % this.tubularSegments,
c = this.grid[a][b],
d = this.grid[e][b],
e = this.grid[e][f],
f = this.grid[a][f],
g = new THREE.Vector2(a / this.radialSegments, b / this.tubularSegments),
i = new THREE.Vector2((a + 1) / this.radialSegments, b / this.tubularSegments),
k = new THREE.Vector2((a + 1) / this.radialSegments, (b + 1) / this.tubularSegments),
l = new THREE.Vector2(a / this.radialSegments, (b + 1) / this.tubularSegments);
this.faces.push(new THREE.Face4(c, d, e, f));
this.faceVertexUvs[0].push([g, i, k, l])
}
this.computeCentroids();
this.computeFaceNormals();
this.computeVertexNormals()
};
THREE.TorusKnotGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.TubeGeometry = function(a, b, c, d, e) {
THREE.Geometry.call(this);
this.path = a;
this.segments = b || 64;
this.radius = c || 1;
this.radialSegments = d || 8;
this.closed = e || !1;
this.grid = [];
var f, g, d = this.segments + 1,
h, i, k, e = new THREE.Vector3,
l, m, b = new THREE.TubeGeometry.FrenetFrames(this.path, this.segments, this.closed);
l = b.normals;
m = b.binormals;
this.tangents = b.tangents;
this.normals = l;
this.binormals = m;
for (b = 0; b < d; b++) {
this.grid[b] = [];
c = b / (d - 1);
k = a.getPointAt(c);
f = l[b];
g = m[b];
for (c = 0; c < this.radialSegments; c++) h = 2 * (c / this.radialSegments) *
Math.PI, i = -this.radius * Math.cos(h), h = this.radius * Math.sin(h), e.copy(k), e.x += i * f.x + h * g.x, e.y += i * f.y + h * g.y, e.z += i * f.z + h * g.z, this.grid[b][c] = this.vertices.push(new THREE.Vector3(e.x, e.y, e.z)) - 1
}
for (b = 0; b < this.segments; b++)
for (c = 0; c < this.radialSegments; c++) e = this.closed ? (b + 1) % this.segments : b + 1, l = (c + 1) % this.radialSegments, a = this.grid[b][c], d = this.grid[e][c], e = this.grid[e][l], l = this.grid[b][l], m = new THREE.Vector2(b / this.segments, c / this.radialSegments), f = new THREE.Vector2((b + 1) / this.segments, c / this.radialSegments),
g = new THREE.Vector2((b + 1) / this.segments, (c + 1) / this.radialSegments), i = new THREE.Vector2(b / this.segments, (c + 1) / this.radialSegments), this.faces.push(new THREE.Face4(a, d, e, l)), this.faceVertexUvs[0].push([m, f, g, i]);
this.computeCentroids();
this.computeFaceNormals();
this.computeVertexNormals()
};
THREE.TubeGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.TubeGeometry.FrenetFrames = function(a, b, c) {
new THREE.Vector3;
var d = new THREE.Vector3;
new THREE.Vector3;
var e = [],
f = [],
g = [],
h = new THREE.Vector3,
i = new THREE.Matrix4,
b = b + 1,
k, l, m;
this.tangents = e;
this.normals = f;
this.binormals = g;
for (k = 0; k < b; k++) l = k / (b - 1), e[k] = a.getTangentAt(l), e[k].normalize();
f[0] = new THREE.Vector3;
g[0] = new THREE.Vector3;
a = Number.MAX_VALUE;
k = Math.abs(e[0].x);
l = Math.abs(e[0].y);
m = Math.abs(e[0].z);
k <= a && (a = k, d.set(1, 0, 0));
l <= a && (a = l, d.set(0, 1, 0));
m <= a && d.set(0, 0, 1);
h.crossVectors(e[0],
d).normalize();
f[0].crossVectors(e[0], h);
g[0].crossVectors(e[0], f[0]);
for (k = 1; k < b; k++) f[k] = f[k - 1].clone(), g[k] = g[k - 1].clone(), h.crossVectors(e[k - 1], e[k]), 1E-4 < h.length() && (h.normalize(), d = Math.acos(THREE.Math.clamp(e[k - 1].dot(e[k]), -1, 1)), f[k].applyMatrix4(i.makeRotationAxis(h, d))), g[k].crossVectors(e[k], f[k]);
if (c) {
d = Math.acos(THREE.Math.clamp(f[0].dot(f[b - 1]), -1, 1));
d /= b - 1;
0 < e[0].dot(h.crossVectors(f[0], f[b - 1])) && (d = -d);
for (k = 1; k < b; k++) f[k].applyMatrix4(i.makeRotationAxis(e[k], d * k)), g[k].crossVectors(e[k],
f[k])
}
};
THREE.PolyhedronGeometry = function(a, b, c, d) {
function e(a) {
var b = a.normalize().clone();
b.index = h.vertices.push(b) - 1;
var c = Math.atan2(a.z, -a.x) / 2 / Math.PI + 0.5,
a = Math.atan2(-a.y, Math.sqrt(a.x * a.x + a.z * a.z)) / Math.PI + 0.5;
b.uv = new THREE.Vector2(c, 1 - a);
return b
}
function f(a, b, c) {
var d = new THREE.Face3(a.index, b.index, c.index, [a.clone(), b.clone(), c.clone()]);
d.centroid.add(a).add(b).add(c).divideScalar(3);
h.faces.push(d);
d = Math.atan2(d.centroid.z, -d.centroid.x);
h.faceVertexUvs[0].push([g(a.uv, a, d), g(b.uv, b, d),
g(c.uv, c, d)
])
}
function g(a, b, c) {
0 > c && 1 === a.x && (a = new THREE.Vector2(a.x - 1, a.y));
0 === b.x && 0 === b.z && (a = new THREE.Vector2(c / 2 / Math.PI + 0.5, a.y));
return a.clone()
}
THREE.Geometry.call(this);
for (var c = c || 1, d = d || 0, h = this, i = 0, k = a.length; i < k; i++) e(new THREE.Vector3(a[i][0], a[i][1], a[i][2]));
for (var l = this.vertices, a = [], i = 0, k = b.length; i < k; i++) {
var m = l[b[i][0]],
p = l[b[i][1]],
q = l[b[i][2]];
a[i] = new THREE.Face3(m.index, p.index, q.index, [m.clone(), p.clone(), q.clone()])
}
i = 0;
for (k = a.length; i < k; i++) {
p = a[i];
l = d;
b = Math.pow(2,
l);
Math.pow(4, l);
for (var l = e(h.vertices[p.a]), m = e(h.vertices[p.b]), t = e(h.vertices[p.c]), p = [], q = 0; q <= b; q++) {
p[q] = [];
for (var n = e(l.clone().lerp(t, q / b)), r = e(m.clone().lerp(t, q / b)), s = b - q, v = 0; v <= s; v++) p[q][v] = 0 == v && q == b ? n : e(n.clone().lerp(r, v / s))
}
for (q = 0; q < b; q++)
for (v = 0; v < 2 * (b - q) - 1; v++) l = Math.floor(v / 2), 0 == v % 2 ? f(p[q][l + 1], p[q + 1][l], p[q][l]) : f(p[q][l + 1], p[q + 1][l + 1], p[q + 1][l])
}
i = 0;
for (k = this.faceVertexUvs[0].length; i < k; i++) d = this.faceVertexUvs[0][i], a = d[0].x, b = d[1].x, l = d[2].x, m = Math.max(a, Math.max(b, l)),
p = Math.min(a, Math.min(b, l)), 0.9 < m && 0.1 > p && (0.2 > a && (d[0].x += 1), 0.2 > b && (d[1].x += 1), 0.2 > l && (d[2].x += 1));
i = 0;
for (k = this.vertices.length; i < k; i++) this.vertices[i].multiplyScalar(c);
this.mergeVertices();
this.computeCentroids();
this.computeFaceNormals();
this.boundingSphere = new THREE.Sphere(new THREE.Vector3, c)
};
THREE.PolyhedronGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.IcosahedronGeometry = function(a, b) {
this.radius = a;
this.detail = b;
var c = (1 + Math.sqrt(5)) / 2;
THREE.PolyhedronGeometry.call(this, [
[-1, c, 0],
[1, c, 0],
[-1, -c, 0],
[1, -c, 0],
[0, -1, c],
[0, 1, c],
[0, -1, -c],
[0, 1, -c],
[c, 0, -1],
[c, 0, 1],
[-c, 0, -1],
[-c, 0, 1]
], [
[0, 11, 5],
[0, 5, 1],
[0, 1, 7],
[0, 7, 10],
[0, 10, 11],
[1, 5, 9],
[5, 11, 4],
[11, 10, 2],
[10, 7, 6],
[7, 1, 8],
[3, 9, 4],
[3, 4, 2],
[3, 2, 6],
[3, 6, 8],
[3, 8, 9],
[4, 9, 5],
[2, 4, 11],
[6, 2, 10],
[8, 6, 7],
[9, 8, 1]
], a, b)
};
THREE.IcosahedronGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.OctahedronGeometry = function(a, b) {
THREE.PolyhedronGeometry.call(this, [
[1, 0, 0],
[-1, 0, 0],
[0, 1, 0],
[0, -1, 0],
[0, 0, 1],
[0, 0, -1]
], [
[0, 2, 4],
[0, 4, 3],
[0, 3, 5],
[0, 5, 2],
[1, 2, 5],
[1, 5, 3],
[1, 3, 4],
[1, 4, 2]
], a, b)
};
THREE.OctahedronGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.TetrahedronGeometry = function(a, b) {
THREE.PolyhedronGeometry.call(this, [
[1, 1, 1],
[-1, -1, 1],
[-1, 1, -1],
[1, -1, -1]
], [
[2, 1, 0],
[0, 3, 2],
[1, 3, 0],
[2, 3, 1]
], a, b)
};
THREE.TetrahedronGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.ParametricGeometry = function(a, b, c, d) {
THREE.Geometry.call(this);
var e = this.vertices,
f = this.faces,
g = this.faceVertexUvs[0],
d = void 0 === d ? !1 : d,
h, i, k, l, m = b + 1;
for (h = 0; h <= c; h++) {
l = h / c;
for (i = 0; i <= b; i++) k = i / b, k = a(k, l), e.push(k)
}
var p, q, t, n;
for (h = 0; h < c; h++)
for (i = 0; i < b; i++) a = h * m + i, e = h * m + i + 1, l = (h + 1) * m + i, k = (h + 1) * m + i + 1, p = new THREE.Vector2(i / b, h / c), q = new THREE.Vector2((i + 1) / b, h / c), t = new THREE.Vector2(i / b, (h + 1) / c), n = new THREE.Vector2((i + 1) / b, (h + 1) / c), d ? (f.push(new THREE.Face3(a, e, l)), f.push(new THREE.Face3(e,
k, l)), g.push([p, q, t]), g.push([q, n, t])) : (f.push(new THREE.Face4(a, e, k, l)), g.push([p, q, n, t]));
this.computeCentroids();
this.computeFaceNormals();
this.computeVertexNormals()
};
THREE.ParametricGeometry.prototype = Object.create(THREE.Geometry.prototype);
THREE.AxisHelper = function(a) {
var a = a || 1,
b = new THREE.Geometry;
b.vertices.push(new THREE.Vector3, new THREE.Vector3(a, 0, 0), new THREE.Vector3, new THREE.Vector3(0, a, 0), new THREE.Vector3, new THREE.Vector3(0, 0, a));
b.colors.push(new THREE.Color(16711680), new THREE.Color(16755200), new THREE.Color(65280), new THREE.Color(11206400), new THREE.Color(255), new THREE.Color(43775));
a = new THREE.LineBasicMaterial({
vertexColors: THREE.VertexColors
});
THREE.Line.call(this, b, a, THREE.LinePieces)
};
THREE.AxisHelper.prototype = Object.create(THREE.Line.prototype);
THREE.ArrowHelper = function(a, b, c, d) {
THREE.Object3D.call(this);
void 0 === d && (d = 16776960);
void 0 === c && (c = 1);
this.position = b;
b = new THREE.Geometry;
b.vertices.push(new THREE.Vector3(0, 0, 0));
b.vertices.push(new THREE.Vector3(0, 1, 0));
this.line = new THREE.Line(b, new THREE.LineBasicMaterial({
color: d
}));
this.line.matrixAutoUpdate = !1;
this.add(this.line);
b = new THREE.CylinderGeometry(0, 0.05, 0.25, 5, 1);
b.applyMatrix((new THREE.Matrix4).makeTranslation(0, 0.875, 0));
this.cone = new THREE.Mesh(b, new THREE.MeshBasicMaterial({
color: d
}));
this.cone.matrixAutoUpdate = !1;
this.add(this.cone);
this.setDirection(a);
this.setLength(c)
};
THREE.ArrowHelper.prototype = Object.create(THREE.Object3D.prototype);
THREE.ArrowHelper.prototype.setDirection = function() {
var a = new THREE.Vector3,
b;
return function(c) {
0.99999 < c.y ? this.quaternion.set(0, 0, 0, 1) : -0.99999 > c.y ? this.quaternion.set(1, 0, 0, 0) : (a.set(c.z, 0, -c.x).normalize(), b = Math.acos(c.y), this.quaternion.setFromAxisAngle(a, b))
}
}();
THREE.ArrowHelper.prototype.setLength = function(a) {
this.scale.set(a, a, a)
};
THREE.ArrowHelper.prototype.setColor = function(a) {
this.line.material.color.setHex(a);
this.cone.material.color.setHex(a)
};
THREE.BoxHelper = function(a) {
var b = [new THREE.Vector3(1, 1, 1), new THREE.Vector3(-1, 1, 1), new THREE.Vector3(-1, -1, 1), new THREE.Vector3(1, -1, 1), new THREE.Vector3(1, 1, -1), new THREE.Vector3(-1, 1, -1), new THREE.Vector3(-1, -1, -1), new THREE.Vector3(1, -1, -1)];
this.vertices = b;
var c = new THREE.Geometry;
c.vertices.push(b[0], b[1], b[1], b[2], b[2], b[3], b[3], b[0], b[4], b[5], b[5], b[6], b[6], b[7], b[7], b[4], b[0], b[4], b[1], b[5], b[2], b[6], b[3], b[7]);
THREE.Line.call(this, c, new THREE.LineBasicMaterial({
color: 16776960
}), THREE.LinePieces);
void 0 !== a && this.update(a)
};
THREE.BoxHelper.prototype = Object.create(THREE.Line.prototype);
THREE.BoxHelper.prototype.update = function(a) {
var b = a.geometry;
null === b.boundingBox && b.computeBoundingBox();
var c = b.boundingBox.min,
b = b.boundingBox.max,
d = this.vertices;
d[0].set(b.x, b.y, b.z);
d[1].set(c.x, b.y, b.z);
d[2].set(c.x, c.y, b.z);
d[3].set(b.x, c.y, b.z);
d[4].set(b.x, b.y, c.z);
d[5].set(c.x, b.y, c.z);
d[6].set(c.x, c.y, c.z);
d[7].set(b.x, c.y, c.z);
this.geometry.computeBoundingSphere();
this.geometry.verticesNeedUpdate = !0;
this.matrixAutoUpdate = !1;
this.matrixWorld = a.matrixWorld
};
THREE.BoundingBoxHelper = function(a, b) {
var c = b || 8947848;
this.object = a;
this.box = new THREE.Box3;
THREE.Mesh.call(this, new THREE.CubeGeometry(1, 1, 1), new THREE.MeshBasicMaterial({
color: c,
wireframe: !0
}))
};
THREE.BoundingBoxHelper.prototype = Object.create(THREE.Mesh.prototype);
THREE.BoundingBoxHelper.prototype.update = function() {
this.box.setFromObject(this.object);
this.box.size(this.scale);
this.box.center(this.position)
};
THREE.CameraHelper = function(a) {
function b(a, b, d) {
c(a, d);
c(b, d)
}
function c(a, b) {
d.vertices.push(new THREE.Vector3);
d.colors.push(new THREE.Color(b));
void 0 === f[a] && (f[a] = []);
f[a].push(d.vertices.length - 1)
}
var d = new THREE.Geometry,
e = new THREE.LineBasicMaterial({
color: 16777215,
vertexColors: THREE.FaceColors
}),
f = {};
b("n1", "n2", 16755200);
b("n2", "n4", 16755200);
b("n4", "n3", 16755200);
b("n3", "n1", 16755200);
b("f1", "f2", 16755200);
b("f2", "f4", 16755200);
b("f4", "f3", 16755200);
b("f3", "f1", 16755200);
b("n1", "f1", 16755200);
b("n2", "f2", 16755200);
b("n3", "f3", 16755200);
b("n4", "f4", 16755200);
b("p", "n1", 16711680);
b("p", "n2", 16711680);
b("p", "n3", 16711680);
b("p", "n4", 16711680);
b("u1", "u2", 43775);
b("u2", "u3", 43775);
b("u3", "u1", 43775);
b("c", "t", 16777215);
b("p", "c", 3355443);
b("cn1", "cn2", 3355443);
b("cn3", "cn4", 3355443);
b("cf1", "cf2", 3355443);
b("cf3", "cf4", 3355443);
THREE.Line.call(this, d, e, THREE.LinePieces);
this.camera = a;
this.matrixWorld = a.matrixWorld;
this.matrixAutoUpdate = !1;
this.pointMap = f;
this.update()
};
THREE.CameraHelper.prototype = Object.create(THREE.Line.prototype);
THREE.CameraHelper.prototype.update = function() {
var a = new THREE.Vector3,
b = new THREE.Camera,
c = new THREE.Projector;
return function() {
function d(d, g, h, i) {
a.set(g, h, i);
c.unprojectVector(a, b);
d = e.pointMap[d];
if (void 0 !== d) {
g = 0;
for (h = d.length; g < h; g++) e.geometry.vertices[d[g]].copy(a)
}
}
var e = this;
b.projectionMatrix.copy(this.camera.projectionMatrix);
d("c", 0, 0, -1);
d("t", 0, 0, 1);
d("n1", -1, -1, -1);
d("n2", 1, -1, -1);
d("n3", -1, 1, -1);
d("n4", 1, 1, -1);
d("f1", -1, -1, 1);
d("f2", 1, -1, 1);
d("f3", -1, 1, 1);
d("f4", 1, 1, 1);
d("u1",
0.7, 1.1, -1);
d("u2", -0.7, 1.1, -1);
d("u3", 0, 2, -1);
d("cf1", -1, 0, 1);
d("cf2", 1, 0, 1);
d("cf3", 0, -1, 1);
d("cf4", 0, 1, 1);
d("cn1", -1, 0, -1);
d("cn2", 1, 0, -1);
d("cn3", 0, -1, -1);
d("cn4", 0, 1, -1);
this.geometry.verticesNeedUpdate = !0
}
}();
THREE.DirectionalLightHelper = function(a, b) {
THREE.Object3D.call(this);
this.light = a;
this.light.updateMatrixWorld();
this.matrixWorld = a.matrixWorld;
this.matrixAutoUpdate = !1;
var c = new THREE.PlaneGeometry(b, b),
d = new THREE.MeshBasicMaterial({
wireframe: !0,
fog: !1
});
d.color.copy(this.light.color).multiplyScalar(this.light.intensity);
this.lightPlane = new THREE.Mesh(c, d);
this.add(this.lightPlane);
c = new THREE.Geometry;
c.vertices.push(new THREE.Vector3);
c.vertices.push(new THREE.Vector3);
c.computeLineDistances();
d = new THREE.LineBasicMaterial({
fog: !1
});
d.color.copy(this.light.color).multiplyScalar(this.light.intensity);
this.targetLine = new THREE.Line(c, d);
this.add(this.targetLine);
this.update()
};
THREE.DirectionalLightHelper.prototype = Object.create(THREE.Object3D.prototype);
THREE.DirectionalLightHelper.prototype.update = function() {
var a = new THREE.Vector3;
return function() {
a.getPositionFromMatrix(this.light.matrixWorld).negate();
this.lightPlane.lookAt(a);
this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
this.targetLine.geometry.vertices[1].copy(a);
this.targetLine.geometry.verticesNeedUpdate = !0;
this.targetLine.material.color.copy(this.lightPlane.material.color)
}
}();
THREE.FaceNormalsHelper = function(a, b, c, d) {
this.object = a;
this.size = b || 1;
for (var a = c || 16776960, d = d || 1, b = new THREE.Geometry, c = 0, e = this.object.geometry.faces.length; c < e; c++) b.vertices.push(new THREE.Vector3), b.vertices.push(new THREE.Vector3);
THREE.Line.call(this, b, new THREE.LineBasicMaterial({
color: a,
linewidth: d
}), THREE.LinePieces);
this.matrixAutoUpdate = !1;
this.normalMatrix = new THREE.Matrix3;
this.update()
};
THREE.FaceNormalsHelper.prototype = Object.create(THREE.Line.prototype);
THREE.FaceNormalsHelper.prototype.update = function() {
var a = new THREE.Vector3;
return function() {
this.object.updateMatrixWorld(!0);
this.normalMatrix.getNormalMatrix(this.object.matrixWorld);
for (var b = this.geometry.vertices, c = this.object.geometry.faces, d = this.object.matrixWorld, e = 0, f = c.length; e < f; e++) {
var g = c[e];
a.copy(g.normal).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size);
var h = 2 * e;
b[h].copy(g.centroid).applyMatrix4(d);
b[h + 1].addVectors(b[h], a)
}
this.geometry.verticesNeedUpdate = !0;
return this
}
}();
THREE.GridHelper = function(a, b) {
var c = new THREE.Geometry,
d = new THREE.LineBasicMaterial({
vertexColors: THREE.VertexColors
});
this.color1 = new THREE.Color(4473924);
this.color2 = new THREE.Color(8947848);
for (var e = -a; e <= a; e += b) {
c.vertices.push(new THREE.Vector3(-a, 0, e), new THREE.Vector3(a, 0, e), new THREE.Vector3(e, 0, -a), new THREE.Vector3(e, 0, a));
var f = 0 === e ? this.color1 : this.color2;
c.colors.push(f, f, f, f)
}
THREE.Line.call(this, c, d, THREE.LinePieces)
};
THREE.GridHelper.prototype = Object.create(THREE.Line.prototype);
THREE.GridHelper.prototype.setColors = function(a, b) {
this.color1.set(a);
this.color2.set(b);
this.geometry.colorsNeedUpdate = !0
};
THREE.HemisphereLightHelper = function(a, b) {
THREE.Object3D.call(this);
this.light = a;
this.light.updateMatrixWorld();
this.matrixWorld = a.matrixWorld;
this.matrixAutoUpdate = !1;
this.colors = [new THREE.Color, new THREE.Color];
var c = new THREE.SphereGeometry(b, 4, 2);
c.applyMatrix((new THREE.Matrix4).makeRotationX(-Math.PI / 2));
for (var d = 0; 8 > d; d++) c.faces[d].color = this.colors[4 > d ? 0 : 1];
d = new THREE.MeshBasicMaterial({
vertexColors: THREE.FaceColors,
wireframe: !0
});
this.lightSphere = new THREE.Mesh(c, d);
this.add(this.lightSphere);
this.update()
};
THREE.HemisphereLightHelper.prototype = Object.create(THREE.Object3D.prototype);
THREE.HemisphereLightHelper.prototype.update = function() {
var a = new THREE.Vector3;
return function() {
this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity);
this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity);
this.lightSphere.lookAt(a.getPositionFromMatrix(this.light.matrixWorld).negate());
this.lightSphere.geometry.colorsNeedUpdate = !0
}
}();
THREE.PointLightHelper = function(a, b) {
this.light = a;
this.light.updateMatrixWorld();
var c = new THREE.SphereGeometry(b, 4, 2),
d = new THREE.MeshBasicMaterial({
wireframe: !0,
fog: !1
});
d.color.copy(this.light.color).multiplyScalar(this.light.intensity);
THREE.Mesh.call(this, c, d);
this.matrixWorld = this.light.matrixWorld;
this.matrixAutoUpdate = !1
};
THREE.PointLightHelper.prototype = Object.create(THREE.Mesh.prototype);
THREE.PointLightHelper.prototype.update = function() {
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)
};
THREE.SpotLightHelper = function(a) {
THREE.Object3D.call(this);
this.light = a;
this.light.updateMatrixWorld();
this.matrixWorld = a.matrixWorld;
this.matrixAutoUpdate = !1;
a = new THREE.CylinderGeometry(0, 1, 1, 8, 1, !0);
a.applyMatrix((new THREE.Matrix4).makeTranslation(0, -0.5, 0));
a.applyMatrix((new THREE.Matrix4).makeRotationX(-Math.PI / 2));
var b = new THREE.MeshBasicMaterial({
wireframe: !0,
fog: !1
});
this.cone = new THREE.Mesh(a, b);
this.add(this.cone);
this.update()
};
THREE.SpotLightHelper.prototype = Object.create(THREE.Object3D.prototype);
THREE.SpotLightHelper.prototype.update = function() {
var a = new THREE.Vector3;
return function() {
var b = this.light.distance ? this.light.distance : 1E4,
c = b * Math.tan(this.light.angle);
this.cone.scale.set(c, c, b);
this.cone.lookAt(a.getPositionFromMatrix(this.light.matrixWorld).negate());
this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)
}
}();
THREE.VertexNormalsHelper = function(a, b, c, d) {
this.object = a;
this.size = b || 1;
for (var b = c || 16711680, d = d || 1, c = new THREE.Geometry, a = a.geometry.faces, e = 0, f = a.length; e < f; e++)
for (var g = 0, h = a[e].vertexNormals.length; g < h; g++) c.vertices.push(new THREE.Vector3), c.vertices.push(new THREE.Vector3);
THREE.Line.call(this, c, new THREE.LineBasicMaterial({
color: b,
linewidth: d
}), THREE.LinePieces);
this.matrixAutoUpdate = !1;
this.normalMatrix = new THREE.Matrix3;
this.update()
};
THREE.VertexNormalsHelper.prototype = Object.create(THREE.Line.prototype);
THREE.VertexNormalsHelper.prototype.update = function() {
var a = new THREE.Vector3;
return function() {
var b = ["a", "b", "c", "d"];
this.object.updateMatrixWorld(!0);
this.normalMatrix.getNormalMatrix(this.object.matrixWorld);
for (var c = this.geometry.vertices, d = this.object.geometry.vertices, e = this.object.geometry.faces, f = this.object.matrixWorld, g = 0, h = 0, i = e.length; h < i; h++)
for (var k = e[h], l = 0, m = k.vertexNormals.length; l < m; l++) {
var p = k.vertexNormals[l];
c[g].copy(d[k[b[l]]]).applyMatrix4(f);
a.copy(p).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size);
a.add(c[g]);
g += 1;
c[g].copy(a);
g += 1
}
this.geometry.verticesNeedUpdate = !0;
return this
}
}();
THREE.VertexTangentsHelper = function(a, b, c, d) {
this.object = a;
this.size = b || 1;
for (var b = c || 255, d = d || 1, c = new THREE.Geometry, a = a.geometry.faces, e = 0, f = a.length; e < f; e++)
for (var g = 0, h = a[e].vertexTangents.length; g < h; g++) c.vertices.push(new THREE.Vector3), c.vertices.push(new THREE.Vector3);
THREE.Line.call(this, c, new THREE.LineBasicMaterial({
color: b,
linewidth: d
}), THREE.LinePieces);
this.matrixAutoUpdate = !1;
this.update()
};
THREE.VertexTangentsHelper.prototype = Object.create(THREE.Line.prototype);
THREE.VertexTangentsHelper.prototype.update = function() {
var a = new THREE.Vector3;
return function() {
var b = ["a", "b", "c", "d"];
this.object.updateMatrixWorld(!0);
for (var c = this.geometry.vertices, d = this.object.geometry.vertices, e = this.object.geometry.faces, f = this.object.matrixWorld, g = 0, h = 0, i = e.length; h < i; h++)
for (var k = e[h], l = 0, m = k.vertexTangents.length; l < m; l++) {
var p = k.vertexTangents[l];
c[g].copy(d[k[b[l]]]).applyMatrix4(f);
a.copy(p).transformDirection(f).multiplyScalar(this.size);
a.add(c[g]);
g += 1;
c[g].copy(a);
g += 1
}
this.geometry.verticesNeedUpdate = !0;
return this
}
}();
THREE.WireframeHelper = function(a) {
for (var b = [0, 0], c = {}, d = function(a, b) {
return a - b
}, e = ["a", "b", "c", "d"], f = new THREE.Geometry, g = a.geometry.vertices, h = a.geometry.faces, i = 0, k = h.length; i < k; i++)
for (var l = h[i], m = l instanceof THREE.Face4 ? 4 : 3, p = 0; p < m; p++) {
b[0] = l[e[p]];
b[1] = l[e[(p + 1) % m]];
b.sort(d);
var q = b.toString();
void 0 === c[q] && (f.vertices.push(g[b[0]]), f.vertices.push(g[b[1]]), c[q] = !0)
}
THREE.Line.call(this, f, new THREE.LineBasicMaterial({
color: 16777215
}), THREE.LinePieces);
this.matrixAutoUpdate = !1;
this.matrixWorld =
a.matrixWorld
};
THREE.WireframeHelper.prototype = Object.create(THREE.Line.prototype);
THREE.ImmediateRenderObject = function() {
THREE.Object3D.call(this);
this.render = function() {}
};
THREE.ImmediateRenderObject.prototype = Object.create(THREE.Object3D.prototype);
THREE.LensFlare = function(a, b, c, d, e) {
THREE.Object3D.call(this);
this.lensFlares = [];
this.positionScreen = new THREE.Vector3;
this.customUpdateCallback = void 0;
void 0 !== a && this.add(a, b, c, d, e)
};
THREE.LensFlare.prototype = Object.create(THREE.Object3D.prototype);
THREE.LensFlare.prototype.add = function(a, b, c, d, e, f) {
void 0 === b && (b = -1);
void 0 === c && (c = 0);
void 0 === f && (f = 1);
void 0 === e && (e = new THREE.Color(16777215));
void 0 === d && (d = THREE.NormalBlending);
c = Math.min(c, Math.max(0, c));
this.lensFlares.push({
texture: a,
size: b,
distance: c,
x: 0,
y: 0,
z: 0,
scale: 1,
rotation: 1,
opacity: f,
color: e,
blending: d
})
};
THREE.LensFlare.prototype.updateLensFlares = function() {
var a, b = this.lensFlares.length,
c, d = 2 * -this.positionScreen.x,
e = 2 * -this.positionScreen.y;
for (a = 0; a < b; a++) c = this.lensFlares[a], c.x = this.positionScreen.x + d * c.distance, c.y = this.positionScreen.y + e * c.distance, c.wantedRotation = 0.25 * c.x * Math.PI, c.rotation += 0.25 * (c.wantedRotation - c.rotation)
};
THREE.MorphBlendMesh = function(a, b) {
THREE.Mesh.call(this, a, b);
this.animationsMap = {};
this.animationsList = [];
var c = this.geometry.morphTargets.length;
this.createAnimation("__default", 0, c - 1, c / 1);
this.setAnimationWeight("__default", 1)
};
THREE.MorphBlendMesh.prototype = Object.create(THREE.Mesh.prototype);
THREE.MorphBlendMesh.prototype.createAnimation = function(a, b, c, d) {
b = {
startFrame: b,
endFrame: c,
length: c - b + 1,
fps: d,
duration: (c - b) / d,
lastFrame: 0,
currentFrame: 0,
active: !1,
time: 0,
direction: 1,
weight: 1,
directionBackwards: !1,
mirroredLoop: !1
};
this.animationsMap[a] = b;
this.animationsList.push(b)
};
THREE.MorphBlendMesh.prototype.autoCreateAnimations = function(a) {
for (var b = /([a-z]+)(\d+)/, c, d = {}, e = this.geometry, f = 0, g = e.morphTargets.length; f < g; f++) {
var h = e.morphTargets[f].name.match(b);
if (h && 1 < h.length) {
var i = h[1];
d[i] || (d[i] = {
start: Infinity,
end: -Infinity
});
h = d[i];
f < h.start && (h.start = f);
f > h.end && (h.end = f);
c || (c = i)
}
}
for (i in d) h = d[i], this.createAnimation(i, h.start, h.end, a);
this.firstAnimation = c
};
THREE.MorphBlendMesh.prototype.setAnimationDirectionForward = function(a) {
if (a = this.animationsMap[a]) a.direction = 1, a.directionBackwards = !1
};
THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward = function(a) {
if (a = this.animationsMap[a]) a.direction = -1, a.directionBackwards = !0
};
THREE.MorphBlendMesh.prototype.setAnimationFPS = function(a, b) {
var c = this.animationsMap[a];
c && (c.fps = b, c.duration = (c.end - c.start) / c.fps)
};
THREE.MorphBlendMesh.prototype.setAnimationDuration = function(a, b) {
var c = this.animationsMap[a];
c && (c.duration = b, c.fps = (c.end - c.start) / c.duration)
};
THREE.MorphBlendMesh.prototype.setAnimationWeight = function(a, b) {
var c = this.animationsMap[a];
c && (c.weight = b)
};
THREE.MorphBlendMesh.prototype.setAnimationTime = function(a, b) {
var c = this.animationsMap[a];
c && (c.time = b)
};
THREE.MorphBlendMesh.prototype.getAnimationTime = function(a) {
var b = 0;
if (a = this.animationsMap[a]) b = a.time;
return b
};
THREE.MorphBlendMesh.prototype.getAnimationDuration = function(a) {
var b = -1;
if (a = this.animationsMap[a]) b = a.duration;
return b
};
THREE.MorphBlendMesh.prototype.playAnimation = function(a) {
var b = this.animationsMap[a];
b ? (b.time = 0, b.active = !0) : console.warn("animation[" + a + "] undefined")
};
THREE.MorphBlendMesh.prototype.stopAnimation = function(a) {
if (a = this.animationsMap[a]) a.active = !1
};
THREE.MorphBlendMesh.prototype.update = function(a) {
for (var b = 0, c = this.animationsList.length; b < c; b++) {
var d = this.animationsList[b];
if (d.active) {
var e = d.duration / d.length;
d.time += d.direction * a;
if (d.mirroredLoop) {
if (d.time > d.duration || 0 > d.time) d.direction *= -1, d.time > d.duration && (d.time = d.duration, d.directionBackwards = !0), 0 > d.time && (d.time = 0, d.directionBackwards = !1)
} else d.time %= d.duration, 0 > d.time && (d.time += d.duration);
var f = d.startFrame + THREE.Math.clamp(Math.floor(d.time / e), 0, d.length - 1),
g = d.weight;
f !== d.currentFrame && (this.morphTargetInfluences[d.lastFrame] = 0, this.morphTargetInfluences[d.currentFrame] = 1 * g, this.morphTargetInfluences[f] = 0, d.lastFrame = d.currentFrame, d.currentFrame = f);
e = d.time % e / e;
d.directionBackwards && (e = 1 - e);
this.morphTargetInfluences[d.currentFrame] = e * g;
this.morphTargetInfluences[d.lastFrame] = (1 - e) * g
}
}
};
THREE.LensFlarePlugin = function() {
function a(a, c) {
var d = b.createProgram(),
e = b.createShader(b.FRAGMENT_SHADER),
f = b.createShader(b.VERTEX_SHADER),
g = "precision " + c + " float;\n";
b.shaderSource(e, g + a.fragmentShader);
b.shaderSource(f, g + a.vertexShader);
b.compileShader(e);
b.compileShader(f);
b.attachShader(d, e);
b.attachShader(d, f);
b.linkProgram(d);
return d
}
var b, c, d, e, f, g, h, i, k, l, m, p, q;
this.init = function(t) {
b = t.context;
c = t;
d = t.getPrecision();
e = new Float32Array(16);
f = new Uint16Array(6);
t = 0;
e[t++] = -1;
e[t++] = -1;
e[t++] = 0;
e[t++] = 0;
e[t++] = 1;
e[t++] = -1;
e[t++] = 1;
e[t++] = 0;
e[t++] = 1;
e[t++] = 1;
e[t++] = 1;
e[t++] = 1;
e[t++] = -1;
e[t++] = 1;
e[t++] = 0;
e[t++] = 1;
t = 0;
f[t++] = 0;
f[t++] = 1;
f[t++] = 2;
f[t++] = 0;
f[t++] = 2;
f[t++] = 3;
g = b.createBuffer();
h = b.createBuffer();
b.bindBuffer(b.ARRAY_BUFFER, g);
b.bufferData(b.ARRAY_BUFFER, e, b.STATIC_DRAW);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, h);
b.bufferData(b.ELEMENT_ARRAY_BUFFER, f, b.STATIC_DRAW);
i = b.createTexture();
k = b.createTexture();
b.bindTexture(b.TEXTURE_2D, i);
b.texImage2D(b.TEXTURE_2D, 0, b.RGB, 16, 16,
0, b.RGB, b.UNSIGNED_BYTE, null);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S, b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_T, b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MAG_FILTER, b.NEAREST);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, b.NEAREST);
b.bindTexture(b.TEXTURE_2D, k);
b.texImage2D(b.TEXTURE_2D, 0, b.RGBA, 16, 16, 0, b.RGBA, b.UNSIGNED_BYTE, null);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S, b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_T, b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MAG_FILTER, b.NEAREST);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, b.NEAREST);
0 >= b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS) ? (l = !1, m = a(THREE.ShaderFlares.lensFlare, d)) : (l = !0, m = a(THREE.ShaderFlares.lensFlareVertexTexture, d));
p = {};
q = {};
p.vertex = b.getAttribLocation(m, "position");
p.uv = b.getAttribLocation(m, "uv");
q.renderType = b.getUniformLocation(m, "renderType");
q.map = b.getUniformLocation(m, "map");
q.occlusionMap = b.getUniformLocation(m, "occlusionMap");
q.opacity =
b.getUniformLocation(m, "opacity");
q.color = b.getUniformLocation(m, "color");
q.scale = b.getUniformLocation(m, "scale");
q.rotation = b.getUniformLocation(m, "rotation");
q.screenPosition = b.getUniformLocation(m, "screenPosition")
};
this.render = function(a, d, e, f) {
var a = a.__webglFlares,
v = a.length;
if (v) {
var z = new THREE.Vector3,
H = f / e,
B = 0.5 * e,
G = 0.5 * f,
I = 16 / f,
F = new THREE.Vector2(I * H, I),
A = new THREE.Vector3(1, 1, 0),
N = new THREE.Vector2(1, 1),
C = q,
I = p;
b.useProgram(m);
b.enableVertexAttribArray(p.vertex);
b.enableVertexAttribArray(p.uv);
b.uniform1i(C.occlusionMap, 0);
b.uniform1i(C.map, 1);
b.bindBuffer(b.ARRAY_BUFFER, g);
b.vertexAttribPointer(I.vertex, 2, b.FLOAT, !1, 16, 0);
b.vertexAttribPointer(I.uv, 2, b.FLOAT, !1, 16, 8);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, h);
b.disable(b.CULL_FACE);
b.depthMask(!1);
var K, M, y, J, w;
for (K = 0; K < v; K++)
if (I = 16 / f, F.set(I * H, I), J = a[K], z.set(J.matrixWorld.elements[12], J.matrixWorld.elements[13], J.matrixWorld.elements[14]), z.applyMatrix4(d.matrixWorldInverse), z.applyProjection(d.projectionMatrix), A.copy(z), N.x = A.x * B + B,
N.y = A.y * G + G, l || 0 < N.x && N.x < e && 0 < N.y && N.y < f) {
b.activeTexture(b.TEXTURE1);
b.bindTexture(b.TEXTURE_2D, i);
b.copyTexImage2D(b.TEXTURE_2D, 0, b.RGB, N.x - 8, N.y - 8, 16, 16, 0);
b.uniform1i(C.renderType, 0);
b.uniform2f(C.scale, F.x, F.y);
b.uniform3f(C.screenPosition, A.x, A.y, A.z);
b.disable(b.BLEND);
b.enable(b.DEPTH_TEST);
b.drawElements(b.TRIANGLES, 6, b.UNSIGNED_SHORT, 0);
b.activeTexture(b.TEXTURE0);
b.bindTexture(b.TEXTURE_2D, k);
b.copyTexImage2D(b.TEXTURE_2D, 0, b.RGBA, N.x - 8, N.y - 8, 16, 16, 0);
b.uniform1i(C.renderType, 1);
b.disable(b.DEPTH_TEST);
b.activeTexture(b.TEXTURE1);
b.bindTexture(b.TEXTURE_2D, i);
b.drawElements(b.TRIANGLES, 6, b.UNSIGNED_SHORT, 0);
J.positionScreen.copy(A);
J.customUpdateCallback ? J.customUpdateCallback(J) : J.updateLensFlares();
b.uniform1i(C.renderType, 2);
b.enable(b.BLEND);
M = 0;
for (y = J.lensFlares.length; M < y; M++) w = J.lensFlares[M], 0.001 < w.opacity && 0.001 < w.scale && (A.x = w.x, A.y = w.y, A.z = w.z, I = w.size * w.scale / f, F.x = I * H, F.y = I, b.uniform3f(C.screenPosition, A.x, A.y, A.z), b.uniform2f(C.scale, F.x, F.y), b.uniform1f(C.rotation, w.rotation), b.uniform1f(C.opacity,
w.opacity), b.uniform3f(C.color, w.color.r, w.color.g, w.color.b), c.setBlending(w.blending, w.blendEquation, w.blendSrc, w.blendDst), c.setTexture(w.texture, 1), b.drawElements(b.TRIANGLES, 6, b.UNSIGNED_SHORT, 0))
}
b.enable(b.CULL_FACE);
b.enable(b.DEPTH_TEST);
b.depthMask(!0)
}
}
};
THREE.ShadowMapPlugin = function() {
var a, b, c, d, e, f, g = new THREE.Frustum,
h = new THREE.Matrix4,
i = new THREE.Vector3,
k = new THREE.Vector3,
l = new THREE.Vector3;
this.init = function(g) {
a = g.context;
b = g;
var g = THREE.ShaderLib.depthRGBA,
h = THREE.UniformsUtils.clone(g.uniforms);
c = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h
});
d = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h,
morphTargets: !0
});
e = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h,
skinning: !0
});
f = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h,
morphTargets: !0,
skinning: !0
});
c._shadowPass = !0;
d._shadowPass = !0;
e._shadowPass = !0;
f._shadowPass = !0
};
this.render = function(a, c) {
b.shadowMapEnabled && b.shadowMapAutoUpdate && this.update(a, c)
};
this.update = function(m, p) {
var q, t, n, r, s, v, z, H, B, G = [];
r = 0;
a.clearColor(1, 1, 1, 1);
a.disable(a.BLEND);
a.enable(a.CULL_FACE);
a.frontFace(a.CCW);
b.shadowMapCullFace === THREE.CullFaceFront ?
a.cullFace(a.FRONT) : a.cullFace(a.BACK);
b.setDepthTest(!0);
q = 0;
for (t = m.__lights.length; q < t; q++)
if (n = m.__lights[q], n.castShadow)
if (n instanceof THREE.DirectionalLight && n.shadowCascade)
for (s = 0; s < n.shadowCascadeCount; s++) {
var I;
if (n.shadowCascadeArray[s]) I = n.shadowCascadeArray[s];
else {
B = n;
z = s;
I = new THREE.DirectionalLight;
I.isVirtual = !0;
I.onlyShadow = !0;
I.castShadow = !0;
I.shadowCameraNear = B.shadowCameraNear;
I.shadowCameraFar = B.shadowCameraFar;
I.shadowCameraLeft = B.shadowCameraLeft;
I.shadowCameraRight = B.shadowCameraRight;
I.shadowCameraBottom = B.shadowCameraBottom;
I.shadowCameraTop = B.shadowCameraTop;
I.shadowCameraVisible = B.shadowCameraVisible;
I.shadowDarkness = B.shadowDarkness;
I.shadowBias = B.shadowCascadeBias[z];
I.shadowMapWidth = B.shadowCascadeWidth[z];
I.shadowMapHeight = B.shadowCascadeHeight[z];
I.pointsWorld = [];
I.pointsFrustum = [];
H = I.pointsWorld;
v = I.pointsFrustum;
for (var F = 0; 8 > F; F++) H[F] = new THREE.Vector3, v[F] = new THREE.Vector3;
H = B.shadowCascadeNearZ[z];
B = B.shadowCascadeFarZ[z];
v[0].set(-1, -1, H);
v[1].set(1, -1, H);
v[2].set(-1,
1, H);
v[3].set(1, 1, H);
v[4].set(-1, -1, B);
v[5].set(1, -1, B);
v[6].set(-1, 1, B);
v[7].set(1, 1, B);
I.originalCamera = p;
v = new THREE.Gyroscope;
v.position = n.shadowCascadeOffset;
v.add(I);
v.add(I.target);
p.add(v);
n.shadowCascadeArray[s] = I;
console.log("Created virtualLight", I)
}
z = n;
H = s;
B = z.shadowCascadeArray[H];
B.position.copy(z.position);
B.target.position.copy(z.target.position);
B.lookAt(B.target);
B.shadowCameraVisible = z.shadowCameraVisible;
B.shadowDarkness = z.shadowDarkness;
B.shadowBias = z.shadowCascadeBias[H];
v = z.shadowCascadeNearZ[H];
z = z.shadowCascadeFarZ[H];
B = B.pointsFrustum;
B[0].z = v;
B[1].z = v;
B[2].z = v;
B[3].z = v;
B[4].z = z;
B[5].z = z;
B[6].z = z;
B[7].z = z;
G[r] = I;
r++
} else G[r] = n, r++;
q = 0;
for (t = G.length; q < t; q++) {
n = G[q];
n.shadowMap || (s = THREE.LinearFilter, b.shadowMapType === THREE.PCFSoftShadowMap && (s = THREE.NearestFilter), n.shadowMap = new THREE.WebGLRenderTarget(n.shadowMapWidth, n.shadowMapHeight, {
minFilter: s,
magFilter: s,
format: THREE.RGBAFormat
}), n.shadowMapSize = new THREE.Vector2(n.shadowMapWidth, n.shadowMapHeight), n.shadowMatrix = new THREE.Matrix4);
if (!n.shadowCamera) {
if (n instanceof THREE.SpotLight) n.shadowCamera = new THREE.PerspectiveCamera(n.shadowCameraFov, n.shadowMapWidth / n.shadowMapHeight, n.shadowCameraNear, n.shadowCameraFar);
else if (n instanceof THREE.DirectionalLight) n.shadowCamera = new THREE.OrthographicCamera(n.shadowCameraLeft, n.shadowCameraRight, n.shadowCameraTop, n.shadowCameraBottom, n.shadowCameraNear, n.shadowCameraFar);
else {
console.error("Unsupported light type for shadow");
continue
}
m.add(n.shadowCamera);
!0 === m.autoUpdate && m.updateMatrixWorld()
}
n.shadowCameraVisible &&
!n.cameraHelper && (n.cameraHelper = new THREE.CameraHelper(n.shadowCamera), n.shadowCamera.add(n.cameraHelper));
if (n.isVirtual && I.originalCamera == p) {
s = p;
r = n.shadowCamera;
v = n.pointsFrustum;
B = n.pointsWorld;
i.set(Infinity, Infinity, Infinity);
k.set(-Infinity, -Infinity, -Infinity);
for (z = 0; 8 > z; z++) H = B[z], H.copy(v[z]), THREE.ShadowMapPlugin.__projector.unprojectVector(H, s), H.applyMatrix4(r.matrixWorldInverse), H.x < i.x && (i.x = H.x), H.x > k.x && (k.x = H.x), H.y < i.y && (i.y = H.y), H.y > k.y && (k.y = H.y), H.z < i.z && (i.z = H.z), H.z > k.z &&
(k.z = H.z);
r.left = i.x;
r.right = k.x;
r.top = k.y;
r.bottom = i.y;
r.updateProjectionMatrix()
}
r = n.shadowMap;
v = n.shadowMatrix;
s = n.shadowCamera;
s.position.getPositionFromMatrix(n.matrixWorld);
l.getPositionFromMatrix(n.target.matrixWorld);
s.lookAt(l);
s.updateMatrixWorld();
s.matrixWorldInverse.getInverse(s.matrixWorld);
n.cameraHelper && (n.cameraHelper.visible = n.shadowCameraVisible);
n.shadowCameraVisible && n.cameraHelper.update();
v.set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1);
v.multiply(s.projectionMatrix);
v.multiply(s.matrixWorldInverse);
h.multiplyMatrices(s.projectionMatrix, s.matrixWorldInverse);
g.setFromMatrix(h);
b.setRenderTarget(r);
b.clear();
B = m.__webglObjects;
n = 0;
for (r = B.length; n < r; n++)
if (z = B[n], v = z.object, z.render = !1, v.visible && v.castShadow && (!(v instanceof THREE.Mesh || v instanceof THREE.ParticleSystem) || !v.frustumCulled || g.intersectsObject(v))) v._modelViewMatrix.multiplyMatrices(s.matrixWorldInverse, v.matrixWorld), z.render = !0;
n = 0;
for (r = B.length; n < r; n++) z = B[n], z.render && (v = z.object, z = z.buffer, F = v.material instanceof THREE.MeshFaceMaterial ?
v.material.materials[0] : v.material, H = 0 < v.geometry.morphTargets.length && F.morphTargets, F = v instanceof THREE.SkinnedMesh && F.skinning, H = v.customDepthMaterial ? v.customDepthMaterial : F ? H ? f : e : H ? d : c, z instanceof THREE.BufferGeometry ? b.renderBufferDirect(s, m.__lights, null, H, z, v) : b.renderBuffer(s, m.__lights, null, H, z, v));
B = m.__webglObjectsImmediate;
n = 0;
for (r = B.length; n < r; n++) z = B[n], v = z.object, v.visible && v.castShadow && (v._modelViewMatrix.multiplyMatrices(s.matrixWorldInverse, v.matrixWorld), b.renderImmediateObject(s,
m.__lights, null, c, v))
}
q = b.getClearColor();
t = b.getClearAlpha();
a.clearColor(q.r, q.g, q.b, t);
a.enable(a.BLEND);
b.shadowMapCullFace === THREE.CullFaceFront && a.cullFace(a.BACK)
}
};
THREE.ShadowMapPlugin.__projector = new THREE.Projector;
THREE.SpritePlugin = function() {
function a(a, b) {
return a.z !== b.z ? b.z - a.z : b.id - a.id
}
var b, c, d, e, f, g, h, i, k, l;
this.init = function(a) {
b = a.context;
c = a;
d = a.getPrecision();
e = new Float32Array(16);
f = new Uint16Array(6);
a = 0;
e[a++] = -1;
e[a++] = -1;
e[a++] = 0;
e[a++] = 0;
e[a++] = 1;
e[a++] = -1;
e[a++] = 1;
e[a++] = 0;
e[a++] = 1;
e[a++] = 1;
e[a++] = 1;
e[a++] = 1;
e[a++] = -1;
e[a++] = 1;
e[a++] = 0;
e[a++] = 1;
a = 0;
f[a++] = 0;
f[a++] = 1;
f[a++] = 2;
f[a++] = 0;
f[a++] = 2;
f[a++] = 3;
g = b.createBuffer();
h = b.createBuffer();
b.bindBuffer(b.ARRAY_BUFFER, g);
b.bufferData(b.ARRAY_BUFFER,
e, b.STATIC_DRAW);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, h);
b.bufferData(b.ELEMENT_ARRAY_BUFFER, f, b.STATIC_DRAW);
var a = THREE.ShaderSprite.sprite,
p = b.createProgram(),
q = b.createShader(b.FRAGMENT_SHADER),
t = b.createShader(b.VERTEX_SHADER),
n = "precision " + d + " float;\n";
b.shaderSource(q, n + a.fragmentShader);
b.shaderSource(t, n + a.vertexShader);
b.compileShader(q);
b.compileShader(t);
b.attachShader(p, q);
b.attachShader(p, t);
b.linkProgram(p);
i = p;
k = {};
l = {};
k.position = b.getAttribLocation(i, "position");
k.uv = b.getAttribLocation(i,
"uv");
l.uvOffset = b.getUniformLocation(i, "uvOffset");
l.uvScale = b.getUniformLocation(i, "uvScale");
l.rotation = b.getUniformLocation(i, "rotation");
l.scale = b.getUniformLocation(i, "scale");
l.alignment = b.getUniformLocation(i, "alignment");
l.color = b.getUniformLocation(i, "color");
l.map = b.getUniformLocation(i, "map");
l.opacity = b.getUniformLocation(i, "opacity");
l.useScreenCoordinates = b.getUniformLocation(i, "useScreenCoordinates");
l.sizeAttenuation = b.getUniformLocation(i, "sizeAttenuation");
l.screenPosition = b.getUniformLocation(i,
"screenPosition");
l.modelViewMatrix = b.getUniformLocation(i, "modelViewMatrix");
l.projectionMatrix = b.getUniformLocation(i, "projectionMatrix");
l.fogType = b.getUniformLocation(i, "fogType");
l.fogDensity = b.getUniformLocation(i, "fogDensity");
l.fogNear = b.getUniformLocation(i, "fogNear");
l.fogFar = b.getUniformLocation(i, "fogFar");
l.fogColor = b.getUniformLocation(i, "fogColor");
l.alphaTest = b.getUniformLocation(i, "alphaTest")
};
this.render = function(d, e, f, t) {
var n = d.__webglSprites,
r = n.length;
if (r) {
var s = k,
v = l,
z = t /
f,
f = 0.5 * f,
H = 0.5 * t;
b.useProgram(i);
b.enableVertexAttribArray(s.position);
b.enableVertexAttribArray(s.uv);
b.disable(b.CULL_FACE);
b.enable(b.BLEND);
b.bindBuffer(b.ARRAY_BUFFER, g);
b.vertexAttribPointer(s.position, 2, b.FLOAT, !1, 16, 0);
b.vertexAttribPointer(s.uv, 2, b.FLOAT, !1, 16, 8);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, h);
b.uniformMatrix4fv(v.projectionMatrix, !1, e.projectionMatrix.elements);
b.activeTexture(b.TEXTURE0);
b.uniform1i(v.map, 0);
var B = s = 0,
G = d.fog;
G ? (b.uniform3f(v.fogColor, G.color.r, G.color.g, G.color.b),
G instanceof THREE.Fog ? (b.uniform1f(v.fogNear, G.near), b.uniform1f(v.fogFar, G.far), b.uniform1i(v.fogType, 1), B = s = 1) : G instanceof THREE.FogExp2 && (b.uniform1f(v.fogDensity, G.density), b.uniform1i(v.fogType, 2), B = s = 2)) : (b.uniform1i(v.fogType, 0), B = s = 0);
for (var I, F, A = [], G = 0; G < r; G++) I = n[G], F = I.material, I.visible && 0 !== F.opacity && (F.useScreenCoordinates ? I.z = -I.position.z : (I._modelViewMatrix.multiplyMatrices(e.matrixWorldInverse, I.matrixWorld), I.z = -I._modelViewMatrix.elements[14]));
n.sort(a);
for (G = 0; G < r; G++) I =
n[G], F = I.material, I.visible && 0 !== F.opacity && (F.map && F.map.image && F.map.image.width) && (b.uniform1f(v.alphaTest, F.alphaTest), !0 === F.useScreenCoordinates ? (b.uniform1i(v.useScreenCoordinates, 1), b.uniform3f(v.screenPosition, (I.position.x * c.devicePixelRatio - f) / f, (H - I.position.y * c.devicePixelRatio) / H, Math.max(0, Math.min(1, I.position.z))), A[0] = c.devicePixelRatio, A[1] = c.devicePixelRatio) : (b.uniform1i(v.useScreenCoordinates, 0), b.uniform1i(v.sizeAttenuation, F.sizeAttenuation ? 1 : 0), b.uniformMatrix4fv(v.modelViewMatrix, !1, I._modelViewMatrix.elements), A[0] = 1, A[1] = 1), e = d.fog && F.fog ? B : 0, s !== e && (b.uniform1i(v.fogType, e), s = e), e = 1 / (F.scaleByViewport ? t : 1), A[0] *= e * z * I.scale.x, A[1] *= e * I.scale.y, b.uniform2f(v.uvScale, F.uvScale.x, F.uvScale.y), b.uniform2f(v.uvOffset, F.uvOffset.x, F.uvOffset.y), b.uniform2f(v.alignment, F.alignment.x, F.alignment.y), b.uniform1f(v.opacity, F.opacity), b.uniform3f(v.color, F.color.r, F.color.g, F.color.b), b.uniform1f(v.rotation, I.rotation), b.uniform2fv(v.scale, A), c.setBlending(F.blending, F.blendEquation,
F.blendSrc, F.blendDst), c.setDepthTest(F.depthTest), c.setDepthWrite(F.depthWrite), c.setTexture(F.map, 0), b.drawElements(b.TRIANGLES, 6, b.UNSIGNED_SHORT, 0));
b.enable(b.CULL_FACE)
}
}
};
THREE.DepthPassPlugin = function() {
this.enabled = !1;
this.renderTarget = null;
var a, b, c, d, e, f, g = new THREE.Frustum,
h = new THREE.Matrix4;
this.init = function(g) {
a = g.context;
b = g;
var g = THREE.ShaderLib.depthRGBA,
h = THREE.UniformsUtils.clone(g.uniforms);
c = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h
});
d = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h,
morphTargets: !0
});
e = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h,
skinning: !0
});
f = new THREE.ShaderMaterial({
fragmentShader: g.fragmentShader,
vertexShader: g.vertexShader,
uniforms: h,
morphTargets: !0,
skinning: !0
});
c._shadowPass = !0;
d._shadowPass = !0;
e._shadowPass = !0;
f._shadowPass = !0
};
this.render = function(a, b) {
this.enabled && this.update(a, b)
};
this.update = function(i, k) {
var l, m, p, q, t, n;
a.clearColor(1, 1, 1, 1);
a.disable(a.BLEND);
b.setDepthTest(!0);
!0 === i.autoUpdate && i.updateMatrixWorld();
k.matrixWorldInverse.getInverse(k.matrixWorld);
h.multiplyMatrices(k.projectionMatrix,
k.matrixWorldInverse);
g.setFromMatrix(h);
b.setRenderTarget(this.renderTarget);
b.clear();
n = i.__webglObjects;
l = 0;
for (m = n.length; l < m; l++)
if (p = n[l], t = p.object, p.render = !1, t.visible && (!(t instanceof THREE.Mesh || t instanceof THREE.ParticleSystem) || !t.frustumCulled || g.intersectsObject(t))) t._modelViewMatrix.multiplyMatrices(k.matrixWorldInverse, t.matrixWorld), p.render = !0;
var r;
l = 0;
for (m = n.length; l < m; l++)
if (p = n[l], p.render && (t = p.object, p = p.buffer, !(t instanceof THREE.ParticleSystem) || t.customDepthMaterial))(r =
t.material instanceof THREE.MeshFaceMaterial ? t.material.materials[0] : t.material) && b.setMaterialFaces(t.material), q = 0 < t.geometry.morphTargets.length && r.morphTargets, r = t instanceof THREE.SkinnedMesh && r.skinning, q = t.customDepthMaterial ? t.customDepthMaterial : r ? q ? f : e : q ? d : c, p instanceof THREE.BufferGeometry ? b.renderBufferDirect(k, i.__lights, null, q, p, t) : b.renderBuffer(k, i.__lights, null, q, p, t);
n = i.__webglObjectsImmediate;
l = 0;
for (m = n.length; l < m; l++) p = n[l], t = p.object, t.visible && (t._modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,
t.matrixWorld), b.renderImmediateObject(k, i.__lights, null, c, t));
l = b.getClearColor();
m = b.getClearAlpha();
a.clearColor(l.r, l.g, l.b, m);
a.enable(a.BLEND)
}
};
THREE.ShaderFlares = {
lensFlareVertexTexture: {
vertexShader: "uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = visibility.r / 9.0;\nvVisibility *= 1.0 - visibility.g / 9.0;\nvVisibility *= visibility.b / 9.0;\nvVisibility *= 1.0 - visibility.a / 9.0;\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
fragmentShader: "uniform lowp int renderType;\nuniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"
},
lensFlare: {
vertexShader: "uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
fragmentShader: "precision mediump float;\nuniform lowp int renderType;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"
}
};
THREE.ShaderSprite = {
sprite: {
vertexShader: "uniform int useScreenCoordinates;\nuniform int sizeAttenuation;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( sizeAttenuation == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",
fragmentShader: "uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"
}
};
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6
*
* Requires: 1.2.2+
*/
(function(a) {
function d(b) {
var c = b || window.event,
d = [].slice.call(arguments, 1),
e = 0,
f = !0,
g = 0,
h = 0;
return b = a.event.fix(c), b.type = "mousewheel", c.wheelDelta && (e = c.wheelDelta / 120), c.detail && (e = -c.detail / 3), h = e, c.axis !== undefined && c.axis === c.HORIZONTAL_AXIS && (h = 0, g = -1 * e), c.wheelDeltaY !== undefined && (h = c.wheelDeltaY / 120), c.wheelDeltaX !== undefined && (g = -1 * c.wheelDeltaX / 120), d.unshift(b, e, g, h), (a.event.dispatch || a.event.handle).apply(this, d)
}
var b = ["DOMMouseScroll", "mousewheel"];
if (a.event.fixHooks)
for (var c = b.length; c;) a.event.fixHooks[b[--c]] = a.event.mouseHooks;
a.event.special.mousewheel = {
setup: function() {
if (this.addEventListener)
for (var a = b.length; a;) this.addEventListener(b[--a], d, !1);
else this.onmousewheel = d
},
teardown: function() {
if (this.removeEventListener)
for (var a = b.length; a;) this.removeEventListener(b[--a], d, !1);
else this.onmousewheel = null
}
}, a.fn.extend({
mousewheel: function(a) {
return a ? this.bind("mousewheel", a) : this.trigger("mousewheel")
},
unmousewheel: function(a) {
return this.unbind("mousewheel", a)
}
})
})(jQuery)
THREE.BinaryLoader = function(showStatus) {
THREE.Loader.call(this, showStatus);
};
THREE.BinaryLoader.prototype = Object.create(THREE.Loader.prototype);
THREE.BinaryLoader.prototype.load = function(url, callback, texturePath, binaryPath) {
texturePath = texturePath || this.extractUrlBase(url);
binaryPath = binaryPath || this.extractUrlBase(url);
var callbackProgress = this.showProgress ? THREE.Loader.prototype.updateProgress : undefined;
this.onLoadStart();
this.loadAjaxJSON(this, url, callback, texturePath, binaryPath, callbackProgress);
};
THREE.BinaryLoader.prototype.loadAjaxJSON = function(context, url, callback, texturePath, binaryPath, callbackProgress) {
var xhr = new XMLHttpRequest();
texturePath = texturePath && (typeof texturePath === "string") ? texturePath : this.extractUrlBase(url);
binaryPath = binaryPath && (typeof binaryPath === "string") ? binaryPath : this.extractUrlBase(url);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status == 0) {
var json = JSON.parse(xhr.responseText);
context.loadAjaxBuffers(json, callback, binaryPath, texturePath, callbackProgress);
} else {
console.error("THREE.BinaryLoader: Couldn't load [" + url + "] [" + xhr.status + "]");
}
}
};
xhr.open("GET", url, true);
xhr.send(null);
};
THREE.BinaryLoader.prototype.loadAjaxBuffers = function(json, callback, binaryPath, texturePath, callbackProgress) {
var xhr = new XMLHttpRequest(),
url = binaryPath + "/" + json.buffers;
xhr.addEventListener('load', function(event) {
var buffer = xhr.response;
if (buffer === undefined) {
buffer = (new Uint8Array(xhr.responseBody)).buffer;
}
if (buffer.byteLength == 0) {
var buffer = new ArrayBuffer(xhr.responseText.length);
var bufView = new Uint8Array(buffer);
for (var i = 0, l = xhr.responseText.length; i < l; i++) {
bufView[i] = xhr.responseText.charCodeAt(i) & 0xff;
}
}
THREE.BinaryLoader.prototype.createBinModel(buffer, callback, texturePath, json.materials);
}, false);
if (callbackProgress !== undefined) {
xhr.addEventListener('progress', function(event) {
callbackProgress(event);
}, false);
}
xhr.addEventListener('error', function(event) {
console.error("THREE.BinaryLoader: Couldn't load [" + url + "] [" + xhr.status + "]");
}, false);
xhr.open("GET", url, true);
xhr.responseType = "arraybuffer";
if (xhr.overrideMimeType) xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send(null);
};
THREE.BinaryLoader.prototype.createBinModel = function(data, callback, texturePath, jsonMaterials) {
var Model = function(texturePath) {
var scope = this,
currentOffset = 0,
md, normals = [],
uvs = [],
start_tri_flat, start_tri_smooth, start_tri_flat_uv, start_tri_smooth_uv, start_quad_flat, start_quad_smooth, start_quad_flat_uv, start_quad_smooth_uv, tri_size, quad_size, len_tri_flat, len_tri_smooth, len_tri_flat_uv, len_tri_smooth_uv, len_quad_flat, len_quad_smooth, len_quad_flat_uv, len_quad_smooth_uv;
THREE.Geometry.call(this);
md = parseMetaData(data, currentOffset);
currentOffset += md.header_bytes;
tri_size = md.vertex_index_bytes * 3 + md.material_index_bytes;
quad_size = md.vertex_index_bytes * 4 + md.material_index_bytes;
len_tri_flat = md.ntri_flat * (tri_size);
len_tri_smooth = md.ntri_smooth * (tri_size + md.normal_index_bytes * 3);
len_tri_flat_uv = md.ntri_flat_uv * (tri_size + md.uv_index_bytes * 3);
len_tri_smooth_uv = md.ntri_smooth_uv * (tri_size + md.normal_index_bytes * 3 + md.uv_index_bytes * 3);
len_quad_flat = md.nquad_flat * (quad_size);
len_quad_smooth = md.nquad_smooth * (quad_size + md.normal_index_bytes * 4);
len_quad_flat_uv = md.nquad_flat_uv * (quad_size + md.uv_index_bytes * 4);
len_quad_smooth_uv = md.nquad_smooth_uv * (quad_size + md.normal_index_bytes * 4 + md.uv_index_bytes * 4);
currentOffset += init_vertices(currentOffset);
currentOffset += init_normals(currentOffset);
currentOffset += handlePadding(md.nnormals * 3);
currentOffset += init_uvs(currentOffset);
start_tri_flat = currentOffset;
start_tri_smooth = start_tri_flat + len_tri_flat + handlePadding(md.ntri_flat * 2);
start_tri_flat_uv = start_tri_smooth + len_tri_smooth + handlePadding(md.ntri_smooth * 2);
start_tri_smooth_uv = start_tri_flat_uv + len_tri_flat_uv + handlePadding(md.ntri_flat_uv * 2);
start_quad_flat = start_tri_smooth_uv + len_tri_smooth_uv + handlePadding(md.ntri_smooth_uv * 2);
start_quad_smooth = start_quad_flat + len_quad_flat + handlePadding(md.nquad_flat * 2);
start_quad_flat_uv = start_quad_smooth + len_quad_smooth + handlePadding(md.nquad_smooth * 2);
start_quad_smooth_uv = start_quad_flat_uv + len_quad_flat_uv + handlePadding(md.nquad_flat_uv * 2);
init_triangles_flat_uv(start_tri_flat_uv);
init_triangles_smooth_uv(start_tri_smooth_uv);
init_quads_flat_uv(start_quad_flat_uv);
init_quads_smooth_uv(start_quad_smooth_uv);
init_triangles_flat(start_tri_flat);
init_triangles_smooth(start_tri_smooth);
init_quads_flat(start_quad_flat);
init_quads_smooth(start_quad_smooth);
this.computeCentroids();
this.computeFaceNormals();
function handlePadding(n) {
return (n % 4) ? (4 - n % 4) : 0;
};
function parseMetaData(data, offset) {
var metaData = {
'signature': parseString(data, offset, 12),
'header_bytes': parseUChar8(data, offset + 12),
'vertex_coordinate_bytes': parseUChar8(data, offset + 13),
'normal_coordinate_bytes': parseUChar8(data, offset + 14),
'uv_coordinate_bytes': parseUChar8(data, offset + 15),
'vertex_index_bytes': parseUChar8(data, offset + 16),
'normal_index_bytes': parseUChar8(data, offset + 17),
'uv_index_bytes': parseUChar8(data, offset + 18),
'material_index_bytes': parseUChar8(data, offset + 19),
'nvertices': parseUInt32(data, offset + 20),
'nnormals': parseUInt32(data, offset + 20 + 4 * 1),
'nuvs': parseUInt32(data, offset + 20 + 4 * 2),
'ntri_flat': parseUInt32(data, offset + 20 + 4 * 3),
'ntri_smooth': parseUInt32(data, offset + 20 + 4 * 4),
'ntri_flat_uv': parseUInt32(data, offset + 20 + 4 * 5),
'ntri_smooth_uv': parseUInt32(data, offset + 20 + 4 * 6),
'nquad_flat': parseUInt32(data, offset + 20 + 4 * 7),
'nquad_smooth': parseUInt32(data, offset + 20 + 4 * 8),
'nquad_flat_uv': parseUInt32(data, offset + 20 + 4 * 9),
'nquad_smooth_uv': parseUInt32(data, offset + 20 + 4 * 10)
};
return metaData;
};
function parseString(data, offset, length) {
var charArray = new Uint8Array(data, offset, length);
var text = "";
for (var i = 0; i < length; i++) {
text += String.fromCharCode(charArray[offset + i]);
}
return text;
};
function parseUChar8(data, offset) {
var charArray = new Uint8Array(data, offset, 1);
return charArray[0];
};
function parseUInt32(data, offset) {
var intArray = new Uint32Array(data, offset, 1);
return intArray[0];
};
function init_vertices(start) {
var nElements = md.nvertices;
var coordArray = new Float32Array(data, start, nElements * 3);
var i, x, y, z;
for (i = 0; i < nElements; i++) {
x = coordArray[i * 3];
y = coordArray[i * 3 + 1];
z = coordArray[i * 3 + 2];
vertex(scope, x, y, z);
}
return nElements * 3 * Float32Array.BYTES_PER_ELEMENT;
};
function init_normals(start) {
var nElements = md.nnormals;
if (nElements) {
var normalArray = new Int8Array(data, start, nElements * 3);
var i, x, y, z;
for (i = 0; i < nElements; i++) {
x = normalArray[i * 3];
y = normalArray[i * 3 + 1];
z = normalArray[i * 3 + 2];
normals.push(x / 127, y / 127, z / 127);
}
}
return nElements * 3 * Int8Array.BYTES_PER_ELEMENT;
};
function init_uvs(start) {
var nElements = md.nuvs;
if (nElements) {
var uvArray = new Float32Array(data, start, nElements * 2);
var i, u, v;
for (i = 0; i < nElements; i++) {
u = uvArray[i * 2];
v = uvArray[i * 2 + 1];
uvs.push(u, v);
}
}
return nElements * 2 * Float32Array.BYTES_PER_ELEMENT;
};
function init_uvs3(nElements, offset) {
var i, uva, uvb, uvc, u1, u2, u3, v1, v2, v3;
var uvIndexBuffer = new Uint32Array(data, offset, 3 * nElements);
for (i = 0; i < nElements; i++) {
uva = uvIndexBuffer[i * 3];
uvb = uvIndexBuffer[i * 3 + 1];
uvc = uvIndexBuffer[i * 3 + 2];
u1 = uvs[uva * 2];
v1 = uvs[uva * 2 + 1];
u2 = uvs[uvb * 2];
v2 = uvs[uvb * 2 + 1];
u3 = uvs[uvc * 2];
v3 = uvs[uvc * 2 + 1];
uv3(scope.faceVertexUvs[0], u1, v1, u2, v2, u3, v3);
}
};
function init_uvs4(nElements, offset) {
var i, uva, uvb, uvc, uvd, u1, u2, u3, u4, v1, v2, v3, v4;
var uvIndexBuffer = new Uint32Array(data, offset, 4 * nElements);
for (i = 0; i < nElements; i++) {
uva = uvIndexBuffer[i * 4];
uvb = uvIndexBuffer[i * 4 + 1];
uvc = uvIndexBuffer[i * 4 + 2];
uvd = uvIndexBuffer[i * 4 + 3];
u1 = uvs[uva * 2];
v1 = uvs[uva * 2 + 1];
u2 = uvs[uvb * 2];
v2 = uvs[uvb * 2 + 1];
u3 = uvs[uvc * 2];
v3 = uvs[uvc * 2 + 1];
u4 = uvs[uvd * 2];
v4 = uvs[uvd * 2 + 1];
uv4(scope.faceVertexUvs[0], u1, v1, u2, v2, u3, v3, u4, v4);
}
};
function init_faces3_flat(nElements, offsetVertices, offsetMaterials) {
var i, a, b, c, m;
var vertexIndexBuffer = new Uint32Array(data, offsetVertices, 3 * nElements);
var materialIndexBuffer = new Uint16Array(data, offsetMaterials, nElements);
for (i = 0; i < nElements; i++) {
a = vertexIndexBuffer[i * 3];
b = vertexIndexBuffer[i * 3 + 1];
c = vertexIndexBuffer[i * 3 + 2];
m = materialIndexBuffer[i];
f3(scope, a, b, c, m);
}
};
function init_faces4_flat(nElements, offsetVertices, offsetMaterials) {
var i, a, b, c, d, m;
var vertexIndexBuffer = new Uint32Array(data, offsetVertices, 4 * nElements);
var materialIndexBuffer = new Uint16Array(data, offsetMaterials, nElements);
for (i = 0; i < nElements; i++) {
a = vertexIndexBuffer[i * 4];
b = vertexIndexBuffer[i * 4 + 1];
c = vertexIndexBuffer[i * 4 + 2];
d = vertexIndexBuffer[i * 4 + 3];
m = materialIndexBuffer[i];
f4(scope, a, b, c, d, m);
}
};
function init_faces3_smooth(nElements, offsetVertices, offsetNormals, offsetMaterials) {
var i, a, b, c, m;
var na, nb, nc;
var vertexIndexBuffer = new Uint32Array(data, offsetVertices, 3 * nElements);
var normalIndexBuffer = new Uint32Array(data, offsetNormals, 3 * nElements);
var materialIndexBuffer = new Uint16Array(data, offsetMaterials, nElements);
for (i = 0; i < nElements; i++) {
a = vertexIndexBuffer[i * 3];
b = vertexIndexBuffer[i * 3 + 1];
c = vertexIndexBuffer[i * 3 + 2];
na = normalIndexBuffer[i * 3];
nb = normalIndexBuffer[i * 3 + 1];
nc = normalIndexBuffer[i * 3 + 2];
m = materialIndexBuffer[i];
f3n(scope, normals, a, b, c, m, na, nb, nc);
}
};
function init_faces4_smooth(nElements, offsetVertices, offsetNormals, offsetMaterials) {
var i, a, b, c, d, m;
var na, nb, nc, nd;
var vertexIndexBuffer = new Uint32Array(data, offsetVertices, 4 * nElements);
var normalIndexBuffer = new Uint32Array(data, offsetNormals, 4 * nElements);
var materialIndexBuffer = new Uint16Array(data, offsetMaterials, nElements);
for (i = 0; i < nElements; i++) {
a = vertexIndexBuffer[i * 4];
b = vertexIndexBuffer[i * 4 + 1];
c = vertexIndexBuffer[i * 4 + 2];
d = vertexIndexBuffer[i * 4 + 3];
na = normalIndexBuffer[i * 4];
nb = normalIndexBuffer[i * 4 + 1];
nc = normalIndexBuffer[i * 4 + 2];
nd = normalIndexBuffer[i * 4 + 3];
m = materialIndexBuffer[i];
f4n(scope, normals, a, b, c, d, m, na, nb, nc, nd);
}
};
function init_triangles_flat(start) {
var nElements = md.ntri_flat;
if (nElements) {
var offsetMaterials = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
init_faces3_flat(nElements, start, offsetMaterials);
}
};
function init_triangles_flat_uv(start) {
var nElements = md.ntri_flat_uv;
if (nElements) {
var offsetUvs = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
init_faces3_flat(nElements, start, offsetMaterials);
init_uvs3(nElements, offsetUvs);
}
};
function init_triangles_smooth(start) {
var nElements = md.ntri_smooth;
if (nElements) {
var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
var offsetMaterials = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
init_faces3_smooth(nElements, start, offsetNormals, offsetMaterials);
}
};
function init_triangles_smooth_uv(start) {
var nElements = md.ntri_smooth_uv;
if (nElements) {
var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
var offsetUvs = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 3;
init_faces3_smooth(nElements, start, offsetNormals, offsetMaterials);
init_uvs3(nElements, offsetUvs);
}
};
function init_quads_flat(start) {
var nElements = md.nquad_flat;
if (nElements) {
var offsetMaterials = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
init_faces4_flat(nElements, start, offsetMaterials);
}
};
function init_quads_flat_uv(start) {
var nElements = md.nquad_flat_uv;
if (nElements) {
var offsetUvs = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
init_faces4_flat(nElements, start, offsetMaterials);
init_uvs4(nElements, offsetUvs);
}
};
function init_quads_smooth(start) {
var nElements = md.nquad_smooth;
if (nElements) {
var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
var offsetMaterials = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
init_faces4_smooth(nElements, start, offsetNormals, offsetMaterials);
}
};
function init_quads_smooth_uv(start) {
var nElements = md.nquad_smooth_uv;
if (nElements) {
var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
var offsetUvs = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 4;
init_faces4_smooth(nElements, start, offsetNormals, offsetMaterials);
init_uvs4(nElements, offsetUvs);
}
};
};
function vertex(scope, x, y, z) {
scope.vertices.push(new THREE.Vector3(x, y, z));
};
function f3(scope, a, b, c, mi) {
scope.faces.push(new THREE.Face3(a, b, c, null, null, mi));
};
function f4(scope, a, b, c, d, mi) {
scope.faces.push(new THREE.Face4(a, b, c, d, null, null, mi));
};
function f3n(scope, normals, a, b, c, mi, na, nb, nc) {
var nax = normals[na * 3],
nay = normals[na * 3 + 1],
naz = normals[na * 3 + 2],
nbx = normals[nb * 3],
nby = normals[nb * 3 + 1],
nbz = normals[nb * 3 + 2],
ncx = normals[nc * 3],
ncy = normals[nc * 3 + 1],
ncz = normals[nc * 3 + 2];
scope.faces.push(new THREE.Face3(a, b, c, [new THREE.Vector3(nax, nay, naz), new THREE.Vector3(nbx, nby, nbz), new THREE.Vector3(ncx, ncy, ncz)], null, mi));
};
function f4n(scope, normals, a, b, c, d, mi, na, nb, nc, nd) {
var nax = normals[na * 3],
nay = normals[na * 3 + 1],
naz = normals[na * 3 + 2],
nbx = normals[nb * 3],
nby = normals[nb * 3 + 1],
nbz = normals[nb * 3 + 2],
ncx = normals[nc * 3],
ncy = normals[nc * 3 + 1],
ncz = normals[nc * 3 + 2],
ndx = normals[nd * 3],
ndy = normals[nd * 3 + 1],
ndz = normals[nd * 3 + 2];
scope.faces.push(new THREE.Face4(a, b, c, d, [new THREE.Vector3(nax, nay, naz), new THREE.Vector3(nbx, nby, nbz), new THREE.Vector3(ncx, ncy, ncz), new THREE.Vector3(ndx, ndy, ndz)], null, mi));
};
function uv3(where, u1, v1, u2, v2, u3, v3) {
where.push([new THREE.Vector2(u1, v1), new THREE.Vector2(u2, v2), new THREE.Vector2(u3, v3)]);
};
function uv4(where, u1, v1, u2, v2, u3, v3, u4, v4) {
where.push([new THREE.Vector2(u1, v1), new THREE.Vector2(u2, v2), new THREE.Vector2(u3, v3), new THREE.Vector2(u4, v4)]);
};
Model.prototype = Object.create(THREE.Geometry.prototype);
var geometry = new Model(texturePath);
var materials = this.initMaterials(jsonMaterials, texturePath);
if (this.needsTangents(materials)) geometry.computeTangents();
callback(geometry, materials);
};
THREE.SubdivisionModifier = function(subdivisions) {
this.subdivisions = (subdivisions === undefined) ? 1 : subdivisions;
this.useOldVertexColors = false;
this.supportUVs = true;
this.debug = false;
};
THREE.SubdivisionModifier.prototype.modify = function(geometry) {
var repeats = this.subdivisions;
while (repeats-- > 0) {
this.smooth(geometry);
}
};
THREE.GeometryUtils.orderedKey = function(a, b) {
return Math.min(a, b) + "_" + Math.max(a, b);
};
THREE.GeometryUtils.computeEdgeFaces = function(geometry) {
var i, il, v1, v2, j, k, face, faceIndices, faceIndex, edge, hash, edgeFaceMap = {};
var orderedKey = THREE.GeometryUtils.orderedKey;
function mapEdgeHash(hash, i) {
if (edgeFaceMap[hash] === undefined) {
edgeFaceMap[hash] = [];
}
edgeFaceMap[hash].push(i);
}
for (i = 0, il = geometry.faces.length; i < il; i++) {
face = geometry.faces[i];
if (face instanceof THREE.Face3) {
hash = orderedKey(face.a, face.b);
mapEdgeHash(hash, i);
hash = orderedKey(face.b, face.c);
mapEdgeHash(hash, i);
hash = orderedKey(face.c, face.a);
mapEdgeHash(hash, i);
} else if (face instanceof THREE.Face4) {
hash = orderedKey(face.a, face.b);
mapEdgeHash(hash, i);
hash = orderedKey(face.b, face.c);
mapEdgeHash(hash, i);
hash = orderedKey(face.c, face.d);
mapEdgeHash(hash, i);
hash = orderedKey(face.d, face.a);
mapEdgeHash(hash, i);
}
}
return edgeFaceMap;
}
THREE.SubdivisionModifier.prototype.smooth = function(oldGeometry) {
var newVertices = [],
newFaces = [],
newUVs = [];
function v(x, y, z) {
newVertices.push(new THREE.Vector3(x, y, z));
}
var scope = this;
var orderedKey = THREE.GeometryUtils.orderedKey;
var computeEdgeFaces = THREE.GeometryUtils.computeEdgeFaces;
function assert() {
if (scope.debug && console && console.assert) console.assert.apply(console, arguments);
}
function debug() {
if (scope.debug) console.log.apply(console, arguments);
}
function warn() {
if (console)
console.log.apply(console, arguments);
}
function f4(a, b, c, d, oldFace, orders, facei) {
var newFace = new THREE.Face4(a, b, c, d, null, oldFace.color, oldFace.materialIndex);
if (scope.useOldVertexColors) {
newFace.vertexColors = [];
var color, tmpColor, order;
for (var i = 0; i < 4; i++) {
order = orders[i];
color = new THREE.Color(), color.setRGB(0, 0, 0);
for (var j = 0, jl = 0; j < order.length; j++) {
tmpColor = oldFace.vertexColors[order[j] - 1];
color.r += tmpColor.r;
color.g += tmpColor.g;
color.b += tmpColor.b;
}
color.r /= order.length;
color.g /= order.length;
color.b /= order.length;
newFace.vertexColors[i] = color;
}
}
newFaces.push(newFace);
if (scope.supportUVs) {
var aUv = [getUV(a, ''), getUV(b, facei), getUV(c, facei), getUV(d, facei)];
if (!aUv[0]) debug('a :( ', a + ':' + facei);
else if (!aUv[1]) debug('b :( ', b + ':' + facei);
else if (!aUv[2]) debug('c :( ', c + ':' + facei);
else if (!aUv[3]) debug('d :( ', d + ':' + facei);
else
newUVs.push(aUv);
}
}
var originalPoints = oldGeometry.vertices;
var originalFaces = oldGeometry.faces;
var originalVerticesLength = originalPoints.length;
var newPoints = originalPoints.concat();
var facePoints = [],
edgePoints = {};
var sharpEdges = {},
sharpVertices = [];
var uvForVertices = {};
function debugCoreStuff() {
console.log('facePoints', facePoints, 'edgePoints', edgePoints);
console.log('edgeFaceMap', edgeFaceMap, 'vertexEdgeMap', vertexEdgeMap);
}
function getUV(vertexNo, oldFaceNo) {
var j, jl;
var key = vertexNo + ':' + oldFaceNo;
var theUV = uvForVertices[key];
if (!theUV) {
if (vertexNo >= originalVerticesLength && vertexNo < (originalVerticesLength + originalFaces.length)) {
debug('face pt');
} else {
debug('edge pt');
}
warn('warning, UV not found for', key);
return null;
}
return theUV;
}
function addUV(vertexNo, oldFaceNo, value) {
var key = vertexNo + ':' + oldFaceNo;
if (!(key in uvForVertices)) {
uvForVertices[key] = value;
} else {
warn('dup vertexNo', vertexNo, 'oldFaceNo', oldFaceNo, 'value', value, 'key', key, uvForVertices[key]);
}
}
var i, il, j, jl, face;
var uvs = oldGeometry.faceVertexUvs[0];
var abcd = 'abcd',
vertice;
debug('originalFaces, uvs, originalVerticesLength', originalFaces.length, uvs.length, originalVerticesLength);
if (scope.supportUVs)
for (i = 0, il = uvs.length; i < il; i++) {
for (j = 0, jl = uvs[i].length; j < jl; j++) {
vertice = originalFaces[i][abcd.charAt(j)];
addUV(vertice, i, uvs[i][j]);
}
}
if (uvs.length == 0) scope.supportUVs = false;
var uvCount = 0;
for (var u in uvForVertices) {
uvCount++;
}
if (!uvCount) {
scope.supportUVs = false;
debug('no uvs');
}
var avgUv;
for (i = 0, il = originalFaces.length; i < il; i++) {
face = originalFaces[i];
facePoints.push(face.centroid);
newPoints.push(face.centroid);
if (!scope.supportUVs) continue;
avgUv = new THREE.Vector2();
if (face instanceof THREE.Face3) {
avgUv.x = getUV(face.a, i).x + getUV(face.b, i).x + getUV(face.c, i).x;
avgUv.y = getUV(face.a, i).y + getUV(face.b, i).y + getUV(face.c, i).y;
avgUv.x /= 3;
avgUv.y /= 3;
} else if (face instanceof THREE.Face4) {
avgUv.x = getUV(face.a, i).x + getUV(face.b, i).x + getUV(face.c, i).x + getUV(face.d, i).x;
avgUv.y = getUV(face.a, i).y + getUV(face.b, i).y + getUV(face.c, i).y + getUV(face.d, i).y;
avgUv.x /= 4;
avgUv.y /= 4;
}
addUV(originalVerticesLength + i, '', avgUv);
}
var edgeFaceMap = computeEdgeFaces(oldGeometry);
var edge, faceIndexA, faceIndexB, avg;
var edgeCount = 0;
var edgeVertex, edgeVertexA, edgeVertexB;
var vertexEdgeMap = {};
var vertexFaceMap = {};
function addVertexEdgeMap(vertex, edge) {
if (vertexEdgeMap[vertex] === undefined) {
vertexEdgeMap[vertex] = [];
}
vertexEdgeMap[vertex].push(edge);
}
function addVertexFaceMap(vertex, face, edge) {
if (vertexFaceMap[vertex] === undefined) {
vertexFaceMap[vertex] = {};
}
vertexFaceMap[vertex][face] = edge;
}
for (i in edgeFaceMap) {
edge = edgeFaceMap[i];
edgeVertex = i.split('_');
edgeVertexA = edgeVertex[0];
edgeVertexB = edgeVertex[1];
addVertexEdgeMap(edgeVertexA, [edgeVertexA, edgeVertexB]);
addVertexEdgeMap(edgeVertexB, [edgeVertexA, edgeVertexB]);
for (j = 0, jl = edge.length; j < jl; j++) {
face = edge[j];
addVertexFaceMap(edgeVertexA, face, i);
addVertexFaceMap(edgeVertexB, face, i);
}
if (edge.length < 2) {
sharpEdges[i] = true;
sharpVertices[edgeVertexA] = true;
sharpVertices[edgeVertexB] = true;
}
}
for (i in edgeFaceMap) {
edge = edgeFaceMap[i];
faceIndexA = edge[0];
faceIndexB = edge[1];
edgeVertex = i.split('_');
edgeVertexA = edgeVertex[0];
edgeVertexB = edgeVertex[1];
avg = new THREE.Vector3();
assert(edge.length > 0, 'an edge without faces?!');
if (edge.length == 1) {
avg.add(originalPoints[edgeVertexA]);
avg.add(originalPoints[edgeVertexB]);
avg.multiplyScalar(0.5);
sharpVertices[newPoints.length] = true;
} else {
avg.add(facePoints[faceIndexA]);
avg.add(facePoints[faceIndexB]);
avg.add(originalPoints[edgeVertexA]);
avg.add(originalPoints[edgeVertexB]);
avg.multiplyScalar(0.25);
}
edgePoints[i] = originalVerticesLength + originalFaces.length + edgeCount;
newPoints.push(avg);
edgeCount++;
if (!scope.supportUVs) {
continue;
}
avgUv = new THREE.Vector2();
avgUv.x = getUV(edgeVertexA, faceIndexA).x + getUV(edgeVertexB, faceIndexA).x;
avgUv.y = getUV(edgeVertexA, faceIndexA).y + getUV(edgeVertexB, faceIndexA).y;
avgUv.x /= 2;
avgUv.y /= 2;
addUV(edgePoints[i], faceIndexA, avgUv);
if (edge.length >= 2) {
assert(edge.length == 2, 'did we plan for more than 2 edges?');
avgUv = new THREE.Vector2();
avgUv.x = getUV(edgeVertexA, faceIndexB).x + getUV(edgeVertexB, faceIndexB).x;
avgUv.y = getUV(edgeVertexA, faceIndexB).y + getUV(edgeVertexB, faceIndexB).y;
avgUv.x /= 2;
avgUv.y /= 2;
addUV(edgePoints[i], faceIndexB, avgUv);
}
}
debug('-- Step 2 done');
var facePt, currentVerticeIndex;
var hashAB, hashBC, hashCD, hashDA, hashCA;
var abc123 = ['123', '12', '2', '23'];
var bca123 = ['123', '23', '3', '31'];
var cab123 = ['123', '31', '1', '12'];
var abc1234 = ['1234', '12', '2', '23'];
var bcd1234 = ['1234', '23', '3', '34'];
var cda1234 = ['1234', '34', '4', '41'];
var dab1234 = ['1234', '41', '1', '12'];
for (i = 0, il = facePoints.length; i < il; i++) {
facePt = facePoints[i];
face = originalFaces[i];
currentVerticeIndex = originalVerticesLength + i;
if (face instanceof THREE.Face3) {
hashAB = orderedKey(face.a, face.b);
hashBC = orderedKey(face.b, face.c);
hashCA = orderedKey(face.c, face.a);
f4(currentVerticeIndex, edgePoints[hashAB], face.b, edgePoints[hashBC], face, abc123, i);
f4(currentVerticeIndex, edgePoints[hashBC], face.c, edgePoints[hashCA], face, bca123, i);
f4(currentVerticeIndex, edgePoints[hashCA], face.a, edgePoints[hashAB], face, cab123, i);
} else if (face instanceof THREE.Face4) {
hashAB = orderedKey(face.a, face.b);
hashBC = orderedKey(face.b, face.c);
hashCD = orderedKey(face.c, face.d);
hashDA = orderedKey(face.d, face.a);
f4(currentVerticeIndex, edgePoints[hashAB], face.b, edgePoints[hashBC], face, abc1234, i);
f4(currentVerticeIndex, edgePoints[hashBC], face.c, edgePoints[hashCD], face, bcd1234, i);
f4(currentVerticeIndex, edgePoints[hashCD], face.d, edgePoints[hashDA], face, cda1234, i);
f4(currentVerticeIndex, edgePoints[hashDA], face.a, edgePoints[hashAB], face, dab1234, i);
} else {
debug('face should be a face!', face);
}
}
newVertices = newPoints;
var F = new THREE.Vector3();
var R = new THREE.Vector3();
var n;
for (i = 0, il = originalPoints.length; i < il; i++) {
if (vertexEdgeMap[i] === undefined) continue;
F.set(0, 0, 0);
R.set(0, 0, 0);
var newPos = new THREE.Vector3(0, 0, 0);
var f = 0;
for (j in vertexFaceMap[i]) {
F.add(facePoints[j]);
f++;
}
var sharpEdgeCount = 0;
n = vertexEdgeMap[i].length;
var boundary_case = f != n;
for (j = 0; j < n; j++) {
if (sharpEdges[orderedKey(vertexEdgeMap[i][j][0], vertexEdgeMap[i][j][1])]) {
sharpEdgeCount++;
}
}
F.divideScalar(f);
var boundary_edges = 0;
if (boundary_case) {
var bb_edge;
for (j = 0; j < n; j++) {
edge = vertexEdgeMap[i][j];
bb_edge = edgeFaceMap[orderedKey(edge[0], edge[1])].length == 1
if (bb_edge) {
var midPt = originalPoints[edge[0]].clone().add(originalPoints[edge[1]]).divideScalar(2);
R.add(midPt);
boundary_edges++;
}
}
R.divideScalar(4);
assert(boundary_edges == 2, 'should have only 2 boundary edges');
} else {
for (j = 0; j < n; j++) {
edge = vertexEdgeMap[i][j];
var midPt = originalPoints[edge[0]].clone().add(originalPoints[edge[1]]).divideScalar(2);
R.add(midPt);
}
R.divideScalar(n);
}
newPos.add(originalPoints[i]);
if (boundary_case) {
newPos.divideScalar(2);
newPos.add(R);
} else {
newPos.multiplyScalar(n - 3);
newPos.add(F);
newPos.add(R.multiplyScalar(2));
newPos.divideScalar(n);
}
newVertices[i] = newPos;
}
var newGeometry = oldGeometry;
newGeometry.vertices = newVertices;
newGeometry.faces = newFaces;
newGeometry.faceVertexUvs[0] = newUVs;
delete newGeometry.__tmpVertices;
newGeometry.computeCentroids();
newGeometry.computeFaceNormals();
newGeometry.computeVertexNormals();
};
THREE.TrackballControls = function(object, domElement) {
var _this = this;
var STATE = {
NONE: -1,
ROTATE: 0,
ZOOM: 1,
PAN: 2,
TOUCH_ROTATE: 3,
TOUCH_ZOOM: 4,
TOUCH_PAN: 5
};
this.object = object;
this.domElement = (domElement !== undefined) ? domElement : document;
this.enabled = true;
this.screen = {
left: 0,
top: 0,
width: 0,
height: 0
};
this.rotateSpeed = 1.0;
this.zoomSpeed = 1.2;
this.panSpeed = 0.3;
this.noRotate = false;
this.noZoom = false;
this.noPan = false;
this.noRoll = false;
this.staticMoving = false;
this.dynamicDampingFactor = 0.2;
this.minDistance = 0;
this.maxDistance = Infinity;
this.keys = [65, 83, 68];
this.target = new THREE.Vector3();
var lastPosition = new THREE.Vector3();
var _keyPressed = false;
var _state = STATE.NONE,
_prevState = STATE.NONE,
_eye = new THREE.Vector3(),
_rotateStart = new THREE.Vector3(),
_rotateEnd = new THREE.Vector3(),
_zoomStart = new THREE.Vector2(),
_zoomEnd = new THREE.Vector2(),
_touchZoomDistanceStart = 0,
_touchZoomDistanceEnd = 0,
_panStart = new THREE.Vector2(),
_panEnd = new THREE.Vector2();
this.target0 = this.target.clone();
this.position0 = this.object.position.clone();
this.up0 = this.object.up.clone();
var changeEvent = {
type: 'change'
};
this.handleResize = function() {
if (this.domElement === document) {
this.screen.left = 0;
this.screen.top = 0;
this.screen.width = window.innerWidth;
this.screen.height = window.innerHeight;
} else {
this.screen = this.domElement.getBoundingClientRect();
}
};
this.handleEvent = function(event) {
if (typeof this[event.type] == 'function') {
this[event.type](event);
}
};
this.getMouseOnScreen = function(clientX, clientY) {
return new THREE.Vector2((clientX - _this.screen.left) / _this.screen.width, (clientY - _this.screen.top) / _this.screen.height);
};
this.getMouseProjectionOnBall = function(clientX, clientY) {
var mouseOnBall = new THREE.Vector3((clientX - _this.screen.width * 0.5 - _this.screen.left) / (_this.screen.width * .5), (_this.screen.height * 0.5 + _this.screen.top - clientY) / (_this.screen.height * .5), 0.0);
var length = mouseOnBall.length();
if (_this.noRoll) {
if (length < Math.SQRT1_2) {
mouseOnBall.z = Math.sqrt(1.0 - length * length);
} else {
mouseOnBall.z = .5 / length;
}
} else if (length > 1.0) {
mouseOnBall.normalize();
} else {
mouseOnBall.z = Math.sqrt(1.0 - length * length);
}
_eye.copy(_this.object.position).sub(_this.target);
var projection = _this.object.up.clone().setLength(mouseOnBall.y);
projection.add(_this.object.up.clone().cross(_eye).setLength(mouseOnBall.x));
projection.add(_eye.setLength(mouseOnBall.z));
return projection;
};
this.rotateCamera = function() {
var angle = Math.acos(_rotateStart.dot(_rotateEnd) / _rotateStart.length() / _rotateEnd.length());
if (angle) {
var axis = (new THREE.Vector3()).crossVectors(_rotateStart, _rotateEnd).normalize(),
quaternion = new THREE.Quaternion();
angle *= _this.rotateSpeed;
quaternion.setFromAxisAngle(axis, -angle);
_eye.applyQuaternion(quaternion);
_this.object.up.applyQuaternion(quaternion);
_rotateEnd.applyQuaternion(quaternion);
if (_this.staticMoving) {
_rotateStart.copy(_rotateEnd);
} else {
quaternion.setFromAxisAngle(axis, angle * (_this.dynamicDampingFactor - 1.0));
_rotateStart.applyQuaternion(quaternion);
}
}
};
this.zoomCamera = function() {
if (_state === STATE.TOUCH_ZOOM) {
var factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
_touchZoomDistanceStart = _touchZoomDistanceEnd;
_eye.multiplyScalar(factor);
} else {
var factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * _this.zoomSpeed;
if (factor !== 1.0 && factor > 0.0) {
_eye.multiplyScalar(factor);
if (_this.staticMoving) {
_zoomStart.copy(_zoomEnd);
} else {
_zoomStart.y += (_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
}
}
}
};
this.panCamera = function() {
var mouseChange = _panEnd.clone().sub(_panStart);
if (mouseChange.lengthSq()) {
mouseChange.multiplyScalar(_eye.length() * _this.panSpeed);
var pan = _eye.clone().cross(_this.object.up).setLength(mouseChange.x);
pan.add(_this.object.up.clone().setLength(mouseChange.y));
_this.object.position.add(pan);
_this.target.add(pan);
if (_this.staticMoving) {
_panStart = _panEnd;
} else {
_panStart.add(mouseChange.subVectors(_panEnd, _panStart).multiplyScalar(_this.dynamicDampingFactor));
}
}
};
this.checkDistances = function() {
if (!_this.noZoom || !_this.noPan) {
if (_eye.lengthSq() > _this.maxDistance * _this.maxDistance) {
_this.object.position.addVectors(_this.target, _eye.setLength(_this.maxDistance));
}
if (_eye.lengthSq() < _this.minDistance * _this.minDistance) {
_this.object.position.addVectors(_this.target, _eye.setLength(_this.minDistance));
}
}
};
this.update = function() {
_eye.subVectors(_this.object.position, _this.target);
if (!_this.noRotate) {
_this.rotateCamera();
}
if (!_this.noZoom) {
_this.zoomCamera();
}
if (!_this.noPan) {
_this.panCamera();
}
_this.object.position.addVectors(_this.target, _eye);
_this.checkDistances();
_this.object.lookAt(_this.target);
if (lastPosition.distanceToSquared(_this.object.position) > 0) {
_this.dispatchEvent(changeEvent);
lastPosition.copy(_this.object.position);
}
};
this.reset = function() {
_state = STATE.NONE;
_prevState = STATE.NONE;
_this.target.copy(_this.target0);
_this.object.position.copy(_this.position0);
_this.object.up.copy(_this.up0);
_eye.subVectors(_this.object.position, _this.target);
_this.object.lookAt(_this.target);
_this.dispatchEvent(changeEvent);
lastPosition.copy(_this.object.position);
};
function keydown(event) {
if (_this.enabled === false) return;
window.removeEventListener('keydown', keydown);
_prevState = _state;
if (_state !== STATE.NONE) {
return;
} else if (event.keyCode === _this.keys[STATE.ROTATE] && !_this.noRotate) {
_state = STATE.ROTATE;
} else if (event.keyCode === _this.keys[STATE.ZOOM] && !_this.noZoom) {
_state = STATE.ZOOM;
} else if (event.keyCode === _this.keys[STATE.PAN] && !_this.noPan) {
_state = STATE.PAN;
}
if (_state !== STATE.NONE) {
_keyPressed = true;
document.addEventListener('mousemove', mousemove, false);
}
}
function keyup(event) {
if (_this.enabled === false) return;
_state = _prevState;
window.addEventListener('keydown', keydown, false);
document.removeEventListener('mousemove', mousemove);
}
function mousedown(event) {
if (_this.enabled === false) return;
event.preventDefault();
event.stopPropagation();
if (_state === STATE.NONE) {
_state = event.button;
}
if (_state === STATE.ROTATE && !_this.noRotate) {
_rotateStart = _this.getMouseProjectionOnBall(event.clientX, event.clientY);
_rotateEnd.copy(_rotateStart)
} else if (_state === STATE.ZOOM && !_this.noZoom) {
_zoomStart = _this.getMouseOnScreen(event.clientX, event.clientY);
_zoomEnd.copy(_zoomStart);
} else if (_state === STATE.PAN && !_this.noPan) {
_panStart = _this.getMouseOnScreen(event.clientX, event.clientY);
_panEnd.copy(_panStart)
}
document.addEventListener('mousemove', mousemove, false);
document.addEventListener('mouseup', mouseup, false);
}
function mousemove(event) {
if (_this.enabled === false) return;
if (_keyPressed) {
_rotateStart = _rotateEnd = _this.getMouseProjectionOnBall(event.clientX, event.clientY);
_zoomStart = _zoomEnd = _this.getMouseOnScreen(event.clientX, event.clientY);
_panStart = _panEnd = _this.getMouseOnScreen(event.clientX, event.clientY);
_keyPressed = false;
}
event.preventDefault();
event.stopPropagation();
if (_state === STATE.ROTATE && !_this.noRotate) {
_rotateEnd = _this.getMouseProjectionOnBall(event.clientX, event.clientY);
} else if (_state === STATE.ZOOM && !_this.noZoom) {
_zoomEnd = _this.getMouseOnScreen(event.clientX, event.clientY);
} else if (_state === STATE.PAN && !_this.noPan) {
_panEnd = _this.getMouseOnScreen(event.clientX, event.clientY);
}
}
function mouseup(event) {
if (_this.enabled === false) return;
event.preventDefault();
event.stopPropagation();
_state = STATE.NONE;
document.removeEventListener('mousemove', mousemove);
document.removeEventListener('mouseup', mouseup);
}
function mousewheel(event) {
if (_this.enabled === false) return;
event.preventDefault();
event.stopPropagation();
var delta = 0;
if (event.wheelDelta) {
delta = event.wheelDelta / 40;
} else if (event.detail) {
delta = -event.detail / 3;
}
_zoomStart.y += delta * 0.01;
}
function touchstart(event) {
if (_this.enabled === false) return;
switch (event.touches.length) {
case 1:
_state = STATE.TOUCH_ROTATE;
_rotateStart = _rotateEnd = _this.getMouseProjectionOnBall(event.touches[0].pageX, event.touches[0].pageY);
break;
case 2:
_state = STATE.TOUCH_ZOOM;
var dx = event.touches[0].pageX - event.touches[1].pageX;
var dy = event.touches[0].pageY - event.touches[1].pageY;
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
break;
case 3:
_state = STATE.TOUCH_PAN;
_panStart = _panEnd = _this.getMouseOnScreen(event.touches[0].pageX, event.touches[0].pageY);
break;
default:
_state = STATE.NONE;
}
}
function touchmove(event) {
if (_this.enabled === false) return;
event.preventDefault();
event.stopPropagation();
switch (event.touches.length) {
case 1:
_rotateEnd = _this.getMouseProjectionOnBall(event.touches[0].pageX, event.touches[0].pageY);
break;
case 2:
var dx = event.touches[0].pageX - event.touches[1].pageX;
var dy = event.touches[0].pageY - event.touches[1].pageY;
_touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy)
break;
case 3:
_panEnd = _this.getMouseOnScreen(event.touches[0].pageX, event.touches[0].pageY);
break;
default:
_state = STATE.NONE;
}
}
function touchend(event) {
if (_this.enabled === false) return;
switch (event.touches.length) {
case 1:
_rotateStart = _rotateEnd = _this.getMouseProjectionOnBall(event.touches[0].pageX, event.touches[0].pageY);
break;
case 2:
_touchZoomDistanceStart = _touchZoomDistanceEnd = 0;
break;
case 3:
_panStart = _panEnd = _this.getMouseOnScreen(event.touches[0].pageX, event.touches[0].pageY);
break;
}
_state = STATE.NONE;
}
this.domElement.addEventListener('contextmenu', function(event) {
event.preventDefault();
}, false);
this.domElement.addEventListener('mousedown', mousedown, false);
this.domElement.addEventListener('mousewheel', mousewheel, false);
this.domElement.addEventListener('DOMMouseScroll', mousewheel, false);
this.domElement.addEventListener('touchstart', touchstart, false);
this.domElement.addEventListener('touchend', touchend, false);
this.domElement.addEventListener('touchmove', touchmove, false);
window.addEventListener('keydown', keydown, false);
window.addEventListener('keyup', keyup, false);
this.handleResize();
};
THREE.TrackballControls.prototype = Object.create(THREE.EventDispatcher.prototype);
var P3D = P3D || {};
P3D.ShaderChunk = {
tangent_pars_fragment: ["#if defined(USE_TANGENTS)", "varying vec3 vTangent;", "varying vec3 vBinormal;", "#endif", ].join("\n"),
tangent_pars_vertex: ["#if defined(USE_TANGENTS)", "attribute vec4 tangent;", "varying vec3 vTangent;", "varying vec3 vBinormal;", "#endif", ].join("\n"),
tangent_vertex: ["#if defined(USE_TANGENTS)", "vTangent = normalMatrix * tangent.xyz;", "vBinormal = cross( vNormal, vTangent ) * tangent.w;", "#endif", ].join("\n"),
normalmap_pars_fragment: ["#if defined(USE_NORMAL_MAP)", "uniform bool enableNormal;", "uniform sampler2D tNormal;", "uniform float uNormalScale;", "#endif", "#if defined(USE_NORMAL_MAP)", "vec3 applyTangentNormal( vec3 normal ) {", "vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;", "normalTex.xy *= uNormalScale;", "normalTex = normalize( normalTex );", "mat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( normal ) );", "return (tsb * normalTex);", "}", "#endif", ].join("\n"),
normalmap_fragment: ["#if defined(USE_NORMAL_MAP)", "if (enableNormal) normal = applyTangentNormal(normal);", "#endif", ].join("\n"),
detail_normalmap_pars_fragment: ["#if defined(USE_DETAIL_NORMAL_MAP)", "uniform bool enableDetailNormal;", "uniform sampler2D tDetailNormal;", "uniform float uDetailNormalStrength;", "uniform float uDetailNormalRepeat;", "vec3 applyDetailTangentNormal( vec3 normal ) {", "vec3 normalTex = texture2D( tDetailNormal, vUv * uDetailNormalRepeat).xyz * 2.0 - 1.0;", "normalTex.xy *= uDetailNormalStrength;", "normalTex = normalize( normalTex );", "mat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( normal ) );", "return (tsb * normalTex);", "}", "#endif", ].join("\n"),
detail_normalmap_fragment: ["#if defined(USE_DETAIL_NORMAL_MAP)", "if (enableDetailNormal) normal = applyDetailTangentNormal(normal);", "#endif", ].join("\n"),
bump_base_pars_fragment: ["#if defined(USE_BUMP_DERIVATIVES)", "#extension GL_OES_standard_derivatives : enable", "vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {", "vec3 vSigmaX = dFdx( surf_pos );", "vec3 vSigmaY = dFdy( surf_pos );", "vec3 vN = surf_norm;", "vec3 R1 = cross( vSigmaY, vN );", "vec3 R2 = cross( vN, vSigmaX );", "float fDet = dot( vSigmaX, R1 );", "vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );", "return normalize( abs( fDet ) * surf_norm - vGrad );", "}", "#endif", ].join("\n"),
bumpmap_pars_fragment: ["#ifdef USE_BUMPMAP", "uniform bool enableBump;", "uniform sampler2D bumpMap;", "uniform float bumpScale;", "vec2 dHdxy_fwd() {", "vec2 dSTdx = dFdx( vUv );", "vec2 dSTdy = dFdy( vUv );", "float Hll = bumpScale * texture2D( bumpMap, vUv ).x;", "float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;", "float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;", "return vec2( dBx, dBy );", "}", "#endif", ].join("\n"),
bumpmap_fragment: ["#ifdef USE_BUMPMAP", "if (enableBump) normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );", "#endif", ].join("\n"),
detail_bumpmap_pars_fragment: ["#ifdef USE_DETAIL_BUMPMAP", "uniform bool enableDetailBump;", "uniform sampler2D detailBumpMap;", "uniform float uDetailBumpStrength;", "uniform float uDetailBumpRepeat;", "vec2 detail_dHdxy_fwd() {", "vec2 dSTdx = dFdx( vUv );", "vec2 dSTdy = dFdy( vUv );", "float Hll = uDetailBumpStrength * texture2D( detailBumpMap, vUv * uDetailBumpRepeat ).x;", "float dBx = uDetailBumpStrength * texture2D( detailBumpMap, (vUv + dSTdx) * uDetailBumpRepeat ).x - Hll;", "float dBy = uDetailBumpStrength * texture2D( detailBumpMap, (vUv + dSTdy) * uDetailBumpRepeat ).x - Hll;", "return vec2( dBx, dBy );", "}", "#endif", ].join("\n"),
detail_bumpmap_fragment: ["#ifdef USE_DETAIL_BUMPMAP", "if (enableDetailBump) normal = perturbNormalArb( -vViewPosition, normal, detail_dHdxy_fwd() );", "#endif", ].join("\n"),
ao_pars_fragment: ["#ifdef USE_AMBIENT_OCCLUSION", "uniform vec3 uAOColor;", "uniform bool enableAO;", "uniform sampler2D tAO;", "uniform float uAOStrength;", "#endif", ].join("\n"),
ao_fragment: ["#ifdef USE_AMBIENT_OCCLUSION", "if( enableAO ) {", "#ifdef GAMMA_INPUT", "vec3 aoColor = texture2D( tAO, vUv ).xyz * uAOColor;", "aoColor.xyz *= aoColor.xyz;", "gl_FragColor.xyz = gl_FragColor.xyz * mix(vec3(1, 1, 1), aoColor.xyz, uAOStrength);", "#else", "gl_FragColor.xyz = gl_FragColor.xyz * mix(vec3(1, 1, 1), texture2D( tAO, vUv ).xyz * uAOColor.xyz, uAOStrength);", "#endif", "}", "#endif", ].join("\n"),
glow_pars_fragment: ["#ifdef USE_GLOW", "uniform bool enableGlow;", "uniform sampler2D tGlow;", "uniform float uGlowStrength;", "uniform vec3 uGlowColor;", "uniform float uGlowDiffuseInfluence;", "#endif", ].join("\n"),
glow_fragment: ["#ifdef USE_GLOW", "if( enableGlow ) {", "vec3 glowColor = texture2D( tGlow, vUv ).xyz;", "#ifdef GAMMA_INPUT", "glowColor.xyz *= glowColor.xyz;", "#endif", "gl_FragColor.xyz = gl_FragColor.xyz + (mix(vec3(1,1,1), diffuseColor.xyz, uGlowDiffuseInfluence) * glowColor.xyz * uGlowColor.xyz * uGlowStrength);", "}", "#endif", ].join("\n"),
reflection_pars_fragment: ["#ifdef USE_REFLECTION", "uniform bool enableReflection;", "uniform sampler2D tReflection;", "uniform float uReflectionStrength;", "uniform vec3 uReflectionColor;", "uniform float uReflectionCoefficient;", "#ifdef USE_REFLECTION_MASK", "uniform bool enableReflectionMask;", "uniform sampler2D tReflectionMask;", "uniform float uReflectionMaskStrength;", "#endif", "#endif", ].join("\n"),
reflection_fragment: ["#ifdef USE_REFLECTION", "if( enableReflection ) {", "vec3 viewNormalized = normalize( -vViewPosition );", "vec3 r = reflect(viewNormalized, normal);", "vec2 texco;", "float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );", "texco.x = r.x/m + 0.5;", "texco.y = r.y/m + 0.5;", "vec3 texelColor = texture2D( tReflection, texco ).xyz * uReflectionColor.xyz;", "#ifdef GAMMA_INPUT", "texelColor *= texelColor;", "#endif", "float fresnel = pow(1.0 + dot(viewNormalized, normal), uReflectionCoefficient);", "#ifdef USE_REFLECTION_MASK", "if( enableReflectionMask ) {", "texelColor = texelColor * mix(vec3(1.0), texture2D( tReflectionMask, vUv ).xyz, uReflectionMaskStrength);", "}", "#endif", "gl_FragColor.xyz = vec3(1.0) - (vec3(1.0) - gl_FragColor.xyz) * (vec3(1.0) - texelColor * uReflectionStrength * fresnel);", "}", "#endif", ].join("\n"),
uv_pars_vertex: ["varying vec2 vUv;", "uniform vec2 uOffset;", "uniform vec2 uRepeat;", ].join("\n"),
uv_vertex: ["vUv = vec2(uv.x, 1.0 - uv.y) * uRepeat + uOffset;", ].join("\n"),
uv_pars_fragment: ["varying vec2 vUv;", ].join("\n"),
diffuse_pars_fragment: ["uniform vec3 uDiffuseColor;", "#ifdef USE_DIFFUSE_TEXTURE", "uniform bool enableDiffuse;", "uniform sampler2D tDiffuse;", "#endif", ].join("\n"),
diffuse_fragment: ["gl_FragColor.xyz *= uDiffuseColor;", "vec4 diffuseColor = gl_FragColor;", "#ifdef USE_DIFFUSE_TEXTURE", "if( enableDiffuse ) {", "diffuseColor = texture2D( tDiffuse, vUv );", "#ifdef GAMMA_INPUT", "vec4 texelColor = diffuseColor;", "texelColor.xyz *= texelColor.xyz;", "gl_FragColor = gl_FragColor * texelColor;", "#else", "gl_FragColor = gl_FragColor * diffuseColor;", "#endif", "}", "#endif", ].join("\n"),
detail_diffuse_pars_fragment: ["#ifdef USE_DETAIL_DIFFUSE_TEXTURE", "uniform float uDetailDiffuseStrength;", "uniform float uDetailDiffuseRepeat;", "uniform bool enableDetailDiffuse;", "uniform sampler2D tDetailDiffuse;", "#endif", ].join("\n"),
detail_diffuse_fragment: ["#ifdef USE_DETAIL_DIFFUSE_TEXTURE", "if( enableDetailDiffuse ) {", "vec4 texelDetailColor = texture2D( tDetailDiffuse, vUv * uDetailDiffuseRepeat );", "#ifdef GAMMA_INPUT", "texelDetailColor.xyz *= texelDetailColor.xyz;", "#endif", "texelDetailColor.xyz *= 2.0;", "gl_FragColor.xyz = gl_FragColor.xyz * mix(vec3(1, 1, 1), texelDetailColor.xyz, uDetailDiffuseStrength);", "}", "#endif", ].join("\n"),
directionlight_pars_fragment: ["#if MAX_DIR_LIGHTS > 0", "uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];", "uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];", "#endif", ].join("\n"),
directionlight_fragment: ["#if MAX_DIR_LIGHTS > 0", "vec3 dirDiffuse = vec3( 0.0 );", "vec3 dirSpecular = vec3( 0.0 );", "for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {", "vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );", "vec3 dirVector = normalize( lDirection.xyz );", "float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );", "dirDiffuse += directionalLightColor[ i ] * dirDiffuseWeight;", "vec3 dirHalfVector = normalize( dirVector + viewPosition );", "float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );", "vec3 dirSpecularWeight = specularTex * max( pow( dirDotNormalHalf, specShininess + 0.0001 ), 0.0 );", "#ifdef PHYSICALLY_BASED_SHADING", "float specularNormalization = ( specShininess + 2.0001 ) / 8.0;", "vec3 schlick = uSpecularColor + uSpecularColor * vec3( 1.0 - uSpecularColor.r ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );", "dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;", "#else", "dirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;", "#endif", "}", "gl_FragColor.xyz = gl_FragColor.xyz * ( dirDiffuse + ambientLightColor * uAmbientColor) + dirSpecular;", "#endif", ].join("\n"),
hslshift_pars_fragment: ["uniform float uHueShift;", "uniform float uSaturationShift;", "uniform float uLightnessShift;", "vec3 RGBtoHSL( vec3 color) {", "float var_Min = min(color.x, min(color.y, color.z));", "float var_Max = max(color.x, max(color.y, color.z));", "float del_Max = var_Max - var_Min;", "float L = ( var_Max + var_Min ) / 2.0;", "if ( del_Max == 0.0 )", "{", "return vec3(0.0, 0.0, L);", "}", "else", "{", "float S = 0.0;", "float H = 0.0;", "if ( L < 0.5 ) S = del_Max / ( var_Max + var_Min );", "else S = del_Max / ( 2.0 - var_Max - var_Min );", "float del_R = ( ( ( var_Max - color.x ) / 6.0 ) + ( del_Max / 2.0 ) ) / del_Max;", "float del_G = ( ( ( var_Max - color.y ) / 6.0 ) + ( del_Max / 2.0 ) ) / del_Max;", "float del_B = ( ( ( var_Max - color.z ) / 6.0 ) + ( del_Max / 2.0 ) ) / del_Max;", "if ( color.x == var_Max ) H = del_B - del_G;", "else if ( color.y == var_Max ) H = ( 1.0 / 3.0 ) + del_R - del_B;", "else if ( color.z == var_Max ) H = ( 2.0 / 3.0 ) + del_G - del_R;", "if ( H < 0.0 ) H += 1.0;", "if ( H > 1.0 ) H -= 1.0;", "return vec3(H, S, L);", "}", "}", "float Hue_2_RGB( float v1, float v2, float vH ) {", "if ( vH < 0.0 ) vH += 1.0;", "if ( vH > 1.0 ) vH -= 1.0;", "if ( ( 6.0 * vH ) < 1.0 ) return ( v1 + ( v2 - v1 ) * 6.0 * vH );", "if ( ( 2.0 * vH ) < 1.0 ) return ( v2 );", "if ( ( 3.0 * vH ) < 2.0 ) return ( v1 + ( v2 - v1 ) * ( ( 2.0 / 3.0 ) - vH ) * 6.0 );", "return v1;", "}", "vec3 HSLtoRGB( vec3 color) {", "if ( color.y == 0.0 ) {", "return vec3(color.z);", "}", "else {", "float var_2 = 0.0;", "if ( color.z < 0.5 ) var_2 = color.z * ( 1.0 + color.y );", "else var_2 = ( color.z + color.y ) - ( color.y * color.z );", "float var_1 = 2.0 * color.z - var_2;", "return vec3(Hue_2_RGB(var_1, var_2, color.x+(1.0/3.0)), Hue_2_RGB(var_1, var_2, color.x), Hue_2_RGB(var_1, var_2, color.x - (1.0 / 3.0)));", "}", "}", "vec3 applyHSLShift( vec3 color, float hue, float saturation, float lightness ) {", "vec3 hsl = RGBtoHSL(color);", "hsl.x = hsl.x + hue;", "if (hsl.x<0.0) hsl.x = hsl.x + 1.0;", "if (hsl.x>1.0) hsl.x = hsl.x - 1.0;", "hsl.y = hsl.y + saturation;", "if (hsl.y<0.0) hsl.y = 0.0;", "if (hsl.y>1.0) hsl.y = 1.0;", "hsl.z = hsl.z + lightness;", "if (hsl.z<0.0) hsl.z = 0.0;", "if (hsl.z>1.0) hsl.z = 1.0;", "return HSLtoRGB(hsl);", "}", ].join("\n"),
position_vertex: ["vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", "vViewPosition = -mvPosition.xyz;", "gl_Position = projectionMatrix * mvPosition;", ].join("\n"),
alphaclip_pars_fragment: ["uniform float uAlphaClip;", ].join("\n"),
alphaclip_fragment: ["if (gl_FragColor.a < uAlphaClip) discard;", ].join("\n"),
colormultiply_pars_fragment: ["uniform float uMultiply;", ].join("\n"),
colormultiply_fragment: ["gl_FragColor.xyz *= uMultiply;", ].join("\n"),
};
P3D.UniformsLib = {
ao: {
"enableAO": {
type: "i",
value: 0
},
"tAO": {
type: "t",
value: null
},
"uAOStrength": {
type: "f",
value: 1.0
},
"uAOColor": {
type: "c",
value: new THREE.Color(0xffffff)
},
},
glow: {
"enableGlow": {
type: "i",
value: 0
},
"tGlow": {
type: "t",
value: null
},
"uGlowStrength": {
type: "f",
value: 1.0
},
"uGlowColor": {
type: "c",
value: new THREE.Color(0xffffff)
},
"uGlowDiffuseInfluence": {
type: "f",
value: 0.0
},
},
reflection: {
"enableReflection": {
type: "i",
value: 0
},
"enableReflectionMask": {
type: "i",
value: 0
},
"tReflection": {
type: "t",
value: null
},
"tReflectionMask": {
type: "t",
value: null
},
"uReflectionStrength": {
type: "f",
value: 0.5
},
"uReflectionMaskStrength": {
type: "f",
value: 1.0
},
"uReflectionColor": {
type: "c",
value: new THREE.Color(0xffffff)
},
"uReflectionCoefficient": {
type: "f",
value: 0.0
},
},
diffuse: {
"enableDiffuse": {
type: "i",
value: 0
},
"tDiffuse": {
type: "t",
value: null
},
"uDiffuseColor": {
type: "c",
value: new THREE.Color(0xffffff)
},
},
detail_diffuse: {
"enableDetailDiffuse": {
type: "i",
value: 0
},
"tDetailDiffuse": {
type: "t",
value: null
},
"uDetailDiffuseStrength": {
type: "f",
value: 1.0
},
"uDetailDiffuseRepeat": {
type: "f",
value: 1.0
},
},
uv: {
"uOffset": {
type: "v2",
value: new THREE.Vector2(0, 0)
},
"uRepeat": {
type: "v2",
value: new THREE.Vector2(1, 1)
},
},
bump: THREE.UniformsUtils.merge([THREE.UniformsLib["bump"], {
"enableBump": {
type: "i",
value: 0
},
}]),
detail_bump: {
"enableDetailBump": {
type: "i",
value: 0
},
"detailBumpMap": {
type: "t",
value: null
},
"uDetailBumpStrength": {
type: "f",
value: 1.0
},
"uDetailBumpRepeat": {
type: "f",
value: 1.0
},
},
normalmap: {
"enableNormal": {
type: "i",
value: 0
},
"tNormal": {
type: "t",
value: null
},
"uNormalScale": {
type: "f",
value: 1.0
},
},
detail_normalmap: {
"enableDetailNormal": {
type: "i",
value: 0
},
"tDetailNormal": {
type: "t",
value: null
},
"uDetailNormalStrength": {
type: "f",
value: 1.0
},
"uDetailNormalRepeat": {
type: "f",
value: 1.0
},
},
hslshift: {
"uHueShift": {
type: "f",
value: 0.0
},
"uSaturationShift": {
type: "f",
value: 0.0
},
"uLightnessShift": {
type: "f",
value: 0.0
},
},
alphaclip: {
"uAlphaClip": {
type: "f",
value: 0
},
},
colormultiply: {
"uMultiply": {
type: "f",
value: 1.0
},
},
};
P3D.Shaders = {
'normal': {
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib["lights"], P3D.UniformsLib["ao"], P3D.UniformsLib["glow"], P3D.UniformsLib["reflection"], P3D.UniformsLib["uv"], P3D.UniformsLib["diffuse"], P3D.UniformsLib["detail_diffuse"], P3D.UniformsLib["bump"], P3D.UniformsLib["detail_bump"], P3D.UniformsLib["normalmap"], P3D.UniformsLib["detail_normalmap"], P3D.UniformsLib["alphaclip"], P3D.UniformsLib["colormultiply"], {
"enableSpecular": {
type: "i",
value: 0
},
"enableSpecularShine": {
type: "i",
value: 0
},
"tSpecular": {
type: "t",
value: 1,
texture: null
},
"tSpecularShine": {
type: "t",
value: 2,
texture: null
},
"uSpecularColor": {
type: "c",
value: new THREE.Color(0x111111)
},
"uAmbientColor": {
type: "c",
value: new THREE.Color(0xffffff)
},
"uShininess": {
type: "f",
value: 30
},
}]),
fragmentShader: ["uniform vec3 uAmbientColor;", "uniform vec3 uSpecularColor;", "uniform float uShininess;", "#ifdef USE_SPEC_TEX", "uniform sampler2D tSpecular;", "uniform bool enableSpecular;", "#endif", "#ifdef USE_SPEC_SHINE_TEX", "uniform sampler2D tSpecularShine;", "uniform bool enableSpecularShine;", "#endif", "varying vec3 vNormal;", "uniform vec3 ambientLightColor;", "varying vec3 vViewPosition;", P3D.ShaderChunk["uv_pars_fragment"], P3D.ShaderChunk["bump_base_pars_fragment"], P3D.ShaderChunk["bumpmap_pars_fragment"], P3D.ShaderChunk["detail_bumpmap_pars_fragment"], P3D.ShaderChunk["ao_pars_fragment"], P3D.ShaderChunk["glow_pars_fragment"], P3D.ShaderChunk["reflection_pars_fragment"], P3D.ShaderChunk["diffuse_pars_fragment"], P3D.ShaderChunk["detail_diffuse_pars_fragment"], P3D.ShaderChunk["directionlight_pars_fragment"], P3D.ShaderChunk["tangent_pars_fragment"], P3D.ShaderChunk["normalmap_pars_fragment"], P3D.ShaderChunk["detail_normalmap_pars_fragment"], P3D.ShaderChunk["alphaclip_pars_fragment"], P3D.ShaderChunk["colormultiply_pars_fragment"], "void main() {", "gl_FragColor = vec4( 1.0 );", "vec3 normal = vNormal;", P3D.ShaderChunk["diffuse_fragment"], P3D.ShaderChunk["detail_diffuse_fragment"], P3D.ShaderChunk["alphaclip_fragment"], P3D.ShaderChunk["ao_fragment"], "vec3 specularTex = vec3( 1.0 );", "#ifdef USE_SPEC_TEX", "if( enableSpecular )", "specularTex = texture2D( tSpecular, vUv ).xyz;", "#endif", "float specShininess = uShininess;", "#ifdef USE_SPEC_SHINE_TEX", "if (enableSpecularShine) specShininess *= texture2D( tSpecularShine, vUv ).x;", "#endif", P3D.ShaderChunk["bumpmap_fragment"], P3D.ShaderChunk["detail_bumpmap_fragment"], P3D.ShaderChunk["normalmap_fragment"], P3D.ShaderChunk["detail_normalmap_fragment"], "normal = normalize( normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) ) );", "vec3 viewPosition = normalize( vViewPosition );", P3D.ShaderChunk["directionlight_fragment"], P3D.ShaderChunk["reflection_fragment"], P3D.ShaderChunk["glow_fragment"], P3D.ShaderChunk["colormultiply_fragment"], THREE.ShaderChunk["linear_to_gamma_fragment"], "}"].join("\n"),
vertexShader: ["varying vec3 vNormal;", "varying vec3 vViewPosition;", P3D.ShaderChunk["uv_pars_vertex"], P3D.ShaderChunk["tangent_pars_vertex"], "void main() {", P3D.ShaderChunk["position_vertex"], "vNormal = normalMatrix * normal;", P3D.ShaderChunk["tangent_vertex"], P3D.ShaderChunk["uv_vertex"], "}"].join("\n")
},
'shadesphere': {
uniforms: THREE.UniformsUtils.merge([P3D.UniformsLib["bump"], P3D.UniformsLib["detail_bump"], P3D.UniformsLib["normalmap"], P3D.UniformsLib["detail_normalmap"], P3D.UniformsLib["hslshift"], P3D.UniformsLib["colormultiply"], {
"enableShadesphere": {
type: "i",
value: 0
},
"tShadesphere": {
type: "t",
value: 0,
texture: null
},
"uShadesphereColor": {
type: "c",
value: new THREE.Color(0xffffff)
},
}]),
fragmentShader: ["uniform vec3 uShadesphereColor;", "uniform bool enableShadesphere;", "uniform sampler2D tShadesphere;", "varying vec3 vNormal;", "varying vec3 vViewPosition;", P3D.ShaderChunk["uv_pars_fragment"], P3D.ShaderChunk["bump_base_pars_fragment"], P3D.ShaderChunk["bumpmap_pars_fragment"], P3D.ShaderChunk["detail_bumpmap_pars_fragment"], P3D.ShaderChunk["tangent_pars_fragment"], P3D.ShaderChunk["normalmap_pars_fragment"], P3D.ShaderChunk["detail_normalmap_pars_fragment"], P3D.ShaderChunk["hslshift_pars_fragment"], P3D.ShaderChunk["colormultiply_pars_fragment"], "void main() {", "gl_FragColor = vec4( vec3(0.5), 1.0 );", "vec3 normal = vNormal;", P3D.ShaderChunk["bumpmap_fragment"], P3D.ShaderChunk["detail_bumpmap_fragment"], P3D.ShaderChunk["normalmap_fragment"], P3D.ShaderChunk["detail_normalmap_fragment"], "normal = normalize( normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) ) );", "vec3 viewPosition = normalize( vViewPosition );", "if( enableShadesphere ) {", "vec2 texco;", "texco.x = 0.5 + 0.49 * normal.x;", "texco.y = 0.5 + 0.49 * normal.y;", "#ifdef GAMMA_INPUT", "vec3 texelColor = texture2D( tShadesphere, texco ).xyz;", "texelColor *= texelColor;", "gl_FragColor.xyz = texelColor;", "#else", "gl_FragColor.xyz = texture2D( tShadesphere, texco ).xyz;", "#endif", "}", "gl_FragColor.xyz *= uShadesphereColor;", P3D.ShaderChunk["colormultiply_fragment"], THREE.ShaderChunk["linear_to_gamma_fragment"], "if (uHueShift != 0.0 || uSaturationShift != 0.0 || uLightnessShift != 0.0) gl_FragColor.xyz = applyHSLShift(gl_FragColor.xyz, uHueShift, uSaturationShift, uLightnessShift);", "}"].join("\n"),
vertexShader: ["varying vec3 vNormal;", "varying vec2 vUv;", "varying vec3 vViewPosition;", P3D.ShaderChunk["tangent_pars_vertex"], "void main() {", P3D.ShaderChunk["position_vertex"], "vNormal = normalMatrix * normal;", P3D.ShaderChunk["tangent_vertex"], "vUv = vec2(uv.x, 1.0 - uv.y);", "}"].join("\n")
},
'shadeless': {
uniforms: THREE.UniformsUtils.merge([P3D.UniformsLib["diffuse"], P3D.UniformsLib["detail_diffuse"], P3D.UniformsLib["uv"], P3D.UniformsLib["alphaclip"], P3D.UniformsLib["colormultiply"], ]),
vertexShader: [P3D.ShaderChunk["uv_pars_vertex"], "varying vec3 vViewPosition;", "void main() {", P3D.ShaderChunk["position_vertex"], P3D.ShaderChunk["uv_vertex"], "}"].join("\n"),
fragmentShader: [P3D.ShaderChunk["alphaclip_pars_fragment"], P3D.ShaderChunk["uv_pars_fragment"], P3D.ShaderChunk["diffuse_pars_fragment"], P3D.ShaderChunk["detail_diffuse_pars_fragment"], P3D.ShaderChunk["colormultiply_pars_fragment"], "void main() {", "gl_FragColor = vec4( 1.0 );", P3D.ShaderChunk["diffuse_fragment"], P3D.ShaderChunk["detail_diffuse_fragment"], P3D.ShaderChunk["alphaclip_fragment"], P3D.ShaderChunk["colormultiply_fragment"], THREE.ShaderChunk["linear_to_gamma_fragment"], "}"].join("\n")
},
'xray': {
uniforms: THREE.UniformsUtils.merge([P3D.UniformsLib["colormultiply"], {
"uDiffuseColor": {
type: "c",
value: new THREE.Color(0xffffff)
},
}]),
vertexShader: ["varying vec3 vViewPosition;", "varying float vAlpha;", "void main() {", P3D.ShaderChunk["position_vertex"], "vec4 worldPosition = modelMatrix * vec4( position, 1.0 );", "vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );", "vec3 I = worldPosition.xyz - cameraPosition;", "vAlpha = 0.04 + (1.0 - pow( abs(dot( normalize( I ), worldNormal )), 0.2 ));", "}"].join("\n"),
fragmentShader: [P3D.ShaderChunk["diffuse_pars_fragment"], P3D.ShaderChunk["colormultiply_pars_fragment"], "varying float vAlpha;", "void main() {", "gl_FragColor = vec4( uDiffuseColor, vAlpha );", P3D.ShaderChunk["colormultiply_fragment"], "}"].join("\n")
},
};
'use strict';
var P3DV = P3DV || {};
P3DV.width = 0;
P3DV.height = 0;
P3DV.destroy = false;
P3DV.viewer_settings = {};
P3DV.model_settings = {};
P3DV.resetModel = function() {
P3DV.model = {
name: '',
url: false,
id: 'new',
status: 'new',
};
};
P3DV.resetModel();
P3DV.materials = [{
textures: new Object(),
settings: new Object()
}];
P3DV.floor = 0;
P3DV.initial_size = 1;
P3DV.initial_zoom = 5, P3DV.mousewheel_zoom_speed = 1.2;
P3DV.renderer;
P3DV.loader;
P3DV.stats;
P3DV.mesh = false;
P3DV.settings_force_changed = false;
P3DV.directional_light1;
P3DV.directional_light2;
P3DV.directional_light3;
P3DV.directional_light4;
P3DV.light1_pos = new THREE.Vector3(10, 10, 10);
P3DV.light2_pos = new THREE.Vector3(-5, 10, 5);
P3DV.light3_pos = new THREE.Vector3(0, -10, 5);
P3DV.light4_pos = new THREE.Vector3(0, 0, -10);
P3DV.mat_shading_modes = [];
P3DV.mat_overrides = [{
textures: new Object(),
settings: new Object()
}];
P3DV.radius = 40;
P3DV.scene_time = 0;
P3DV.rotate_lock = 0;
P3DV.autorot_slow = 0;
P3DV.render_anims = new Array();
P3DV.render_anim_time = 0;
P3DV.reset_time = 0;
P3DV.reset_phase = 0;
P3DV.reset_duration = 500;
P3DV.orig_geometry;
P3DV.subd_geometry;
P3DV.render_geometry;
P3DV.camera;
P3DV.controls;
P3DV.scene;
P3DV.world;
P3DV.last_cam_pos;
P3DV.empty;
P3DV.show_stats = 0;
P3DV.thumb_timeout = 0;
P3DV.force_render_frames = 0;
P3DV.callbacks = {
modelStateChange: null,
textureStateChange: null,
updateMeshInfo: null,
updateViewerPreviews: null
};
$(window).keyup(function(e) {
if (P3DV.viewer_settings.noPan && P3DV.viewer_settings.noZoom && P3DV.viewer_settings.noRotate)
return;
if (e.keyCode == 82) {
P3DV.resetCamera();
}
});
P3DV.resetCamera = function() {
P3DV.reset_time = new Date().getTime();
P3DV.reset_phase = P3DV.reset_duration;
};
P3DV.initViewer = function(w, h, elemId) {
P3DV.width = w;
P3DV.height = h;
P3DV.destroy = false;
if (!Detector.webgl) {
P3d.viewerSync.webglSetSupported(false);
return;
}
var elem = document.getElementById(elemId);
P3DV.renderer_init(elem);
$(window).resize(function() {
P3DV.width = window.innerWidth;
P3DV.height = window.innerHeight;
P3DV.renderer_setSize(P3DV.width, P3DV.height);
P3DV.renderer_render();
});
P3DV.renderer_render();
P3DV.animate();
};
P3DV.destroyViewer = function() {
P3DV.loadStates.reset();
P3DV.scene_freeGeometry();
this.mat_overrides = [{
textures: new Object(),
settings: new Object()
}];
this.materials = [{
textures: new Object(),
settings: new Object()
}];
P3DV.textureCache_cleanup();
P3DV.model_freeShadingModes();
P3DV.renderer_checkMemory();
if (this.scene) {
this.scene.remove(this.world);
this.renderer.initWebGLObjects(this.scene);
}
delete this.camera;
delete this.controls;
delete this.world;
delete this.scene;
delete this.mesh;
delete this.orig_geometry;
delete this.render_geometry;
this.viewer_settings = {};
this.model_settings = {};
this.autorot_slow = 0;
this.reset_phase = 0;
$(window).unbind('resize');
this.destroy = true;
};
'use strict';
P3DV.URL_BASE = "";
P3DV.URL_BASE_REGEXP = "";
P3DV.callbacks.modelStateChange = function() {
if (P3DV.loadStates.model_loading)
P3DV.model.status = 'loading';
else
P3DV.model.status = 'ready';
};
'use strict';
P3DV.renderer_init = function(context_container) {
$(context_container).mousewheel(function(event, delta) {
if (!P3DV.controls.noZoom) {
var newPos = P3DV.camera.position.clone()
newPos.sub(P3DV.controls.target);
newPos.multiplyScalar(delta < 0 ? P3DV.mousewheel_zoom_speed : 1.0 / P3DV.mousewheel_zoom_speed);
newPos.add(P3DV.controls.target);
P3DV.camera.position = newPos;
}
event.preventDefault();
});
P3DV.scene = new THREE.Scene();
P3DV.world = new THREE.Object3D();
P3DV.scene.add(P3DV.world);
if (!P3DV.renderer) {
P3DV.renderer = new THREE.WebGLRenderer({
antialias: true
});
P3DV.renderer.gammaInput = true;
P3DV.renderer.gammaOutput = true;
P3DV.renderer.physicallyBasedShading = true;
P3DV.renderer.sortObjects = false;
P3DV.renderer.autoClear = true;
P3DV.renderer.domElement.className = 'radial';
P3DV.renderer_checkHardware();
}
P3DV.renderer.setSize(P3DV.width, P3DV.height);
context_container.appendChild(P3DV.renderer.domElement);
P3DV.camera = new THREE.PerspectiveCamera(25, P3DV.width / P3DV.height, 0.1, 100);
P3DV.controls = new THREE.TrackballControls(P3DV.camera, context_container);
P3DV.controls.rotateSpeed = 1.0;
P3DV.controls.zoomSpeed = 1.2;
P3DV.controls.panSpeed = 0.2;
P3DV.controls.noRotate = (P3DV.viewer_settings.noRotate) ? true : false;
P3DV.controls.noZoom = (P3DV.viewer_settings.noZoom) ? true : false;
P3DV.controls.noPan = (P3DV.viewer_settings.noPan) ? true : false;
P3DV.controls.noRoll = true;
P3DV.controls.staticMoving = false;
P3DV.controls.dynamicDampingFactor = 0.3;
P3DV.controls.maxDistance = P3DV.radius;
P3DV.controls.keys = [90, 88, 67];
P3DV.camera_setDefault(P3DV.camera, false, P3DV.controls, P3DV.initial_zoom);
P3DV.camera_setSettings(P3DV.camera, false, P3DV.controls, P3DV.model_settings.default_camera);
P3DV.scene.add(P3DV.camera);
P3DV.last_cam_pos = P3DV.camera.position.clone();
P3DV.camera.updateMatrixWorld(true);
var ambient = new THREE.AmbientLight(0x000000);
P3DV.scene.add(ambient);
P3DV.directional_light1 = new THREE.DirectionalLight(0xfffaf0, 1.15);
P3DV.scene.add(P3DV.directional_light1);
P3DV.directional_light2 = new THREE.DirectionalLight(0xb3e5ff, .55);
P3DV.scene.add(P3DV.directional_light2);
P3DV.directional_light3 = new THREE.DirectionalLight(0xfdffcc, .55);
P3DV.scene.add(P3DV.directional_light3);
P3DV.directional_light4 = new THREE.DirectionalLight(0xb3e5ff, .55);
P3DV.scene.add(P3DV.directional_light4);
P3DV.setLightsForCamera(P3DV.camera);
if (P3DV.model.url) {
P3DV.loadModel(P3DV.model.url);
}
if (P3DV.show_stats) {
P3DV.stats = new Stats();
P3DV.stats.domElement.style.position = 'absolute';
P3DV.stats.domElement.style.top = '0px';
P3DV.stats.domElement.style.zIndex = 90;
context_container.appendChild(P3DV.stats.domElement);
}
};
P3DV.renderer_checkHardware = function() {
var gl = P3DV.renderer.context;
if (!gl.getExtension('OES_standard_derivatives')) {
P3DV.disabled_textures.bump = true;
P3DV.disabled_textures.dbump = true;
P3d.viewerSync.setIncompatibleTextures(Object.keys(P3DV.disabled_textures));
console.log("Bump maps not supported");
}
var max_textures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
if (max_textures) {
P3DV.maximum_textures = max_textures;
P3d.viewerSync.webglSetMaximumTextures(max_textures);
}
};
P3DV.renderer_setSize = function(width, height, enforce_in_pixels) {
if (enforce_in_pixels && P3DV.renderer.devicePixelRatio) {
if (P3DV.renderer.devicePixelRatio !== 1) {
width = width / P3DV.renderer.devicePixelRatio;
height = height / P3DV.renderer.devicePixelRatio;
}
}
P3DV.renderer.setSize(width, height);
P3DV.camera.aspect = width / height;
P3DV.controls.handleResize();
P3DV.camera.updateProjectionMatrix();
};
P3DV.setLightsForCamera = function(cam) {
var quaternion = new THREE.Quaternion();
cam.updateMatrixWorld(true);
quaternion.setFromRotationMatrix(cam.matrixWorld);
P3DV.directional_light1.position = P3DV.light1_pos.clone().applyQuaternion(quaternion);
P3DV.directional_light2.position = P3DV.light2_pos.clone().applyQuaternion(quaternion);
P3DV.directional_light3.position = P3DV.light3_pos.clone().applyQuaternion(quaternion);
P3DV.directional_light4.position = P3DV.light4_pos.clone().applyQuaternion(quaternion);
};
P3DV.renderer_captureImage = function(width, height, camera_settings, force_shader) {
if (P3DV.model.status != "ready" || !P3DV.mesh) return 0;
P3DV.renderer_setSize(width, height, true); {
var orig_rot = P3DV.getThreeRotation(P3DV.world.rotation);
var camera2 = new THREE.PerspectiveCamera(25, width / height, 0.1, 100);
P3DV.camera_setDefault(camera2, P3DV.world, false, P3DV.initial_zoom);
P3DV.camera_setSettings(camera2, P3DV.world, false, camera_settings);
P3DV.scene.add(camera2);
P3DV.setLightsForCamera(camera2);
P3DV.mesh.updateMatrix();
if (force_shader) {
P3DV.updateShader(force_shader, true);
}
P3DV.renderer.render(P3DV.scene, camera2);
P3DV.setThreeRotation(P3DV.world.rotation, orig_rot);
P3DV.mesh.updateMatrix();
P3DV.scene.remove(camera2);
P3DV.setLightsForCamera(P3DV.camera);
if (force_shader) {
P3DV.updateShader(P3DV.viewer_settings.shading, true);
}
}
var dataurl = P3DV.renderer.domElement.toDataURL("image/png");
P3DV.renderer_setSize(window.innerWidth, window.innerHeight);
P3DV.renderer.render(P3DV.scene, P3DV.camera);
return dataurl;
};
P3DV.renderer_checkMemory = function() {
var valid = true;
var checkRendererInfoObject = function(info) {
var data = P3DV.renderer.info[info];
var keys = Object.keys(data);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = data[key];
if (value) {
valid = false;
console.log('Renderer "' + info + '" not empty: ' + key + ' = ' + value);
}
}
};
checkRendererInfoObject('memory');
if (valid) {
console.log('Renderer memory released');
} else {
console.log('Renderer memory release failure!');
}
};
P3DV.renderer_render = function() {
P3DV.scene_update();
P3DV.renderer.render(P3DV.scene, P3DV.camera);
};
'use strict';
P3DV.loadStates = {
model_rev: 0,
model_loading: false,
textures_rev: new Array(),
textures_loading: new Array(),
};
P3DV.loadStates.reset = function() {
this.model_rev++;
this.textures_rev = new Array();
this.textures_loading = new Array();
};
P3DV.loadStates.modelCallback = function() {
if (P3DV.callbacks.modelStateChange)
P3DV.callbacks.modelStateChange();
}
P3DV.loadStates.modelSetLoading = function() {
this.model_rev++;
this.model_loading = true;
this.modelCallback();
return this.model_rev;
};
P3DV.loadStates.modelSetReady = function(rev) {
if (rev == this.model_rev) {
this.model_loading = false;
this.modelCallback();
return true;
}
return false;
};
P3DV.loadStates.textureCallback = function() {
if (P3DV.callbacks.textureStateChange)
P3DV.callbacks.textureStateChange();
}
P3DV.loadStates.resetTextures = function(idx) {
this.textures_loading[idx] = new Array();
if (this.textures_rev[idx]) {
this.textures_rev[idx]++;
} else {
this.textures_rev[idx] = 1;
}
this.textureCallback();
return this.textures_rev[idx];
};
P3DV.loadStates.textureSetLoading = function(url, idx, rev) {
if (rev == this.textures_rev[idx]) {
this.textures_loading[idx].push(url);
this.textureCallback();
}
};
P3DV.loadStates.textureSetReady = function(url, idx, rev) {
if (rev == this.textures_rev[idx]) {
for (var i = 0; i < this.textures_loading[idx].length; i++) {
if (this.textures_loading[idx][i] == url) {
this.textures_loading[idx].splice(i, 1);
break;
}
}
this.textureCallback();
return true;
}
return false;
};
'use strict';
P3DV.disabled_textures = {};
P3DV.maximum_textures = 32;
P3DV.texture_priority_order = ['diff', 'norm', 'bump', 'spec'];
P3DV.viewer_materials = {
normal: {
shader: 'normal',
textures: ['diff', ['spec', 'spec_glossiness'],
['reflection', 'reflection_mask'], 'glow', 'ao', 'norm', 'bump', 'ddiff', 'dnorm', 'dbump'
],
},
shadesphere: {
shader: 'shadesphere',
textures: ['shadesphere', 'norm', 'bump', 'dnorm', 'dbump'],
},
shadeless: {
shader: 'shadeless',
textures: ['diff', 'ddiff'],
force_settings: {
diff_str: 1.0,
diff_tex_str: 1.0,
},
},
};
P3DV.viewer_shading_modes = {
wire: {
type: 'wire',
color: function(s) {
return P3DV.getShaderColor(s.diff_col, 0.75).getHex();
},
setting_bindings: ['diff_col'],
mat_types: {
shadesphere: {
force_settings: {
diff_col: 'FFFFFF',
},
}
},
},
xray: {
type: 'shader',
doublesided: true,
depthtest: false,
transparent: true,
wireonname: 'wireonxray',
wirecolor: 0xbebebe,
force_shader: 'xray',
force_settings: {
diff_col: '2bb0d8',
diff_str: 1.0,
diff_tex_str: 1.0,
},
},
shadeless: {
type: 'shader',
wireonname: 'wireonshadeless',
wirecolor: 0x888888,
force_shader: 'shadeless',
mat_types: {
shadesphere: {
force_settings: {
diff_col: 'FFFFFF',
},
},
},
force_settings: {
diff_str: 1.0,
diff_tex_str: 1.0,
},
},
smooth: {
type: 'shader',
wireonname: 'wireonsmooth',
wirecolor: 0x888888,
},
clean: {
type: 'shader',
wireonname: 'wireonclean',
force_shader: 'normal',
disable_textures: ['diff', 'ddiff', 'ao'],
mat_types: {
shadesphere: {
force_settings: {
ao_col: 'FFFFFF',
spec_col: 'FFFFFF',
spec_str: 0.15,
spec_shininess: 0.1,
},
},
shadeless: {
force_settings: {
ao_col: 'FFFFFF',
spec_col: 'FFFFFF',
spec_str: 0.15,
spec_shininess: 0.1,
},
}
},
force_settings: {
diff_str: 0.5,
diff_col: 'FFFFFF',
},
},
};
P3DV.shader_params = {
normal: {
threejs_lights: true,
},
shadesphere: {
threejs_lights: false,
},
shadeless: {
threejs_lights: false,
},
xray: {
threejs_lights: false,
},
};
P3DV.shader_uniform_mapping = {
uAlphaClip: {
bindings: ['alpha_clip'],
mapping: 'float',
},
uAOColor: {
bindings: ['ao_col'],
mapping: 'color',
},
uAOStrength: {
bindings: ['ao_str'],
mapping: 'float',
},
uDiffuseColor: {
bindings: ['diff_str', 'diff_tex_str', 'diff_col'],
mapping: function(s, mat_idx, mode_def) {
var diff_intensity = P3DV.shadingMode_hasTexture(mode_def, mat_idx, 'diff') ? s.diff_tex_str : s.diff_str;
return P3DV.getShaderColor(s.diff_col, diff_intensity);
},
},
uHueShift: {
bindings: ['shadesphere_hue'],
mapping: 'float',
},
uSaturationShift: {
bindings: ['shadesphere_saturation'],
mapping: 'float',
},
uLightnessShift: {
bindings: ['shadesphere_lightness'],
mapping: 'float',
},
uDetailDiffuseStrength: {
bindings: ['ddiff_str'],
mapping: 'float',
},
uDetailDiffuseRepeat: {
bindings: ['ddiff_repeat'],
mapping: 'float',
},
uNormalScale: {
bindings: ['norm_str'],
mapping: 'float',
},
uDetailNormalStrength: {
bindings: ['dnorm_str'],
mapping: 'float',
},
uDetailNormalRepeat: {
bindings: ['dnorm_repeat'],
mapping: 'float',
},
bumpScale: {
bindings: ['bump_str'],
mapping: function(s) {
return s.bump_str * 0.1;
},
},
uDetailBumpStrength: {
bindings: ['dbump_str'],
mapping: function(s) {
return s.dbump_str * 0.1;
},
},
uDetailBumpRepeat: {
bindings: ['dbump_repeat'],
mapping: 'float',
},
uSpecularColor: {
bindings: ['spec_col', 'spec_str'],
mapping: function(s) {
return P3DV.getShaderColor(s.spec_col, s.spec_str);
},
},
uShininess: {
bindings: ['spec_shininess'],
mapping: function(s) {
return s.spec_shininess * 255.0;
},
},
uGlowStrength: {
bindings: ['glow_str'],
mapping: 'float',
},
uGlowColor: {
bindings: ['glow_col'],
mapping: 'color',
},
uGlowDiffuseInfluence: {
bindings: ['glow_diffuse'],
mapping: 'float',
},
uReflectionStrength: {
bindings: ['reflection_str'],
mapping: 'float',
},
uReflectionColor: {
bindings: ['reflection_col'],
mapping: 'color',
},
uReflectionMaskStrength: {
bindings: ['reflection_mask_str'],
mapping: 'float',
},
uReflectionCoefficient: {
bindings: ['reflection_fresnel'],
mapping: function(s) {
return Math.pow(s.reflection_fresnel, 2.0) * 8.0;
},
},
};
P3DV.shader_texture_settings = {
ao: {
param: 'tAO',
defines: [{
d: 'USE_AMBIENT_OCCLUSION',
frag: true
}],
enable_flag: 'enableAO',
},
bump: {
param: 'bumpMap',
defines: [{
d: 'USE_BUMPMAP',
frag: true
}, {
d: 'USE_BUMP_DERIVATIVES',
frag: true
}],
skip_filter: true,
enable_flag: 'enableBump',
},
dbump: {
param: 'detailBumpMap',
defines: [{
d: 'USE_DETAIL_BUMPMAP',
frag: true
}, {
d: 'USE_BUMP_DERIVATIVES',
frag: true
}],
skip_filter: true,
enable_flag: 'enableDetailBump',
},
diff: {
param: 'tDiffuse',
defines: [{
d: 'USE_DIFFUSE_TEXTURE',
frag: true
}],
enable_flag: 'enableDiffuse',
},
ddiff: {
param: 'tDetailDiffuse',
defines: [{
d: 'USE_DETAIL_DIFFUSE_TEXTURE',
frag: true
}],
enable_flag: 'enableDetailDiffuse',
},
shadesphere: {
param: 'tShadesphere',
defines: [],
skip_filter: true,
enable_flag: 'enableShadesphere',
},
norm: {
param: 'tNormal',
defines: [{
d: 'USE_NORMAL_MAP',
frag: true
}, {
d: 'USE_TANGENTS',
frag: true,
vert: true
}],
enable_flag: 'enableNormal',
},
dnorm: {
param: 'tDetailNormal',
defines: [{
d: 'USE_DETAIL_NORMAL_MAP',
frag: true
}, {
d: 'USE_TANGENTS',
frag: true,
vert: true
}],
enable_flag: 'enableDetailNormal',
},
spec: {
param: 'tSpecular',
defines: [{
d: 'USE_SPEC_TEX',
frag: true
}],
enable_flag: 'enableSpecular',
},
spec_glossiness: {
param: 'tSpecularShine',
defines: [{
d: 'USE_SPEC_SHINE_TEX',
frag: true
}],
enable_flag: 'enableSpecularShine',
},
glow: {
param: 'tGlow',
defines: [{
d: 'USE_GLOW',
frag: true
}],
enable_flag: 'enableGlow',
},
reflection: {
param: 'tReflection',
defines: [{
d: 'USE_REFLECTION',
frag: true
}],
enable_flag: 'enableReflection',
},
reflection_mask: {
param: 'tReflectionMask',
defines: [{
d: 'USE_REFLECTION_MASK',
frag: true
}],
enable_flag: 'enableReflectionMask',
},
};
P3DV.mat_setting_bindings = {};
P3DV.valid_shading_mode_names = [];
P3DV.viewer_shading_mode_keys = Object.keys(P3DV.viewer_shading_modes);
(function() {
for (var i = 0; i < P3DV.viewer_shading_mode_keys.length; i++) {
var key = P3DV.viewer_shading_mode_keys[i];
P3DV.viewer_shading_modes[key].key = key;
}
})();
P3DV.setShading = function(shadingName) {
shadingName = P3DV.shadingMode_verifyName(shadingName);
if (!shadingName || shadingName === P3DV.viewer_settings.shading) {
return;
}
P3DV.updateShader(shadingName);
P3DV.viewer_settings.shading = shadingName;
}
P3DV.refreshShader = function() {
P3DV.updateShader(P3DV.viewer_settings.shading);
}
P3DV.updateShader = function(shading_mode, skip_render) {
var newMesh, materials = [];
var totalMaterials = P3DV.model_usesMultimaterial() ? P3DV.mat_shading_modes.length : 1;
for (var i = 0; i < totalMaterials; i++) {
var shading_list = P3DV.mat_shading_modes[i];
var material_data = P3DV.material_getFinal(i);
var mat_item = shading_list ? shading_list[shading_mode] : false;
var mode_defs = P3DV.shadingMode_getDefines(shading_mode);
if (!mat_item) {
return;
}
var mat = $.isArray(mat_item) ? mat_item[0] : mat_item;
var use_doublesided = ('doublesided' in mode_defs) ? mode_defs.doublesided : P3DV.material_getSetting(i, "double_sided");
mat.side = use_doublesided ? THREE.DoubleSide : THREE.FrontSide;
mat.depthTest = ('depthtest' in mode_defs) ? mode_defs.depthtest : true;
mat.shading = P3DV.material_getSetting(i, "flat_shading") ? THREE.FlatShading : THREE.SmoothShading;
mat.transparent = mode_defs.transparent || material_data.possibly_alpha;
mat.needsUpdate = true;
materials.push(mat_item);
}
if (!materials.length || !P3DV.mesh)
return;
if (materials.length == 1) {
var mat = materials[0];
if ($.isArray(mat)) {
newMesh = THREE.SceneUtils.createMultiMaterialObject(P3DV.render_geometry, mat);
} else {
newMesh = new THREE.Mesh(P3DV.render_geometry, mat);
}
} else {
if ($.isArray(materials[0])) {
newMesh = P3DV.createMultiDualMaterialObject(P3DV.render_geometry, materials);
} else {
newMesh = new THREE.Mesh(P3DV.render_geometry, new THREE.MeshFaceMaterial(materials));
}
}
newMesh.position = P3DV.mesh.position;
newMesh.setRotationFromQuaternion(P3DV.mesh.quaternion);
newMesh.scale = P3DV.mesh.scale;
newMesh.matrix = P3DV.mesh.matrix;
newMesh.overdraw = P3DV.mesh.overdraw;
P3DV.world.remove(P3DV.mesh);
P3DV.world.add(newMesh);
P3DV.mesh = newMesh;
if (skip_render) return;
P3DV.force_render_frames = 4;
P3DV.renderer_render();
}
P3DV.createMultiDualMaterialObject = function(geometry, dualmaterials) {
var i, j, group = new THREE.Object3D();
for (i = 0; i < 2; i++) {
var materials = [];
for (j = 0; j < dualmaterials.length; j++) {
materials.push(dualmaterials[j][i]);
}
var object = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
group.add(object);
}
return group;
}
P3DV.textureLoadCallback = function() {
if (P3DV.callbacks.updateViewerPreviews) {
P3DV.callbacks.updateViewerPreviews();
}
}
P3DV._textureCache = new Object();
P3DV.textureCache_cleanup = function() {
var cached = Object.keys(P3DV._textureCache);
var urls = new Object();
for (var i = 0; i < P3DV.model_getNumberOfMaterials(); i++) {
var mats = [P3DV.materials[i], P3DV.mat_overrides[i]];
for (var j = 0; j < 2; j++) {
var mat = mats[j];
if (mat) {
var keys = Object.keys(mat.textures);
for (var k = 0; k < keys.length; k++) {
var cache_id = mat.textures[keys[k]];
var tex_settings = P3DV.shader_texture_settings[keys[k]];
if (tex_settings && tex_settings.skip_filter)
cache_id += '_skip_filter';
urls[cache_id] = true;
}
}
}
}
urls = Object.keys(urls);
for (var i = 0; i < cached.length; i++) {
var url = cached[i];
if (urls.indexOf(url) == -1) {
P3DV.texture_freeMemory(P3DV._textureCache[url]);
delete P3DV._textureCache[url];
}
}
}
P3DV.textureCache_set = function(url, texture) {
P3DV._textureCache[url] = texture;
}
P3DV.textureCache_load = function(url) {
return (P3DV._textureCache[url]) ? P3DV._textureCache[url] : false;
}
P3DV.shader_updateUniform = function(key, uniforms, s, mat_idx, shader_def) {
var item = P3DV.shader_uniform_mapping[key];
if (item && (key in uniforms)) {
if (shader_def.force_settings) {
s = $.extend({}, s, shader_def.force_settings);
}
var uniform = uniforms[key];
if (item.mapping == 'float') {
uniform.value = s[item.bindings[0]];
} else if (item.mapping == 'color') {
uniform.value = P3DV.getShaderColor(s[item.bindings[0]]);
} else if (typeof(item.mapping) == "function") {
uniform.value = item.mapping(s, mat_idx, shader_def);
}
}
}
P3DV.shader_applySettings = function(uniforms, s, mat_idx, shader_def) {
var keys = Object.keys(uniforms);
for (var i = 0; i < keys.length; i++) {
P3DV.shader_updateUniform(keys[i], uniforms, s, mat_idx, shader_def);
}
}
P3DV.material_validateType = function(name) {
if (!name || !P3DV.viewer_materials[name]) return "normal";
return name;
}
P3DV.setUniforms = function(mat_idx, list_shaders, mat_settings, mat_textures, mat_shading_modes) {
var active_material = P3DV.material_validateType(mat_settings.material_type);
for (var i = 0; i < list_shaders.length; ++i) {
var item = list_shaders[i];
var item_shader = P3DV.viewer_materials[active_material].shader;
if (item.force_shader) {
item_shader = item.force_shader;
}
item.shader = P3D.Shaders[item_shader];
item.shader_name = item_shader;
item.uniforms = THREE.UniformsUtils.clone(item.shader.uniforms);
item.fragHeaders = [];
item.vertHeaders = [];
P3DV.shader_applySettings(item.uniforms, mat_settings, mat_idx, item);
if (item.mat_types && item.mat_types[active_material]) {
var s = item.mat_types[active_material];
if (s.force_settings) {
var settings = $.extend({}, mat_settings, s.force_settings);
P3DV.shader_applySettings(item.uniforms, settings, mat_idx, item);
}
}
}
var active_textures = 0;
var trev = (mat_textures) ? P3DV.loadStates.resetTextures(mat_idx) : 0;
P3DV.textureCache_cleanup();
var uniform_fillTexture = function(uniform, texture, skip_filter) {
uniform.value = texture;
uniform.value.wrapS = uniform.value.wrapT = P3DV.getThreeWrapping(mat_settings.tex_wrap);
uniform.value.anisotropy = (skip_filter || mat_settings.tex_filter != 'nearest') ? P3DV.renderer.getMaxAnisotropy() : 1;
if (!skip_filter) {
uniform.value.magFilter = P3DV.getThreeFilter(mat_settings.tex_filter);
}
};
var shader_processTexture = function(texture, type, url) {
var s = P3DV.shader_texture_settings[type];
if (P3DV.loadStates.textureSetReady(url, mat_idx, trev)) {
for (var i = 0; i < list_shaders.length; i++) {
var item = list_shaders[i];
if (P3DV.shadingMode_textureDisabled(item, type) || !(s.param in item.uniforms))
continue;
uniform_fillTexture(item.uniforms[s.param], texture, s.skip_filter);
if (s.uniform_callback)
s.uniform_callback(item.uniforms, mat_settings);
if (s.enable_flag)
item.uniforms[s.enable_flag].value = true;
P3DV.textureLoadCallback();
}
if (s.generic_callback)
s.generic_callback(texture, mat_shading_modes);
P3DV.force_render_frames = 4;
}
}
var shader_loadTexture = function(type) {
var s = P3DV.shader_texture_settings[type];
if (P3DV.disabled_textures[type])
return;
if (s && mat_textures && mat_textures[type] && P3DV.viewer_materials[active_material].textures_list.indexOf(type) !== -1) {
var url = mat_textures[type];
if (active_textures >= P3DV.maximum_textures)
return;
active_textures++;
P3DV.loadStates.textureSetLoading(url, mat_idx, trev);
var cache_id = url;
if (s.skip_filter)
cache_id += '_skip_filter';
var texture;
if (texture = P3DV.textureCache_load(cache_id)) {
texture.needsUpdate = true;
shader_processTexture(texture, type, url);
} else {
THREE.ImageUtils.loadTexture(url, {}, function(texture) {
if (P3DV.textureCache_load(cache_id)) {
texture = P3DV.textureCache_load(cache_id);
}
P3DV.textureCache_set(cache_id, texture);
shader_processTexture(texture, type, url);
});
}
s.defines.forEach(function(define) {
var def = "#define " + define.d;
for (var i = 0; i < list_shaders.length; i++) {
var item = list_shaders[i];
if (P3DV.shadingMode_textureDisabled(item, type) || !(s.param in item.uniforms))
continue;
if (define.frag && item.fragHeaders.indexOf(def) == -1) item.fragHeaders.push(def);
if (define.vert && item.vertHeaders.indexOf(def) == -1) item.vertHeaders.push(def);
}
});
}
}
var textures = Object.keys(mat_textures);
textures.sort(function(a, b) {
var a_priority = P3DV.texture_priority_order.indexOf(a);
var b_priority = P3DV.texture_priority_order.indexOf(b);
if (a_priority == -1)
a_priority = P3DV.texture_priority_order.length;
if (b_priority == -1)
b_priority = P3DV.texture_priority_order.length;
if (a_priority > b_priority)
return 1;
if (a_priority < b_priority)
return -1;
return 0;
});
for (var i = 0; i < textures.length; i++) {
shader_loadTexture(textures[i]);
}
for (var i = 0; i < list_shaders.length; ++i) {
var item = list_shaders[i];
item.vertShader = item.vertHeaders.join('\n') + '\n' + item.shader.vertexShader;
item.fragShader = item.fragHeaders.join('\n') + '\n' + item.shader.fragmentShader;
}
}
P3DV.threeMaterial_getParameter = function(shader_def, key, mat_settings) {
if (shader_def.mat_types) {
var active_material = P3DV.material_validateType(mat_settings.material_type);
if (shader_def.mat_types[active_material]) {
var s = shader_def.mat_types[active_material];
if (s.force_settings) {
mat_settings = $.extend({}, mat_settings, s.force_settings);
}
}
}
var item = shader_def[key];
if (typeof(item) == "function") {
return item(mat_settings);
} else {
return item;
}
}
P3DV.threeMaterial_applySettings = function(base_mat, wireon_mat, shader_def, mat_settings) {
var material_settings = {};
var wireon_settings = {};
if (shader_def.color) {
material_settings.color = P3DV.threeMaterial_getParameter(shader_def, 'color', mat_settings);
}
if (shader_def.opacity) {
material_settings.opacity = P3DV.threeMaterial_getParameter(shader_def, 'opacity', mat_settings);
material_settings.transparent = true;
}
if (shader_def.wireonname) {
if (shader_def.wirecolor) {
wireon_settings.color = P3DV.threeMaterial_getParameter(shader_def, 'wirecolor', mat_settings);
}
}
if (material_settings) {
var mat = $.isArray(base_mat) ? base_mat[1] : base_mat;
mat.setValues(material_settings);
}
if (wireon_settings && wireon_mat) {
wireon_mat[1].setValues(wireon_settings);
}
}
P3DV.material_updateBindings = function(mat_index, mat_settings, key) {
var bindings = P3DV.mat_setting_bindings;
var shaderkeys = P3DV.viewer_shading_mode_keys;
if (bindings[key]) {
var binding = bindings[key];
var force_settings = P3DV.viewer_materials[P3DV.material_validateType(mat_settings.material_type)].force_settings;
if (force_settings) {
mat_settings = $.extend({}, mat_settings, force_settings);
}
if ('mat' in binding) {
for (var i = 0; i < binding.mat.length; i++) {
var shader = binding.mat[i];
var mode_def = P3DV.viewer_shading_modes[shader];
var base_mat = P3DV.mat_shading_modes[mat_index][shader];
base_mat = $.isArray(base_mat) ? base_mat[1] : base_mat;
var wireon_mat;
if (mode_def.wireonname) {
wireon_mat = P3DV.mat_shading_modes[mat_index][mode_def.wireonname];
}
P3DV.threeMaterial_applySettings(base_mat, wireon_mat, mode_def, mat_settings);
}
}
if ('uniform' in binding) {
for (var i = 0; i < binding.uniform.length; i++) {
var uniform = binding.uniform[i];
for (var i = 0; i < shaderkeys.length; i++) {
var key = shaderkeys[i];
var mode_def = P3DV.viewer_shading_modes[key];
if (mode_def.type == 'shader') {
P3DV.shader_updateUniform(uniform, P3DV.mat_shading_modes[mat_index][key].uniforms, mat_settings, mat_index, mode_def);
}
}
}
}
}
}
P3DV.recreateMaterials = function() {
P3DV.model_freeShadingModes();
for (var i = 0; i < P3DV.model_getNumberOfMaterials(); i++) {
P3DV.recreateMaterial(i);
}
}
P3DV.recreateMaterial = function(index) {
var mat_shading_modes = new Object();
var material = P3DV.material_getFinal(index);
var mat_textures = material.textures;
var mat_settings = material.settings;
var material_type = P3DV.material_validateType(mat_settings.material_type);
var force_settings = P3DV.viewer_materials[material_type].force_settings;
if (force_settings) {
mat_settings = $.extend({}, mat_settings, force_settings);
}
var shaderkeys = P3DV.viewer_shading_mode_keys;
var createMaterial = function(type, settings) {
if (type == 'basic')
return new THREE.MeshBasicMaterial(settings);
else {
if (type == 'wire') {
settings.wireframe = true;
settings.wireframeLinewidth = 1;
}
return new THREE.MeshLambertMaterial(settings);
}
}
for (var i = 0; i < shaderkeys.length; i++) {
var key = shaderkeys[i];
var mode_def = P3DV.viewer_shading_modes[key];
var base_mat = createMaterial(mode_def.type, {});
var wireon_mat;
if (mode_def.wireonname) {
wireon_mat = [base_mat, createMaterial('wire', {
color: 0x888888,
shading: THREE.FlatShading,
wireframe: true,
wireframeLinewidth: 1,
transparent: true
})];
mat_shading_modes[mode_def.wireonname] = wireon_mat;
}
if (mode_def.fix_opacity) {
base_mat = [new THREE.MeshBasicMaterial({
color: 0x000000,
transparent: true,
opacity: 0.0
}), base_mat];
}
mat_shading_modes[key] = base_mat;
P3DV.threeMaterial_applySettings(base_mat, wireon_mat, mode_def, mat_settings);
}
P3DV.material_freeShadingModes(index);
P3DV.mat_shading_modes[index] = mat_shading_modes; {
var list_shaders = new Array();
for (var i = 0; i < shaderkeys.length; i++) {
var mode_def = P3DV.viewer_shading_modes[shaderkeys[i]];
if (mode_def.type == 'shader') {
list_shaders.push($.extend({}, mode_def));
}
}
P3DV.setUniforms(index, list_shaders, mat_settings, mat_textures, mat_shading_modes);
for (var i = 0; i < list_shaders.length; i++) {
var name = list_shaders[i].shader_name;
var parameters = {
fragmentShader: list_shaders[i].fragShader,
vertexShader: list_shaders[i].vertShader,
uniforms: list_shaders[i].uniforms,
lights: P3DV.shader_params[name].threejs_lights
};
mat_shading_modes[list_shaders[i].key] = new THREE.ShaderMaterial(parameters);
mat_shading_modes[list_shaders[i].wireonname][0] = mat_shading_modes[list_shaders[i].key];
}
}
}
THREE.Color.prototype.multiply = function(a) {
this.r *= a;
this.g *= a;
this.b *= a;
return this;
}
P3DV.getShaderColor = function(c, multiplier) {
if (multiplier === undefined) {
multiplier = 1.0;
}
if (c.length == 3) {
c = c.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function(m, r, g, b) {
return r + r + g + g + b + b;
});
}
return new THREE.Color(parseInt(c, 16)).multiply(multiplier);
}
P3DV.valueToHex = function(value) {
value = Math.floor(value);
value = Math.max(0, Math.min(255, value));
return value << 16 ^ value << 8 ^ value;
}
P3DV.getThreeFilter = function(id) {
if (id == 'nearest') return THREE.NearestFilter;
else return THREE.LinearFilter;
}
P3DV.getThreeWrapping = function(id) {
if (id == 'clamp') return THREE.ClampToEdgeWrapping;
else return THREE.RepeatWrapping;
}
P3DV.applyOverrides = function(target, overrides) {
if (!overrides) return;
for (var i in overrides) {
target[i] = overrides[i];
}
}
P3DV.shadingMode_verifyName = function(shadingmode) {
if (P3DV.valid_shading_mode_names.indexOf(shadingmode) == -1) return false;
return shadingmode;
}
P3DV.shadingMode_getDefines = function(shading_mode) {
if (P3DV.viewer_shading_modes[shading_mode])
return P3DV.viewer_shading_modes[shading_mode];
else {
var modekeys = P3DV.viewer_shading_mode_keys;
for (var i = 0; i < modekeys.length; i++) {
var mode_def = P3DV.viewer_shading_modes[modekeys[i]];
if (shading_mode === mode_def.wireonname)
return mode_def;
}
}
}
P3DV.texture_freeMemory = function(texture) {
if (texture && texture.dispose) {
texture.dispose();
}
};
P3DV.threeMaterial_freeMemory = function(material) {
if (material && material.dispose) {
material.dispose();
}
};
P3DV.material_freeShadingModes = function(mat_index) {
var mode_list = P3DV.mat_shading_modes[mat_index];
if (!mode_list) {
return;
}
var modekeys = Object.keys(mode_list);
for (var i = 0; i < modekeys.length; i++) {
var key = modekeys[i];
var mode = mode_list[key];
P3DV.threeMaterial_freeMemory(mode);
}
};
P3DV.model_freeShadingModes = function() {
for (var i = 0; i < P3DV.mat_shading_modes.length; i++) {
P3DV.material_freeShadingModes(i);
}
P3DV.mat_shading_modes = [];
};
P3DV.material_updateTextures = function(mat_index) {
if (!P3DV.render_geometry.hasTangents && P3DV.model_hasTextureTypes(['norm', 'dnorm'])) {
P3DV.orig_geometry.tangentsNeedUpdate = true;
P3DV.orig_geometry.buffersNeedUpdate = true;
P3DV.geometry_freeMemory(P3DV.subd_geometry);
delete P3DV.subd_geometry;
P3DV.prepareMesh(P3DV.orig_geometry);
P3DV.updateGeometry(P3DV.viewer_settings.subdivision ? 1 : 0);
}
P3DV.recreateMaterial(mat_index);
P3DV.updateShader("smooth");
P3DV.refreshShader();
};
P3DV.material_getFinal = function(mat_idx) {
var mat = P3DV.material_getInitialState(mat_idx);
if (P3DV.mat_overrides[mat_idx]) {
for (var i in P3DV.mat_overrides[mat_idx]) {
if (i == "settings" || i == "textures")
P3DV.applyOverrides(mat[i], P3DV.mat_overrides[mat_idx][i]);
else
mat[i] = P3DV.mat_overrides[mat_idx][i];
}
}
return mat;
};
P3DV.material_isModified = function(mat_idx) {
var init_settings = P3DV.material_getInitialSettings(mat_idx);
var init_textures = P3DV.material_getInitialTextures(mat_idx);
if (P3DV.mat_overrides[mat_idx]) {
for (var i in P3DV.mat_overrides[mat_idx].settings) {
if (init_settings[i] != P3DV.mat_overrides[mat_idx].settings[i]) return true;
}
for (var i in P3DV.mat_overrides[mat_idx].textures) {
if (init_textures[i] != P3DV.mat_overrides[mat_idx].textures[i]) return true;
}
for (var i in init_textures) {
if (init_textures[i] != P3DV.mat_overrides[mat_idx].textures[i]) return true;
}
}
return false;
};
P3DV.material_getTexture = function(mat_idx, tex_id) {
if (!tex_id) return false;
if (P3DV.mat_overrides[mat_idx] && (tex_id in P3DV.mat_overrides[mat_idx].textures)) {
return P3DV.mat_overrides[mat_idx].textures[tex_id];
}
return false;
};
P3DV.material_getInitialTextures = function(mat_idx) {
var init_textures = new Object();
P3DV.applyOverrides(init_textures, P3DV.materials[mat_idx].textures);
return init_textures;
}
P3DV.material_getInitialSettings = function(mat_idx) {
var init_settings = new Object();
P3DV.applyOverrides(init_settings, P3DV.default_material);
if (P3DV.materials[mat_idx])
P3DV.applyOverrides(init_settings, P3DV.materials[mat_idx].settings);
return init_settings;
};
P3DV.material_getInitialState = function(mat_idx) {
var mat = new Object();
for (var i in P3DV.materials[mat_idx]) {
if (i != "settings" && i != "textures")
mat[i] = P3DV.materials[mat_idx][i];
}
mat.settings = P3DV.material_getInitialSettings(mat_idx);
mat.textures = new Object();
return mat;
};
P3DV.material_getSetting = function(mat_idx, setting) {
if (P3DV.mat_overrides[mat_idx] && (setting in P3DV.mat_overrides[mat_idx].settings)) {
return P3DV.mat_overrides[mat_idx].settings[setting];
}
if (P3DV.materials[mat_idx] && (setting in P3DV.materials[mat_idx].settings))
return P3DV.materials[mat_idx].settings[setting];
};
P3DV.shadingMode_textureDisabled = function(mode_def, tex_type) {
return (mode_def.disable_textures && (mode_def.disable_textures.indexOf(tex_type) != -1));
};
P3DV.shadingMode_hasTexture = function(mode_def, mat_idx, tex_type) {
return (P3DV.shadingMode_textureDisabled(mode_def, tex_type)) ? false : P3DV.material_getTexture(mat_idx, tex_type);
};
P3DV.model_hasTextureTypes = function(types) {
var mats = P3DV.model_getNumberOfMaterials();
for (var m = 0; m < mats; m++) {
var n = types.length;
for (var i = 0; i < n; i++) {
if (P3DV.material_getTexture(m, types[i])) return true;
}
}
return false;
};
P3DV.model_usesMultimaterial = function() {
return (P3DV.model_settings.material_mode == 'multi');
};
P3DV.model_getNumberOfMaterials = function() {
return P3DV.materials.length;
};
(function() {
var createMaterialBindings = function() {
var new_bindings = new Object();
var updateBinding = function(binding, group, key) {
if (!(binding in new_bindings)) {
new_bindings[binding] = {};
}
if (!(group in new_bindings[binding])) {
new_bindings[binding][group] = [];
}
new_bindings[binding][group].push(key);
};
var modekeys = P3DV.viewer_shading_mode_keys;
for (var i = 0; i < modekeys.length; i++) {
var key = modekeys[i];
var mode_def = P3DV.viewer_shading_modes[key];
if (mode_def.setting_bindings) {
var bindings = mode_def.setting_bindings;
for (var j = 0; j < bindings.length; j++) {
updateBinding(bindings[j], 'mat', key);
}
}
}
var paramkeys = Object.keys(P3DV.shader_uniform_mapping);
for (var i = 0; i < paramkeys.length; i++) {
var key = paramkeys[i];
var mapping = P3DV.shader_uniform_mapping[key];
for (var j = 0; j < mapping.bindings.length; j++) {
updateBinding(mapping.bindings[j], 'uniform', key);
}
}
return new_bindings;
};
P3DV.mat_setting_bindings = createMaterialBindings();
})();
(function() {
for (var i = 0; i < P3DV.viewer_shading_mode_keys.length; i++) {
var key = P3DV.viewer_shading_mode_keys[i];
P3DV.valid_shading_mode_names.push(key);
if (P3DV.viewer_shading_modes[key].wireonname) {
P3DV.valid_shading_mode_names.push(P3DV.viewer_shading_modes[key].wireonname);
}
}
})();
(function() {
var mat_keys = Object.keys(P3DV.viewer_materials);
for (var i = 0; i < mat_keys.length; i++) {
var key = mat_keys[i];
var mat = P3DV.viewer_materials[key];
if (mat.textures) {
var textures = [];
mat.textures.forEach(function(type) {
if ($.isArray(type)) {
textures = textures.concat(type);
} else {
textures.push(type);
}
});
mat.textures_list = textures;
}
}
})();
'use strict';
P3DV.renderer_init = function(context_container) {
$(context_container).mousewheel(function(event, delta) {
if (!P3DV.controls.noZoom) {
var newPos = P3DV.camera.position.clone()
newPos.sub(P3DV.controls.target);
newPos.multiplyScalar(delta < 0 ? P3DV.mousewheel_zoom_speed : 1.0 / P3DV.mousewheel_zoom_speed);
newPos.add(P3DV.controls.target);
P3DV.camera.position = newPos;
}
event.preventDefault();
});
P3DV.scene = new THREE.Scene();
P3DV.world = new THREE.Object3D();
P3DV.scene.add(P3DV.world);
if (!P3DV.renderer) {
P3DV.renderer = new THREE.WebGLRenderer({
antialias: true
});
P3DV.renderer.gammaInput = true;
P3DV.renderer.gammaOutput = true;
P3DV.renderer.physicallyBasedShading = true;
P3DV.renderer.sortObjects = false;
P3DV.renderer.autoClear = true;
P3DV.renderer.domElement.className = 'radial';
P3DV.renderer_checkHardware();
}
P3DV.renderer.setSize(P3DV.width, P3DV.height);
context_container.appendChild(P3DV.renderer.domElement);
P3DV.camera = new THREE.PerspectiveCamera(25, P3DV.width / P3DV.height, 0.1, 100);
P3DV.controls = new THREE.TrackballControls(P3DV.camera, context_container);
P3DV.controls.rotateSpeed = 1.0;
P3DV.controls.zoomSpeed = 1.2;
P3DV.controls.panSpeed = 0.2;
P3DV.controls.noRotate = (P3DV.viewer_settings.noRotate) ? true : false;
P3DV.controls.noZoom = (P3DV.viewer_settings.noZoom) ? true : false;
P3DV.controls.noPan = (P3DV.viewer_settings.noPan) ? true : false;
P3DV.controls.noRoll = true;
P3DV.controls.staticMoving = false;
P3DV.controls.dynamicDampingFactor = 0.3;
P3DV.controls.maxDistance = P3DV.radius;
P3DV.controls.keys = [90, 88, 67];
P3DV.camera_setDefault(P3DV.camera, false, P3DV.controls, P3DV.initial_zoom);
P3DV.camera_setSettings(P3DV.camera, false, P3DV.controls, P3DV.model_settings.default_camera);
P3DV.scene.add(P3DV.camera);
P3DV.last_cam_pos = P3DV.camera.position.clone();
P3DV.camera.updateMatrixWorld(true);
var ambient = new THREE.AmbientLight(0x000000);
P3DV.scene.add(ambient);
P3DV.directional_light1 = new THREE.DirectionalLight(0xfffaf0, 1.15);
P3DV.scene.add(P3DV.directional_light1);
P3DV.directional_light2 = new THREE.DirectionalLight(0xb3e5ff, .55);
P3DV.scene.add(P3DV.directional_light2);
P3DV.directional_light3 = new THREE.DirectionalLight(0xfdffcc, .55);
P3DV.scene.add(P3DV.directional_light3);
P3DV.directional_light4 = new THREE.DirectionalLight(0xb3e5ff, .55);
P3DV.scene.add(P3DV.directional_light4);
P3DV.setLightsForCamera(P3DV.camera);
if (P3DV.model.url) {
P3DV.loadModel(P3DV.model.url);
}
if (P3DV.show_stats) {
P3DV.stats = new Stats();
P3DV.stats.domElement.style.position = 'absolute';
P3DV.stats.domElement.style.top = '0px';
P3DV.stats.domElement.style.zIndex = 90;
context_container.appendChild(P3DV.stats.domElement);
}
};
P3DV.renderer_checkHardware = function() {
var gl = P3DV.renderer.context;
if (!gl.getExtension('OES_standard_derivatives')) {
P3DV.disabled_textures.bump = true;
P3DV.disabled_textures.dbump = true;
P3d.viewerSync.setIncompatibleTextures(Object.keys(P3DV.disabled_textures));
console.log("Bump maps not supported");
}
var max_textures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
if (max_textures) {
P3DV.maximum_textures = max_textures;
P3d.viewerSync.webglSetMaximumTextures(max_textures);
}
};
P3DV.renderer_setSize = function(width, height, enforce_in_pixels) {
if (enforce_in_pixels && P3DV.renderer.devicePixelRatio) {
if (P3DV.renderer.devicePixelRatio !== 1) {
width = width / P3DV.renderer.devicePixelRatio;
height = height / P3DV.renderer.devicePixelRatio;
}
}
P3DV.renderer.setSize(width, height);
P3DV.camera.aspect = width / height;
P3DV.controls.handleResize();
P3DV.camera.updateProjectionMatrix();
};
P3DV.setLightsForCamera = function(cam) {
var quaternion = new THREE.Quaternion();
cam.updateMatrixWorld(true);
quaternion.setFromRotationMatrix(cam.matrixWorld);
P3DV.directional_light1.position = P3DV.light1_pos.clone().applyQuaternion(quaternion);
P3DV.directional_light2.position = P3DV.light2_pos.clone().applyQuaternion(quaternion);
P3DV.directional_light3.position = P3DV.light3_pos.clone().applyQuaternion(quaternion);
P3DV.directional_light4.position = P3DV.light4_pos.clone().applyQuaternion(quaternion);
};
P3DV.renderer_captureImage = function(width, height, camera_settings, force_shader) {
if (P3DV.model.status != "ready" || !P3DV.mesh) return 0;
P3DV.renderer_setSize(width, height, true); {
var orig_rot = P3DV.getThreeRotation(P3DV.world.rotation);
var camera2 = new THREE.PerspectiveCamera(25, width / height, 0.1, 100);
P3DV.camera_setDefault(camera2, P3DV.world, false, P3DV.initial_zoom);
P3DV.camera_setSettings(camera2, P3DV.world, false, camera_settings);
P3DV.scene.add(camera2);
P3DV.setLightsForCamera(camera2);
P3DV.mesh.updateMatrix();
if (force_shader) {
P3DV.updateShader(force_shader, true);
}
P3DV.renderer.render(P3DV.scene, camera2);
P3DV.setThreeRotation(P3DV.world.rotation, orig_rot);
P3DV.mesh.updateMatrix();
P3DV.scene.remove(camera2);
P3DV.setLightsForCamera(P3DV.camera);
if (force_shader) {
P3DV.updateShader(P3DV.viewer_settings.shading, true);
}
}
var dataurl = P3DV.renderer.domElement.toDataURL("image/png");
P3DV.renderer_setSize(window.innerWidth, window.innerHeight);
P3DV.renderer.render(P3DV.scene, P3DV.camera);
return dataurl;
};
P3DV.renderer_checkMemory = function() {
var valid = true;
var checkRendererInfoObject = function(info) {
var data = P3DV.renderer.info[info];
var keys = Object.keys(data);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = data[key];
if (value) {
valid = false;
console.log('Renderer "' + info + '" not empty: ' + key + ' = ' + value);
}
}
};
checkRendererInfoObject('memory');
if (valid) {
console.log('Renderer memory released');
} else {
console.log('Renderer memory release failure!');
}
};
P3DV.renderer_render = function() {
P3DV.scene_update();
P3DV.renderer.render(P3DV.scene, P3DV.camera);
};
'use strict';
P3DV.createScene = function(geometry, x, y, z) {
P3DV.scene_freeGeometry();
console.log('geometry loaded');
P3DV.orig_geometry = geometry;
if (P3DV.orig_geometry.faces && P3DV.orig_geometry.faces.length > 0) {
if (!P3DV.orig_geometry.faces[0].vertexNormals || P3DV.orig_geometry.faces[0].vertexNormals.length == 0 || P3DV.orig_geometry.faces[0].vertexNormals[0].lengthSq() == 0.0) {
console.log('computing vertex normals');
var start = new Date().getTime();
P3DV.computeNormals(P3DV.orig_geometry);
console.log('computing vertex normals duration: ' + (new Date().getTime() - start));
}
}
P3DV.recreateMaterials();
P3DV.prepareMesh(P3DV.orig_geometry, true);
P3DV.orig_geometry.dynamic = true;
var subd = (P3DV.viewer_settings.subdivision) ? 1 : 0;
P3DV.updateGeometry(subd);
if (P3DV.mesh) P3DV.world.remove(P3DV.mesh);
P3DV.mesh = new THREE.Mesh(P3DV.render_geometry, P3DV.mat_shading_modes[0].smooth);
P3DV.mesh.flipSided = false;
P3DV.mesh.overdraw = true;
if (P3DV.model_settings.orientation)
P3DV.setThreeRotation(P3DV.mesh.rotation, P3DV.model_settings.orientation);
P3DV.world.position.x = x;
P3DV.world.position.z = y;
P3DV.world.position.y = z;
if (!geometry.boundingSphere) {
geometry.computeBoundingSphere();
}
P3DV.world.scale.x = P3DV.world.scale.y = P3DV.world.scale.z = (P3DV.initial_size / geometry.boundingSphere.radius);
if (P3DV.model_settings.default_camera) {
var dc = P3DV.model_settings.default_camera
if ("world_rot" in dc) {
P3DV.setThreeRotation(P3DV.world.rotation, dc.world_rot);
}
}
P3DV.world.add(P3DV.mesh);
P3DV.force_render_frames = 4;
if (P3DV.viewer_settings.autorotate) {
P3DV.scene_time = new Date().getTime();
}
if (P3DV.viewer_settings.shading) {
P3DV.updateShader('smooth');
} else {
P3DV.viewer_settings.shading = "smooth";
}
P3DV.refreshShader();
if (P3DV.callbacks.updateViewerPreviews) {
P3DV.callbacks.updateViewerPreviews();
}
};
P3DV.computeNormals = function(geo) {
var v, vl, f, fl, face, vertices;
console.log('init vertex arry');
vertices = new Array(geo.vertices.length);
for (v = 0, vl = geo.vertices.length; v < vl; v++) {
vertices[v] = new THREE.Vector3();
}
console.log('add face normals');
for (f = 0, fl = geo.faces.length; f < fl; f++) {
face = geo.faces[f];
if (face instanceof THREE.Face3) {
vertices[face.a].add(face.normal);
vertices[face.b].add(face.normal);
vertices[face.c].add(face.normal);
} else if (face instanceof THREE.Face4) {
vertices[face.a].add(face.normal);
vertices[face.b].add(face.normal);
vertices[face.c].add(face.normal);
vertices[face.d].add(face.normal);
}
}
console.log('normalize');
for (v = 0, vl = vertices.length; v < vl; v++) {
vertices[v].normalize();
}
console.log('set face normals');
for (f = 0, fl = geo.faces.length; f < fl; f++) {
face = geo.faces[f];
if (face instanceof THREE.Face3) {
face.vertexNormals = [vertices[face.a], vertices[face.b], vertices[face.c]];
} else if (face instanceof THREE.Face4) {
face.vertexNormals = [vertices[face.a], vertices[face.b], vertices[face.c], vertices[face.d]];
}
}
};
P3DV.prepareMesh = function(geometry, orig) {
var start = new Date().getTime();
console.log('verifying uvs');
var f, fl;
var dummyUvs = [new THREE.Vector2(0.0, 0.0), new THREE.Vector2(0.0, 1.0), new THREE.Vector2(1.0, 1.0), new THREE.Vector2(1.0, 0.0)];
for (f = 0, fl = geometry.faces.length; f < fl; f++) {
if (geometry.faceVertexUvs[0][f] == undefined) {
geometry.faceVertexUvs[0][f] = dummyUvs;
}
}
console.log('verifying uvs duration: ' + (new Date().getTime() - start));
if (P3DV.model_hasTextureTypes(['norm', 'dnorm'])) {
console.log('computing tangents');
geometry.computeTangents();
}
console.log('prep mesh duration: ' + (new Date().getTime() - start));
};
P3DV.updateGeometry = function(subdivision_level) {
P3DV.viewer_settings.subdivision = subdivision_level;
if (P3DV.viewer_settings.subdivision == 0 || P3DV.orig_geometry.faces.length >= 50000) {
P3DV.render_geometry = P3DV.orig_geometry;
} else {
if (!P3DV.subd_geometry) {
P3DV.subd_geometry = P3DV.orig_geometry.clone();
P3DV.render_geometry = P3DV.subd_geometry;
var modifier = new THREE.SubdivisionModifier(P3DV.viewer_settings.subdivision);
modifier.modify(P3DV.render_geometry);
P3DV.prepareMesh(P3DV.render_geometry);
} else {
P3DV.render_geometry = P3DV.subd_geometry;
}
}
if (P3DV.callbacks.updateMeshInfo) {
P3DV.callbacks.updateMeshInfo(P3DV.orig_geometry.faces.length, P3DV.render_geometry.faces.length, P3DV.render_geometry.vertices.length);
}
P3DV.updateShader("smooth");
P3DV.refreshShader();
};
P3DV.toggleAutorotation = function() {
P3DV.scene_time = new Date().getTime();
P3DV.viewer_settings.autorotate = !P3DV.viewer_settings.autorotate;
};
P3DV.toggleSubdivision = function() {
if (!P3DV.mesh) return;
P3DV.updateGeometry(P3DV.viewer_settings.subdivision ? 0 : 1);
};
P3DV.geometry_freeMemory = function(geometry) {
if (geometry && geometry.dispose) {
geometry.dispose();
}
};
P3DV.scene_freeGeometry = function() {
P3DV.geometry_freeMemory(P3DV.orig_geometry);
delete P3DV.orig_geometry;
P3DV.geometry_freeMemory(P3DV.subd_geometry);
delete P3DV.subd_geometry;
delete P3DV.render_geometry;
};
P3DV.loadModel = function(modelUrl) {
var mrev = P3DV.loadStates.modelSetLoading();
P3DV.loader = new THREE.BinaryLoader(true);
P3DV.loader.showProgress = true;
P3DV.loader.load(modelUrl, function(geometry, materials) {
if (P3DV.loadStates.modelSetReady(mrev)) {
P3d.viewerSync.setMaterialsFromMesh(materials);
P3DV.createScene(geometry, 0, 0, P3DV.floor);
}
});
};
P3DV.rotateModelAxis = function(axis, dir) {
var PI_2 = Math.PI / 2;
var imat = new THREE.Matrix4().getInverse(P3DV.mesh.matrix.clone());
axis.transformDirection(imat);
P3DV.mesh.matrix.multiply(new THREE.Matrix4().makeRotationAxis(axis, dir * PI_2));
P3DV.mesh.rotation.setFromRotationMatrix(P3DV.mesh.matrix);
P3DV.mesh.rotation.x = Math.round(P3DV.mesh.rotation.x / PI_2) * PI_2;
P3DV.mesh.rotation.y = Math.round(P3DV.mesh.rotation.y / PI_2) * PI_2;
P3DV.mesh.rotation.z = Math.round(P3DV.mesh.rotation.z / PI_2) * PI_2;
P3DV.model_settings.orientation = P3DV.getThreeRotation(P3DV.mesh.rotation);
P3DV.settings_force_changed = true;
if (P3DV.callbacks.updateViewerPreviews)
P3DV.callbacks.updateViewerPreviews();
};
P3DV.animate = function() {
if (P3DV.destroy)
return;
requestAnimationFrame(P3DV.animate);
if (P3DV.show_stats && P3DV.stats) P3DV.stats.update();
var cam_move_len = P3DV.camera.position.clone().sub(P3DV.last_cam_pos).length();
if (cam_move_len < 1e-5 && P3DV.force_render_frames-- < 1) {
P3DV.controls.update();
if (!(P3DV.viewer_settings.autorotate || P3DV.autorot_slow || P3DV.reset_phase || P3DV.render_anims.length)) return;
}
var c = P3DV.camera.position.clone();
c.normalize();
var angle = Math.acos(P3DV.last_cam_pos.dot(c) / P3DV.last_cam_pos.length() / c.length());
if (angle) {
P3DV.setLightsForCamera(P3DV.camera);
if (P3DV.viewer_settings.autorotate && angle > 1e-5)
P3DV.rotate_lock = new Date().getTime() + 1500;
}
P3DV.last_cam_pos = P3DV.camera.position.clone();
P3DV.renderer_render();
};
P3DV.createAnimation = function(execution_time, callback) {
var anim = new Object();
anim.time = execution_time;
anim.phase = 1.0;
anim.callback = callback;
if (!P3DV.render_anims.length)
P3DV.render_anim_time = new Date().getTime();
P3DV.render_anims.push(anim);
};
P3DV.executeAnimations = function() {
var time = new Date().getTime();
var step = time - P3DV.render_anim_time;
P3DV.render_anim_time = time;
for (var i = 0; i < P3DV.render_anims.length; i++) {
var anim = P3DV.render_anims[i];
var orig_time = anim.time;
anim.time -= step;
if (anim.time > 0) {
anim.phase *= (anim.time / orig_time);
anim.callback(anim.phase);
} else {
anim.callback(0.0);
P3DV.render_anims.splice(i, 1);
i -= 1;
}
}
}
P3DV.scene_update = function() {
var current_time = new Date().getTime();
if (P3DV.mesh && (P3DV.viewer_settings.autorotate || P3DV.autorot_slow) && P3DV.scene_time) {
var timestep = (current_time - P3DV.scene_time) / 1000.0;
P3DV.scene_time = current_time;
if (P3DV.viewer_settings.autorotate && current_time > P3DV.rotate_lock) {
if (P3DV.autorot_slow < 1.0) {
P3DV.autorot_slow += timestep / 2.0;
} else P3DV.autorot_slow = 1.0;
} else {
if (P3DV.autorot_slow > 0.0) {
P3DV.autorot_slow -= timestep / 1.0;
} else P3DV.autorot_slow = 0.0;
}
P3DV.world.rotation.y -= (0.5 * P3DV.autorot_slow) * timestep;
P3DV.world.updateMatrix();
}
if (P3DV.reset_phase) {
var timestep = current_time - P3DV.reset_time;
P3DV.reset_time = current_time;
P3DV.reset_phase -= timestep;
if (P3DV.reset_phase <= 0)
P3DV.reset_phase = 0;
P3DV.camera_resetStep(timestep / P3DV.reset_duration * 4);
}
P3DV.executeAnimations();
};
P3DV.camera_setDefault = function(camera, world, controls, init_distance) {
if (camera) {
camera.position = new THREE.Vector3(0, 0, init_distance);
camera.rotation.set(0, 0, 0);
camera.up = new THREE.Vector3(0, 1, 0);
}
if (world) {
world.rotation.set(0, 0, 0);
}
if (controls) {
controls.target = new THREE.Vector3();
}
};
THREE.Euler.prototype.multiplyScalar = function(scalar) {
this.x *= scalar;
this.y *= scalar;
this.z *= scalar;
return this;
}
P3DV.setThreeRotation = function(target, v) {
target.set(v.x || 0, v.y || 0, v.z || 0);
}
P3DV.getThreeRotation = function(r) {
return new THREE.Vector3(r.x, r.y, r.z);
}
P3DV.camera_setSettings = function(camera, world, controls, camera_settings) {
if (camera_settings) {
var cs = camera_settings;
if (camera) {
if ("cam_pos" in cs)
camera.position.copy(cs.cam_pos);
if ("cam_rot" in cs)
P3DV.setThreeRotation(camera.rotation, cs.cam_rot);
if ("cam_up" in cs)
camera.up.copy(cs.cam_up);
}
if (world) {
if ("world_rot" in cs)
P3DV.setThreeRotation(world.rotation, cs.world_rot);
}
if (controls) {
if ("con_target" in cs)
controls.target.copy(cs.con_target);
}
}
};
P3DV.camera_getSettings = function() {
var cs = new Object();
cs.cam_pos = P3DV.camera.position.clone();
cs.cam_rot = P3DV.getThreeRotation(P3DV.camera.rotation);
cs.cam_up = P3DV.camera.up.clone();
cs.con_target = P3DV.controls.target.clone();
cs.world_rot = P3DV.getThreeRotation(P3DV.world.rotation);
return cs;
};
P3DV.camera_resetStep = function(step) {
var i = 1.0 - step;
P3DV.camera.position.multiplyScalar(i);
P3DV.camera.position.z += step * P3DV.initial_zoom;
P3DV.camera.rotation.multiplyScalar(i);
P3DV.camera.up.multiplyScalar(i);
P3DV.camera.up.y += step * 1;
P3DV.controls.target.multiplyScalar(i);
P3DV.world.rotation.y = ((P3DV.world.rotation.y - Math.PI) % (Math.PI * 2)) + Math.PI;
P3DV.world.rotation.y *= i;
P3DV.rotate_lock = new Date().getTime() + 1500;
P3DV.autorot_slow = 0.0;
P3DV.controls.update();
P3DV.camera.updateMatrixWorld(true);
P3DV.setLightsForCamera(P3DV.camera);
};
P3DV.raycastScreen = function(x, y) {
if (!P3DV.mesh) {
return;
}
var projector = new THREE.Projector();
x = (x / P3DV.width) * 2 - 1;
y = -(y / P3DV.height) * 2 + 1;
var vector = new THREE.Vector3(x, y, 0.5);
var mesh = P3DV.mesh;
if (!(mesh instanceof THREE.Mesh)) {
mesh = mesh.children[0];
}
projector.unprojectVector(vector, P3DV.camera);
var raycaster = new THREE.Raycaster(P3DV.camera.position, vector.sub(P3DV.camera.position).normalize());
var intersects = raycaster.intersectObject(mesh);
if (intersects.length > 0) {
return intersects[0].face;
}
}
P3d.viewerSync = Em.Object.create({
model: null,
controller: null,
viewer_view: null,
converted_model: false,
initialize: function(controller, viewer_view) {
var sync = this;
var model = controller.get('content');
this.set('model', model);
this.set('controller', controller);
this.set('viewer_view', viewer_view);
controller.set('isModelDataChanged', false);
this.removeModelObservers();
this.initMaterials(model);
this.removeControllerObservers();
this.initControllerObservers();
controller.set('materialDefinitions', P3DV.viewer_materials);
model.notifyPropertyChange('settings');
this.updateModelSettings();
model.addObserver('settingsObj.material_mode', this, this.modelSettingChanged);
this.applyDefaultOptions();
var canvas = $('#canvas');
canvas.doubletap(function() {
P3DV.resetCamera();
});
canvas.mousedown(function(orig_e) {
if (!controller.get('isOwner') || controller.get('isEmbed') || controller.get('modelLoading')) {
return;
}
var time = new Date().getTime();
canvas.one('mouseup', function(e) {
if (e.pageX != orig_e.pageX || e.pageY != orig_e.pageY || ((new Date().getTime() - time) > 500))
return;
var x = e.pageX - $(this).children('canvas').offset().left;
var y = e.pageY - $(this).children('canvas').offset().top;
var face = P3DV.raycastScreen(x, y);
if (face) {
var materialIndex = face.materialIndex;
var assignment = sync.get('model.materialAssignments').objectAt(materialIndex);
if (assignment) {
if (controller.get('leftPanelName') != 'shading') {
sync.get('viewer_view.parentView').send('showPanel', P3d.panels.shading);
}
var previous_mat = controller.get('activeMaterial');
controller.set('activeFaceGroup', assignment);
sync.materialHighlight(assignment.get('material'));
var list = $('#face-groups-list');
var facegroupElement = list.find('li[data-id=' + materialIndex + ']');
if (facegroupElement) {
try {
var newScroll = facegroupElement.position().top + list.scrollTop() - list.position().top - facegroupElement.height();
newScroll = Math.max(newScroll, 0);
list.stop(true).animate({
scrollTop: newScroll
}, 500);
} catch (e) {}
}
}
}
});
});
},
initControllerObservers: function() {
var controller = this.get('controller');
var sync = this;
var model = controller.get('content');
controller.addObserver('subdivision', this, function(sender) {
var subdivision_level = sender.get('subdivision') ? 1 : 0;
P3DV.viewer_settings.subdivision = subdivision_level;
if (!P3DV.mesh) return;
P3DV.updateGeometry(subdivision_level);
this.updateUrl(false);
});
controller.addObserver('spin', this, function(sender) {
P3DV.scene_time = new Date().getTime();
P3DV.viewer_settings.autorotate = sender.get('spin');
this.updateUrl(false);
console.log('spin changed! : ' + sender.get('spin'));
});
controller.addObserver('shading', this, function(sender) {
P3DV.setShading(sender.get('shading'));
this.updateUrl(false);
});
},
updateUrl: function() {
if (!this.model.get('shortid') || this.get('controller.isEmbed'))
return;
var params = new Array();
if (P3DV.viewer_settings.shading && P3DV.viewer_settings.shading != "smooth") params.push(P3DV.viewer_settings.shading);
if (P3DV.viewer_settings.subdivision) params.push("subd");
if (P3DV.viewer_settings.autorotate) params.push("spin");
var paramString = params.join("+");
var route = this.get('controller.target');
route.replaceWith('/' + this.model.get('shortid') + '/' + paramString);
},
settingsFromUrl: function() {
var controller = this.controller;
var regexp = new RegExp(P3DV.URL_BASE_REGEXP + '([^/]+)');
var pathname = location.pathname;
try {
pathname = decodeURIComponent(pathname);
} catch (e) {
console.log('Parameter decodeURIComponent failed : ' + e);
}
var params = regexp.exec(pathname);
if (params) {
params = params[1];
} else {
params = '';
P3DV.setShading(controller.get('shading'), true);
}
params = params.replace('=', '-');
console.log(params);
params = params.split(/[+ ]/);
P3DV.viewer_settings.subdivision = controller.get('subdivision') ? 1 : 0;
P3DV.viewer_settings.autorotate = controller.get('spin');
var list_params = {};
for (var i = 0; i < params.length; i++) {
var item = params[i];
var split = params[i].split('-', 2);
var parameters = item;
var value = false;
var separator = item.indexOf('-');
if (separator != -1) {
parameters = item.substring(0, item.indexOf('-'));
value = item.substring(item.indexOf('-') + 1);
}
parameters = parameters.split(',');
for (var j = 0; j < parameters.length; j++) {
var param = parameters[j];
list_params[param] = (value) ? value : true;
console.log('PARAM ' + param + ' : ' + value);
if (!value) {
if (param == "subd") this.controller.set('subdivision', true);
else if (param == "spin") this.controller.set('spin', true);
else if (param == "load") this.controller.set('clickToLoad', false);
if (this.model.get('isOwnerPlus') && this.controller.get('isEmbed')) {
if (param == "nopan") {
this.controller.set('noPan', true);
P3DV.viewer_settings.noPan = true;
} else if (param == "nozoom") {
this.controller.set('noZoom', true);
P3DV.viewer_settings.noZoom = true;
} else if (param == "norotate") {
this.controller.set('noRotate', true);
P3DV.viewer_settings.noRotate = true;
}
}
if (P3DV.shadingMode_verifyName(param)) {
var matName = P3DV.shadingMode_verifyName(param);
if (matName) {
this.controller.set('shading', matName);
}
}
}
if (value && this.controller.get('isEmbed')) {
if (this.model.get('isOwnerPlus')) {
if (value == 'hidden') {
if (param == 'controls' || param == 'link') this.controller.set('hideP3dLink', true);
if (param == 'controls' || param == 'shading') this.controller.set('hideShadingSelector', true);
if (param == 'controls' || param == 'subd') this.controller.set('hideSubdControl', true);
if (param == 'controls' || param == 'spin') this.controller.set('hideSpinControl', true);
if (param == 'controls' || param == 'help') this.controller.set('hideNavigationHints', true);
if (param == 'controls' || param == 'dl') this.controller.set('hideDownload', true);
if (param == 'controls' || param == 'fs') this.controller.set('hideFullScreen', true);
}
}
}
}
}
},
removeControllerObservers: function() {
var controller = this.get('controller');
if (!controller) {
return;
}
if (controller.hasObserverFor('subdivision')) {
controller.removeObserver('subdivision', this);
}
if (controller.hasObserverFor('spin')) {
controller.removeObserver('spin', this);
}
if (controller.hasObserverFor('shading')) {
controller.removeObserver('shading', this);
}
},
removeModelObservers: function() {
var model = this.get('model');
if (!model) {
return;
}
if (model.hasObserverFor('settingsObj.material_mode')) {
model.removeObserver('settingsObj.material_mode', this);
}
model.get('materialAssignments').forEach(function(matAssign) {
var material = matAssign.get('material');
if (material && material.hasObserverFor('textureAssignments.@each')) {
material.removeObserver('textureAssignments.@each', this);
}
var settingsObj = matAssign.get('material.settingsObj');
for (var i in settingsObj) {
if (settingsObj.isProperty(i)) {
settingsObj.removeObserver(i, this);
}
}
}, this);
},
updateModelSettings: function() {
P3DV.model_settings = this.model.get('settingsObj').getJSObject();
P3DV.refreshShader();
},
modelSettingChanged: function() {
this.updateModelSettings();
this.controller.didChangeModelData();
},
initMaterials: function(model) {
model.get('materialAssignments').forEach(function(matAssign) {
this.initMaterial(matAssign);
matAssign.get('material').addObserver('textureAssignments.@each', this, 'matTextureChanged');
}, this);
},
initMaterial: function(matAssign) {
var i = matAssign.get('index');
var t_assignments = matAssign.get('material.textureAssignments').toArray();
P3DV.materials[i] = {
textures: new Object(),
settings: new Object()
};
P3DV.mat_overrides[i] = {
textures: new Object(),
settings: new Object()
};
var material = matAssign.get('material');
material.notifyPropertyChange('settings');
this.setMaterialSettings(matAssign.get('material.settingsObj'), i);
this.setTextures(t_assignments, i, true);
this.setTextures(t_assignments, i);
},
setMaterialSettings: function(settings_obj, mat_index) {
var settings = P3DV.materials[mat_index].settings = new Object();
P3DV.mat_overrides[mat_index].settings = new Object();
for (var i in settings_obj) {
if (settings_obj.isProperty(i)) {
settings[i] = settings_obj[i];
settings_obj.addObserver(i, this, 'matSettingChanged');
}
}
},
materialHighlight: function(material) {
var mat_index = P3d.viewerSync.model_getMaterialIndex(material);
if (!P3DV.renderer || !P3DV.mat_shading_modes.length)
return;
var mat_settings = P3DV.material_getFinal(mat_index).settings;
var shaderkeys = Object.keys(P3DV.viewer_shading_modes);
P3DV.renderer_render();
P3DV.createAnimation(400, function(phase) {
var factor = -Math.sin(phase * Math.PI * 2);
factor = 1.0 + Math.pow(Math.abs(factor), 0.4) * 0.4 * ((factor > 0) ? 1 : -1);
var mat_shader = P3DV.mat_shading_modes[mat_index];
mat_shader.smooth.uniforms["uMultiply"].value = factor;
mat_shader.clean.uniforms["uMultiply"].value = factor;
for (var i = 0; i < shaderkeys.length; i++) {
var key = shaderkeys[i];
var shader_def = P3DV.viewer_shading_modes[key];
var color_hex, mat;
mat = P3DV.mat_shading_modes[mat_index][key];
mat = $.isArray(mat) ? mat[1] : mat;
if (shader_def.type == 'shader') {
mat.uniforms["uMultiply"].value = factor;
} else {
if (shader_def.color)
color_hex = P3DV.threeMaterial_getParameter(shader_def, 'color', mat_settings);
else
color_hex = 0xffffff;
mat.color = new THREE.Color(color_hex).multiply(factor);
}
if (shader_def.wireonname) {
mat = P3DV.mat_shading_modes[mat_index][shader_def.wireonname][1];
if (shader_def.wirecolor)
color_hex = P3DV.threeMaterial_getParameter(shader_def, 'wirecolor', mat_settings);
else
color_hex = 0x888888;
mat.color = new THREE.Color(color_hex).multiply(factor);
}
}
});
},
matSettingChanged: function(sender, key, value, rev) {
var newValue = sender.get(key);
var index = this.model_getMaterialIndex(sender.material);
if (!P3DV.mat_shading_modes.length)
return;
var mat_shader = P3DV.mat_shading_modes[index];
P3DV.mat_overrides[index].settings[key] = newValue;
var material = P3DV.material_getFinal(index);
P3DV.material_updateBindings(index, material.settings, key);
var presets = this.controller.get('texturePresets');
for (var i = 0; i < presets.length; i++) {
if (key == presets[i].setting) {
if (this.setTextures(sender.material.get('textureAssignments').toArray(), index)) {
P3DV.material_updateTextures(index);
}
}
}
switch (key) {
case 'double_sided':
P3DV.refreshShader();
break;
case 'flat_shading':
P3DV.orig_geometry.normalsNeedUpdate = true;
P3DV.geometry_freeMemory(P3DV.subd_geometry);
delete P3DV.subd_geometry;
P3DV.prepareMesh(P3DV.orig_geometry);
P3DV.updateGeometry(P3DV.viewer_settings.subdivision ? 1 : 0);
break;
case 'material_type':
case 'tex_filter':
case 'tex_wrap':
P3DV.material_updateTextures(index);
break;
default:
P3DV.renderer_render();
}
this.checkModifications();
},
fillTextureInfo: function(texture) {
if (!texture.get('format')) {
texture.set('format', 'LOADING');
P3dData.getImageInfo(texture.get('url'), function(info) {
if (info) {
texture.setProperties({
format: info.format,
width: info.width,
height: info.height,
hasAlpha: info.alpha
});
}
});
}
},
refreshMaterials: function() {
for (var i = 0; i < P3DV.model_getNumberOfMaterials(); i++) {
P3DV.material_updateTextures(i);
}
},
setTexture: function(textureAssignment, mat_index, new_textures) {
var texture = textureAssignment.get('texture');
var type = textureAssignment.get('textureType');
if (texture && texture.get('url')) {
new_textures[type] = texture.get('url');
if (!texture.get('format') && !texture.get('needsUpload')) {
this.fillTextureInfo(texture);
}
}
return {
texture: texture,
type: type
};
},
setTextures: function(texture_array, mat_index, init) {
var new_textures = new Object();
var possibly_alpha = false;
for (var i = 0; i < texture_array.length; i++) {
var added = this.setTexture(texture_array[i], mat_index, new_textures);
if (added.texture && added.type === 'diff') {
diffuse_tex_url = added.texture.get('needsUpload') ? added.texture.get('uploadBlob').name : added.texture.get('url');
possibly_alpha = !(added.texture.get('format') !== 'LOADING' && added.texture.get('hasAlpha') === false) && diffuse_tex_url.match(/.png$/i);
}
}
var presets = this.controller.get('texturePresets');
for (var i = 0; i < presets.length; i++) {
var presetDefine = presets[i];
if (!new_textures[presetDefine.type]) {
var preset = this.controller.get(presetDefine.presetList).findProperty('id', P3DV.material_getSetting(mat_index, presetDefine.setting));
if (!preset && presetDefine.alwaysActive) {
preset = this.controller.get(presetDefine.presetList).objectAt(0);
}
if (preset) {
new_textures[presetDefine.type] = preset.get('url');
}
}
}
var has_changed = (JSON.stringify(new_textures) != JSON.stringify(P3DV.mat_overrides[mat_index].textures));
if (init) {
P3DV.materials[mat_index].textures = new_textures;
P3DV.materials[mat_index].possibly_alpha = possibly_alpha;
} else {
P3DV.mat_overrides[mat_index].textures = new_textures;
P3DV.mat_overrides[mat_index].possibly_alpha = possibly_alpha;
}
return has_changed;
},
matTextureChanged: function(sender, idx, value, rev) {
var material = sender;
if (!material) {
return;
}
var mat_index = this.model_getMaterialIndex(material);
if (this.setTextures(material.get('textureAssignments').toArray(), mat_index)) {
P3DV.material_updateTextures(mat_index);
}
this.checkModifications();
},
checkModifications: function() {
var modified = false;
for (var i = 0; i < P3DV.materials.length; ++i) {
if (P3DV.material_isModified(i)) {
modified = true;
break;
}
}
this.controller.set('hasMaterialsChanged', modified);
},
model_getMaterialIndex: function(model) {
if (!this.get('model')) {
console.log("model_getMaterialIndex error(0): Uninitialized viewerSync.model");
return;
}
var materials = this.get('model.materialAssignments').toArray();
for (var i = 0; i < materials.length; i++) {
if (model.constructor === P3d.MaterialAssignment) {
if (materials[i] === model)
return materials[i].get('index');
} else {
var material = materials[i].get('material');
if (model.constructor === P3d.Material) {
if (material === model)
return materials[i].get('index');
}
}
}
console.log("model_getMaterialIndex error(1): Invalid model");
try {
throw new Error('Stack trace:')
} catch (e) {
console.log(e.stack);
}
return 0;
},
setMaterialsFromMesh: function(geometry_materials) {
var sync = this;
var model = this.model;
var default_name = 'Material';
if (geometry_materials.length === 0) {
geometry_materials[0] = {
name: default_name
};
}
var previous_materials = [];
var assignments_array = model.get('materialAssignments').toArray();
for (var i = 0; i < assignments_array.length; i++) {
var assignment = assignments_array[i];
var mat = assignment.get('material');
previous_materials.push(mat);
model.get('materialAssignments').removeObject(assignment);
assignment.deleteRecord();
}
var new_materials = [];
$.each(geometry_materials, function(index, material) {
var material_name = (material.name) ? material.name : (default_name + ' ' + index);
new_materials[index] = null;
for (var i = 0; i < previous_materials.length; i++) {
var item = previous_materials[i];
if (item.get('name') == material_name) {
new_materials[index] = item;
previous_materials.splice(i, 1);
break;
}
}
});
$.each(geometry_materials, function(index, material) {
var material_name = (material.name) ? material.name : (default_name + ' ' + index);
var mat = new_materials[index];
if (!mat && previous_materials.length) {
mat = previous_materials.shift();
if (mat) {
mat.set('name', material_name);
}
}
if (!mat) {
var settingsObj = P3d.MaterialSettings.create().getJSObject();
mat = sync.get('controller.store').createRecord('material');
mat.set('settings', JSON.stringify(settingsObj));
mat.set('name', material_name);
mat.addObserver('textureAssignments.@each', sync, 'matTextureChanged');
}
var assignment = model.get('materialAssignments').createRecord({
index: index,
material: mat
});
sync.initMaterial(assignment);
});
for (var i = 0; i < previous_materials.length; i++) {
var mat = previous_materials[i];
mat.removeObserver('textureAssignments.@each', sync, 'matTextureChanged');
mat.deleteRecord();
}
var afg_found = false;
model.get('materialAssignments').forEach(function(assignment) {
if (sync.controller.get('activeFaceGroup') == assignment)
afg_found = true;
});
if (!afg_found) {
sync.controller.set('activeFaceGroup', sync.controller.get("materialAssignments.firstObject"));
}
},
updateMesh: function(new_model, mrev) {
this.converted_model = new_model;
var sync = this;
var binLoader = new THREE.BinaryLoader();
this.controller.set('modelReplace', true);
binLoader.createBinModel(new_model.binary, function(geometry, materials) {
if (P3DV.loadStates.modelSetReady(mrev)) {
P3d.viewerSync.setMaterialsFromMesh(materials);
P3DV.createScene(geometry, 0, 0, P3DV.floor);
if (sync.controller.get('leftPanelName') == '') {
sync.get('viewer_view.parentView').send('showPanel', P3d.panels.shading);
}
}
}, "", new_model.meta.materials);
this.controller.didChangeModelData();
},
getNewModel: function() {
return this.converted_model;
},
getSaveObjects: function() {
var texture_models = new Object();
this.model.get('materialAssignments').forEach(function(matAssign) {
matAssign.get('material.textureAssignments').forEach(function(texAssign) {
var texture = texAssign.get('texture');
if (texture.get('needsUpload')) {
texture_models[texture.get('url')] = texture;
}
}, this);
}, this);
var texture_keys = Object.keys(texture_models);
var materials = new Array();
this.model.get('materialAssignments').forEach(function(matAssign) {
var new_settings = matAssign.get('material.settingsObj').getJSObject();
var new_textures = new Object();
matAssign.get('material.textureAssignments').forEach(function(texAssign) {
var type = texAssign.get('textureType');
var texture = texAssign.get('texture');
if (texture.get('needsUpload')) {
var new_index = texture_keys.indexOf(texture.get('url'));
new_textures[type] = {
new_index: new_index
};
} else {
new_textures[type] = {
id: texture.get('id')
};
}
}, this);
materials.push({
name: matAssign.get('material.name'),
settings: new_settings,
textures: new_textures
});
}, this);
var user_tags = new Array();
this.model.get('userTags').forEach(function(uTag) {
var name = uTag.get('name');
user_tags.push(name);
}, this);
var sys_tags = new Array();
this.model.get('sysTags').forEach(function(sTag) {
var name = sTag.get('name');
sys_tags.push(name);
}, this);
return {
materials: materials,
texture_keys: texture_keys,
texture_models: texture_models,
user_tags: user_tags,
sys_tags: sys_tags,
};
},
getModelThumbnail: function() {
return P3DV.renderer_captureImage(512, 512, P3DV.model_settings.default_camera, this.get('controller.defaultShading'));
},
updateProgress: function(evt) {
if (evt && evt.lengthComputable) {
var getTimeString = function(timediff) {
var result = '';
if (timediff > 60) {
min = Math.floor(timediff / 60);
timediff = timediff - min * 60;
result = min.toString() + ' min ';
}
return result + (timediff).toFixed(0) + ' seconds';
};
var percent = Math.floor(evt.loaded / evt.total * 100);
var loaded = evt.loaded / 1024;
var total = evt.total / 1024;
var time_diff = (new Date().getTime() - this.controller.get('uploadStart')) / 1000;
var speed_string = '';
if (loaded && time_diff > 2.0) {
var upload_speed = (loaded / time_diff);
var kbytes_left = total - loaded;
var seconds_left = Math.ceil(kbytes_left / upload_speed);
if (seconds_left > 1) {
speed_string = ' (' + upload_speed.toFixed(1) + ' kB/s - ' + getTimeString(kbytes_left / upload_speed) + ' left)';
} else {
speed_string += ' (Almost... don\'t close yet!)';
}
}
this.controller.set('progressTitle', percent.toString() + '%' + speed_string);
this.controller.set('progressPercent', percent);
} else {
this.controller.set('progressTitle', 'Uploading...');
this.controller.set('progressPercent', 0);
}
},
startUpload: function() {
this.controller.set('uploadStart', new Date().getTime());
this.updateProgress();
},
endUpload: function() {
this.controller.set('uploadStart', false);
},
didSaveModel: function(newmodel) {
var model = this.get('model');
this.endUpload();
if (this.get('controller') !== null) this.get('controller').didSaveModel();
this.converted_model = undefined;
if (model !== null) {
if (newmodel) {
this.set('controller.isTransitionFromNewToShortid', true);
this.get('controller.target').replaceWith('viewer.index', model.get('shortid'));
Ember.run.scheduleOnce('routerTransitions', this, function() {
this.set('controller.isTransitionFromNewToShortid', undefined);
});
}
}
this.checkModifications();
},
didCancelChanges: function() {
this.endUpload();
if (this.get('controller') !== null) this.get('controller').didCancelChanges();
},
clearHSLShift: function(material) {
material.get('settingsObj').set('shadesphere_hue', 0.0);
material.get('settingsObj').set('shadesphere_saturation', 0.0);
material.get('settingsObj').set('shadesphere_lightness', 0.0);
},
applyDefaultOptions: function() {
var controller = this.controller;
if (controller.get('isOwnerPlus')) {
var defaultOptions = controller.get('content.settingsObj.defaultOptions');
var validOptions = controller.get('options');
if (defaultOptions) {
validOptions.forEach(function(option) {
if (option in defaultOptions) {
controller.set(option, defaultOptions[option]);
}
});
}
}
},
initializeViewer: function(embed_load) {
P3DV.initViewer(window.innerWidth, window.innerHeight, 'canvas');
if (embed_load !== undefined && embed_load == true) {
P3d.uaLoadEmbeddedModel(P3DV.model.id + ' - ' + P3DV.model.name);
}
if (this.controller.get('isEmbed')) {
window.focus();
$(document).mouseenter(function(e) {
window.focus();
});
}
},
webglSetSupported: function(state) {
if (this.controller) {
this.controller.set('webglNotSupported', !state);
}
},
webglSetMaximumTextures: function(count) {
if (this.controller) {
this.controller.set('webglMaximumTextures', count);
}
},
setIncompatibleTextures: function(textures) {
if (this.controller) {
this.controller.set('incompatibleTextures', textures);
}
},
modelStateChanged: function() {
if (this.controller) {
this.controller.set('modelProgress', '');
this.controller.set('modelLoading', P3DV.loadStates.model_loading);
if (this.controller.get('isEmbed') && !P3DV.loadStates.model_loading) {
$('.snapshot-centered').hide();
}
}
},
modelProgressUpdate: function(event) {
if (!P3d.viewerSync.controller)
return;
if (event.total) {
P3d.viewerSync.controller.set('modelProgress', (100 * event.loaded / event.total).toFixed(0) + '%');
} else if (P3d.viewerSync.get('controller.content.payloadSize')) {
var loaded = event.loaded / P3d.viewerSync.get('controller.content.payloadSize') / 0.50;
if (loaded > 1.0) {
loaded = 1.0;
}
P3d.viewerSync.controller.set('modelProgress', (100 * loaded).toFixed(0) + '%');
} else {
P3d.viewerSync.controller.set('modelProgress', (event.loaded / 1024 / 1024).toFixed(2) + ' MB');
}
},
textureStateChanged: function() {
if (this.controller) {
var loading = {};
for (var i = 0; i < P3DV.loadStates.textures_loading.length; i++) {
var mat_loading = P3DV.loadStates.textures_loading[i];
if (mat_loading) {
for (var j = 0; j < mat_loading.length; j++) {
loading[mat_loading[j]] = true;
}
}
}
this.controller.set('texturesLoading', Object.keys(loading).length);
}
},
updateMeshInfo: function(fo, f, v) {
this.controller.set('totalOriginalFaces', fo);
this.controller.set('totalFaces', f);
this.controller.set('totalVertices', v);
},
rotateModelX: function(dir) {
P3DV.rotateModelAxis(new THREE.Vector3(1, 0, 0), dir);
this.controller.didChangeModelData();
},
rotateModelY: function(dir) {
P3DV.rotateModelAxis(new THREE.Vector3(0, 1, 0), dir);
this.controller.didChangeModelData();
},
rotateModelZ: function(dir) {
P3DV.rotateModelAxis(new THREE.Vector3(0, 0, 1), dir);
this.controller.didChangeModelData();
},
updateOrientationPreview: function() {
var thumbDataURL = P3DV.renderer_captureImage(200, 200, null, this.get('controller.defaultShading'));
this.controller.set('orientationPreviewUrl', thumbDataURL);
if (P3DV.model_settings.orientation.clone)
this.model.set('settingsObj.orientation', P3DV.model_settings.orientation.clone());
},
captureScreenshot: function(width, height, use_default_camera) {
var camera = P3DV.model_settings.default_camera;
if (!use_default_camera) {
camera = P3DV.camera_getSettings();
}
return P3DV.renderer_captureImage(width, height, camera);
},
updateCameraThumbnail: function() {
var thumbDataURL = P3DV.renderer_captureImage(200, 200, P3DV.model_settings.default_camera, this.get('controller.defaultShading'));
this.controller.set('cameraPreviewUrl', thumbDataURL);
},
setDefaultCamera: function(custom) {
var settings = false;
if (custom) {
settings = P3DV.camera_getSettings();
}
this.model.set('settingsObj.default_camera', settings);
P3DV.model_settings.default_camera = settings;
this.updateCameraThumbnail();
this.controller.didChangeModelData();
},
updateViewerPreviews: function(force) {
var viewer_view = this.get('viewer_view');
if (!force && viewer_view && (!P3d.panels || !viewer_view.isPanelVisible(P3d.panels.get('settings')))) {
return;
}
this.updateOrientationPreview();
this.updateCameraThumbnail();
},
});
(function(p) {
var modelStateChange = p.callbacks.modelStateChange;
p.callbacks.modelStateChange = function() {
P3d.viewerSync.modelStateChanged();
if (modelStateChange)
modelStateChange();
}
var textureStateChange = p.callbacks.textureStateChange;
p.callbacks.textureStateChange = function() {
P3d.viewerSync.textureStateChanged();
if (textureStateChange)
textureStateChange();
}
var updateMeshInfo = p.callbacks.updateMeshInfo;
p.callbacks.updateMeshInfo = function(fo, f, v) {
P3d.viewerSync.updateMeshInfo(fo, f, v);
if (updateMeshInfo)
updateMeshInfo(fo, f, v);
}
})(P3DV);
P3DV.callbacks.updateViewerPreviews = function(force) {
P3d.viewerSync.updateViewerPreviews(force);
};
THREE.Loader.prototype.updateProgress = P3d.viewerSync.modelProgressUpdate;
var TR_EPSILON = 1e-12;
function trArea(contour) {
var n = contour.length;
var A = 0.0;
for (var p = n - 1, q = 0; q < n; p = q++) {
A += contour[p].x * contour[q].y - contour[q].x * contour[p].y;
}
return A * 0.5;
}
function trInsideTriangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py) {
var ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
var cCROSSap, bCROSScp, aCROSSbp;
ax = Cx - Bx;
ay = Cy - By;
bx = Ax - Cx;
by = Ay - Cy;
cx = Bx - Ax;
cy = By - Ay;
apx = Px - Ax;
apy = Py - Ay;
bpx = Px - Bx;
bpy = Py - By;
cpx = Px - Cx;
cpy = Py - Cy;
aCROSSbp = ax * bpy - ay * bpx;
cCROSSap = cx * apy - cy * apx;
bCROSScp = bx * cpy - by * cpx;
return ((aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0));
};
function trSnip(contour, u, v, w, n, V) {
var p;
var Ax, Ay, Bx, By, Cx, Cy, Px, Py;
Ax = contour[V[u]].x;
Ay = contour[V[u]].y;
Bx = contour[V[v]].x;
By = contour[V[v]].y;
Cx = contour[V[w]].x;
Cy = contour[V[w]].y;
if (TR_EPSILON > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) return false;
for (p = 0; p < n; p++) {
if ((p == u) || (p == v) || (p == w)) continue;
Px = contour[V[p]].x;
Py = contour[V[p]].y;
if (trInsideTriangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py)) return false;
}
return true;
}
function triangulateProcess(contour, result) {
var n = contour.length;
if (n < 3) return false;
var V = new Array();
if (0.0 < trArea(contour))
for (var v = 0; v < n; v++) V[v] = v;
else
for (var v = 0; v < n; v++) V[v] = (n - 1) - v;
var nv = n;
var count = 2 * nv;
for (var m = 0, v = nv - 1; nv > 2;) {
if (0 >= (count--)) {
return false;
}
var u = v;
if (nv <= u) u = 0;
v = u + 1;
if (nv <= v) v = 0;
var w = v + 1;
if (nv <= w) w = 0;
if (trSnip(contour, u, v, w, nv, V)) {
var a, b, c, s, t;
a = V[u];
b = V[v];
c = V[w];
result.push(contour[a]);
result.push(contour[b]);
result.push(contour[c]);
m++;
for (s = v, t = v + 1; t < nv; s++, t++) V[s] = V[t];
nv--;
count = 2 * nv;
}
}
return true;
}
function tessellate_polygon(vertices) {
var poly_contour = [];
var n = new THREE.Vector3(0, 0, 0);
var i;
for (i = 0; i < vertices.length; i++) {
var v = vertices[(i + 1) % vertices.length];
var prev = vertices[i];
n.x += (prev.y - v.y) * (prev.z + v.z);
n.y += (prev.z - v.z) * (prev.x + v.x);
n.z += (prev.x - v.x) * (prev.y + v.y);
}
n.normalize();
var h = new THREE.Vector3(vertices[1].x - vertices[0].x, vertices[1].y - vertices[0].y, vertices[1].z - vertices[0].z).normalize();
var vx = new THREE.Vector3().crossVectors(n, h).normalize();
var vy = new THREE.Vector3().crossVectors(n, vx).normalize();
for (i = 0; i < vertices.length; i++) {
var v = vertices[i];
var p = new THREE.Vector2(vx.dot(v), vy.dot(v));
p.index = v.index;
if (v["index_n"] !== undefined) p.index_n = v.index_n;
if (v["index_uv"] !== undefined) p.index_uv = v.index_uv;
poly_contour.push(p);
}
var result = new Array();
triangulateProcess(poly_contour, result);
if (result.length / 3 != vertices.length - 2)
console.log("Unexpected tri count: " + (vertices.length - 2) + " -> " + (result.length / 3));
return result;
}
function obj2bin(input) {
var overAllStartTime;
var startTime = 0;
function start() {
startTime = new Date().getTime();
}
function duration() {
return new Date().getTime() - startTime;
}
function status(msg) {
console.log(msg);
}
overAllStartTime = new Date().getTime();
status("Converting 1st pass");
var faceblocks = [];
var faceblock_idx = 0;
var faceblock;
var last_faceblock_pos = 0;
(function() {
pattern = /(f[\s\d-\/]+[\n\r])+/gi;
while ((result = pattern.exec(input)) !== null) {
faceblocks.push({
v: -1,
vn: -1,
vt: -1,
pos: pattern.lastIndex - result[0].length
});
}
last_faceblock_pos = faceblocks[faceblocks.length - 1].pos;
faceblocks.push({
v: -1,
vn: -1,
vt: -1,
pos: input.length
});
})();
if (faceblocks.length == 1) {
return {
error: 'Model seems to have no faces'
};
}
start();
faceblock_idx = 0;
faceblock = faceblocks[0];
pattern = /v( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)[ \\\n\r]+([\d|\.|\+|\-|e]+)/gi;
var vcount = 0;
(function() {
while ((result = pattern.exec(input)) !== null) {
if (pattern.lastIndex > last_faceblock_pos) {
break;
}
while (pattern.lastIndex > faceblock.pos) {
faceblock = faceblocks[++faceblock_idx];
faceblock.v = vcount;
}
++vcount;
}
})();
faceblocks[++faceblock_idx].v = vcount;
console.log("vcount: " + vcount);
console.log(" duration: " + duration());
start();
faceblock_idx = 0;
faceblock = faceblocks[0];
pattern = /vn( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)[ \\\n\r]+([\d|\.|\+|\-|e]+)/gi;
var ncount = 0;
(function() {
while ((result = pattern.exec(input)) !== null) {
if (pattern.lastIndex > last_faceblock_pos) {
break;
}
while (pattern.lastIndex > faceblock.pos) {
faceblock = faceblocks[++faceblock_idx];
faceblock.vn = ncount;
}
++ncount;
}
})();
faceblocks[++faceblock_idx].vn = ncount;
console.log("ncount: " + ncount);
console.log(" duration: " + duration());
start();
faceblock_idx = 0;
faceblock = faceblocks[0];
pattern = /vt( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/gi;
var tcount = 0;
(function() {
while ((result = pattern.exec(input)) !== null) {
if (pattern.lastIndex > last_faceblock_pos) {
break;
}
while (pattern.lastIndex > faceblock.pos) {
faceblock = faceblocks[++faceblock_idx];
faceblock.vt = tcount;
}
++tcount;
}
})();
faceblocks[++faceblock_idx].vt = tcount;
console.log("tcount: " + tcount);
console.log(" duration: " + duration());
var fbv = -1;
var fbvn = -1;
var fbvt = -1;
for (var i = 0, il = faceblocks.length; i < il; ++i) {
var fb = faceblocks[i];
if (fbv < fb.v) fbv = fb.v;
if (fbvn < fb.vn) fbvn = fb.vn;
if (fbvt < fb.vt) fbvt = fb.vt;
if (fb.v < fbv) fb.v = fbv;
if (fb.vn < fbvn) fb.vn = fbvn;
if (fb.vt < fbvt) fb.vt = fbvt;
}
pattern = /usemtl (.+)/gi;
var materials = [];
var material_pos = [];
(function() {
while ((result = pattern.exec(input)) !== null) {
var name = result[1];
var index = materials.indexOf(name);
if (index < 0) {
index = materials.length;
materials.push(name);
}
material_pos.push({
index: index,
pos: pattern.lastIndex
});
}
})();
material_pos.push({
index: 0,
pos: input.length
});
console.log('materials: ' + JSON.stringify(materials));
console.log('material_pos: ' + JSON.stringify(material_pos));
console.log('faceblocks: ' + JSON.stringify(faceblocks));
start();
pattern = /f +((-?\d+(\/(-?\d+)?)?(\/(-?\d+)?)?[ \\\n\r]*)+)/gi;
var f3_count = [0, 0, 0, 0];
var f4_count = [0, 0, 0, 0];
var FTYPE_POS = 0;
var FTYPE_POS_UV = 1;
var FTYPE_POS_NORM = 2;
var FTYPE_POS_UV_NORM = 3;
var verts;
var vert;
var type;
(function() {
while ((result = pattern.exec(input)) !== null) {
verts = result[1].trim().split(/[ \\\n\r]+/);
vert = verts[0].split('/');
type = 0;
if (!!vert[1]) type |= FTYPE_POS_UV;
if (!!vert[2]) type |= FTYPE_POS_NORM;
if (verts.length == 3) {
++f3_count[type];
} else if (verts.length == 4) {
++f4_count[type];
} else if (verts.length > 4) {
f3_count[type] += verts.length - 2;
}
}
})();
console.log("tris (pos): " + f3_count[FTYPE_POS]);
console.log("quads (pos): " + f4_count[FTYPE_POS]);
console.log("tris (pos,uv): " + f3_count[FTYPE_POS_UV]);
console.log("quads (pos,uv): " + f4_count[FTYPE_POS_UV]);
console.log("tris (pos,norm): " + f3_count[FTYPE_POS_NORM]);
console.log("quads (pos,norm): " + f4_count[FTYPE_POS_NORM]);
console.log("tris (pos,uv,norm): " + f3_count[FTYPE_POS_UV_NORM]);
console.log("quads (pos,uv,norm): " + f4_count[FTYPE_POS_UV_NORM]);
console.log(" duration: " + duration());
status("Converting 2nd pass");
function handlePadding(n) {
return (n % 4) ? (4 - n % 4) : 0;
}
function addPadding(size) {
return size + handlePadding(size);
}
function writeString(buffer, offset, str) {
var charArray = new Uint8Array(buffer, offset, str.length);
for (var i = 0; i < str.length; ++i) {
charArray[i] = str.charCodeAt(i);
}
}
function writeUint8(buffer, offset, value) {
var charArray = new Uint8Array(buffer, offset, 1);
charArray[0] = value;
}
function writeUint32(buffer, offset, value) {
var intArray = new Uint32Array(buffer, offset, 1);
intArray[0] = value;
}
var total_size = 0x40;
var pos_start = total_size;
total_size += (3 * 4) * vcount;
var norm_start = total_size;
total_size += addPadding(3 * ncount);
var uv_start = total_size;
total_size += (2 * 4) * tcount;
var f3_start = [0, 0, 0, 0];
var f4_start = [0, 0, 0, 0];
f3_start[FTYPE_POS] = total_size;
total_size += addPadding((3 * 4 + 2) * f3_count[FTYPE_POS]);
f3_start[FTYPE_POS_NORM] = total_size;
total_size += addPadding((3 * (4 + 4) + 2) * f3_count[FTYPE_POS_NORM]);
f3_start[FTYPE_POS_UV] = total_size;
total_size += addPadding((3 * (4 + 4) + 2) * f3_count[FTYPE_POS_UV]);
f3_start[FTYPE_POS_UV_NORM] = total_size;
total_size += addPadding((3 * (4 + 4 + 4) + 2) * f3_count[FTYPE_POS_UV_NORM]);
f4_start[FTYPE_POS] = total_size;
total_size += addPadding((4 * 4 + 2) * f4_count[FTYPE_POS]);
f4_start[FTYPE_POS_NORM] = total_size;
total_size += addPadding((4 * (4 + 4) + 2) * f4_count[FTYPE_POS_NORM]);
f4_start[FTYPE_POS_UV] = total_size;
total_size += addPadding((4 * (4 + 4) + 2) * f4_count[FTYPE_POS_UV]);
f4_start[FTYPE_POS_UV_NORM] = total_size;
total_size += addPadding((4 * (4 + 4 + 4) + 2) * f4_count[FTYPE_POS_UV_NORM]);
console.log("total size: " + total_size);
var buffer = new ArrayBuffer(total_size);
writeString(buffer, 0, "Three.js 003");
writeUint8(buffer, 12, 64);
writeUint8(buffer, 13, 4);
writeUint8(buffer, 14, 1);
writeUint8(buffer, 15, 4);
writeUint8(buffer, 16, 4);
writeUint8(buffer, 17, 4);
writeUint8(buffer, 18, 4);
writeUint8(buffer, 19, 2);
writeUint32(buffer, 20 + 4 * 0, vcount);
writeUint32(buffer, 20 + 4 * 1, ncount);
writeUint32(buffer, 20 + 4 * 2, tcount);
writeUint32(buffer, 20 + 4 * 3, f3_count[FTYPE_POS]);
writeUint32(buffer, 20 + 4 * 4, f3_count[FTYPE_POS_NORM]);
writeUint32(buffer, 20 + 4 * 5, f3_count[FTYPE_POS_UV]);
writeUint32(buffer, 20 + 4 * 6, f3_count[FTYPE_POS_UV_NORM]);
writeUint32(buffer, 20 + 4 * 7, f4_count[FTYPE_POS]);
writeUint32(buffer, 20 + 4 * 8, f4_count[FTYPE_POS_NORM]);
writeUint32(buffer, 20 + 4 * 9, f4_count[FTYPE_POS_UV]);
writeUint32(buffer, 20 + 4 * 10, f4_count[FTYPE_POS_UV_NORM]);
start();
var posArray = new Float32Array(buffer, pos_start, 3 * vcount);
var i = 0;
pattern = /v( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)[ \\\n\r]+([\d|\.|\+|\-|e]+)/gi;
var x, y, z;
var xmin = ymin = zmin = Infinity;
var xmax = ymax = zmax = -Infinity;
(function() {
while ((result = pattern.exec(input)) !== null) {
if (pattern.lastIndex > last_faceblock_pos) {
break;
}
x = parseFloat(result[1]);
y = parseFloat(result[2]);
z = parseFloat(result[3]);
posArray[i++] = x;
posArray[i++] = y;
posArray[i++] = z;
xmin = Math.min(xmin, x);
ymin = Math.min(ymin, y);
zmin = Math.min(zmin, z);
xmax = Math.max(xmax, x);
ymax = Math.max(ymax, y);
zmax = Math.max(zmax, z);
}
})();
console.log("wrote positions: " + vcount);
console.log(" duration: " + duration());
var center_x = (xmin + xmax) / 2.0;
var center_y = (ymin + ymax) / 2.0;
var center_z = (zmin + zmax) / 2.0;
console.log(" center: " + center_x + ", " + center_y + ", " + center_z);
for (i = 0; i < 3 * vcount;) {
posArray[i++] -= center_x;
posArray[i++] -= center_y;
posArray[i++] -= center_z;
}
if (ncount > 0) {
start();
var normArray = new Int8Array(buffer, norm_start, 3 * ncount);
var i = 0;
var nx, ny, nz, nlen;
(function() {
pattern = /vn( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)[ \\\n\r]+([\d|\.|\+|\-|e]+)/gi;
while ((result = pattern.exec(input)) !== null) {
if (pattern.lastIndex > last_faceblock_pos) {
break;
}
nx = parseFloat(result[1]);
ny = parseFloat(result[2]);
nz = parseFloat(result[3]);
nlen = nx * nx + ny * ny + nz * nz;
if (nlen > 0) {
nlen = Math.sqrt(nlen);
}
normArray[i++] = nx / nlen * 127;
normArray[i++] = ny / nlen * 127;
normArray[i++] = nz / nlen * 127;
}
})();
console.log("wrote normals: " + ncount);
console.log(" duration: " + duration());
}
if (tcount > 0) {
start();
var uvArray = new Float32Array(buffer, uv_start, 2 * tcount);
var i = 0;
pattern = /vt( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/gi;
(function() {
while ((result = pattern.exec(input)) !== null) {
if (pattern.lastIndex > last_faceblock_pos) {
break;
}
uvArray[i++] = parseFloat(result[1]);
uvArray[i++] = 1.0 - parseFloat(result[2]);
}
})();
console.log("wrote uvs: " + tcount);
console.log(" duration: " + duration());
}
start();
var f3_pos_array = new Array(4);
var f3_pos_offset = [0, 0, 0, 0];
var f3_norm_array = new Array(4);
var f3_norm_offset = [0, 0, 0, 0];
var f3_uv_array = new Array(4);
var f3_uv_offset = [0, 0, 0, 0];
var f3_mat_array = new Array(4);
var f3_mat_offset = [0, 0, 0, 0];
var f4_pos_array = new Array(4);
var f4_pos_offset = [0, 0, 0, 0];
var f4_norm_array = new Array(4);
var f4_norm_offset = [0, 0, 0, 0];
var f4_uv_array = new Array(4);
var f4_uv_offset = [0, 0, 0, 0];
var f4_mat_array = new Array(4);
var f4_mat_offset = [0, 0, 0, 0];
var mat_index;
var mat_pos_index;
var next_mat_pos;
function calcIdx(str, offset) {
var idx = parseInt(str);
return idx > 0 ? idx - 1 : idx + offset;
}
if (f3_count[FTYPE_POS] > 0 || f4_count[FTYPE_POS] > 0) {
f3_pos_array[FTYPE_POS] = new Uint32Array(buffer, f3_start[FTYPE_POS], f3_count[FTYPE_POS] * 3);
f3_mat_array[FTYPE_POS] = new Uint16Array(buffer, f3_start[FTYPE_POS] + f3_count[FTYPE_POS] * 3 * 4, f3_count[FTYPE_POS]);
f4_pos_array[FTYPE_POS] = new Uint32Array(buffer, f4_start[FTYPE_POS], f4_count[FTYPE_POS] * 4);
f4_mat_array[FTYPE_POS] = new Uint16Array(buffer, f4_start[FTYPE_POS] + f4_count[FTYPE_POS] * 4 * 4, f4_count[FTYPE_POS]);
}
if (f3_count[FTYPE_POS_NORM] > 0 || f4_count[FTYPE_POS_NORM] > 0) {
f3_pos_array[FTYPE_POS_NORM] = new Uint32Array(buffer, f3_start[FTYPE_POS_NORM], f3_count[FTYPE_POS_NORM] * 3);
f3_norm_array[FTYPE_POS_NORM] = new Uint32Array(buffer, f3_start[FTYPE_POS_NORM] + f3_count[FTYPE_POS_NORM] * 3 * 4, f3_count[FTYPE_POS_NORM] * 3);
f3_mat_array[FTYPE_POS_NORM] = new Uint16Array(buffer, f3_start[FTYPE_POS_NORM] + f3_count[FTYPE_POS_NORM] * 6 * 4, f3_count[FTYPE_POS_NORM]);
f4_pos_array[FTYPE_POS_NORM] = new Uint32Array(buffer, f4_start[FTYPE_POS_NORM], f4_count[FTYPE_POS_NORM] * 4);
f4_norm_array[FTYPE_POS_NORM] = new Uint32Array(buffer, f4_start[FTYPE_POS_NORM] + f4_count[FTYPE_POS_NORM] * 4 * 4, f4_count[FTYPE_POS_NORM] * 4);
f4_mat_array[FTYPE_POS_NORM] = new Uint16Array(buffer, f4_start[FTYPE_POS_NORM] + f4_count[FTYPE_POS_NORM] * 8 * 4, f4_count[FTYPE_POS_NORM]);
}
if (f3_count[FTYPE_POS_UV] > 0 || f4_count[FTYPE_POS_UV] > 0) {
f3_pos_array[FTYPE_POS_UV] = new Uint32Array(buffer, f3_start[FTYPE_POS_UV], f3_count[FTYPE_POS_UV] * 3);
f3_uv_array[FTYPE_POS_UV] = new Uint32Array(buffer, f3_start[FTYPE_POS_UV] + f3_count[FTYPE_POS_UV] * 3 * 4, f3_count[FTYPE_POS_UV] * 3);
f3_mat_array[FTYPE_POS_UV] = new Uint16Array(buffer, f3_start[FTYPE_POS_UV] + f3_count[FTYPE_POS_UV] * 6 * 4, f3_count[FTYPE_POS_UV]);
f4_pos_array[FTYPE_POS_UV] = new Uint32Array(buffer, f4_start[FTYPE_POS_UV], f4_count[FTYPE_POS_UV] * 4);
f4_uv_array[FTYPE_POS_UV] = new Uint32Array(buffer, f4_start[FTYPE_POS_UV] + f4_count[FTYPE_POS_UV] * 4 * 4, f4_count[FTYPE_POS_UV] * 4);
f4_mat_array[FTYPE_POS_UV] = new Uint16Array(buffer, f4_start[FTYPE_POS_UV] + f4_count[FTYPE_POS_UV] * 8 * 4, f4_count[FTYPE_POS_UV]);
}
if (f3_count[FTYPE_POS_UV_NORM] > 0 || f4_count[FTYPE_POS_UV_NORM] > 0) {
f3_pos_array[FTYPE_POS_UV_NORM] = new Uint32Array(buffer, f3_start[FTYPE_POS_UV_NORM], f3_count[FTYPE_POS_UV_NORM] * 3);
f3_norm_array[FTYPE_POS_UV_NORM] = new Uint32Array(buffer, f3_start[FTYPE_POS_UV_NORM] + f3_count[FTYPE_POS_UV_NORM] * 3 * 4, f3_count[FTYPE_POS_UV_NORM] * 3);
f3_uv_array[FTYPE_POS_UV_NORM] = new Uint32Array(buffer, f3_start[FTYPE_POS_UV_NORM] + f3_count[FTYPE_POS_UV_NORM] * 6 * 4, f3_count[FTYPE_POS_UV_NORM] * 3);
f3_mat_array[FTYPE_POS_UV_NORM] = new Uint16Array(buffer, f3_start[FTYPE_POS_UV_NORM] + f3_count[FTYPE_POS_UV_NORM] * 9 * 4, f3_count[FTYPE_POS_UV_NORM]);
f4_pos_array[FTYPE_POS_UV_NORM] = new Uint32Array(buffer, f4_start[FTYPE_POS_UV_NORM], f4_count[FTYPE_POS_UV_NORM] * 4);
f4_norm_array[FTYPE_POS_UV_NORM] = new Uint32Array(buffer, f4_start[FTYPE_POS_UV_NORM] + f4_count[FTYPE_POS_UV_NORM] * 4 * 4, f4_count[FTYPE_POS_UV_NORM] * 4);
f4_uv_array[FTYPE_POS_UV_NORM] = new Uint32Array(buffer, f4_start[FTYPE_POS_UV_NORM] + f4_count[FTYPE_POS_UV_NORM] * 8 * 4, f4_count[FTYPE_POS_UV_NORM] * 4);
f4_mat_array[FTYPE_POS_UV_NORM] = new Uint16Array(buffer, f4_start[FTYPE_POS_UV_NORM] + f4_count[FTYPE_POS_UV_NORM] * 12 * 4, f4_count[FTYPE_POS_UV_NORM]);
}
mat_index = 0;
mat_pos_index = 0;
next_mat_pos = material_pos[mat_pos_index].pos;
faceblock_idx = 0;
faceblock = faceblocks[0];
var vert2;
var vert3;
var vertlen;
var num_of_ngons = 0;
(function() {
pattern = /f +((-?\d+(\/(-?\d+)?)?(\/(-?\d+)?)?[ \\\n\r]*)+)/gi;
while ((result = pattern.exec(input)) != null) {
if (pattern.lastIndex > next_mat_pos) {
mat_index = material_pos[mat_pos_index].index;
next_mat_pos = material_pos[++mat_pos_index].pos;
}
if (pattern.lastIndex > faceblock.pos) {
faceblock = faceblocks[++faceblock_idx];
}
verts = result[1].trim().split(/[ \\\n\r]+/);
vertlen = verts.length;
vert = verts[0].split('/');
type = 0;
if (!!vert[1]) type |= FTYPE_POS_UV;
if (!!vert[2]) type |= FTYPE_POS_NORM;
if (vertlen == 3) {
for (var i = 0; i < 3; ++i) {
if (i > 0) vert = verts[i].split('/');
f3_pos_array[type][f3_pos_offset[type]++] = calcIdx(vert[0], faceblock.v);
if (type & FTYPE_POS_NORM) f3_norm_array[type][f3_norm_offset[type]++] = calcIdx(vert[2], faceblock.vn);
if (type & FTYPE_POS_UV) f3_uv_array[type][f3_uv_offset[type]++] = calcIdx(vert[1], faceblock.vt);
}
f3_mat_array[type][f3_mat_offset[type]++] = mat_index;
} else if (vertlen == 4) {
for (var i = 0; i < 4; ++i) {
if (i > 0) vert = verts[i].split('/');
f4_pos_array[type][f4_pos_offset[type]++] = calcIdx(vert[0], faceblock.v);
if (type & FTYPE_POS_NORM) f4_norm_array[type][f4_norm_offset[type]++] = calcIdx(vert[2], faceblock.vn);
if (type & FTYPE_POS_UV) f4_uv_array[type][f4_uv_offset[type]++] = calcIdx(vert[1], faceblock.vt);
}
f4_mat_array[type][f4_mat_offset[type]++] = mat_index;
} else if (vertlen > 4) {
var vertices = new Array();
for (var i = 0; i < vertlen; i++) {
_vert = verts[i].split('/');
vidx = calcIdx(_vert[0], faceblock.v);
vertices[i] = new THREE.Vector3();
vertices[i].index = vidx;
if (type & FTYPE_POS_NORM) vertices[i].index_n = _vert[2];
if (type & FTYPE_POS_UV) vertices[i].index_uv = _vert[1];
vertices[i].x = posArray[vidx * 3];
vertices[i].y = posArray[vidx * 3 + 1];
vertices[i].z = posArray[vidx * 3 + 2];
}
var tris = tessellate_polygon(vertices);
for (var i = 0; i < tris.length; ++i) {
var ve = tris[i];
f3_pos_array[type][f3_pos_offset[type]++] = ve.index;
if (ve["index_n"] !== undefined) f3_norm_array[type][f3_norm_offset[type]++] = calcIdx(ve.index_n, faceblock.vn);
if (ve["index_uv"] !== undefined) f3_uv_array[type][f3_uv_offset[type]++] = calcIdx(ve.index_uv, faceblock.vt);
if (!(i % 3)) {
f3_mat_array[type][f3_mat_offset[type]++] = mat_index;
}
}
num_of_ngons++;
}
}
})();
console.log("wrote faces");
console.log(num_of_ngons + " ngons");
console.log(" duration: " + duration());
var overAllDuration = new Date().getTime() - overAllStartTime;
console.log("over all conversion time: " + overAllDuration);
status("Conversion done, duration: " + overAllDuration + "ms");
var meta = {
"metadata": {
"formatVersion": 3,
"sourceFile": ".obj",
"generatedBy": "JS OBJConverter",
"vertices": vcount,
"faces": f3_count[FTYPE_POS] + f4_count[FTYPE_POS] +
f3_count[FTYPE_POS_NORM] + f4_count[FTYPE_POS_NORM] +
f3_count[FTYPE_POS_UV] + f4_count[FTYPE_POS_UV] +
f3_count[FTYPE_POS_UV_NORM] + f4_count[FTYPE_POS_UV_NORM],
"normals": ncount,
"uvs": tcount,
"materials": materials.length
},
"materials": [],
"buffers": ".bin"
};
for (var i = 0; i < materials.length; ++i) {
meta.materials.push({
"DbgColor": 0xffffff,
"DbgIndex": 0,
"DbgName": materials[i]
});
}
return {
binary: buffer,
meta: meta
};
}
if (typeof(exports) != 'undefined') {
exports.obj2bin = obj2bin;
}