diff --git a/assets/sounds/beatHit.ogg b/assets/sounds/beatHit.ogg
new file mode 100644
index 0000000..8dd23fd
Binary files /dev/null and b/assets/sounds/beatHit.ogg differ
diff --git a/assets/sounds/saber.ogg b/assets/sounds/saber.ogg
deleted file mode 100644
index 17fb4a3..0000000
Binary files a/assets/sounds/saber.ogg and /dev/null differ
diff --git a/package-lock.json b/package-lock.json
index b138304..60eefb5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -97,9 +97,9 @@
"integrity": "sha512-2Zm07u163vwzT7VLE7y9h9oL1e3RH8CNQGIUvdE+wgl2Yo6iSZwGhIpcYRFODthEdb0vHrCyFMOATZfniq7yhw=="
},
"aframe-audioanalyser-component": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/aframe-audioanalyser-component/-/aframe-audioanalyser-component-4.0.1.tgz",
- "integrity": "sha512-jTkt9umD4SoRmW6vlJfm2zG9fV8pzecNzTdJYn12w8hpZ0lp3BtFSKqTDy0RE3dqAsDJo9AU72niZAu8w3NeeA=="
+ "version": "5.0.0-beta1",
+ "resolved": "https://registry.npmjs.org/aframe-audioanalyser-component/-/aframe-audioanalyser-component-5.0.0-beta1.tgz",
+ "integrity": "sha512-VKDwHBXq3QjX+nBZuoOtGTg7qBytVVC7um7yZSpBCI3hHxhjKtldTeZHohP6R8P5jaDrwygQkXXFfHyJCKOubw=="
},
"aframe-event-decorators": {
"version": "1.0.2",
diff --git a/src/components/beat-hit.js b/src/components/beat-hit.js
new file mode 100644
index 0000000..a6a0e9c
--- /dev/null
+++ b/src/components/beat-hit.js
@@ -0,0 +1,28 @@
+var audioContext = new window.AudioContext();
+
+/**
+ * Beat hit sound using positional audio and audio buffer source.
+ * Pitch the sound up and down using the song audioanalyser FFT.
+ */
+AFRAME.registerComponent('beat-hit', {
+ dependencies: ['sound__beathit'],
+
+ init: function () {
+ const data = this.data;
+ const el = this.el;
+
+ this.processSound = this.processSound.bind(this);
+
+ const soundPool = el.components.sound__beathit;
+ el.addEventListener('beathit', evt => {
+ this.currentBeatEl = evt.detail;
+ soundPool.playSound(this.processSound);
+ });
+ },
+
+ processSound: function (sound) {
+ this.currentBeatEl.object3D.getWorldPosition(sound.position);
+ console.log(sound.position);
+ // this.currentBeatEl.setObject3D('sound', sound);
+ }
+});
diff --git a/src/components/beat.js b/src/components/beat.js
index c437808..0839f5e 100644
--- a/src/components/beat.js
+++ b/src/components/beat.js
@@ -421,14 +421,14 @@ AFRAME.registerComponent('beat', {
saberBoundingBox = saberEls[i].components['saber-controls'].boundingBox;
if (!boundingBox || !saberBoundingBox) { break; }
if (saberBoundingBox.intersectsBox(boundingBox)) {
+ this.el.emit('beathit', this.el);
this.destroyBeat(saberEls[i]);
- this.el.sceneEl.emit('beathit', null, false);
break;
}
if (saberBoundingBox.intersectsBox(beatBoundingBox)) {
+ this.el.emit('beathit', this.el);
this.destroyBeat(saberEls[i]);
this.wrongCut(saberEls[i].getAttribute('saber-controls').hand);
- this.el.sceneEl.emit('beatwrong', null, false);
break;
}
}
diff --git a/src/index.html b/src/index.html
index 3d232e9..f110470 100644
--- a/src/index.html
+++ b/src/index.html
@@ -100,8 +100,11 @@
-
-
+
{% include './templates/stage.html' %}
{% include './templates/score.html' %}
{% include './templates/menu.html' %}
diff --git a/vendor/README.md b/vendor/README.md
new file mode 100644
index 0000000..14a1d61
--- /dev/null
+++ b/vendor/README.md
@@ -0,0 +1,2 @@
+A-Frame currently derived from `overlay` branch from either Kevin or Diego's
+A-Frame GitHub repositories.
diff --git a/vendor/aframe.effects.js b/vendor/aframe.effects.js
index 118619c..3064421 100644
--- a/vendor/aframe.effects.js
+++ b/vendor/aframe.effects.js
@@ -50,9 +50,9 @@ function(a){a=P(a);for(var c=v.length;c--;)for(var d=v[c],b=d.animations,f=b.len
},{}],3:[function(_dereq_,module,exports){
module.exports = function numtype(num, def) {
- return typeof num === 'number'
- ? num
- : (typeof def === 'number' ? def : 0)
+ return typeof num === 'number'
+ ? num
+ : (typeof def === 'number' ? def : 0)
}
},{}],4:[function(_dereq_,module,exports){
'use strict'
@@ -207,7 +207,7 @@ module.exports = {
var value = attributes[key];
style.setAttribute('data-' + key, value);
}
-
+
if (style.sheet) { // for jsdom and IE9+
style.innerHTML = cssText;
style.sheet.cssText = cssText;
@@ -416,11 +416,11 @@ module.exports = function (a, b) {
if (!Buffer.isBuffer(b)) return undefined;
if (typeof a.equals === 'function') return a.equals(b);
if (a.length !== b.length) return false;
-
+
for (var i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false;
}
-
+
return true;
};
@@ -2218,7 +2218,7 @@ function isnan (val) {
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"base64-js":4,"ieee754":18,"isarray":9}],9:[function(_dereq_,module,exports){
+},{"base64-js":4,"ieee754":15,"isarray":9}],9:[function(_dereq_,module,exports){
var toString = {}.toString;
module.exports = Array.isArray || function (arr) {
@@ -2226,432 +2226,76 @@ module.exports = Array.isArray || function (arr) {
};
},{}],10:[function(_dereq_,module,exports){
-
-/**
- * This is the web browser implementation of `debug()`.
- *
- * Expose `debug()` as the module.
- */
-
-exports = module.exports = _dereq_('./debug');
-exports.log = log;
-exports.formatArgs = formatArgs;
-exports.save = save;
-exports.load = load;
-exports.useColors = useColors;
-exports.storage = 'undefined' != typeof chrome
- && 'undefined' != typeof chrome.storage
- ? chrome.storage.local
- : localstorage();
-
-/**
- * Colors.
- */
-
-exports.colors = [
- 'lightseagreen',
- 'forestgreen',
- 'goldenrod',
- 'dodgerblue',
- 'darkorchid',
- 'crimson'
-];
-
-/**
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
- * and the Firebug extension (any Firefox version) are known
- * to support "%c" CSS customizations.
- *
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
- */
-
-function useColors() {
- // is webkit? http://stackoverflow.com/a/16459606/376773
- return ('WebkitAppearance' in document.documentElement.style) ||
- // is firebug? http://stackoverflow.com/a/398120/376773
- (window.console && (console.firebug || (console.exception && console.table))) ||
- // is firefox >= v31?
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
- (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
-}
-
-/**
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
- */
-
-exports.formatters.j = function(v) {
- return JSON.stringify(v);
-};
-
-
-/**
- * Colorize log arguments if enabled.
- *
- * @api public
- */
-
-function formatArgs() {
- var args = arguments;
- var useColors = this.useColors;
-
- args[0] = (useColors ? '%c' : '')
- + this.namespace
- + (useColors ? ' %c' : ' ')
- + args[0]
- + (useColors ? '%c ' : ' ');
-
- if (!useColors) return args;
-
- var c = 'color: ' + this.color;
- args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
-
- // the final "%c" is somewhat tricky, because there could be other
- // arguments passed either before or after the %c, so we need to
- // figure out the correct index to insert the CSS into
- var index = 0;
- var lastC = 0;
- args[0].replace(/%[a-z%]/g, function(match) {
- if ('%%' === match) return;
- index++;
- if ('%c' === match) {
- // we only are interested in the *last* %c
- // (the user may have provided their own)
- lastC = index;
- }
- });
-
- args.splice(lastC, 0, c);
- return args;
-}
-
-/**
- * Invokes `console.log()` when available.
- * No-op when `console.log` is not a "function".
- *
- * @api public
- */
-
-function log() {
- // this hackery is required for IE8/9, where
- // the `console.log` function doesn't have 'apply'
- return 'object' === typeof console
- && console.log
- && Function.prototype.apply.call(console.log, console, arguments);
-}
-
-/**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
-
-function save(namespaces) {
- try {
- if (null == namespaces) {
- exports.storage.removeItem('debug');
- } else {
- exports.storage.debug = namespaces;
- }
- } catch(e) {}
-}
-
-/**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
-
-function load() {
- var r;
- try {
- r = exports.storage.debug;
- } catch(e) {}
- return r;
-}
-
-/**
- * Enable namespaces listed in `localStorage.debug` initially.
- */
-
-exports.enable(load());
-
-/**
- * Localstorage attempts to return the localstorage.
- *
- * This is necessary because safari throws
- * when a user disables cookies/localstorage
- * and you attempt to access it.
- *
- * @return {LocalStorage}
- * @api private
- */
-
-function localstorage(){
- try {
- return window.localStorage;
- } catch (e) {}
-}
-
-},{"./debug":11}],11:[function(_dereq_,module,exports){
-
-/**
- * This is the common logic for both the Node.js and web browser
- * implementations of `debug()`.
- *
- * Expose `debug()` as the module.
- */
-
-exports = module.exports = debug;
-exports.coerce = coerce;
-exports.disable = disable;
-exports.enable = enable;
-exports.enabled = enabled;
-
-/**
- * The currently active debug mode names, and names to skip.
- */
-
-exports.names = [];
-exports.skips = [];
-
-/**
- * Map of special "%n" handling functions, for the debug "format" argument.
- *
- * Valid key names are a single, lowercased letter, i.e. "n".
- */
-
-exports.formatters = {};
-
-/**
- * Previously assigned color.
- */
-
-var prevColor = 0;
-
-/**
- * Select a color.
- *
- * @return {Number}
- * @api private
- */
-
-function selectColor() {
- return exports.colors[prevColor++ % exports.colors.length];
-}
-
-/**
- * Create a debugger with the given `namespace`.
- *
- * @param {String} namespace
- * @return {Function}
- * @api public
- */
-
-function debug(namespace) {
-
- // define the `disabled` version
- function disabled() {
- }
- disabled.enabled = false;
-
- // define the `enabled` version
- function enabled() {
-
- var self = enabled;
-
- // add the `color` if not set
- if (null == self.useColors) self.useColors = exports.useColors();
- if (null == self.color && self.useColors) self.color = selectColor();
-
- var args = Array.prototype.slice.call(arguments);
-
- args[0] = exports.coerce(args[0]);
-
- if ('string' !== typeof args[0]) {
- // anything else let's inspect with %o
- args = ['%o'].concat(args);
- }
-
- // apply any `formatters` transformations
- var index = 0;
- args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
- // if we encounter an escaped % then don't increase the array index
- if (match === '%%') return match;
- index++;
- var formatter = exports.formatters[format];
- if ('function' === typeof formatter) {
- var val = args[index];
- match = formatter.call(self, val);
-
- // now we need to remove `args[index]` since it's inlined in the `format`
- args.splice(index, 1);
- index--;
- }
- return match;
- });
-
- if ('function' === typeof exports.formatArgs) {
- args = exports.formatArgs.apply(self, args);
- }
- var logFn = enabled.log || exports.log || console.log.bind(console);
- logFn.apply(self, args);
- }
- enabled.enabled = true;
-
- var fn = exports.enabled(namespace) ? enabled : disabled;
-
- fn.namespace = namespace;
-
- return fn;
-}
-
-/**
- * Enables a debug mode by namespaces. This can include modes
- * separated by a colon and wildcards.
- *
- * @param {String} namespaces
- * @api public
- */
-
-function enable(namespaces) {
- exports.save(namespaces);
-
- var split = (namespaces || '').split(/[\s,]+/);
- var len = split.length;
-
- for (var i = 0; i < len; i++) {
- if (!split[i]) continue; // ignore empty strings
- namespaces = split[i].replace(/\*/g, '.*?');
- if (namespaces[0] === '-') {
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
- } else {
- exports.names.push(new RegExp('^' + namespaces + '$'));
- }
- }
-}
-
-/**
- * Disable debug output.
- *
- * @api public
- */
-
-function disable() {
- exports.enable('');
-}
-
-/**
- * Returns true if the given mode name is enabled, false otherwise.
- *
- * @param {String} name
- * @return {Boolean}
- * @api public
- */
-
-function enabled(name) {
- var i, len;
- for (i = 0, len = exports.skips.length; i < len; i++) {
- if (exports.skips[i].test(name)) {
- return false;
- }
- }
- for (i = 0, len = exports.names.length; i < len; i++) {
- if (exports.names[i].test(name)) {
- return true;
- }
- }
- return false;
-}
-
-/**
- * Coerce `val`.
- *
- * @param {Mixed} val
- * @return {Mixed}
- * @api private
- */
-
-function coerce(val) {
- if (val instanceof Error) return val.stack || val.message;
- return val;
-}
-
-},{}],12:[function(_dereq_,module,exports){
'use strict';
var isObj = _dereq_('is-obj');
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Sources cannot be null or undefined');
- }
+ if (val === null || val === undefined) {
+ throw new TypeError('Sources cannot be null or undefined');
+ }
- return Object(val);
+ return Object(val);
}
function assignKey(to, from, key) {
- var val = from[key];
+ var val = from[key];
- if (val === undefined || val === null) {
- return;
- }
+ if (val === undefined || val === null) {
+ return;
+ }
- if (hasOwnProperty.call(to, key)) {
- if (to[key] === undefined || to[key] === null) {
- throw new TypeError('Cannot convert undefined or null to object (' + key + ')');
- }
- }
+ if (hasOwnProperty.call(to, key)) {
+ if (to[key] === undefined || to[key] === null) {
+ throw new TypeError('Cannot convert undefined or null to object (' + key + ')');
+ }
+ }
- if (!hasOwnProperty.call(to, key) || !isObj(val)) {
- to[key] = val;
- } else {
- to[key] = assign(Object(to[key]), from[key]);
- }
+ if (!hasOwnProperty.call(to, key) || !isObj(val)) {
+ to[key] = val;
+ } else {
+ to[key] = assign(Object(to[key]), from[key]);
+ }
}
function assign(to, from) {
- if (to === from) {
- return to;
- }
+ if (to === from) {
+ return to;
+ }
- from = Object(from);
+ from = Object(from);
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- assignKey(to, from, key);
- }
- }
+ for (var key in from) {
+ if (hasOwnProperty.call(from, key)) {
+ assignKey(to, from, key);
+ }
+ }
- if (Object.getOwnPropertySymbols) {
- var symbols = Object.getOwnPropertySymbols(from);
+ if (Object.getOwnPropertySymbols) {
+ var symbols = Object.getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- assignKey(to, from, symbols[i]);
- }
- }
- }
+ for (var i = 0; i < symbols.length; i++) {
+ if (propIsEnumerable.call(from, symbols[i])) {
+ assignKey(to, from, symbols[i]);
+ }
+ }
+ }
- return to;
+ return to;
}
module.exports = function deepAssign(target) {
- target = toObject(target);
+ target = toObject(target);
- for (var s = 1; s < arguments.length; s++) {
- assign(target, arguments[s]);
- }
+ for (var s = 1; s < arguments.length; s++) {
+ assign(target, arguments[s]);
+ }
- return target;
+ return target;
};
-},{"is-obj":22}],13:[function(_dereq_,module,exports){
-/*! (C) WebReflection Mit Style License */
-(function(t,n,r,i){"use strict";function st(e,t){for(var n=0,r=e.length;n>0),o="attached",u="detached",a="extends",f="ADDITION",l="MODIFICATION",c="REMOVAL",h="DOMAttrModified",p="DOMContentLoaded",d="DOMSubtreeModified",v="<",m="=",g=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,y=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],b=[],w=[],E="",S=n.documentElement,x=b.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},T=r.prototype,N=T.hasOwnProperty,C=T.isPrototypeOf,k=r.defineProperty,L=r.getOwnPropertyDescriptor,A=r.getOwnPropertyNames,O=r.getPrototypeOf,M=r.setPrototypeOf,_=!!r.__proto__,D=r.create||function yt(e){return e?(yt.prototype=e,new yt):this},P=M||(_?function(e,t){return e.__proto__=t,e}:A&&L?function(){function e(e,t){for(var n,r=A(t),i=0,s=r.length;i= 0)
+ if (idx >= 0)
return font.chars[idx].height
}
return 0
@@ -3202,7 +2846,7 @@ function getMGlyph(font) {
for (var i=0; i= 0)
+ if (idx >= 0)
return font.chars[idx]
}
return 0
@@ -3212,7 +2856,7 @@ function getCapHeight(font) {
for (var i=0; i= 0)
+ if (idx >= 0)
return font.chars[idx].height
}
return 0
@@ -3248,7 +2892,7 @@ function findChar (array, value, start) {
}
return -1
}
-},{"as-number":3,"word-wrapper":47,"xtend":50}],24:[function(_dereq_,module,exports){
+},{"as-number":3,"word-wrapper":44,"xtend":47}],21:[function(_dereq_,module,exports){
(function (Buffer){
var xhr = _dereq_('xhr')
var noop = function(){}
@@ -3282,7 +2926,7 @@ module.exports = function(opt, cb) {
if (!body)
return cb(new Error('no body result'))
- var binary = false
+ var binary = false
//if the response type is an array buffer,
//we need to convert it into a regular Buffer object
@@ -3296,9 +2940,9 @@ module.exports = function(opt, cb) {
if (isBinaryFormat(body)) {
binary = true
//if we have a string, turn it into a Buffer
- if (typeof body === 'string')
+ if (typeof body === 'string')
body = new Buffer(body, 'binary')
- }
+ }
//we are not parsing a binary format, just ASCII/XML/etc
if (!binary) {
@@ -3336,7 +2980,7 @@ function getBinaryOpts(opt) {
//IE10+ and other modern browsers support array buffers
if (xml2)
return xtend(opt, { responseType: 'arraybuffer' })
-
+
if (typeof self.XMLHttpRequest === 'undefined')
throw new Error('your browser does not support XHR loading')
@@ -3350,7 +2994,7 @@ function getBinaryOpts(opt) {
}).call(this,_dereq_("buffer").Buffer)
-},{"./lib/is-binary":25,"buffer":8,"parse-bmfont-ascii":27,"parse-bmfont-binary":28,"parse-bmfont-xml":29,"xhr":48,"xtend":50}],25:[function(_dereq_,module,exports){
+},{"./lib/is-binary":22,"buffer":8,"parse-bmfont-ascii":24,"parse-bmfont-binary":25,"parse-bmfont-xml":26,"xhr":45,"xtend":47}],22:[function(_dereq_,module,exports){
(function (Buffer){
var equal = _dereq_('buffer-equal')
var HEADER = new Buffer([66, 77, 70, 3])
@@ -3362,7 +3006,7 @@ module.exports = function(buf) {
}
}).call(this,_dereq_("buffer").Buffer)
-},{"buffer":8,"buffer-equal":7}],26:[function(_dereq_,module,exports){
+},{"buffer":8,"buffer-equal":7}],23:[function(_dereq_,module,exports){
/*
object-assign
(c) Sindre Sorhus
@@ -3376,85 +3020,85 @@ var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
+ if (val === null || val === undefined) {
+ throw new TypeError('Object.assign cannot be called with null or undefined');
+ }
- return Object(val);
+ return Object(val);
}
function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
+ try {
+ if (!Object.assign) {
+ return false;
+ }
- // Detect buggy property enumeration order in older V8 versions.
+ // Detect buggy property enumeration order in older V8 versions.
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
+ test1[5] = 'de';
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
+ return false;
+ }
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
+ var test2 = {};
+ for (var i = 0; i < 10; i++) {
+ test2['_' + String.fromCharCode(i)] = i;
+ }
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
+ return test2[n];
+ });
+ if (order2.join('') !== '0123456789') {
+ return false;
+ }
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
+ var test3 = {};
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
+ test3[letter] = letter;
+ });
+ if (Object.keys(Object.assign({}, test3)).join('') !==
+ 'abcdefghijklmnopqrst') {
+ return false;
+ }
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
+ return true;
+ } catch (err) {
+ // We don't expect any of the above to throw, but better to be safe.
+ return false;
+ }
}
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
+ var from;
+ var to = toObject(target);
+ var symbols;
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
+ for (var s = 1; s < arguments.length; s++) {
+ from = Object(arguments[s]);
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
+ for (var key in from) {
+ if (hasOwnProperty.call(from, key)) {
+ to[key] = from[key];
+ }
+ }
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
+ if (getOwnPropertySymbols) {
+ symbols = getOwnPropertySymbols(from);
+ for (var i = 0; i < symbols.length; i++) {
+ if (propIsEnumerable.call(from, symbols[i])) {
+ to[symbols[i]] = from[symbols[i]];
+ }
+ }
+ }
+ }
- return to;
+ return to;
};
-},{}],27:[function(_dereq_,module,exports){
+},{}],24:[function(_dereq_,module,exports){
module.exports = function parseBMFontAscii(data) {
if (!data)
throw new Error('no data provided')
@@ -3502,7 +3146,7 @@ function splitLine(line, idx) {
return null
var space = line.indexOf(' ')
- if (space === -1)
+ if (space === -1)
throw new Error("no named row at line " + idx)
var key = line.substring(0, space)
@@ -3510,7 +3154,7 @@ function splitLine(line, idx) {
line = line.substring(space + 1)
//clear "letter" field as it is non-standard and
//requires additional complexity to parse " / = symbols
- line = line.replace(/letter=[\'\"]\S+[\'\"]/gi, '')
+ line = line.replace(/letter=[\'\"]\S+[\'\"]/gi, '')
line = line.split("=")
line = line.map(function(str) {
return str.trim().match((/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g))
@@ -3563,7 +3207,7 @@ function parseIntList(data) {
return parseInt(val, 10)
})
}
-},{}],28:[function(_dereq_,module,exports){
+},{}],25:[function(_dereq_,module,exports){
var HEADER = [66, 77, 70]
module.exports = function readBMFontBinary(buf) {
@@ -3581,7 +3225,7 @@ module.exports = function readBMFontBinary(buf) {
var vers = buf.readUInt8(i++)
if (vers > 3)
throw new Error('Only supports BMFont Binary v3 (BMFont App v1.10)')
-
+
var target = { kernings: [], chars: [] }
for (var b=0; b<5; b++)
i += readBlock(target, buf, i)
@@ -3597,7 +3241,7 @@ function readBlock(target, buf, i) {
i += 4
switch(blockID) {
- case 1:
+ case 1:
target.info = readInfo(buf, i)
break
case 2:
@@ -3625,11 +3269,11 @@ function readInfo(buf, i) {
info.unicode = (bitField >> 6) & 1
info.italic = (bitField >> 5) & 1
info.bold = (bitField >> 4) & 1
-
- //fixedHeight is only mentioned in binary spec
+
+ //fixedHeight is only mentioned in binary spec
if ((bitField >> 3) & 1)
info.fixedHeight = 1
-
+
info.charset = buf.readUInt8(i+3) || ''
info.stretchH = buf.readUInt16LE(i+4)
info.aa = buf.readUInt8(i+6)
@@ -3715,7 +3359,7 @@ function readKernings(buf, i, blockSize) {
function readNameNT(buf, offset) {
var pos=offset
for (; pos 0 ) ? 1 : + x;
+ return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;
- };
+ };
- }
+ }
- if ( 'name' in Function.prototype === false ) {
+ if ( 'name' in Function.prototype === false ) {
- // Missing in IE
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
+ // Missing in IE
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
- Object.defineProperty( Function.prototype, 'name', {
+ Object.defineProperty( Function.prototype, 'name', {
- get: function () {
+ get: function () {
- return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ];
+ return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ];
- }
+ }
- } );
+ } );
- }
+ }
- if ( Object.assign === undefined ) {
+ if ( Object.assign === undefined ) {
- // Missing in IE
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
+ // Missing in IE
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
- ( function () {
+ ( function () {
- Object.assign = function ( target ) {
+ Object.assign = function ( target ) {
- if ( target === undefined || target === null ) {
+ if ( target === undefined || target === null ) {
- throw new TypeError( 'Cannot convert undefined or null to object' );
+ throw new TypeError( 'Cannot convert undefined or null to object' );
- }
+ }
- var output = Object( target );
+ var output = Object( target );
- for ( var index = 1; index < arguments.length; index ++ ) {
+ for ( var index = 1; index < arguments.length; index ++ ) {
- var source = arguments[ index ];
+ var source = arguments[ index ];
- if ( source !== undefined && source !== null ) {
+ if ( source !== undefined && source !== null ) {
- for ( var nextKey in source ) {
+ for ( var nextKey in source ) {
- if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
+ if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
- output[ nextKey ] = source[ nextKey ];
+ output[ nextKey ] = source[ nextKey ];
- }
+ }
- }
+ }
- }
+ }
- }
+ }
- return output;
+ return output;
- };
+ };
- } )();
+ } )();
- }
+ }
- /**
- * https://github.com/mrdoob/eventdispatcher.js/
- */
+ /**
+ * https://github.com/mrdoob/eventdispatcher.js/
+ */
- function EventDispatcher() {}
+ function EventDispatcher() {}
- Object.assign( EventDispatcher.prototype, {
+ Object.assign( EventDispatcher.prototype, {
- addEventListener: function ( type, listener ) {
+ addEventListener: function ( type, listener ) {
- if ( this._listeners === undefined ) this._listeners = {};
+ if ( this._listeners === undefined ) this._listeners = {};
- var listeners = this._listeners;
+ var listeners = this._listeners;
- if ( listeners[ type ] === undefined ) {
+ if ( listeners[ type ] === undefined ) {
- listeners[ type ] = [];
+ listeners[ type ] = [];
- }
+ }
- if ( listeners[ type ].indexOf( listener ) === - 1 ) {
+ if ( listeners[ type ].indexOf( listener ) === - 1 ) {
- listeners[ type ].push( listener );
+ listeners[ type ].push( listener );
- }
+ }
- },
+ },
- hasEventListener: function ( type, listener ) {
+ hasEventListener: function ( type, listener ) {
- if ( this._listeners === undefined ) return false;
+ if ( this._listeners === undefined ) return false;
- var listeners = this._listeners;
+ var listeners = this._listeners;
- return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
+ return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
- },
+ },
- removeEventListener: function ( type, listener ) {
+ removeEventListener: function ( type, listener ) {
- if ( this._listeners === undefined ) return;
+ if ( this._listeners === undefined ) return;
- var listeners = this._listeners;
- var listenerArray = listeners[ type ];
+ var listeners = this._listeners;
+ var listenerArray = listeners[ type ];
- if ( listenerArray !== undefined ) {
+ if ( listenerArray !== undefined ) {
- var index = listenerArray.indexOf( listener );
+ var index = listenerArray.indexOf( listener );
- if ( index !== - 1 ) {
+ if ( index !== - 1 ) {
- listenerArray.splice( index, 1 );
+ listenerArray.splice( index, 1 );
- }
+ }
- }
+ }
- },
+ },
- dispatchEvent: function ( event ) {
+ dispatchEvent: function ( event ) {
- if ( this._listeners === undefined ) return;
+ if ( this._listeners === undefined ) return;
- var listeners = this._listeners;
- var listenerArray = listeners[ event.type ];
+ var listeners = this._listeners;
+ var listenerArray = listeners[ event.type ];
- if ( listenerArray !== undefined ) {
+ if ( listenerArray !== undefined ) {
- event.target = this;
+ event.target = this;
- var array = listenerArray.slice( 0 );
+ var array = listenerArray.slice( 0 );
- for ( var i = 0, l = array.length; i < l; i ++ ) {
+ for ( var i = 0, l = array.length; i < l; i ++ ) {
- array[ i ].call( this, event );
+ array[ i ].call( this, event );
- }
+ }
- }
+ }
- }
+ }
- } );
-
- var REVISION = '95';
- var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
- var CullFaceNone = 0;
- var CullFaceBack = 1;
- var CullFaceFront = 2;
- var CullFaceFrontBack = 3;
- var FrontFaceDirectionCW = 0;
- var FrontFaceDirectionCCW = 1;
- var BasicShadowMap = 0;
- var PCFShadowMap = 1;
- var PCFSoftShadowMap = 2;
- var FrontSide = 0;
- var BackSide = 1;
- var DoubleSide = 2;
- var FlatShading = 1;
- var SmoothShading = 2;
- var NoColors = 0;
- var FaceColors = 1;
- var VertexColors = 2;
- var NoBlending = 0;
- var NormalBlending = 1;
- var AdditiveBlending = 2;
- var SubtractiveBlending = 3;
- var MultiplyBlending = 4;
- var CustomBlending = 5;
- var AddEquation = 100;
- var SubtractEquation = 101;
- var ReverseSubtractEquation = 102;
- var MinEquation = 103;
- var MaxEquation = 104;
- var ZeroFactor = 200;
- var OneFactor = 201;
- var SrcColorFactor = 202;
- var OneMinusSrcColorFactor = 203;
- var SrcAlphaFactor = 204;
- var OneMinusSrcAlphaFactor = 205;
- var DstAlphaFactor = 206;
- var OneMinusDstAlphaFactor = 207;
- var DstColorFactor = 208;
- var OneMinusDstColorFactor = 209;
- var SrcAlphaSaturateFactor = 210;
- var NeverDepth = 0;
- var AlwaysDepth = 1;
- var LessDepth = 2;
- var LessEqualDepth = 3;
- var EqualDepth = 4;
- var GreaterEqualDepth = 5;
- var GreaterDepth = 6;
- var NotEqualDepth = 7;
- var MultiplyOperation = 0;
- var MixOperation = 1;
- var AddOperation = 2;
- var NoToneMapping = 0;
- var LinearToneMapping = 1;
- var ReinhardToneMapping = 2;
- var Uncharted2ToneMapping = 3;
- var CineonToneMapping = 4;
- var UVMapping = 300;
- var CubeReflectionMapping = 301;
- var CubeRefractionMapping = 302;
- var EquirectangularReflectionMapping = 303;
- var EquirectangularRefractionMapping = 304;
- var SphericalReflectionMapping = 305;
- var CubeUVReflectionMapping = 306;
- var CubeUVRefractionMapping = 307;
- var RepeatWrapping = 1000;
- var ClampToEdgeWrapping = 1001;
- var MirroredRepeatWrapping = 1002;
- var NearestFilter = 1003;
- var NearestMipMapNearestFilter = 1004;
- var NearestMipMapLinearFilter = 1005;
- var LinearFilter = 1006;
- var LinearMipMapNearestFilter = 1007;
- var LinearMipMapLinearFilter = 1008;
- var UnsignedByteType = 1009;
- var ByteType = 1010;
- var ShortType = 1011;
- var UnsignedShortType = 1012;
- var IntType = 1013;
- var UnsignedIntType = 1014;
- var FloatType = 1015;
- var HalfFloatType = 1016;
- var UnsignedShort4444Type = 1017;
- var UnsignedShort5551Type = 1018;
- var UnsignedShort565Type = 1019;
- var UnsignedInt248Type = 1020;
- var AlphaFormat = 1021;
- var RGBFormat = 1022;
- var RGBAFormat = 1023;
- var LuminanceFormat = 1024;
- var LuminanceAlphaFormat = 1025;
- var RGBEFormat = RGBAFormat;
- var DepthFormat = 1026;
- var DepthStencilFormat = 1027;
- var RGB_S3TC_DXT1_Format = 33776;
- var RGBA_S3TC_DXT1_Format = 33777;
- var RGBA_S3TC_DXT3_Format = 33778;
- var RGBA_S3TC_DXT5_Format = 33779;
- var RGB_PVRTC_4BPPV1_Format = 35840;
- var RGB_PVRTC_2BPPV1_Format = 35841;
- var RGBA_PVRTC_4BPPV1_Format = 35842;
- var RGBA_PVRTC_2BPPV1_Format = 35843;
- var RGB_ETC1_Format = 36196;
- var RGBA_ASTC_4x4_Format = 37808;
- var RGBA_ASTC_5x4_Format = 37809;
- var RGBA_ASTC_5x5_Format = 37810;
- var RGBA_ASTC_6x5_Format = 37811;
- var RGBA_ASTC_6x6_Format = 37812;
- var RGBA_ASTC_8x5_Format = 37813;
- var RGBA_ASTC_8x6_Format = 37814;
- var RGBA_ASTC_8x8_Format = 37815;
- var RGBA_ASTC_10x5_Format = 37816;
- var RGBA_ASTC_10x6_Format = 37817;
- var RGBA_ASTC_10x8_Format = 37818;
- var RGBA_ASTC_10x10_Format = 37819;
- var RGBA_ASTC_12x10_Format = 37820;
- var RGBA_ASTC_12x12_Format = 37821;
- var LoopOnce = 2200;
- var LoopRepeat = 2201;
- var LoopPingPong = 2202;
- var InterpolateDiscrete = 2300;
- var InterpolateLinear = 2301;
- var InterpolateSmooth = 2302;
- var ZeroCurvatureEnding = 2400;
- var ZeroSlopeEnding = 2401;
- var WrapAroundEnding = 2402;
- var TrianglesDrawMode = 0;
- var TriangleStripDrawMode = 1;
- var TriangleFanDrawMode = 2;
- var LinearEncoding = 3000;
- var sRGBEncoding = 3001;
- var GammaEncoding = 3007;
- var RGBEEncoding = 3002;
- var LogLuvEncoding = 3003;
- var RGBM7Encoding = 3004;
- var RGBM16Encoding = 3005;
- var RGBDEncoding = 3006;
- var BasicDepthPacking = 3200;
- var RGBADepthPacking = 3201;
- var TangentSpaceNormalMap = 0;
- var ObjectSpaceNormalMap = 1;
-
- /**
- * @author alteredq / http://alteredqualia.com/
- * @author mrdoob / http://mrdoob.com/
- */
-
- var _Math = {
-
- DEG2RAD: Math.PI / 180,
- RAD2DEG: 180 / Math.PI,
-
- generateUUID: ( function () {
-
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
+ } );
+
+ var REVISION = '95';
+ var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
+ var CullFaceNone = 0;
+ var CullFaceBack = 1;
+ var CullFaceFront = 2;
+ var CullFaceFrontBack = 3;
+ var FrontFaceDirectionCW = 0;
+ var FrontFaceDirectionCCW = 1;
+ var BasicShadowMap = 0;
+ var PCFShadowMap = 1;
+ var PCFSoftShadowMap = 2;
+ var FrontSide = 0;
+ var BackSide = 1;
+ var DoubleSide = 2;
+ var FlatShading = 1;
+ var SmoothShading = 2;
+ var NoColors = 0;
+ var FaceColors = 1;
+ var VertexColors = 2;
+ var NoBlending = 0;
+ var NormalBlending = 1;
+ var AdditiveBlending = 2;
+ var SubtractiveBlending = 3;
+ var MultiplyBlending = 4;
+ var CustomBlending = 5;
+ var AddEquation = 100;
+ var SubtractEquation = 101;
+ var ReverseSubtractEquation = 102;
+ var MinEquation = 103;
+ var MaxEquation = 104;
+ var ZeroFactor = 200;
+ var OneFactor = 201;
+ var SrcColorFactor = 202;
+ var OneMinusSrcColorFactor = 203;
+ var SrcAlphaFactor = 204;
+ var OneMinusSrcAlphaFactor = 205;
+ var DstAlphaFactor = 206;
+ var OneMinusDstAlphaFactor = 207;
+ var DstColorFactor = 208;
+ var OneMinusDstColorFactor = 209;
+ var SrcAlphaSaturateFactor = 210;
+ var NeverDepth = 0;
+ var AlwaysDepth = 1;
+ var LessDepth = 2;
+ var LessEqualDepth = 3;
+ var EqualDepth = 4;
+ var GreaterEqualDepth = 5;
+ var GreaterDepth = 6;
+ var NotEqualDepth = 7;
+ var MultiplyOperation = 0;
+ var MixOperation = 1;
+ var AddOperation = 2;
+ var NoToneMapping = 0;
+ var LinearToneMapping = 1;
+ var ReinhardToneMapping = 2;
+ var Uncharted2ToneMapping = 3;
+ var CineonToneMapping = 4;
+ var UVMapping = 300;
+ var CubeReflectionMapping = 301;
+ var CubeRefractionMapping = 302;
+ var EquirectangularReflectionMapping = 303;
+ var EquirectangularRefractionMapping = 304;
+ var SphericalReflectionMapping = 305;
+ var CubeUVReflectionMapping = 306;
+ var CubeUVRefractionMapping = 307;
+ var RepeatWrapping = 1000;
+ var ClampToEdgeWrapping = 1001;
+ var MirroredRepeatWrapping = 1002;
+ var NearestFilter = 1003;
+ var NearestMipMapNearestFilter = 1004;
+ var NearestMipMapLinearFilter = 1005;
+ var LinearFilter = 1006;
+ var LinearMipMapNearestFilter = 1007;
+ var LinearMipMapLinearFilter = 1008;
+ var UnsignedByteType = 1009;
+ var ByteType = 1010;
+ var ShortType = 1011;
+ var UnsignedShortType = 1012;
+ var IntType = 1013;
+ var UnsignedIntType = 1014;
+ var FloatType = 1015;
+ var HalfFloatType = 1016;
+ var UnsignedShort4444Type = 1017;
+ var UnsignedShort5551Type = 1018;
+ var UnsignedShort565Type = 1019;
+ var UnsignedInt248Type = 1020;
+ var AlphaFormat = 1021;
+ var RGBFormat = 1022;
+ var RGBAFormat = 1023;
+ var LuminanceFormat = 1024;
+ var LuminanceAlphaFormat = 1025;
+ var RGBEFormat = RGBAFormat;
+ var DepthFormat = 1026;
+ var DepthStencilFormat = 1027;
+ var RGB_S3TC_DXT1_Format = 33776;
+ var RGBA_S3TC_DXT1_Format = 33777;
+ var RGBA_S3TC_DXT3_Format = 33778;
+ var RGBA_S3TC_DXT5_Format = 33779;
+ var RGB_PVRTC_4BPPV1_Format = 35840;
+ var RGB_PVRTC_2BPPV1_Format = 35841;
+ var RGBA_PVRTC_4BPPV1_Format = 35842;
+ var RGBA_PVRTC_2BPPV1_Format = 35843;
+ var RGB_ETC1_Format = 36196;
+ var RGBA_ASTC_4x4_Format = 37808;
+ var RGBA_ASTC_5x4_Format = 37809;
+ var RGBA_ASTC_5x5_Format = 37810;
+ var RGBA_ASTC_6x5_Format = 37811;
+ var RGBA_ASTC_6x6_Format = 37812;
+ var RGBA_ASTC_8x5_Format = 37813;
+ var RGBA_ASTC_8x6_Format = 37814;
+ var RGBA_ASTC_8x8_Format = 37815;
+ var RGBA_ASTC_10x5_Format = 37816;
+ var RGBA_ASTC_10x6_Format = 37817;
+ var RGBA_ASTC_10x8_Format = 37818;
+ var RGBA_ASTC_10x10_Format = 37819;
+ var RGBA_ASTC_12x10_Format = 37820;
+ var RGBA_ASTC_12x12_Format = 37821;
+ var LoopOnce = 2200;
+ var LoopRepeat = 2201;
+ var LoopPingPong = 2202;
+ var InterpolateDiscrete = 2300;
+ var InterpolateLinear = 2301;
+ var InterpolateSmooth = 2302;
+ var ZeroCurvatureEnding = 2400;
+ var ZeroSlopeEnding = 2401;
+ var WrapAroundEnding = 2402;
+ var TrianglesDrawMode = 0;
+ var TriangleStripDrawMode = 1;
+ var TriangleFanDrawMode = 2;
+ var LinearEncoding = 3000;
+ var sRGBEncoding = 3001;
+ var GammaEncoding = 3007;
+ var RGBEEncoding = 3002;
+ var LogLuvEncoding = 3003;
+ var RGBM7Encoding = 3004;
+ var RGBM16Encoding = 3005;
+ var RGBDEncoding = 3006;
+ var BasicDepthPacking = 3200;
+ var RGBADepthPacking = 3201;
+ var TangentSpaceNormalMap = 0;
+ var ObjectSpaceNormalMap = 1;
+
+ /**
+ * @author alteredq / http://alteredqualia.com/
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+ var _Math = {
+
+ DEG2RAD: Math.PI / 180,
+ RAD2DEG: 180 / Math.PI,
+
+ generateUUID: ( function () {
+
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
- var lut = [];
+ var lut = [];
- for ( var i = 0; i < 256; i ++ ) {
+ for ( var i = 0; i < 256; i ++ ) {
- lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );
+ lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );
- }
+ }
- return function generateUUID() {
+ return function generateUUID() {
- var d0 = Math.random() * 0xffffffff | 0;
- var d1 = Math.random() * 0xffffffff | 0;
- var d2 = Math.random() * 0xffffffff | 0;
- var d3 = Math.random() * 0xffffffff | 0;
- var uuid = lut[ d0 & 0xff ] + lut[ d0 >> 8 & 0xff ] + lut[ d0 >> 16 & 0xff ] + lut[ d0 >> 24 & 0xff ] + '-' +
- lut[ d1 & 0xff ] + lut[ d1 >> 8 & 0xff ] + '-' + lut[ d1 >> 16 & 0x0f | 0x40 ] + lut[ d1 >> 24 & 0xff ] + '-' +
- lut[ d2 & 0x3f | 0x80 ] + lut[ d2 >> 8 & 0xff ] + '-' + lut[ d2 >> 16 & 0xff ] + lut[ d2 >> 24 & 0xff ] +
- lut[ d3 & 0xff ] + lut[ d3 >> 8 & 0xff ] + lut[ d3 >> 16 & 0xff ] + lut[ d3 >> 24 & 0xff ];
+ var d0 = Math.random() * 0xffffffff | 0;
+ var d1 = Math.random() * 0xffffffff | 0;
+ var d2 = Math.random() * 0xffffffff | 0;
+ var d3 = Math.random() * 0xffffffff | 0;
+ var uuid = lut[ d0 & 0xff ] + lut[ d0 >> 8 & 0xff ] + lut[ d0 >> 16 & 0xff ] + lut[ d0 >> 24 & 0xff ] + '-' +
+ lut[ d1 & 0xff ] + lut[ d1 >> 8 & 0xff ] + '-' + lut[ d1 >> 16 & 0x0f | 0x40 ] + lut[ d1 >> 24 & 0xff ] + '-' +
+ lut[ d2 & 0x3f | 0x80 ] + lut[ d2 >> 8 & 0xff ] + '-' + lut[ d2 >> 16 & 0xff ] + lut[ d2 >> 24 & 0xff ] +
+ lut[ d3 & 0xff ] + lut[ d3 >> 8 & 0xff ] + lut[ d3 >> 16 & 0xff ] + lut[ d3 >> 24 & 0xff ];
- // .toUpperCase() here flattens concatenated strings to save heap memory space.
- return uuid.toUpperCase();
+ // .toUpperCase() here flattens concatenated strings to save heap memory space.
+ return uuid.toUpperCase();
- };
+ };
- } )(),
+ } )(),
- clamp: function ( value, min, max ) {
+ clamp: function ( value, min, max ) {
- return Math.max( min, Math.min( max, value ) );
+ return Math.max( min, Math.min( max, value ) );
- },
+ },
- // compute euclidian modulo of m % n
- // https://en.wikipedia.org/wiki/Modulo_operation
+ // compute euclidian modulo of m % n
+ // https://en.wikipedia.org/wiki/Modulo_operation
- euclideanModulo: function ( n, m ) {
+ euclideanModulo: function ( n, m ) {
- return ( ( n % m ) + m ) % m;
+ return ( ( n % m ) + m ) % m;
- },
+ },
- // Linear mapping from range to range
+ // Linear mapping from range to range
- mapLinear: function ( x, a1, a2, b1, b2 ) {
+ mapLinear: function ( x, a1, a2, b1, b2 ) {
- return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
+ return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
- },
+ },
- // https://en.wikipedia.org/wiki/Linear_interpolation
+ // https://en.wikipedia.org/wiki/Linear_interpolation
- lerp: function ( x, y, t ) {
+ lerp: function ( x, y, t ) {
- return ( 1 - t ) * x + t * y;
+ return ( 1 - t ) * x + t * y;
- },
+ },
- // http://en.wikipedia.org/wiki/Smoothstep
+ // http://en.wikipedia.org/wiki/Smoothstep
- smoothstep: function ( x, min, max ) {
+ smoothstep: function ( x, min, max ) {
- if ( x <= min ) return 0;
- if ( x >= max ) return 1;
+ if ( x <= min ) return 0;
+ if ( x >= max ) return 1;
- x = ( x - min ) / ( max - min );
+ x = ( x - min ) / ( max - min );
- return x * x * ( 3 - 2 * x );
+ return x * x * ( 3 - 2 * x );
- },
+ },
- smootherstep: function ( x, min, max ) {
+ smootherstep: function ( x, min, max ) {
- if ( x <= min ) return 0;
- if ( x >= max ) return 1;
+ if ( x <= min ) return 0;
+ if ( x >= max ) return 1;
- x = ( x - min ) / ( max - min );
+ x = ( x - min ) / ( max - min );
- return x * x * x * ( x * ( x * 6 - 15 ) + 10 );
+ return x * x * x * ( x * ( x * 6 - 15 ) + 10 );
- },
+ },
- // Random integer from interval
+ // Random integer from interval
- randInt: function ( low, high ) {
+ randInt: function ( low, high ) {
- return low + Math.floor( Math.random() * ( high - low + 1 ) );
+ return low + Math.floor( Math.random() * ( high - low + 1 ) );
- },
+ },
- // Random float from interval
+ // Random float from interval
- randFloat: function ( low, high ) {
+ randFloat: function ( low, high ) {
- return low + Math.random() * ( high - low );
+ return low + Math.random() * ( high - low );
- },
+ },
- // Random float from <-range/2, range/2> interval
+ // Random float from <-range/2, range/2> interval
- randFloatSpread: function ( range ) {
+ randFloatSpread: function ( range ) {
- return range * ( 0.5 - Math.random() );
+ return range * ( 0.5 - Math.random() );
- },
+ },
- degToRad: function ( degrees ) {
+ degToRad: function ( degrees ) {
- return degrees * _Math.DEG2RAD;
+ return degrees * _Math.DEG2RAD;
- },
+ },
- radToDeg: function ( radians ) {
+ radToDeg: function ( radians ) {
- return radians * _Math.RAD2DEG;
+ return radians * _Math.RAD2DEG;
- },
+ },
- isPowerOfTwo: function ( value ) {
+ isPowerOfTwo: function ( value ) {
- return ( value & ( value - 1 ) ) === 0 && value !== 0;
+ return ( value & ( value - 1 ) ) === 0 && value !== 0;
- },
+ },
- ceilPowerOfTwo: function ( value ) {
+ ceilPowerOfTwo: function ( value ) {
- return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );
+ return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );
- },
+ },
- floorPowerOfTwo: function ( value ) {
+ floorPowerOfTwo: function ( value ) {
- return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
+ return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
- }
+ }
- };
+ };
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author philogb / http://blog.thejit.org/
- * @author egraether / http://egraether.com/
- * @author zz85 / http://www.lab4games.net/zz85/blog
- */
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author philogb / http://blog.thejit.org/
+ * @author egraether / http://egraether.com/
+ * @author zz85 / http://www.lab4games.net/zz85/blog
+ */
- function Vector2( x, y ) {
+ function Vector2( x, y ) {
- this.x = x || 0;
- this.y = y || 0;
+ this.x = x || 0;
+ this.y = y || 0;
- }
+ }
- Object.defineProperties( Vector2.prototype, {
+ Object.defineProperties( Vector2.prototype, {
- "width": {
+ "width": {
- get: function () {
+ get: function () {
- return this.x;
+ return this.x;
- },
+ },
- set: function ( value ) {
+ set: function ( value ) {
- this.x = value;
+ this.x = value;
- }
+ }
- },
+ },
- "height": {
+ "height": {
- get: function () {
+ get: function () {
- return this.y;
+ return this.y;
- },
+ },
- set: function ( value ) {
+ set: function ( value ) {
- this.y = value;
+ this.y = value;
- }
+ }
- }
+ }
- } );
+ } );
- Object.assign( Vector2.prototype, {
+ Object.assign( Vector2.prototype, {
- isVector2: true,
+ isVector2: true,
- set: function ( x, y ) {
+ set: function ( x, y ) {
- this.x = x;
- this.y = y;
+ this.x = x;
+ this.y = y;
- return this;
+ return this;
- },
+ },
- setScalar: function ( scalar ) {
+ setScalar: function ( scalar ) {
- this.x = scalar;
- this.y = scalar;
+ this.x = scalar;
+ this.y = scalar;
- return this;
+ return this;
- },
+ },
- setX: function ( x ) {
+ setX: function ( x ) {
- this.x = x;
+ this.x = x;
- return this;
+ return this;
- },
+ },
- setY: function ( y ) {
+ setY: function ( y ) {
- this.y = y;
+ this.y = y;
- return this;
+ return this;
- },
+ },
- setComponent: function ( index, value ) {
+ setComponent: function ( index, value ) {
- switch ( index ) {
+ switch ( index ) {
- case 0: this.x = value; break;
- case 1: this.y = value; break;
- default: throw new Error( 'index is out of range: ' + index );
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
- }
+ }
- return this;
+ return this;
- },
+ },
- getComponent: function ( index ) {
+ getComponent: function ( index ) {
- switch ( index ) {
+ switch ( index ) {
- case 0: return this.x;
- case 1: return this.y;
- default: throw new Error( 'index is out of range: ' + index );
+ case 0: return this.x;
+ case 1: return this.y;
+ default: throw new Error( 'index is out of range: ' + index );
- }
+ }
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor( this.x, this.y );
+ return new this.constructor( this.x, this.y );
- },
+ },
- copy: function ( v ) {
+ copy: function ( v ) {
- this.x = v.x;
- this.y = v.y;
+ this.x = v.x;
+ this.y = v.y;
- return this;
+ return this;
- },
+ },
- add: function ( v, w ) {
+ add: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
- return this.addVectors( v, w );
+ console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
- }
+ }
- this.x += v.x;
- this.y += v.y;
+ this.x += v.x;
+ this.y += v.y;
- return this;
+ return this;
- },
+ },
- addScalar: function ( s ) {
+ addScalar: function ( s ) {
- this.x += s;
- this.y += s;
+ this.x += s;
+ this.y += s;
- return this;
+ return this;
- },
+ },
- addVectors: function ( a, b ) {
+ addVectors: function ( a, b ) {
- this.x = a.x + b.x;
- this.y = a.y + b.y;
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
- return this;
+ return this;
- },
+ },
- addScaledVector: function ( v, s ) {
+ addScaledVector: function ( v, s ) {
- this.x += v.x * s;
- this.y += v.y * s;
+ this.x += v.x * s;
+ this.y += v.y * s;
- return this;
+ return this;
- },
+ },
- sub: function ( v, w ) {
+ sub: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
- return this.subVectors( v, w );
+ console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
- }
+ }
- this.x -= v.x;
- this.y -= v.y;
+ this.x -= v.x;
+ this.y -= v.y;
- return this;
+ return this;
- },
+ },
- subScalar: function ( s ) {
+ subScalar: function ( s ) {
- this.x -= s;
- this.y -= s;
+ this.x -= s;
+ this.y -= s;
- return this;
+ return this;
- },
+ },
- subVectors: function ( a, b ) {
+ subVectors: function ( a, b ) {
- this.x = a.x - b.x;
- this.y = a.y - b.y;
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
- return this;
+ return this;
- },
+ },
- multiply: function ( v ) {
+ multiply: function ( v ) {
- this.x *= v.x;
- this.y *= v.y;
+ this.x *= v.x;
+ this.y *= v.y;
- return this;
+ return this;
- },
+ },
- multiplyScalar: function ( scalar ) {
+ multiplyScalar: function ( scalar ) {
- this.x *= scalar;
- this.y *= scalar;
+ this.x *= scalar;
+ this.y *= scalar;
- return this;
+ return this;
- },
+ },
- divide: function ( v ) {
+ divide: function ( v ) {
- this.x /= v.x;
- this.y /= v.y;
+ this.x /= v.x;
+ this.y /= v.y;
- return this;
+ return this;
- },
+ },
- divideScalar: function ( scalar ) {
+ divideScalar: function ( scalar ) {
- return this.multiplyScalar( 1 / scalar );
+ return this.multiplyScalar( 1 / scalar );
- },
+ },
- applyMatrix3: function ( m ) {
+ applyMatrix3: function ( m ) {
- var x = this.x, y = this.y;
- var e = m.elements;
+ var x = this.x, y = this.y;
+ var e = m.elements;
- this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];
- this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];
+ this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];
+ this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];
- return this;
+ return this;
- },
+ },
- min: function ( v ) {
+ min: function ( v ) {
- this.x = Math.min( this.x, v.x );
- this.y = Math.min( this.y, v.y );
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
- return this;
+ return this;
- },
+ },
- max: function ( v ) {
+ max: function ( v ) {
- this.x = Math.max( this.x, v.x );
- this.y = Math.max( this.y, v.y );
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
- return this;
+ return this;
- },
+ },
- clamp: function ( min, max ) {
+ clamp: function ( min, max ) {
- // assumes min < max, componentwise
+ // assumes min < max, componentwise
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
- return this;
+ return this;
- },
+ },
- clampScalar: function () {
+ clampScalar: function () {
- var min = new Vector2();
- var max = new Vector2();
+ var min = new Vector2();
+ var max = new Vector2();
- return function clampScalar( minVal, maxVal ) {
+ return function clampScalar( minVal, maxVal ) {
- min.set( minVal, minVal );
- max.set( maxVal, maxVal );
+ min.set( minVal, minVal );
+ max.set( maxVal, maxVal );
- return this.clamp( min, max );
+ return this.clamp( min, max );
- };
+ };
- }(),
+ }(),
- clampLength: function ( min, max ) {
+ clampLength: function ( min, max ) {
- var length = this.length();
+ var length = this.length();
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
- },
+ },
- floor: function () {
+ floor: function () {
- this.x = Math.floor( this.x );
- this.y = Math.floor( this.y );
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
- return this;
+ return this;
- },
+ },
- ceil: function () {
+ ceil: function () {
- this.x = Math.ceil( this.x );
- this.y = Math.ceil( this.y );
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
- return this;
+ return this;
- },
+ },
- round: function () {
+ round: function () {
- this.x = Math.round( this.x );
- this.y = Math.round( this.y );
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
- return this;
+ return this;
- },
+ },
- roundToZero: function () {
+ roundToZero: function () {
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
- return this;
+ return this;
- },
+ },
- negate: function () {
+ negate: function () {
- this.x = - this.x;
- this.y = - this.y;
+ this.x = - this.x;
+ this.y = - this.y;
- return this;
+ return this;
- },
+ },
- dot: function ( v ) {
+ dot: function ( v ) {
- return this.x * v.x + this.y * v.y;
+ return this.x * v.x + this.y * v.y;
- },
+ },
- cross: function ( v ) {
+ cross: function ( v ) {
- return this.x * v.y - this.y * v.x;
+ return this.x * v.y - this.y * v.x;
- },
+ },
- lengthSq: function () {
+ lengthSq: function () {
- return this.x * this.x + this.y * this.y;
+ return this.x * this.x + this.y * this.y;
- },
+ },
- length: function () {
+ length: function () {
- return Math.sqrt( this.x * this.x + this.y * this.y );
+ return Math.sqrt( this.x * this.x + this.y * this.y );
- },
+ },
- manhattanLength: function () {
+ manhattanLength: function () {
- return Math.abs( this.x ) + Math.abs( this.y );
+ return Math.abs( this.x ) + Math.abs( this.y );
- },
+ },
- normalize: function () {
+ normalize: function () {
- return this.divideScalar( this.length() || 1 );
+ return this.divideScalar( this.length() || 1 );
- },
+ },
- angle: function () {
+ angle: function () {
- // computes the angle in radians with respect to the positive x-axis
+ // computes the angle in radians with respect to the positive x-axis
- var angle = Math.atan2( this.y, this.x );
+ var angle = Math.atan2( this.y, this.x );
- if ( angle < 0 ) angle += 2 * Math.PI;
+ if ( angle < 0 ) angle += 2 * Math.PI;
- return angle;
+ return angle;
- },
+ },
- distanceTo: function ( v ) {
+ distanceTo: function ( v ) {
- return Math.sqrt( this.distanceToSquared( v ) );
+ return Math.sqrt( this.distanceToSquared( v ) );
- },
+ },
- distanceToSquared: function ( v ) {
+ distanceToSquared: function ( v ) {
- var dx = this.x - v.x, dy = this.y - v.y;
- return dx * dx + dy * dy;
+ var dx = this.x - v.x, dy = this.y - v.y;
+ return dx * dx + dy * dy;
- },
+ },
- manhattanDistanceTo: function ( v ) {
+ manhattanDistanceTo: function ( v ) {
- return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
+ return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
- },
+ },
- setLength: function ( length ) {
+ setLength: function ( length ) {
- return this.normalize().multiplyScalar( length );
+ return this.normalize().multiplyScalar( length );
- },
+ },
- lerp: function ( v, alpha ) {
+ lerp: function ( v, alpha ) {
- this.x += ( v.x - this.x ) * alpha;
- this.y += ( v.y - this.y ) * alpha;
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
- return this;
+ return this;
- },
+ },
- lerpVectors: function ( v1, v2, alpha ) {
+ lerpVectors: function ( v1, v2, alpha ) {
- return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+ return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
- },
+ },
- equals: function ( v ) {
+ equals: function ( v ) {
- return ( ( v.x === this.x ) && ( v.y === this.y ) );
+ return ( ( v.x === this.x ) && ( v.y === this.y ) );
- },
+ },
- fromArray: function ( array, offset ) {
+ fromArray: function ( array, offset ) {
- if ( offset === undefined ) offset = 0;
+ if ( offset === undefined ) offset = 0;
- this.x = array[ offset ];
- this.y = array[ offset + 1 ];
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
- return this;
+ return this;
- },
+ },
- toArray: function ( array, offset ) {
+ toArray: function ( array, offset ) {
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- array[ offset ] = this.x;
- array[ offset + 1 ] = this.y;
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
- return array;
+ return array;
- },
+ },
- fromBufferAttribute: function ( attribute, index, offset ) {
+ fromBufferAttribute: function ( attribute, index, offset ) {
- if ( offset !== undefined ) {
+ if ( offset !== undefined ) {
- console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );
+ console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );
- }
+ }
- this.x = attribute.getX( index );
- this.y = attribute.getY( index );
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
- return this;
+ return this;
- },
+ },
- rotateAround: function ( center, angle ) {
+ rotateAround: function ( center, angle ) {
- var c = Math.cos( angle ), s = Math.sin( angle );
+ var c = Math.cos( angle ), s = Math.sin( angle );
- var x = this.x - center.x;
- var y = this.y - center.y;
+ var x = this.x - center.x;
+ var y = this.y - center.y;
- this.x = x * c - y * s + center.x;
- this.y = x * s + y * c + center.y;
+ this.x = x * c - y * s + center.x;
+ this.y = x * s + y * c + center.y;
- return this;
+ return this;
- }
+ }
- } );
+ } );
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author supereggbert / http://www.paulbrunt.co.uk/
- * @author philogb / http://blog.thejit.org/
- * @author jordi_ros / http://plattsoft.com
- * @author D1plo1d / http://github.com/D1plo1d
- * @author alteredq / http://alteredqualia.com/
- * @author mikael emtinger / http://gomo.se/
- * @author timknip / http://www.floorplanner.com/
- * @author bhouston / http://clara.io
- * @author WestLangley / http://github.com/WestLangley
- */
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author supereggbert / http://www.paulbrunt.co.uk/
+ * @author philogb / http://blog.thejit.org/
+ * @author jordi_ros / http://plattsoft.com
+ * @author D1plo1d / http://github.com/D1plo1d
+ * @author alteredq / http://alteredqualia.com/
+ * @author mikael emtinger / http://gomo.se/
+ * @author timknip / http://www.floorplanner.com/
+ * @author bhouston / http://clara.io
+ * @author WestLangley / http://github.com/WestLangley
+ */
- function Matrix4() {
+ function Matrix4() {
- this.elements = [
+ this.elements = [
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
- ];
+ ];
- if ( arguments.length > 0 ) {
+ if ( arguments.length > 0 ) {
- console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
+ console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
- }
+ }
- }
+ }
- Object.assign( Matrix4.prototype, {
+ Object.assign( Matrix4.prototype, {
- isMatrix4: true,
+ isMatrix4: true,
- set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
+ set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
- var te = this.elements;
+ var te = this.elements;
- te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;
- te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;
- te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;
- te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;
+ te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;
+ te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;
+ te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;
+ te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;
- return this;
+ return this;
- },
+ },
- identity: function () {
+ identity: function () {
- this.set(
+ this.set(
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- clone: function () {
+ clone: function () {
- return new Matrix4().fromArray( this.elements );
+ return new Matrix4().fromArray( this.elements );
- },
+ },
- copy: function ( m ) {
+ copy: function ( m ) {
- var te = this.elements;
- var me = m.elements;
+ var te = this.elements;
+ var me = m.elements;
- te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];
- te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];
- te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];
- te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];
+ te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];
+ te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];
+ te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];
+ te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];
- return this;
+ return this;
- },
+ },
- copyPosition: function ( m ) {
+ copyPosition: function ( m ) {
- var te = this.elements, me = m.elements;
+ var te = this.elements, me = m.elements;
- te[ 12 ] = me[ 12 ];
- te[ 13 ] = me[ 13 ];
- te[ 14 ] = me[ 14 ];
+ te[ 12 ] = me[ 12 ];
+ te[ 13 ] = me[ 13 ];
+ te[ 14 ] = me[ 14 ];
- return this;
+ return this;
- },
+ },
- extractBasis: function ( xAxis, yAxis, zAxis ) {
+ extractBasis: function ( xAxis, yAxis, zAxis ) {
- xAxis.setFromMatrixColumn( this, 0 );
- yAxis.setFromMatrixColumn( this, 1 );
- zAxis.setFromMatrixColumn( this, 2 );
+ xAxis.setFromMatrixColumn( this, 0 );
+ yAxis.setFromMatrixColumn( this, 1 );
+ zAxis.setFromMatrixColumn( this, 2 );
- return this;
+ return this;
- },
+ },
- makeBasis: function ( xAxis, yAxis, zAxis ) {
+ makeBasis: function ( xAxis, yAxis, zAxis ) {
- this.set(
- xAxis.x, yAxis.x, zAxis.x, 0,
- xAxis.y, yAxis.y, zAxis.y, 0,
- xAxis.z, yAxis.z, zAxis.z, 0,
- 0, 0, 0, 1
- );
+ this.set(
+ xAxis.x, yAxis.x, zAxis.x, 0,
+ xAxis.y, yAxis.y, zAxis.y, 0,
+ xAxis.z, yAxis.z, zAxis.z, 0,
+ 0, 0, 0, 1
+ );
- return this;
+ return this;
- },
+ },
- extractRotation: function () {
+ extractRotation: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function extractRotation( m ) {
+ return function extractRotation( m ) {
- // this method does not support reflection matrices
+ // this method does not support reflection matrices
- var te = this.elements;
- var me = m.elements;
+ var te = this.elements;
+ var me = m.elements;
- var scaleX = 1 / v1.setFromMatrixColumn( m, 0 ).length();
- var scaleY = 1 / v1.setFromMatrixColumn( m, 1 ).length();
- var scaleZ = 1 / v1.setFromMatrixColumn( m, 2 ).length();
+ var scaleX = 1 / v1.setFromMatrixColumn( m, 0 ).length();
+ var scaleY = 1 / v1.setFromMatrixColumn( m, 1 ).length();
+ var scaleZ = 1 / v1.setFromMatrixColumn( m, 2 ).length();
- te[ 0 ] = me[ 0 ] * scaleX;
- te[ 1 ] = me[ 1 ] * scaleX;
- te[ 2 ] = me[ 2 ] * scaleX;
- te[ 3 ] = 0;
+ te[ 0 ] = me[ 0 ] * scaleX;
+ te[ 1 ] = me[ 1 ] * scaleX;
+ te[ 2 ] = me[ 2 ] * scaleX;
+ te[ 3 ] = 0;
- te[ 4 ] = me[ 4 ] * scaleY;
- te[ 5 ] = me[ 5 ] * scaleY;
- te[ 6 ] = me[ 6 ] * scaleY;
- te[ 7 ] = 0;
+ te[ 4 ] = me[ 4 ] * scaleY;
+ te[ 5 ] = me[ 5 ] * scaleY;
+ te[ 6 ] = me[ 6 ] * scaleY;
+ te[ 7 ] = 0;
- te[ 8 ] = me[ 8 ] * scaleZ;
- te[ 9 ] = me[ 9 ] * scaleZ;
- te[ 10 ] = me[ 10 ] * scaleZ;
- te[ 11 ] = 0;
+ te[ 8 ] = me[ 8 ] * scaleZ;
+ te[ 9 ] = me[ 9 ] * scaleZ;
+ te[ 10 ] = me[ 10 ] * scaleZ;
+ te[ 11 ] = 0;
- te[ 12 ] = 0;
- te[ 13 ] = 0;
- te[ 14 ] = 0;
- te[ 15 ] = 1;
+ te[ 12 ] = 0;
+ te[ 13 ] = 0;
+ te[ 14 ] = 0;
+ te[ 15 ] = 1;
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- makeRotationFromEuler: function ( euler ) {
+ makeRotationFromEuler: function ( euler ) {
- if ( ! ( euler && euler.isEuler ) ) {
+ if ( ! ( euler && euler.isEuler ) ) {
- console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );
+ console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );
- }
+ }
- var te = this.elements;
+ var te = this.elements;
- var x = euler.x, y = euler.y, z = euler.z;
- var a = Math.cos( x ), b = Math.sin( x );
- var c = Math.cos( y ), d = Math.sin( y );
- var e = Math.cos( z ), f = Math.sin( z );
+ var x = euler.x, y = euler.y, z = euler.z;
+ var a = Math.cos( x ), b = Math.sin( x );
+ var c = Math.cos( y ), d = Math.sin( y );
+ var e = Math.cos( z ), f = Math.sin( z );
- if ( euler.order === 'XYZ' ) {
+ if ( euler.order === 'XYZ' ) {
- var ae = a * e, af = a * f, be = b * e, bf = b * f;
+ var ae = a * e, af = a * f, be = b * e, bf = b * f;
- te[ 0 ] = c * e;
- te[ 4 ] = - c * f;
- te[ 8 ] = d;
+ te[ 0 ] = c * e;
+ te[ 4 ] = - c * f;
+ te[ 8 ] = d;
- te[ 1 ] = af + be * d;
- te[ 5 ] = ae - bf * d;
- te[ 9 ] = - b * c;
+ te[ 1 ] = af + be * d;
+ te[ 5 ] = ae - bf * d;
+ te[ 9 ] = - b * c;
- te[ 2 ] = bf - ae * d;
- te[ 6 ] = be + af * d;
- te[ 10 ] = a * c;
+ te[ 2 ] = bf - ae * d;
+ te[ 6 ] = be + af * d;
+ te[ 10 ] = a * c;
- } else if ( euler.order === 'YXZ' ) {
+ } else if ( euler.order === 'YXZ' ) {
- var ce = c * e, cf = c * f, de = d * e, df = d * f;
+ var ce = c * e, cf = c * f, de = d * e, df = d * f;
- te[ 0 ] = ce + df * b;
- te[ 4 ] = de * b - cf;
- te[ 8 ] = a * d;
+ te[ 0 ] = ce + df * b;
+ te[ 4 ] = de * b - cf;
+ te[ 8 ] = a * d;
- te[ 1 ] = a * f;
- te[ 5 ] = a * e;
- te[ 9 ] = - b;
+ te[ 1 ] = a * f;
+ te[ 5 ] = a * e;
+ te[ 9 ] = - b;
- te[ 2 ] = cf * b - de;
- te[ 6 ] = df + ce * b;
- te[ 10 ] = a * c;
+ te[ 2 ] = cf * b - de;
+ te[ 6 ] = df + ce * b;
+ te[ 10 ] = a * c;
- } else if ( euler.order === 'ZXY' ) {
+ } else if ( euler.order === 'ZXY' ) {
- var ce = c * e, cf = c * f, de = d * e, df = d * f;
+ var ce = c * e, cf = c * f, de = d * e, df = d * f;
- te[ 0 ] = ce - df * b;
- te[ 4 ] = - a * f;
- te[ 8 ] = de + cf * b;
+ te[ 0 ] = ce - df * b;
+ te[ 4 ] = - a * f;
+ te[ 8 ] = de + cf * b;
- te[ 1 ] = cf + de * b;
- te[ 5 ] = a * e;
- te[ 9 ] = df - ce * b;
+ te[ 1 ] = cf + de * b;
+ te[ 5 ] = a * e;
+ te[ 9 ] = df - ce * b;
- te[ 2 ] = - a * d;
- te[ 6 ] = b;
- te[ 10 ] = a * c;
+ te[ 2 ] = - a * d;
+ te[ 6 ] = b;
+ te[ 10 ] = a * c;
- } else if ( euler.order === 'ZYX' ) {
+ } else if ( euler.order === 'ZYX' ) {
- var ae = a * e, af = a * f, be = b * e, bf = b * f;
+ var ae = a * e, af = a * f, be = b * e, bf = b * f;
- te[ 0 ] = c * e;
- te[ 4 ] = be * d - af;
- te[ 8 ] = ae * d + bf;
+ te[ 0 ] = c * e;
+ te[ 4 ] = be * d - af;
+ te[ 8 ] = ae * d + bf;
- te[ 1 ] = c * f;
- te[ 5 ] = bf * d + ae;
- te[ 9 ] = af * d - be;
+ te[ 1 ] = c * f;
+ te[ 5 ] = bf * d + ae;
+ te[ 9 ] = af * d - be;
- te[ 2 ] = - d;
- te[ 6 ] = b * c;
- te[ 10 ] = a * c;
+ te[ 2 ] = - d;
+ te[ 6 ] = b * c;
+ te[ 10 ] = a * c;
- } else if ( euler.order === 'YZX' ) {
+ } else if ( euler.order === 'YZX' ) {
- var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+ var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
- te[ 0 ] = c * e;
- te[ 4 ] = bd - ac * f;
- te[ 8 ] = bc * f + ad;
+ te[ 0 ] = c * e;
+ te[ 4 ] = bd - ac * f;
+ te[ 8 ] = bc * f + ad;
- te[ 1 ] = f;
- te[ 5 ] = a * e;
- te[ 9 ] = - b * e;
+ te[ 1 ] = f;
+ te[ 5 ] = a * e;
+ te[ 9 ] = - b * e;
- te[ 2 ] = - d * e;
- te[ 6 ] = ad * f + bc;
- te[ 10 ] = ac - bd * f;
+ te[ 2 ] = - d * e;
+ te[ 6 ] = ad * f + bc;
+ te[ 10 ] = ac - bd * f;
- } else if ( euler.order === 'XZY' ) {
+ } else if ( euler.order === 'XZY' ) {
- var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+ var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
- te[ 0 ] = c * e;
- te[ 4 ] = - f;
- te[ 8 ] = d * e;
+ te[ 0 ] = c * e;
+ te[ 4 ] = - f;
+ te[ 8 ] = d * e;
- te[ 1 ] = ac * f + bd;
- te[ 5 ] = a * e;
- te[ 9 ] = ad * f - bc;
+ te[ 1 ] = ac * f + bd;
+ te[ 5 ] = a * e;
+ te[ 9 ] = ad * f - bc;
- te[ 2 ] = bc * f - ad;
- te[ 6 ] = b * e;
- te[ 10 ] = bd * f + ac;
+ te[ 2 ] = bc * f - ad;
+ te[ 6 ] = b * e;
+ te[ 10 ] = bd * f + ac;
- }
+ }
- // bottom row
- te[ 3 ] = 0;
- te[ 7 ] = 0;
- te[ 11 ] = 0;
+ // bottom row
+ te[ 3 ] = 0;
+ te[ 7 ] = 0;
+ te[ 11 ] = 0;
- // last column
- te[ 12 ] = 0;
- te[ 13 ] = 0;
- te[ 14 ] = 0;
- te[ 15 ] = 1;
+ // last column
+ te[ 12 ] = 0;
+ te[ 13 ] = 0;
+ te[ 14 ] = 0;
+ te[ 15 ] = 1;
- return this;
+ return this;
- },
+ },
- makeRotationFromQuaternion: function () {
+ makeRotationFromQuaternion: function () {
- var zero = new Vector3( 0, 0, 0 );
- var one = new Vector3( 1, 1, 1 );
+ var zero = new Vector3( 0, 0, 0 );
+ var one = new Vector3( 1, 1, 1 );
- return function makeRotationFromQuaternion( q ) {
+ return function makeRotationFromQuaternion( q ) {
- return this.compose( zero, q, one );
+ return this.compose( zero, q, one );
- };
+ };
- }(),
+ }(),
- lookAt: function () {
+ lookAt: function () {
- var x = new Vector3();
- var y = new Vector3();
- var z = new Vector3();
+ var x = new Vector3();
+ var y = new Vector3();
+ var z = new Vector3();
- return function lookAt( eye, target, up ) {
+ return function lookAt( eye, target, up ) {
- var te = this.elements;
+ var te = this.elements;
- z.subVectors( eye, target );
+ z.subVectors( eye, target );
- if ( z.lengthSq() === 0 ) {
+ if ( z.lengthSq() === 0 ) {
- // eye and target are in the same position
+ // eye and target are in the same position
- z.z = 1;
+ z.z = 1;
- }
+ }
- z.normalize();
- x.crossVectors( up, z );
+ z.normalize();
+ x.crossVectors( up, z );
- if ( x.lengthSq() === 0 ) {
+ if ( x.lengthSq() === 0 ) {
- // up and z are parallel
+ // up and z are parallel
- if ( Math.abs( up.z ) === 1 ) {
+ if ( Math.abs( up.z ) === 1 ) {
- z.x += 0.0001;
+ z.x += 0.0001;
- } else {
+ } else {
- z.z += 0.0001;
+ z.z += 0.0001;
- }
+ }
- z.normalize();
- x.crossVectors( up, z );
+ z.normalize();
+ x.crossVectors( up, z );
- }
+ }
- x.normalize();
- y.crossVectors( z, x );
+ x.normalize();
+ y.crossVectors( z, x );
- te[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x;
- te[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y;
- te[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z;
+ te[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x;
+ te[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y;
+ te[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z;
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- multiply: function ( m, n ) {
+ multiply: function ( m, n ) {
- if ( n !== undefined ) {
+ if ( n !== undefined ) {
- console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );
- return this.multiplyMatrices( m, n );
+ console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );
+ return this.multiplyMatrices( m, n );
- }
+ }
- return this.multiplyMatrices( this, m );
+ return this.multiplyMatrices( this, m );
- },
+ },
- premultiply: function ( m ) {
+ premultiply: function ( m ) {
- return this.multiplyMatrices( m, this );
+ return this.multiplyMatrices( m, this );
- },
+ },
- multiplyMatrices: function ( a, b ) {
+ multiplyMatrices: function ( a, b ) {
- var ae = a.elements;
- var be = b.elements;
- var te = this.elements;
+ var ae = a.elements;
+ var be = b.elements;
+ var te = this.elements;
- var a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];
- var a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];
- var a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];
- var a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];
+ var a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];
+ var a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];
+ var a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];
+ var a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];
- var b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];
- var b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];
- var b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];
- var b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];
+ var b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];
+ var b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];
+ var b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];
+ var b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];
- te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
- te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
- te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
- te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
+ te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
+ te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
+ te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
+ te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
- te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
- te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
- te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
- te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
+ te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
+ te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
+ te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
+ te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
- te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
- te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
- te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
- te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
+ te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
+ te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
+ te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
+ te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
- te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
- te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
- te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
- te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
+ te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
+ te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
+ te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
+ te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
- return this;
+ return this;
- },
+ },
- multiplyScalar: function ( s ) {
+ multiplyScalar: function ( s ) {
- var te = this.elements;
+ var te = this.elements;
- te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;
- te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;
- te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;
- te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;
+ te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;
+ te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;
+ te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;
+ te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;
- return this;
+ return this;
- },
+ },
- applyToBufferAttribute: function () {
+ applyToBufferAttribute: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function applyToBufferAttribute( attribute ) {
+ return function applyToBufferAttribute( attribute ) {
- for ( var i = 0, l = attribute.count; i < l; i ++ ) {
+ for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- v1.x = attribute.getX( i );
- v1.y = attribute.getY( i );
- v1.z = attribute.getZ( i );
+ v1.x = attribute.getX( i );
+ v1.y = attribute.getY( i );
+ v1.z = attribute.getZ( i );
- v1.applyMatrix4( this );
+ v1.applyMatrix4( this );
- attribute.setXYZ( i, v1.x, v1.y, v1.z );
+ attribute.setXYZ( i, v1.x, v1.y, v1.z );
- }
+ }
- return attribute;
+ return attribute;
- };
+ };
- }(),
+ }(),
- determinant: function () {
+ determinant: function () {
- var te = this.elements;
+ var te = this.elements;
- var n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];
- var n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];
- var n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];
- var n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];
+ var n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];
+ var n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];
+ var n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];
+ var n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];
- //TODO: make this more efficient
- //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
+ //TODO: make this more efficient
+ //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
- return (
- n41 * (
- + n14 * n23 * n32
- - n13 * n24 * n32
- - n14 * n22 * n33
- + n12 * n24 * n33
- + n13 * n22 * n34
- - n12 * n23 * n34
- ) +
- n42 * (
- + n11 * n23 * n34
- - n11 * n24 * n33
- + n14 * n21 * n33
- - n13 * n21 * n34
- + n13 * n24 * n31
- - n14 * n23 * n31
- ) +
- n43 * (
- + n11 * n24 * n32
- - n11 * n22 * n34
- - n14 * n21 * n32
- + n12 * n21 * n34
- + n14 * n22 * n31
- - n12 * n24 * n31
- ) +
- n44 * (
- - n13 * n22 * n31
- - n11 * n23 * n32
- + n11 * n22 * n33
- + n13 * n21 * n32
- - n12 * n21 * n33
- + n12 * n23 * n31
- )
+ return (
+ n41 * (
+ + n14 * n23 * n32
+ - n13 * n24 * n32
+ - n14 * n22 * n33
+ + n12 * n24 * n33
+ + n13 * n22 * n34
+ - n12 * n23 * n34
+ ) +
+ n42 * (
+ + n11 * n23 * n34
+ - n11 * n24 * n33
+ + n14 * n21 * n33
+ - n13 * n21 * n34
+ + n13 * n24 * n31
+ - n14 * n23 * n31
+ ) +
+ n43 * (
+ + n11 * n24 * n32
+ - n11 * n22 * n34
+ - n14 * n21 * n32
+ + n12 * n21 * n34
+ + n14 * n22 * n31
+ - n12 * n24 * n31
+ ) +
+ n44 * (
+ - n13 * n22 * n31
+ - n11 * n23 * n32
+ + n11 * n22 * n33
+ + n13 * n21 * n32
+ - n12 * n21 * n33
+ + n12 * n23 * n31
+ )
- );
+ );
- },
+ },
- transpose: function () {
+ transpose: function () {
- var te = this.elements;
- var tmp;
+ var te = this.elements;
+ var tmp;
- tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;
- tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;
- tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;
+ tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;
+ tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;
+ tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;
- tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;
- tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;
- tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;
+ tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;
+ tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;
+ tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;
- return this;
+ return this;
- },
+ },
- setPosition: function ( v ) {
+ setPosition: function ( v ) {
- var te = this.elements;
+ var te = this.elements;
- te[ 12 ] = v.x;
- te[ 13 ] = v.y;
- te[ 14 ] = v.z;
+ te[ 12 ] = v.x;
+ te[ 13 ] = v.y;
+ te[ 14 ] = v.z;
- return this;
+ return this;
- },
+ },
- getInverse: function ( m, throwOnDegenerate ) {
+ getInverse: function ( m, throwOnDegenerate ) {
- // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
- var te = this.elements,
- me = m.elements,
+ // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
+ var te = this.elements,
+ me = m.elements,
- n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],
- n12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],
- n13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],
- n14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],
+ n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],
+ n12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],
+ n13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],
+ n14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],
- t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
- t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
- t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
- t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
+ t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
+ t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
+ t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
+ t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
- var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
+ var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
- if ( det === 0 ) {
+ if ( det === 0 ) {
- var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
+ var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
- if ( throwOnDegenerate === true ) {
+ if ( throwOnDegenerate === true ) {
- throw new Error( msg );
+ throw new Error( msg );
- } else {
+ } else {
- console.warn( msg );
+ console.warn( msg );
- }
+ }
- return this.identity();
+ return this.identity();
- }
+ }
- var detInv = 1 / det;
+ var detInv = 1 / det;
- te[ 0 ] = t11 * detInv;
- te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;
- te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;
- te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;
+ te[ 0 ] = t11 * detInv;
+ te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;
+ te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;
+ te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;
- te[ 4 ] = t12 * detInv;
- te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;
- te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;
- te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;
+ te[ 4 ] = t12 * detInv;
+ te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;
+ te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;
+ te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;
- te[ 8 ] = t13 * detInv;
- te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;
- te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;
- te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;
+ te[ 8 ] = t13 * detInv;
+ te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;
+ te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;
+ te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;
- te[ 12 ] = t14 * detInv;
- te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;
- te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;
- te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;
+ te[ 12 ] = t14 * detInv;
+ te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;
+ te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;
+ te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;
- return this;
+ return this;
- },
+ },
- scale: function ( v ) {
+ scale: function ( v ) {
- var te = this.elements;
- var x = v.x, y = v.y, z = v.z;
+ var te = this.elements;
+ var x = v.x, y = v.y, z = v.z;
- te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;
- te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;
- te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;
- te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;
+ te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;
+ te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;
+ te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;
+ te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;
- return this;
+ return this;
- },
+ },
- getMaxScaleOnAxis: function () {
+ getMaxScaleOnAxis: function () {
- var te = this.elements;
+ var te = this.elements;
- var scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];
- var scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];
- var scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];
+ var scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];
+ var scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];
+ var scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];
- return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );
+ return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );
- },
+ },
- makeTranslation: function ( x, y, z ) {
+ makeTranslation: function ( x, y, z ) {
- this.set(
+ this.set(
- 1, 0, 0, x,
- 0, 1, 0, y,
- 0, 0, 1, z,
- 0, 0, 0, 1
+ 1, 0, 0, x,
+ 0, 1, 0, y,
+ 0, 0, 1, z,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- makeRotationX: function ( theta ) {
+ makeRotationX: function ( theta ) {
- var c = Math.cos( theta ), s = Math.sin( theta );
+ var c = Math.cos( theta ), s = Math.sin( theta );
- this.set(
+ this.set(
- 1, 0, 0, 0,
- 0, c, - s, 0,
- 0, s, c, 0,
- 0, 0, 0, 1
+ 1, 0, 0, 0,
+ 0, c, - s, 0,
+ 0, s, c, 0,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- makeRotationY: function ( theta ) {
+ makeRotationY: function ( theta ) {
- var c = Math.cos( theta ), s = Math.sin( theta );
+ var c = Math.cos( theta ), s = Math.sin( theta );
- this.set(
+ this.set(
- c, 0, s, 0,
- 0, 1, 0, 0,
- - s, 0, c, 0,
- 0, 0, 0, 1
+ c, 0, s, 0,
+ 0, 1, 0, 0,
+ - s, 0, c, 0,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- makeRotationZ: function ( theta ) {
+ makeRotationZ: function ( theta ) {
- var c = Math.cos( theta ), s = Math.sin( theta );
+ var c = Math.cos( theta ), s = Math.sin( theta );
- this.set(
+ this.set(
- c, - s, 0, 0,
- s, c, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
+ c, - s, 0, 0,
+ s, c, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- makeRotationAxis: function ( axis, angle ) {
+ makeRotationAxis: function ( axis, angle ) {
- // Based on http://www.gamedev.net/reference/articles/article1199.asp
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
- var c = Math.cos( angle );
- var s = Math.sin( angle );
- var t = 1 - c;
- var x = axis.x, y = axis.y, z = axis.z;
- var tx = t * x, ty = t * y;
+ var c = Math.cos( angle );
+ var s = Math.sin( angle );
+ var t = 1 - c;
+ var x = axis.x, y = axis.y, z = axis.z;
+ var tx = t * x, ty = t * y;
- this.set(
+ this.set(
- tx * x + c, tx * y - s * z, tx * z + s * y, 0,
- tx * y + s * z, ty * y + c, ty * z - s * x, 0,
- tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
- 0, 0, 0, 1
+ tx * x + c, tx * y - s * z, tx * z + s * y, 0,
+ tx * y + s * z, ty * y + c, ty * z - s * x, 0,
+ tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- makeScale: function ( x, y, z ) {
+ makeScale: function ( x, y, z ) {
- this.set(
+ this.set(
- x, 0, 0, 0,
- 0, y, 0, 0,
- 0, 0, z, 0,
- 0, 0, 0, 1
+ x, 0, 0, 0,
+ 0, y, 0, 0,
+ 0, 0, z, 0,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- makeShear: function ( x, y, z ) {
+ makeShear: function ( x, y, z ) {
- this.set(
+ this.set(
- 1, y, z, 0,
- x, 1, z, 0,
- x, y, 1, 0,
- 0, 0, 0, 1
+ 1, y, z, 0,
+ x, 1, z, 0,
+ x, y, 1, 0,
+ 0, 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- compose: function ( position, quaternion, scale ) {
+ compose: function ( position, quaternion, scale ) {
- var te = this.elements;
+ var te = this.elements;
- var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
- var x2 = x + x, y2 = y + y, z2 = z + z;
- var xx = x * x2, xy = x * y2, xz = x * z2;
- var yy = y * y2, yz = y * z2, zz = z * z2;
- var wx = w * x2, wy = w * y2, wz = w * z2;
+ var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
+ var x2 = x + x, y2 = y + y, z2 = z + z;
+ var xx = x * x2, xy = x * y2, xz = x * z2;
+ var yy = y * y2, yz = y * z2, zz = z * z2;
+ var wx = w * x2, wy = w * y2, wz = w * z2;
- var sx = scale.x, sy = scale.y, sz = scale.z;
+ var sx = scale.x, sy = scale.y, sz = scale.z;
- te[ 0 ] = ( 1 - ( yy + zz ) ) * sx;
- te[ 1 ] = ( xy + wz ) * sx;
- te[ 2 ] = ( xz - wy ) * sx;
- te[ 3 ] = 0;
+ te[ 0 ] = ( 1 - ( yy + zz ) ) * sx;
+ te[ 1 ] = ( xy + wz ) * sx;
+ te[ 2 ] = ( xz - wy ) * sx;
+ te[ 3 ] = 0;
- te[ 4 ] = ( xy - wz ) * sy;
- te[ 5 ] = ( 1 - ( xx + zz ) ) * sy;
- te[ 6 ] = ( yz + wx ) * sy;
- te[ 7 ] = 0;
+ te[ 4 ] = ( xy - wz ) * sy;
+ te[ 5 ] = ( 1 - ( xx + zz ) ) * sy;
+ te[ 6 ] = ( yz + wx ) * sy;
+ te[ 7 ] = 0;
- te[ 8 ] = ( xz + wy ) * sz;
- te[ 9 ] = ( yz - wx ) * sz;
- te[ 10 ] = ( 1 - ( xx + yy ) ) * sz;
- te[ 11 ] = 0;
+ te[ 8 ] = ( xz + wy ) * sz;
+ te[ 9 ] = ( yz - wx ) * sz;
+ te[ 10 ] = ( 1 - ( xx + yy ) ) * sz;
+ te[ 11 ] = 0;
- te[ 12 ] = position.x;
- te[ 13 ] = position.y;
- te[ 14 ] = position.z;
- te[ 15 ] = 1;
+ te[ 12 ] = position.x;
+ te[ 13 ] = position.y;
+ te[ 14 ] = position.z;
+ te[ 15 ] = 1;
- return this;
+ return this;
- },
+ },
- decompose: function () {
+ decompose: function () {
- var vector = new Vector3();
- var matrix = new Matrix4();
+ var vector = new Vector3();
+ var matrix = new Matrix4();
- return function decompose( position, quaternion, scale ) {
+ return function decompose( position, quaternion, scale ) {
- var te = this.elements;
+ var te = this.elements;
- var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
- var sy = vector.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
- var sz = vector.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
+ var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
+ var sy = vector.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
+ var sz = vector.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
- // if determine is negative, we need to invert one scale
- var det = this.determinant();
- if ( det < 0 ) sx = - sx;
+ // if determine is negative, we need to invert one scale
+ var det = this.determinant();
+ if ( det < 0 ) sx = - sx;
- position.x = te[ 12 ];
- position.y = te[ 13 ];
- position.z = te[ 14 ];
+ position.x = te[ 12 ];
+ position.y = te[ 13 ];
+ position.z = te[ 14 ];
- // scale the rotation part
- matrix.copy( this );
+ // scale the rotation part
+ matrix.copy( this );
- var invSX = 1 / sx;
- var invSY = 1 / sy;
- var invSZ = 1 / sz;
+ var invSX = 1 / sx;
+ var invSY = 1 / sy;
+ var invSZ = 1 / sz;
- matrix.elements[ 0 ] *= invSX;
- matrix.elements[ 1 ] *= invSX;
- matrix.elements[ 2 ] *= invSX;
+ matrix.elements[ 0 ] *= invSX;
+ matrix.elements[ 1 ] *= invSX;
+ matrix.elements[ 2 ] *= invSX;
- matrix.elements[ 4 ] *= invSY;
- matrix.elements[ 5 ] *= invSY;
- matrix.elements[ 6 ] *= invSY;
+ matrix.elements[ 4 ] *= invSY;
+ matrix.elements[ 5 ] *= invSY;
+ matrix.elements[ 6 ] *= invSY;
- matrix.elements[ 8 ] *= invSZ;
- matrix.elements[ 9 ] *= invSZ;
- matrix.elements[ 10 ] *= invSZ;
+ matrix.elements[ 8 ] *= invSZ;
+ matrix.elements[ 9 ] *= invSZ;
+ matrix.elements[ 10 ] *= invSZ;
- quaternion.setFromRotationMatrix( matrix );
+ quaternion.setFromRotationMatrix( matrix );
- scale.x = sx;
- scale.y = sy;
- scale.z = sz;
+ scale.x = sx;
+ scale.y = sy;
+ scale.z = sz;
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- makePerspective: function ( left, right, top, bottom, near, far ) {
+ makePerspective: function ( left, right, top, bottom, near, far ) {
- if ( far === undefined ) {
+ if ( far === undefined ) {
- console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );
+ console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );
- }
+ }
- var te = this.elements;
- var x = 2 * near / ( right - left );
- var y = 2 * near / ( top - bottom );
+ var te = this.elements;
+ var x = 2 * near / ( right - left );
+ var y = 2 * near / ( top - bottom );
- var a = ( right + left ) / ( right - left );
- var b = ( top + bottom ) / ( top - bottom );
- var c = - ( far + near ) / ( far - near );
- var d = - 2 * far * near / ( far - near );
+ var a = ( right + left ) / ( right - left );
+ var b = ( top + bottom ) / ( top - bottom );
+ var c = - ( far + near ) / ( far - near );
+ var d = - 2 * far * near / ( far - near );
- te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0;
- te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0;
- te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
- te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0;
+ te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0;
+ te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0;
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
+ te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0;
- return this;
+ return this;
- },
+ },
- makeOrthographic: function ( left, right, top, bottom, near, far ) {
+ makeOrthographic: function ( left, right, top, bottom, near, far ) {
- var te = this.elements;
- var w = 1.0 / ( right - left );
- var h = 1.0 / ( top - bottom );
- var p = 1.0 / ( far - near );
+ var te = this.elements;
+ var w = 1.0 / ( right - left );
+ var h = 1.0 / ( top - bottom );
+ var p = 1.0 / ( far - near );
- var x = ( right + left ) * w;
- var y = ( top + bottom ) * h;
- var z = ( far + near ) * p;
+ var x = ( right + left ) * w;
+ var y = ( top + bottom ) * h;
+ var z = ( far + near ) * p;
- te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x;
- te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y;
- te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 * p; te[ 14 ] = - z;
- te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
+ te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x;
+ te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y;
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 * p; te[ 14 ] = - z;
+ te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
- return this;
+ return this;
- },
+ },
- equals: function ( matrix ) {
+ equals: function ( matrix ) {
- var te = this.elements;
- var me = matrix.elements;
+ var te = this.elements;
+ var me = matrix.elements;
- for ( var i = 0; i < 16; i ++ ) {
+ for ( var i = 0; i < 16; i ++ ) {
- if ( te[ i ] !== me[ i ] ) return false;
+ if ( te[ i ] !== me[ i ] ) return false;
- }
+ }
- return true;
+ return true;
- },
+ },
- fromArray: function ( array, offset ) {
+ fromArray: function ( array, offset ) {
- if ( offset === undefined ) offset = 0;
+ if ( offset === undefined ) offset = 0;
- for ( var i = 0; i < 16; i ++ ) {
+ for ( var i = 0; i < 16; i ++ ) {
- this.elements[ i ] = array[ i + offset ];
+ this.elements[ i ] = array[ i + offset ];
- }
+ }
- return this;
+ return this;
- },
+ },
- toArray: function ( array, offset ) {
+ toArray: function ( array, offset ) {
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- var te = this.elements;
+ var te = this.elements;
- array[ offset ] = te[ 0 ];
- array[ offset + 1 ] = te[ 1 ];
- array[ offset + 2 ] = te[ 2 ];
- array[ offset + 3 ] = te[ 3 ];
+ array[ offset ] = te[ 0 ];
+ array[ offset + 1 ] = te[ 1 ];
+ array[ offset + 2 ] = te[ 2 ];
+ array[ offset + 3 ] = te[ 3 ];
- array[ offset + 4 ] = te[ 4 ];
- array[ offset + 5 ] = te[ 5 ];
- array[ offset + 6 ] = te[ 6 ];
- array[ offset + 7 ] = te[ 7 ];
+ array[ offset + 4 ] = te[ 4 ];
+ array[ offset + 5 ] = te[ 5 ];
+ array[ offset + 6 ] = te[ 6 ];
+ array[ offset + 7 ] = te[ 7 ];
- array[ offset + 8 ] = te[ 8 ];
- array[ offset + 9 ] = te[ 9 ];
- array[ offset + 10 ] = te[ 10 ];
- array[ offset + 11 ] = te[ 11 ];
+ array[ offset + 8 ] = te[ 8 ];
+ array[ offset + 9 ] = te[ 9 ];
+ array[ offset + 10 ] = te[ 10 ];
+ array[ offset + 11 ] = te[ 11 ];
- array[ offset + 12 ] = te[ 12 ];
- array[ offset + 13 ] = te[ 13 ];
- array[ offset + 14 ] = te[ 14 ];
- array[ offset + 15 ] = te[ 15 ];
+ array[ offset + 12 ] = te[ 12 ];
+ array[ offset + 13 ] = te[ 13 ];
+ array[ offset + 14 ] = te[ 14 ];
+ array[ offset + 15 ] = te[ 15 ];
- return array;
+ return array;
- }
+ }
- } );
+ } );
- /**
- * @author mikael emtinger / http://gomo.se/
- * @author alteredq / http://alteredqualia.com/
- * @author WestLangley / http://github.com/WestLangley
- * @author bhouston / http://clara.io
- */
+ /**
+ * @author mikael emtinger / http://gomo.se/
+ * @author alteredq / http://alteredqualia.com/
+ * @author WestLangley / http://github.com/WestLangley
+ * @author bhouston / http://clara.io
+ */
- function Quaternion( x, y, z, w ) {
+ function Quaternion( x, y, z, w ) {
- this._x = x || 0;
- this._y = y || 0;
- this._z = z || 0;
- this._w = ( w !== undefined ) ? w : 1;
+ this._x = x || 0;
+ this._y = y || 0;
+ this._z = z || 0;
+ this._w = ( w !== undefined ) ? w : 1;
- }
+ }
- Object.assign( Quaternion, {
+ Object.assign( Quaternion, {
- slerp: function ( qa, qb, qm, t ) {
+ slerp: function ( qa, qb, qm, t ) {
- return qm.copy( qa ).slerp( qb, t );
+ return qm.copy( qa ).slerp( qb, t );
- },
+ },
- slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
+ slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
- // fuzz-free, array-based Quaternion SLERP operation
+ // fuzz-free, array-based Quaternion SLERP operation
- var x0 = src0[ srcOffset0 + 0 ],
- y0 = src0[ srcOffset0 + 1 ],
- z0 = src0[ srcOffset0 + 2 ],
- w0 = src0[ srcOffset0 + 3 ],
+ var x0 = src0[ srcOffset0 + 0 ],
+ y0 = src0[ srcOffset0 + 1 ],
+ z0 = src0[ srcOffset0 + 2 ],
+ w0 = src0[ srcOffset0 + 3 ],
- x1 = src1[ srcOffset1 + 0 ],
- y1 = src1[ srcOffset1 + 1 ],
- z1 = src1[ srcOffset1 + 2 ],
- w1 = src1[ srcOffset1 + 3 ];
+ x1 = src1[ srcOffset1 + 0 ],
+ y1 = src1[ srcOffset1 + 1 ],
+ z1 = src1[ srcOffset1 + 2 ],
+ w1 = src1[ srcOffset1 + 3 ];
- if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
+ if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
- var s = 1 - t,
+ var s = 1 - t,
- cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
+ cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
- dir = ( cos >= 0 ? 1 : - 1 ),
- sqrSin = 1 - cos * cos;
+ dir = ( cos >= 0 ? 1 : - 1 ),
+ sqrSin = 1 - cos * cos;
- // Skip the Slerp for tiny steps to avoid numeric problems:
- if ( sqrSin > Number.EPSILON ) {
+ // Skip the Slerp for tiny steps to avoid numeric problems:
+ if ( sqrSin > Number.EPSILON ) {
- var sin = Math.sqrt( sqrSin ),
- len = Math.atan2( sin, cos * dir );
+ var sin = Math.sqrt( sqrSin ),
+ len = Math.atan2( sin, cos * dir );
- s = Math.sin( s * len ) / sin;
- t = Math.sin( t * len ) / sin;
+ s = Math.sin( s * len ) / sin;
+ t = Math.sin( t * len ) / sin;
- }
+ }
- var tDir = t * dir;
+ var tDir = t * dir;
- x0 = x0 * s + x1 * tDir;
- y0 = y0 * s + y1 * tDir;
- z0 = z0 * s + z1 * tDir;
- w0 = w0 * s + w1 * tDir;
+ x0 = x0 * s + x1 * tDir;
+ y0 = y0 * s + y1 * tDir;
+ z0 = z0 * s + z1 * tDir;
+ w0 = w0 * s + w1 * tDir;
- // Normalize in case we just did a lerp:
- if ( s === 1 - t ) {
+ // Normalize in case we just did a lerp:
+ if ( s === 1 - t ) {
- var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
+ var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
- x0 *= f;
- y0 *= f;
- z0 *= f;
- w0 *= f;
+ x0 *= f;
+ y0 *= f;
+ z0 *= f;
+ w0 *= f;
- }
+ }
- }
+ }
- dst[ dstOffset ] = x0;
- dst[ dstOffset + 1 ] = y0;
- dst[ dstOffset + 2 ] = z0;
- dst[ dstOffset + 3 ] = w0;
+ dst[ dstOffset ] = x0;
+ dst[ dstOffset + 1 ] = y0;
+ dst[ dstOffset + 2 ] = z0;
+ dst[ dstOffset + 3 ] = w0;
- }
+ }
- } );
+ } );
- Object.defineProperties( Quaternion.prototype, {
+ Object.defineProperties( Quaternion.prototype, {
- x: {
+ x: {
- get: function () {
+ get: function () {
- return this._x;
+ return this._x;
- },
+ },
- set: function ( value ) {
+ set: function ( value ) {
- this._x = value;
- this.onChangeCallback();
+ this._x = value;
+ this.onChangeCallback();
- }
+ }
- },
+ },
- y: {
+ y: {
- get: function () {
+ get: function () {
- return this._y;
+ return this._y;
- },
+ },
- set: function ( value ) {
+ set: function ( value ) {
- this._y = value;
- this.onChangeCallback();
+ this._y = value;
+ this.onChangeCallback();
- }
+ }
- },
+ },
- z: {
+ z: {
- get: function () {
+ get: function () {
- return this._z;
+ return this._z;
- },
+ },
- set: function ( value ) {
+ set: function ( value ) {
- this._z = value;
- this.onChangeCallback();
+ this._z = value;
+ this.onChangeCallback();
- }
+ }
- },
+ },
- w: {
+ w: {
- get: function () {
+ get: function () {
- return this._w;
+ return this._w;
- },
+ },
- set: function ( value ) {
+ set: function ( value ) {
- this._w = value;
- this.onChangeCallback();
+ this._w = value;
+ this.onChangeCallback();
- }
+ }
- }
+ }
- } );
+ } );
- Object.assign( Quaternion.prototype, {
+ Object.assign( Quaternion.prototype, {
- set: function ( x, y, z, w ) {
+ set: function ( x, y, z, w ) {
- this._x = x;
- this._y = y;
- this._z = z;
- this._w = w;
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor( this._x, this._y, this._z, this._w );
+ return new this.constructor( this._x, this._y, this._z, this._w );
- },
+ },
- copy: function ( quaternion ) {
+ copy: function ( quaternion ) {
- this._x = quaternion.x;
- this._y = quaternion.y;
- this._z = quaternion.z;
- this._w = quaternion.w;
+ this._x = quaternion.x;
+ this._y = quaternion.y;
+ this._z = quaternion.z;
+ this._w = quaternion.w;
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- setFromEuler: function ( euler, update ) {
+ setFromEuler: function ( euler, update ) {
- if ( ! ( euler && euler.isEuler ) ) {
+ if ( ! ( euler && euler.isEuler ) ) {
- throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );
+ throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );
- }
+ }
- var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
+ var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
- // http://www.mathworks.com/matlabcentral/fileexchange/
- // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
- // content/SpinCalc.m
+ // http://www.mathworks.com/matlabcentral/fileexchange/
+ // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
+ // content/SpinCalc.m
- var cos = Math.cos;
- var sin = Math.sin;
+ var cos = Math.cos;
+ var sin = Math.sin;
- var c1 = cos( x / 2 );
- var c2 = cos( y / 2 );
- var c3 = cos( z / 2 );
+ var c1 = cos( x / 2 );
+ var c2 = cos( y / 2 );
+ var c3 = cos( z / 2 );
- var s1 = sin( x / 2 );
- var s2 = sin( y / 2 );
- var s3 = sin( z / 2 );
+ var s1 = sin( x / 2 );
+ var s2 = sin( y / 2 );
+ var s3 = sin( z / 2 );
- if ( order === 'XYZ' ) {
+ if ( order === 'XYZ' ) {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
- } else if ( order === 'YXZ' ) {
+ } else if ( order === 'YXZ' ) {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
- } else if ( order === 'ZXY' ) {
+ } else if ( order === 'ZXY' ) {
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
- } else if ( order === 'ZYX' ) {
+ } else if ( order === 'ZYX' ) {
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
- } else if ( order === 'YZX' ) {
+ } else if ( order === 'YZX' ) {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
- } else if ( order === 'XZY' ) {
+ } else if ( order === 'XZY' ) {
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
- }
+ }
- if ( update !== false ) this.onChangeCallback();
+ if ( update !== false ) this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- setFromAxisAngle: function ( axis, angle ) {
+ setFromAxisAngle: function ( axis, angle ) {
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
- // assumes axis is normalized
+ // assumes axis is normalized
- var halfAngle = angle / 2, s = Math.sin( halfAngle );
+ var halfAngle = angle / 2, s = Math.sin( halfAngle );
- this._x = axis.x * s;
- this._y = axis.y * s;
- this._z = axis.z * s;
- this._w = Math.cos( halfAngle );
+ this._x = axis.x * s;
+ this._y = axis.y * s;
+ this._z = axis.z * s;
+ this._w = Math.cos( halfAngle );
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- setFromRotationMatrix: function ( m ) {
+ setFromRotationMatrix: function ( m ) {
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
- // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
- var te = m.elements,
+ var te = m.elements,
- m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
- m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
- m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],
+ m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
+ m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
+ m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],
- trace = m11 + m22 + m33,
- s;
+ trace = m11 + m22 + m33,
+ s;
- if ( trace > 0 ) {
+ if ( trace > 0 ) {
- s = 0.5 / Math.sqrt( trace + 1.0 );
+ s = 0.5 / Math.sqrt( trace + 1.0 );
- this._w = 0.25 / s;
- this._x = ( m32 - m23 ) * s;
- this._y = ( m13 - m31 ) * s;
- this._z = ( m21 - m12 ) * s;
+ this._w = 0.25 / s;
+ this._x = ( m32 - m23 ) * s;
+ this._y = ( m13 - m31 ) * s;
+ this._z = ( m21 - m12 ) * s;
- } else if ( m11 > m22 && m11 > m33 ) {
+ } else if ( m11 > m22 && m11 > m33 ) {
- s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
+ s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
- this._w = ( m32 - m23 ) / s;
- this._x = 0.25 * s;
- this._y = ( m12 + m21 ) / s;
- this._z = ( m13 + m31 ) / s;
+ this._w = ( m32 - m23 ) / s;
+ this._x = 0.25 * s;
+ this._y = ( m12 + m21 ) / s;
+ this._z = ( m13 + m31 ) / s;
- } else if ( m22 > m33 ) {
+ } else if ( m22 > m33 ) {
- s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
+ s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
- this._w = ( m13 - m31 ) / s;
- this._x = ( m12 + m21 ) / s;
- this._y = 0.25 * s;
- this._z = ( m23 + m32 ) / s;
+ this._w = ( m13 - m31 ) / s;
+ this._x = ( m12 + m21 ) / s;
+ this._y = 0.25 * s;
+ this._z = ( m23 + m32 ) / s;
- } else {
+ } else {
- s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
+ s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
- this._w = ( m21 - m12 ) / s;
- this._x = ( m13 + m31 ) / s;
- this._y = ( m23 + m32 ) / s;
- this._z = 0.25 * s;
+ this._w = ( m21 - m12 ) / s;
+ this._x = ( m13 + m31 ) / s;
+ this._y = ( m23 + m32 ) / s;
+ this._z = 0.25 * s;
- }
+ }
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- setFromUnitVectors: function () {
+ setFromUnitVectors: function () {
- // assumes direction vectors vFrom and vTo are normalized
+ // assumes direction vectors vFrom and vTo are normalized
- var v1 = new Vector3();
- var r;
+ var v1 = new Vector3();
+ var r;
- var EPS = 0.000001;
+ var EPS = 0.000001;
- return function setFromUnitVectors( vFrom, vTo ) {
+ return function setFromUnitVectors( vFrom, vTo ) {
- if ( v1 === undefined ) v1 = new Vector3();
+ if ( v1 === undefined ) v1 = new Vector3();
- r = vFrom.dot( vTo ) + 1;
+ r = vFrom.dot( vTo ) + 1;
- if ( r < EPS ) {
+ if ( r < EPS ) {
- r = 0;
+ r = 0;
- if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {
+ if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {
- v1.set( - vFrom.y, vFrom.x, 0 );
+ v1.set( - vFrom.y, vFrom.x, 0 );
- } else {
+ } else {
- v1.set( 0, - vFrom.z, vFrom.y );
+ v1.set( 0, - vFrom.z, vFrom.y );
- }
+ }
- } else {
+ } else {
- v1.crossVectors( vFrom, vTo );
+ v1.crossVectors( vFrom, vTo );
- }
+ }
- this._x = v1.x;
- this._y = v1.y;
- this._z = v1.z;
- this._w = r;
+ this._x = v1.x;
+ this._y = v1.y;
+ this._z = v1.z;
+ this._w = r;
- return this.normalize();
+ return this.normalize();
- };
+ };
- }(),
+ }(),
- angleTo: function ( q ) {
+ angleTo: function ( q ) {
- return 2 * Math.acos( Math.abs( _Math.clamp( this.dot( q ), - 1, 1 ) ) );
+ return 2 * Math.acos( Math.abs( _Math.clamp( this.dot( q ), - 1, 1 ) ) );
- },
+ },
- rotateTowards: function ( q, step ) {
+ rotateTowards: function ( q, step ) {
- var angle = this.angleTo( q );
+ var angle = this.angleTo( q );
- if ( angle === 0 ) return this;
+ if ( angle === 0 ) return this;
- var t = Math.min( 1, step / angle );
+ var t = Math.min( 1, step / angle );
- this.slerp( q, t );
+ this.slerp( q, t );
- return this;
+ return this;
- },
+ },
- inverse: function () {
+ inverse: function () {
- // quaternion is assumed to have unit length
+ // quaternion is assumed to have unit length
- return this.conjugate();
+ return this.conjugate();
- },
+ },
- conjugate: function () {
+ conjugate: function () {
- this._x *= - 1;
- this._y *= - 1;
- this._z *= - 1;
+ this._x *= - 1;
+ this._y *= - 1;
+ this._z *= - 1;
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- dot: function ( v ) {
+ dot: function ( v ) {
- return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
+ return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
- },
+ },
- lengthSq: function () {
+ lengthSq: function () {
- return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
- },
+ },
- length: function () {
+ length: function () {
- return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
+ return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
- },
+ },
- normalize: function () {
+ normalize: function () {
- var l = this.length();
+ var l = this.length();
- if ( l === 0 ) {
+ if ( l === 0 ) {
- this._x = 0;
- this._y = 0;
- this._z = 0;
- this._w = 1;
+ this._x = 0;
+ this._y = 0;
+ this._z = 0;
+ this._w = 1;
- } else {
+ } else {
- l = 1 / l;
+ l = 1 / l;
- this._x = this._x * l;
- this._y = this._y * l;
- this._z = this._z * l;
- this._w = this._w * l;
+ this._x = this._x * l;
+ this._y = this._y * l;
+ this._z = this._z * l;
+ this._w = this._w * l;
- }
+ }
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- multiply: function ( q, p ) {
+ multiply: function ( q, p ) {
- if ( p !== undefined ) {
+ if ( p !== undefined ) {
- console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );
- return this.multiplyQuaternions( q, p );
+ console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );
+ return this.multiplyQuaternions( q, p );
- }
+ }
- return this.multiplyQuaternions( this, q );
+ return this.multiplyQuaternions( this, q );
- },
+ },
- premultiply: function ( q ) {
+ premultiply: function ( q ) {
- return this.multiplyQuaternions( q, this );
+ return this.multiplyQuaternions( q, this );
- },
+ },
- multiplyQuaternions: function ( a, b ) {
+ multiplyQuaternions: function ( a, b ) {
- // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
+ // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
- var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
- var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
+ var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
+ var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
- this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
- this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
- this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
- this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+ this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+ this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+ this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+ this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- slerp: function ( qb, t ) {
+ slerp: function ( qb, t ) {
- if ( t === 0 ) return this;
- if ( t === 1 ) return this.copy( qb );
+ if ( t === 0 ) return this;
+ if ( t === 1 ) return this.copy( qb );
- var x = this._x, y = this._y, z = this._z, w = this._w;
+ var x = this._x, y = this._y, z = this._z, w = this._w;
- // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
+ // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
- var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
+ var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
- if ( cosHalfTheta < 0 ) {
+ if ( cosHalfTheta < 0 ) {
- this._w = - qb._w;
- this._x = - qb._x;
- this._y = - qb._y;
- this._z = - qb._z;
+ this._w = - qb._w;
+ this._x = - qb._x;
+ this._y = - qb._y;
+ this._z = - qb._z;
- cosHalfTheta = - cosHalfTheta;
+ cosHalfTheta = - cosHalfTheta;
- } else {
+ } else {
- this.copy( qb );
+ this.copy( qb );
- }
+ }
- if ( cosHalfTheta >= 1.0 ) {
+ if ( cosHalfTheta >= 1.0 ) {
- this._w = w;
- this._x = x;
- this._y = y;
- this._z = z;
+ this._w = w;
+ this._x = x;
+ this._y = y;
+ this._z = z;
- return this;
+ return this;
- }
+ }
- var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
+ var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
- if ( sqrSinHalfTheta <= Number.EPSILON ) {
+ if ( sqrSinHalfTheta <= Number.EPSILON ) {
- var s = 1 - t;
- this._w = s * w + t * this._w;
- this._x = s * x + t * this._x;
- this._y = s * y + t * this._y;
- this._z = s * z + t * this._z;
+ var s = 1 - t;
+ this._w = s * w + t * this._w;
+ this._x = s * x + t * this._x;
+ this._y = s * y + t * this._y;
+ this._z = s * z + t * this._z;
- return this.normalize();
+ return this.normalize();
- }
+ }
- var sinHalfTheta = Math.sqrt( sqrSinHalfTheta );
- var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
- var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
- ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
+ var sinHalfTheta = Math.sqrt( sqrSinHalfTheta );
+ var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
+ var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
+ ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
- this._w = ( w * ratioA + this._w * ratioB );
- this._x = ( x * ratioA + this._x * ratioB );
- this._y = ( y * ratioA + this._y * ratioB );
- this._z = ( z * ratioA + this._z * ratioB );
+ this._w = ( w * ratioA + this._w * ratioB );
+ this._x = ( x * ratioA + this._x * ratioB );
+ this._y = ( y * ratioA + this._y * ratioB );
+ this._z = ( z * ratioA + this._z * ratioB );
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- equals: function ( quaternion ) {
+ equals: function ( quaternion ) {
- return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
+ return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
- },
+ },
- fromArray: function ( array, offset ) {
+ fromArray: function ( array, offset ) {
- if ( offset === undefined ) offset = 0;
+ if ( offset === undefined ) offset = 0;
- this._x = array[ offset ];
- this._y = array[ offset + 1 ];
- this._z = array[ offset + 2 ];
- this._w = array[ offset + 3 ];
+ this._x = array[ offset ];
+ this._y = array[ offset + 1 ];
+ this._z = array[ offset + 2 ];
+ this._w = array[ offset + 3 ];
- this.onChangeCallback();
+ this.onChangeCallback();
- return this;
+ return this;
- },
+ },
- toArray: function ( array, offset ) {
+ toArray: function ( array, offset ) {
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- array[ offset ] = this._x;
- array[ offset + 1 ] = this._y;
- array[ offset + 2 ] = this._z;
- array[ offset + 3 ] = this._w;
+ array[ offset ] = this._x;
+ array[ offset + 1 ] = this._y;
+ array[ offset + 2 ] = this._z;
+ array[ offset + 3 ] = this._w;
- return array;
+ return array;
- },
+ },
- onChange: function ( callback ) {
+ onChange: function ( callback ) {
- this.onChangeCallback = callback;
+ this.onChangeCallback = callback;
- return this;
+ return this;
- },
+ },
- onChangeCallback: function () {}
+ onChangeCallback: function () {}
- } );
+ } );
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author kile / http://kile.stravaganza.org/
- * @author philogb / http://blog.thejit.org/
- * @author mikael emtinger / http://gomo.se/
- * @author egraether / http://egraether.com/
- * @author WestLangley / http://github.com/WestLangley
- */
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author kile / http://kile.stravaganza.org/
+ * @author philogb / http://blog.thejit.org/
+ * @author mikael emtinger / http://gomo.se/
+ * @author egraether / http://egraether.com/
+ * @author WestLangley / http://github.com/WestLangley
+ */
- function Vector3( x, y, z ) {
+ function Vector3( x, y, z ) {
- this.x = x || 0;
- this.y = y || 0;
- this.z = z || 0;
+ this.x = x || 0;
+ this.y = y || 0;
+ this.z = z || 0;
- }
+ }
- Object.assign( Vector3.prototype, {
+ Object.assign( Vector3.prototype, {
- isVector3: true,
+ isVector3: true,
- set: function ( x, y, z ) {
+ set: function ( x, y, z ) {
- this.x = x;
- this.y = y;
- this.z = z;
+ this.x = x;
+ this.y = y;
+ this.z = z;
- return this;
+ return this;
- },
+ },
- setScalar: function ( scalar ) {
+ setScalar: function ( scalar ) {
- this.x = scalar;
- this.y = scalar;
- this.z = scalar;
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
- return this;
+ return this;
- },
+ },
- setX: function ( x ) {
+ setX: function ( x ) {
- this.x = x;
+ this.x = x;
- return this;
+ return this;
- },
+ },
- setY: function ( y ) {
+ setY: function ( y ) {
- this.y = y;
+ this.y = y;
- return this;
+ return this;
- },
+ },
- setZ: function ( z ) {
+ setZ: function ( z ) {
- this.z = z;
+ this.z = z;
- return this;
+ return this;
- },
+ },
- setComponent: function ( index, value ) {
+ setComponent: function ( index, value ) {
- switch ( index ) {
+ switch ( index ) {
- case 0: this.x = value; break;
- case 1: this.y = value; break;
- case 2: this.z = value; break;
- default: throw new Error( 'index is out of range: ' + index );
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ case 2: this.z = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
- }
+ }
- return this;
+ return this;
- },
+ },
- getComponent: function ( index ) {
+ getComponent: function ( index ) {
- switch ( index ) {
+ switch ( index ) {
- case 0: return this.x;
- case 1: return this.y;
- case 2: return this.z;
- default: throw new Error( 'index is out of range: ' + index );
+ case 0: return this.x;
+ case 1: return this.y;
+ case 2: return this.z;
+ default: throw new Error( 'index is out of range: ' + index );
- }
+ }
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor( this.x, this.y, this.z );
+ return new this.constructor( this.x, this.y, this.z );
- },
+ },
- copy: function ( v ) {
+ copy: function ( v ) {
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
- return this;
+ return this;
- },
+ },
- add: function ( v, w ) {
+ add: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
- return this.addVectors( v, w );
+ console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
- }
+ }
- this.x += v.x;
- this.y += v.y;
- this.z += v.z;
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
- return this;
+ return this;
- },
+ },
- addScalar: function ( s ) {
+ addScalar: function ( s ) {
- this.x += s;
- this.y += s;
- this.z += s;
+ this.x += s;
+ this.y += s;
+ this.z += s;
- return this;
+ return this;
- },
+ },
- addVectors: function ( a, b ) {
+ addVectors: function ( a, b ) {
- this.x = a.x + b.x;
- this.y = a.y + b.y;
- this.z = a.z + b.z;
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
- return this;
+ return this;
- },
+ },
- addScaledVector: function ( v, s ) {
+ addScaledVector: function ( v, s ) {
- this.x += v.x * s;
- this.y += v.y * s;
- this.z += v.z * s;
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
- return this;
+ return this;
- },
+ },
- sub: function ( v, w ) {
+ sub: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
- return this.subVectors( v, w );
+ console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
- }
+ }
- this.x -= v.x;
- this.y -= v.y;
- this.z -= v.z;
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
- return this;
+ return this;
- },
+ },
- subScalar: function ( s ) {
+ subScalar: function ( s ) {
- this.x -= s;
- this.y -= s;
- this.z -= s;
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
- return this;
+ return this;
- },
+ },
- subVectors: function ( a, b ) {
+ subVectors: function ( a, b ) {
- this.x = a.x - b.x;
- this.y = a.y - b.y;
- this.z = a.z - b.z;
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
- return this;
+ return this;
- },
+ },
- multiply: function ( v, w ) {
+ multiply: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );
- return this.multiplyVectors( v, w );
+ console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );
+ return this.multiplyVectors( v, w );
- }
+ }
- this.x *= v.x;
- this.y *= v.y;
- this.z *= v.z;
+ this.x *= v.x;
+ this.y *= v.y;
+ this.z *= v.z;
- return this;
+ return this;
- },
+ },
- multiplyScalar: function ( scalar ) {
+ multiplyScalar: function ( scalar ) {
- this.x *= scalar;
- this.y *= scalar;
- this.z *= scalar;
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
- return this;
+ return this;
- },
+ },
- multiplyVectors: function ( a, b ) {
+ multiplyVectors: function ( a, b ) {
- this.x = a.x * b.x;
- this.y = a.y * b.y;
- this.z = a.z * b.z;
+ this.x = a.x * b.x;
+ this.y = a.y * b.y;
+ this.z = a.z * b.z;
- return this;
+ return this;
- },
+ },
- applyEuler: function () {
+ applyEuler: function () {
- var quaternion = new Quaternion();
+ var quaternion = new Quaternion();
- return function applyEuler( euler ) {
+ return function applyEuler( euler ) {
- if ( ! ( euler && euler.isEuler ) ) {
+ if ( ! ( euler && euler.isEuler ) ) {
- console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
+ console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
- }
+ }
- return this.applyQuaternion( quaternion.setFromEuler( euler ) );
+ return this.applyQuaternion( quaternion.setFromEuler( euler ) );
- };
+ };
- }(),
+ }(),
- applyAxisAngle: function () {
+ applyAxisAngle: function () {
- var quaternion = new Quaternion();
+ var quaternion = new Quaternion();
- return function applyAxisAngle( axis, angle ) {
+ return function applyAxisAngle( axis, angle ) {
- return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
+ return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
- };
+ };
- }(),
+ }(),
- applyMatrix3: function ( m ) {
+ applyMatrix3: function ( m ) {
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
+ var x = this.x, y = this.y, z = this.z;
+ var e = m.elements;
- this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;
- this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;
- this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;
+ this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;
+ this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;
+ this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;
- return this;
+ return this;
- },
+ },
- applyMatrix4: function ( m ) {
+ applyMatrix4: function ( m ) {
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
+ var x = this.x, y = this.y, z = this.z;
+ var e = m.elements;
- var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
+ var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
- this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
- this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
- this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
+ this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
+ this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
+ this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
- return this;
+ return this;
- },
+ },
- applyQuaternion: function ( q ) {
+ applyQuaternion: function ( q ) {
- var x = this.x, y = this.y, z = this.z;
- var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
+ var x = this.x, y = this.y, z = this.z;
+ var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
- // calculate quat * vector
+ // calculate quat * vector
- var ix = qw * x + qy * z - qz * y;
- var iy = qw * y + qz * x - qx * z;
- var iz = qw * z + qx * y - qy * x;
- var iw = - qx * x - qy * y - qz * z;
+ var ix = qw * x + qy * z - qz * y;
+ var iy = qw * y + qz * x - qx * z;
+ var iz = qw * z + qx * y - qy * x;
+ var iw = - qx * x - qy * y - qz * z;
- // calculate result * inverse quat
+ // calculate result * inverse quat
- this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
- this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
- this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
+ this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
+ this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
+ this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
- return this;
+ return this;
- },
+ },
- project: function () {
+ project: function () {
- var matrix = new Matrix4();
+ var matrix = new Matrix4();
- return function project( camera ) {
+ return function project( camera ) {
- matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
- return this.applyMatrix4( matrix );
+ matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
+ return this.applyMatrix4( matrix );
- };
+ };
- }(),
+ }(),
- unproject: function () {
+ unproject: function () {
- var matrix = new Matrix4();
+ var matrix = new Matrix4();
- return function unproject( camera ) {
+ return function unproject( camera ) {
- matrix.multiplyMatrices( camera.matrixWorld, matrix.getInverse( camera.projectionMatrix ) );
- return this.applyMatrix4( matrix );
+ matrix.multiplyMatrices( camera.matrixWorld, matrix.getInverse( camera.projectionMatrix ) );
+ return this.applyMatrix4( matrix );
- };
+ };
- }(),
+ }(),
- transformDirection: function ( m ) {
+ transformDirection: function ( m ) {
- // input: THREE.Matrix4 affine matrix
- // vector interpreted as a direction
+ // input: THREE.Matrix4 affine matrix
+ // vector interpreted as a direction
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
+ var x = this.x, y = this.y, z = this.z;
+ var e = m.elements;
- this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;
- this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;
- this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;
+ this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;
+ this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;
+ this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;
- return this.normalize();
+ return this.normalize();
- },
+ },
- divide: function ( v ) {
+ divide: function ( v ) {
- this.x /= v.x;
- this.y /= v.y;
- this.z /= v.z;
+ this.x /= v.x;
+ this.y /= v.y;
+ this.z /= v.z;
- return this;
+ return this;
- },
+ },
- divideScalar: function ( scalar ) {
+ divideScalar: function ( scalar ) {
- return this.multiplyScalar( 1 / scalar );
+ return this.multiplyScalar( 1 / scalar );
- },
+ },
- min: function ( v ) {
+ min: function ( v ) {
- this.x = Math.min( this.x, v.x );
- this.y = Math.min( this.y, v.y );
- this.z = Math.min( this.z, v.z );
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+ this.z = Math.min( this.z, v.z );
- return this;
+ return this;
- },
+ },
- max: function ( v ) {
+ max: function ( v ) {
- this.x = Math.max( this.x, v.x );
- this.y = Math.max( this.y, v.y );
- this.z = Math.max( this.z, v.z );
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+ this.z = Math.max( this.z, v.z );
- return this;
+ return this;
- },
+ },
- clamp: function ( min, max ) {
+ clamp: function ( min, max ) {
- // assumes min < max, componentwise
+ // assumes min < max, componentwise
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
- this.z = Math.max( min.z, Math.min( max.z, this.z ) );
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+ this.z = Math.max( min.z, Math.min( max.z, this.z ) );
- return this;
+ return this;
- },
+ },
- clampScalar: function () {
+ clampScalar: function () {
- var min = new Vector3();
- var max = new Vector3();
+ var min = new Vector3();
+ var max = new Vector3();
- return function clampScalar( minVal, maxVal ) {
+ return function clampScalar( minVal, maxVal ) {
- min.set( minVal, minVal, minVal );
- max.set( maxVal, maxVal, maxVal );
+ min.set( minVal, minVal, minVal );
+ max.set( maxVal, maxVal, maxVal );
- return this.clamp( min, max );
+ return this.clamp( min, max );
- };
+ };
- }(),
+ }(),
- clampLength: function ( min, max ) {
+ clampLength: function ( min, max ) {
- var length = this.length();
+ var length = this.length();
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
- },
+ },
- floor: function () {
+ floor: function () {
- this.x = Math.floor( this.x );
- this.y = Math.floor( this.y );
- this.z = Math.floor( this.z );
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+ this.z = Math.floor( this.z );
- return this;
+ return this;
- },
+ },
- ceil: function () {
+ ceil: function () {
- this.x = Math.ceil( this.x );
- this.y = Math.ceil( this.y );
- this.z = Math.ceil( this.z );
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+ this.z = Math.ceil( this.z );
- return this;
+ return this;
- },
+ },
- round: function () {
+ round: function () {
- this.x = Math.round( this.x );
- this.y = Math.round( this.y );
- this.z = Math.round( this.z );
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+ this.z = Math.round( this.z );
- return this;
+ return this;
- },
+ },
- roundToZero: function () {
+ roundToZero: function () {
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+ this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
- return this;
+ return this;
- },
+ },
- negate: function () {
+ negate: function () {
- this.x = - this.x;
- this.y = - this.y;
- this.z = - this.z;
+ this.x = - this.x;
+ this.y = - this.y;
+ this.z = - this.z;
- return this;
+ return this;
- },
+ },
- dot: function ( v ) {
+ dot: function ( v ) {
- return this.x * v.x + this.y * v.y + this.z * v.z;
+ return this.x * v.x + this.y * v.y + this.z * v.z;
- },
+ },
- // TODO lengthSquared?
+ // TODO lengthSquared?
- lengthSq: function () {
+ lengthSq: function () {
- return this.x * this.x + this.y * this.y + this.z * this.z;
+ return this.x * this.x + this.y * this.y + this.z * this.z;
- },
+ },
- length: function () {
+ length: function () {
- return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+ return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
- },
+ },
- manhattanLength: function () {
+ manhattanLength: function () {
- return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
+ return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
- },
+ },
- normalize: function () {
+ normalize: function () {
- return this.divideScalar( this.length() || 1 );
+ return this.divideScalar( this.length() || 1 );
- },
+ },
- setLength: function ( length ) {
+ setLength: function ( length ) {
- return this.normalize().multiplyScalar( length );
+ return this.normalize().multiplyScalar( length );
- },
+ },
- lerp: function ( v, alpha ) {
+ lerp: function ( v, alpha ) {
- this.x += ( v.x - this.x ) * alpha;
- this.y += ( v.y - this.y ) * alpha;
- this.z += ( v.z - this.z ) * alpha;
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+ this.z += ( v.z - this.z ) * alpha;
- return this;
+ return this;
- },
+ },
- lerpVectors: function ( v1, v2, alpha ) {
+ lerpVectors: function ( v1, v2, alpha ) {
- return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+ return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
- },
+ },
- cross: function ( v, w ) {
+ cross: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );
- return this.crossVectors( v, w );
+ console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );
+ return this.crossVectors( v, w );
- }
+ }
- return this.crossVectors( this, v );
+ return this.crossVectors( this, v );
- },
+ },
- crossVectors: function ( a, b ) {
+ crossVectors: function ( a, b ) {
- var ax = a.x, ay = a.y, az = a.z;
- var bx = b.x, by = b.y, bz = b.z;
+ var ax = a.x, ay = a.y, az = a.z;
+ var bx = b.x, by = b.y, bz = b.z;
- this.x = ay * bz - az * by;
- this.y = az * bx - ax * bz;
- this.z = ax * by - ay * bx;
+ this.x = ay * bz - az * by;
+ this.y = az * bx - ax * bz;
+ this.z = ax * by - ay * bx;
- return this;
+ return this;
- },
+ },
- projectOnVector: function ( vector ) {
+ projectOnVector: function ( vector ) {
- var scalar = vector.dot( this ) / vector.lengthSq();
+ var scalar = vector.dot( this ) / vector.lengthSq();
- return this.copy( vector ).multiplyScalar( scalar );
+ return this.copy( vector ).multiplyScalar( scalar );
- },
+ },
- projectOnPlane: function () {
+ projectOnPlane: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function projectOnPlane( planeNormal ) {
+ return function projectOnPlane( planeNormal ) {
- v1.copy( this ).projectOnVector( planeNormal );
+ v1.copy( this ).projectOnVector( planeNormal );
- return this.sub( v1 );
+ return this.sub( v1 );
- };
+ };
- }(),
+ }(),
- reflect: function () {
+ reflect: function () {
- // reflect incident vector off plane orthogonal to normal
- // normal is assumed to have unit length
+ // reflect incident vector off plane orthogonal to normal
+ // normal is assumed to have unit length
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function reflect( normal ) {
+ return function reflect( normal ) {
- return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
+ return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
- };
+ };
- }(),
+ }(),
- angleTo: function ( v ) {
+ angleTo: function ( v ) {
- var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
+ var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
- // clamp, to handle numerical problems
+ // clamp, to handle numerical problems
- return Math.acos( _Math.clamp( theta, - 1, 1 ) );
+ return Math.acos( _Math.clamp( theta, - 1, 1 ) );
- },
+ },
- distanceTo: function ( v ) {
+ distanceTo: function ( v ) {
- return Math.sqrt( this.distanceToSquared( v ) );
+ return Math.sqrt( this.distanceToSquared( v ) );
- },
+ },
- distanceToSquared: function ( v ) {
+ distanceToSquared: function ( v ) {
- var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+ var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
- return dx * dx + dy * dy + dz * dz;
+ return dx * dx + dy * dy + dz * dz;
- },
+ },
- manhattanDistanceTo: function ( v ) {
+ manhattanDistanceTo: function ( v ) {
- return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
+ return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
- },
+ },
- setFromSpherical: function ( s ) {
+ setFromSpherical: function ( s ) {
- var sinPhiRadius = Math.sin( s.phi ) * s.radius;
+ var sinPhiRadius = Math.sin( s.phi ) * s.radius;
- this.x = sinPhiRadius * Math.sin( s.theta );
- this.y = Math.cos( s.phi ) * s.radius;
- this.z = sinPhiRadius * Math.cos( s.theta );
+ this.x = sinPhiRadius * Math.sin( s.theta );
+ this.y = Math.cos( s.phi ) * s.radius;
+ this.z = sinPhiRadius * Math.cos( s.theta );
- return this;
+ return this;
- },
+ },
- setFromCylindrical: function ( c ) {
+ setFromCylindrical: function ( c ) {
- this.x = c.radius * Math.sin( c.theta );
- this.y = c.y;
- this.z = c.radius * Math.cos( c.theta );
+ this.x = c.radius * Math.sin( c.theta );
+ this.y = c.y;
+ this.z = c.radius * Math.cos( c.theta );
- return this;
+ return this;
- },
+ },
- setFromMatrixPosition: function ( m ) {
+ setFromMatrixPosition: function ( m ) {
- var e = m.elements;
+ var e = m.elements;
- this.x = e[ 12 ];
- this.y = e[ 13 ];
- this.z = e[ 14 ];
+ this.x = e[ 12 ];
+ this.y = e[ 13 ];
+ this.z = e[ 14 ];
- return this;
+ return this;
- },
+ },
- setFromMatrixScale: function ( m ) {
+ setFromMatrixScale: function ( m ) {
- var sx = this.setFromMatrixColumn( m, 0 ).length();
- var sy = this.setFromMatrixColumn( m, 1 ).length();
- var sz = this.setFromMatrixColumn( m, 2 ).length();
+ var sx = this.setFromMatrixColumn( m, 0 ).length();
+ var sy = this.setFromMatrixColumn( m, 1 ).length();
+ var sz = this.setFromMatrixColumn( m, 2 ).length();
- this.x = sx;
- this.y = sy;
- this.z = sz;
+ this.x = sx;
+ this.y = sy;
+ this.z = sz;
- return this;
+ return this;
- },
+ },
- setFromMatrixColumn: function ( m, index ) {
+ setFromMatrixColumn: function ( m, index ) {
- return this.fromArray( m.elements, index * 4 );
+ return this.fromArray( m.elements, index * 4 );
- },
+ },
- equals: function ( v ) {
+ equals: function ( v ) {
- return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
+ return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
- },
+ },
- fromArray: function ( array, offset ) {
+ fromArray: function ( array, offset ) {
- if ( offset === undefined ) offset = 0;
+ if ( offset === undefined ) offset = 0;
- this.x = array[ offset ];
- this.y = array[ offset + 1 ];
- this.z = array[ offset + 2 ];
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+ this.z = array[ offset + 2 ];
- return this;
+ return this;
- },
+ },
- toArray: function ( array, offset ) {
+ toArray: function ( array, offset ) {
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- array[ offset ] = this.x;
- array[ offset + 1 ] = this.y;
- array[ offset + 2 ] = this.z;
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+ array[ offset + 2 ] = this.z;
- return array;
+ return array;
- },
+ },
- fromBufferAttribute: function ( attribute, index, offset ) {
+ fromBufferAttribute: function ( attribute, index, offset ) {
- if ( offset !== undefined ) {
+ if ( offset !== undefined ) {
- console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );
+ console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );
- }
+ }
- this.x = attribute.getX( index );
- this.y = attribute.getY( index );
- this.z = attribute.getZ( index );
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+ this.z = attribute.getZ( index );
- return this;
+ return this;
- }
+ }
- } );
+ } );
- /**
- * @author alteredq / http://alteredqualia.com/
- * @author WestLangley / http://github.com/WestLangley
- * @author bhouston / http://clara.io
- * @author tschw
- */
+ /**
+ * @author alteredq / http://alteredqualia.com/
+ * @author WestLangley / http://github.com/WestLangley
+ * @author bhouston / http://clara.io
+ * @author tschw
+ */
- function Matrix3() {
+ function Matrix3() {
- this.elements = [
+ this.elements = [
- 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
- ];
+ ];
- if ( arguments.length > 0 ) {
+ if ( arguments.length > 0 ) {
- console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
+ console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
- }
+ }
- }
+ }
- Object.assign( Matrix3.prototype, {
+ Object.assign( Matrix3.prototype, {
- isMatrix3: true,
+ isMatrix3: true,
- set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
+ set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
- var te = this.elements;
+ var te = this.elements;
- te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;
- te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;
- te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;
+ te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;
+ te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;
+ te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;
- return this;
+ return this;
- },
+ },
- identity: function () {
+ identity: function () {
- this.set(
+ this.set(
- 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
- );
+ );
- return this;
+ return this;
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor().fromArray( this.elements );
+ return new this.constructor().fromArray( this.elements );
- },
+ },
- copy: function ( m ) {
+ copy: function ( m ) {
- var te = this.elements;
- var me = m.elements;
+ var te = this.elements;
+ var me = m.elements;
- te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];
- te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];
- te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];
+ te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];
+ te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];
+ te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];
- return this;
+ return this;
- },
+ },
- setFromMatrix4: function ( m ) {
+ setFromMatrix4: function ( m ) {
- var me = m.elements;
+ var me = m.elements;
- this.set(
+ this.set(
- me[ 0 ], me[ 4 ], me[ 8 ],
- me[ 1 ], me[ 5 ], me[ 9 ],
- me[ 2 ], me[ 6 ], me[ 10 ]
+ me[ 0 ], me[ 4 ], me[ 8 ],
+ me[ 1 ], me[ 5 ], me[ 9 ],
+ me[ 2 ], me[ 6 ], me[ 10 ]
- );
+ );
- return this;
+ return this;
- },
+ },
- applyToBufferAttribute: function () {
+ applyToBufferAttribute: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function applyToBufferAttribute( attribute ) {
+ return function applyToBufferAttribute( attribute ) {
- for ( var i = 0, l = attribute.count; i < l; i ++ ) {
+ for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- v1.x = attribute.getX( i );
- v1.y = attribute.getY( i );
- v1.z = attribute.getZ( i );
+ v1.x = attribute.getX( i );
+ v1.y = attribute.getY( i );
+ v1.z = attribute.getZ( i );
- v1.applyMatrix3( this );
+ v1.applyMatrix3( this );
- attribute.setXYZ( i, v1.x, v1.y, v1.z );
+ attribute.setXYZ( i, v1.x, v1.y, v1.z );
- }
+ }
- return attribute;
+ return attribute;
- };
+ };
- }(),
+ }(),
- multiply: function ( m ) {
+ multiply: function ( m ) {
- return this.multiplyMatrices( this, m );
+ return this.multiplyMatrices( this, m );
- },
+ },
- premultiply: function ( m ) {
+ premultiply: function ( m ) {
- return this.multiplyMatrices( m, this );
+ return this.multiplyMatrices( m, this );
- },
+ },
- multiplyMatrices: function ( a, b ) {
+ multiplyMatrices: function ( a, b ) {
- var ae = a.elements;
- var be = b.elements;
- var te = this.elements;
+ var ae = a.elements;
+ var be = b.elements;
+ var te = this.elements;
- var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];
- var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];
- var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];
+ var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];
+ var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];
+ var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];
- var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];
- var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];
- var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];
+ var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];
+ var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];
+ var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];
- te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;
- te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;
- te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;
+ te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;
+ te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;
+ te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;
- te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;
- te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;
- te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;
+ te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;
+ te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;
+ te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;
- te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;
- te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;
- te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;
+ te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;
+ te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;
+ te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;
- return this;
+ return this;
- },
+ },
- multiplyScalar: function ( s ) {
+ multiplyScalar: function ( s ) {
- var te = this.elements;
+ var te = this.elements;
- te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;
- te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;
- te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;
+ te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;
+ te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;
+ te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;
- return this;
+ return this;
- },
+ },
- determinant: function () {
+ determinant: function () {
- var te = this.elements;
+ var te = this.elements;
- var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],
- d = te[ 3 ], e = te[ 4 ], f = te[ 5 ],
- g = te[ 6 ], h = te[ 7 ], i = te[ 8 ];
+ var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],
+ d = te[ 3 ], e = te[ 4 ], f = te[ 5 ],
+ g = te[ 6 ], h = te[ 7 ], i = te[ 8 ];
- return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
+ return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
- },
+ },
- getInverse: function ( matrix, throwOnDegenerate ) {
+ getInverse: function ( matrix, throwOnDegenerate ) {
- if ( matrix && matrix.isMatrix4 ) {
+ if ( matrix && matrix.isMatrix4 ) {
- console.error( "THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument." );
+ console.error( "THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument." );
- }
+ }
- var me = matrix.elements,
- te = this.elements,
+ var me = matrix.elements,
+ te = this.elements,
- n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],
- n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],
- n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],
+ n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],
+ n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],
+ n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],
- t11 = n33 * n22 - n32 * n23,
- t12 = n32 * n13 - n33 * n12,
- t13 = n23 * n12 - n22 * n13,
+ t11 = n33 * n22 - n32 * n23,
+ t12 = n32 * n13 - n33 * n12,
+ t13 = n23 * n12 - n22 * n13,
- det = n11 * t11 + n21 * t12 + n31 * t13;
+ det = n11 * t11 + n21 * t12 + n31 * t13;
- if ( det === 0 ) {
+ if ( det === 0 ) {
- var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";
+ var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";
- if ( throwOnDegenerate === true ) {
+ if ( throwOnDegenerate === true ) {
- throw new Error( msg );
+ throw new Error( msg );
- } else {
+ } else {
- console.warn( msg );
+ console.warn( msg );
- }
+ }
- return this.identity();
+ return this.identity();
- }
+ }
- var detInv = 1 / det;
+ var detInv = 1 / det;
- te[ 0 ] = t11 * detInv;
- te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;
- te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;
+ te[ 0 ] = t11 * detInv;
+ te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;
+ te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;
- te[ 3 ] = t12 * detInv;
- te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;
- te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;
+ te[ 3 ] = t12 * detInv;
+ te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;
+ te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;
- te[ 6 ] = t13 * detInv;
- te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;
- te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;
+ te[ 6 ] = t13 * detInv;
+ te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;
+ te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;
- return this;
+ return this;
- },
+ },
- transpose: function () {
+ transpose: function () {
- var tmp, m = this.elements;
+ var tmp, m = this.elements;
- tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;
- tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;
- tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;
+ tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;
+ tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;
+ tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;
- return this;
+ return this;
- },
+ },
- getNormalMatrix: function ( matrix4 ) {
+ getNormalMatrix: function ( matrix4 ) {
- return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();
+ return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();
- },
+ },
- transposeIntoArray: function ( r ) {
+ transposeIntoArray: function ( r ) {
- var m = this.elements;
+ var m = this.elements;
- r[ 0 ] = m[ 0 ];
- r[ 1 ] = m[ 3 ];
- r[ 2 ] = m[ 6 ];
- r[ 3 ] = m[ 1 ];
- r[ 4 ] = m[ 4 ];
- r[ 5 ] = m[ 7 ];
- r[ 6 ] = m[ 2 ];
- r[ 7 ] = m[ 5 ];
- r[ 8 ] = m[ 8 ];
+ r[ 0 ] = m[ 0 ];
+ r[ 1 ] = m[ 3 ];
+ r[ 2 ] = m[ 6 ];
+ r[ 3 ] = m[ 1 ];
+ r[ 4 ] = m[ 4 ];
+ r[ 5 ] = m[ 7 ];
+ r[ 6 ] = m[ 2 ];
+ r[ 7 ] = m[ 5 ];
+ r[ 8 ] = m[ 8 ];
- return this;
+ return this;
- },
+ },
- setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {
+ setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {
- var c = Math.cos( rotation );
- var s = Math.sin( rotation );
+ var c = Math.cos( rotation );
+ var s = Math.sin( rotation );
- this.set(
- sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,
- - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,
- 0, 0, 1
- );
+ this.set(
+ sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,
+ - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,
+ 0, 0, 1
+ );
- },
+ },
- scale: function ( sx, sy ) {
+ scale: function ( sx, sy ) {
- var te = this.elements;
+ var te = this.elements;
- te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;
- te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;
+ te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;
+ te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;
- return this;
+ return this;
- },
+ },
- rotate: function ( theta ) {
+ rotate: function ( theta ) {
- var c = Math.cos( theta );
- var s = Math.sin( theta );
+ var c = Math.cos( theta );
+ var s = Math.sin( theta );
- var te = this.elements;
+ var te = this.elements;
- var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];
- var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];
+ var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];
+ var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];
- te[ 0 ] = c * a11 + s * a21;
- te[ 3 ] = c * a12 + s * a22;
- te[ 6 ] = c * a13 + s * a23;
+ te[ 0 ] = c * a11 + s * a21;
+ te[ 3 ] = c * a12 + s * a22;
+ te[ 6 ] = c * a13 + s * a23;
- te[ 1 ] = - s * a11 + c * a21;
- te[ 4 ] = - s * a12 + c * a22;
- te[ 7 ] = - s * a13 + c * a23;
+ te[ 1 ] = - s * a11 + c * a21;
+ te[ 4 ] = - s * a12 + c * a22;
+ te[ 7 ] = - s * a13 + c * a23;
- return this;
+ return this;
- },
+ },
- translate: function ( tx, ty ) {
+ translate: function ( tx, ty ) {
- var te = this.elements;
+ var te = this.elements;
- te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];
- te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];
+ te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];
+ te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];
- return this;
+ return this;
- },
+ },
- equals: function ( matrix ) {
+ equals: function ( matrix ) {
- var te = this.elements;
- var me = matrix.elements;
+ var te = this.elements;
+ var me = matrix.elements;
- for ( var i = 0; i < 9; i ++ ) {
+ for ( var i = 0; i < 9; i ++ ) {
- if ( te[ i ] !== me[ i ] ) return false;
+ if ( te[ i ] !== me[ i ] ) return false;
- }
+ }
- return true;
+ return true;
- },
+ },
- fromArray: function ( array, offset ) {
+ fromArray: function ( array, offset ) {
- if ( offset === undefined ) offset = 0;
+ if ( offset === undefined ) offset = 0;
- for ( var i = 0; i < 9; i ++ ) {
+ for ( var i = 0; i < 9; i ++ ) {
- this.elements[ i ] = array[ i + offset ];
+ this.elements[ i ] = array[ i + offset ];
- }
+ }
- return this;
+ return this;
- },
+ },
- toArray: function ( array, offset ) {
+ toArray: function ( array, offset ) {
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- var te = this.elements;
+ var te = this.elements;
- array[ offset ] = te[ 0 ];
- array[ offset + 1 ] = te[ 1 ];
- array[ offset + 2 ] = te[ 2 ];
+ array[ offset ] = te[ 0 ];
+ array[ offset + 1 ] = te[ 1 ];
+ array[ offset + 2 ] = te[ 2 ];
- array[ offset + 3 ] = te[ 3 ];
- array[ offset + 4 ] = te[ 4 ];
- array[ offset + 5 ] = te[ 5 ];
+ array[ offset + 3 ] = te[ 3 ];
+ array[ offset + 4 ] = te[ 4 ];
+ array[ offset + 5 ] = te[ 5 ];
- array[ offset + 6 ] = te[ 6 ];
- array[ offset + 7 ] = te[ 7 ];
- array[ offset + 8 ] = te[ 8 ];
+ array[ offset + 6 ] = te[ 6 ];
+ array[ offset + 7 ] = te[ 7 ];
+ array[ offset + 8 ] = te[ 8 ];
- return array;
+ return array;
- }
+ }
- } );
+ } );
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author szimek / https://github.com/szimek/
- */
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ * @author szimek / https://github.com/szimek/
+ */
- var ImageUtils = {
+ var ImageUtils = {
- getDataURL: function ( image ) {
+ getDataURL: function ( image ) {
- var canvas;
+ var canvas;
- if ( image instanceof HTMLCanvasElement ) {
+ if ( image instanceof HTMLCanvasElement ) {
- canvas = image;
+ canvas = image;
- } else {
+ } else {
- if ( typeof OffscreenCanvas !== 'undefined' ) {
+ if ( typeof OffscreenCanvas !== 'undefined' ) {
- canvas = new OffscreenCanvas( image.width, image.height );
+ canvas = new OffscreenCanvas( image.width, image.height );
- } else {
+ } else {
- canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
- canvas.width = image.width;
- canvas.height = image.height;
+ canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
+ canvas.width = image.width;
+ canvas.height = image.height;
- }
+ }
- var context = canvas.getContext( '2d' );
+ var context = canvas.getContext( '2d' );
- if ( image instanceof ImageData ) {
+ if ( image instanceof ImageData ) {
- context.putImageData( image, 0, 0 );
+ context.putImageData( image, 0, 0 );
- } else {
+ } else {
- context.drawImage( image, 0, 0, image.width, image.height );
+ context.drawImage( image, 0, 0, image.width, image.height );
- }
+ }
- }
+ }
- if ( canvas.width > 2048 || canvas.height > 2048 ) {
+ if ( canvas.width > 2048 || canvas.height > 2048 ) {
- return canvas.toDataURL( 'image/jpeg', 0.6 );
+ return canvas.toDataURL( 'image/jpeg', 0.6 );
- } else {
+ } else {
- return canvas.toDataURL( 'image/png' );
+ return canvas.toDataURL( 'image/png' );
- }
+ }
- }
+ }
- };
+ };
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author szimek / https://github.com/szimek/
- */
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ * @author szimek / https://github.com/szimek/
+ */
- var textureId = 0;
+ var textureId = 0;
- function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
+ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
- Object.defineProperty( this, 'id', { value: textureId ++ } );
+ Object.defineProperty( this, 'id', { value: textureId ++ } );
- this.uuid = _Math.generateUUID();
+ this.uuid = _Math.generateUUID();
- this.name = '';
+ this.name = '';
- this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;
- this.mipmaps = [];
+ this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;
+ this.mipmaps = [];
- this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;
+ this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;
- this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;
- this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;
+ this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;
+ this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;
- this.magFilter = magFilter !== undefined ? magFilter : LinearFilter;
- this.minFilter = minFilter !== undefined ? minFilter : LinearMipMapLinearFilter;
+ this.magFilter = magFilter !== undefined ? magFilter : LinearFilter;
+ this.minFilter = minFilter !== undefined ? minFilter : LinearMipMapLinearFilter;
- this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
+ this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
- this.format = format !== undefined ? format : RGBAFormat;
- this.type = type !== undefined ? type : UnsignedByteType;
+ this.format = format !== undefined ? format : RGBAFormat;
+ this.type = type !== undefined ? type : UnsignedByteType;
- this.offset = new Vector2( 0, 0 );
- this.repeat = new Vector2( 1, 1 );
- this.center = new Vector2( 0, 0 );
- this.rotation = 0;
+ this.offset = new Vector2( 0, 0 );
+ this.repeat = new Vector2( 1, 1 );
+ this.center = new Vector2( 0, 0 );
+ this.rotation = 0;
- this.matrixAutoUpdate = true;
- this.matrix = new Matrix3();
+ this.matrixAutoUpdate = true;
+ this.matrix = new Matrix3();
- this.generateMipmaps = true;
- this.premultiplyAlpha = false;
- this.flipY = true;
- this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
+ this.generateMipmaps = true;
+ this.premultiplyAlpha = false;
+ this.flipY = true;
+ this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
- // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
- //
- // Also changing the encoding after already used by a Material will not automatically make the Material
- // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
- this.encoding = encoding !== undefined ? encoding : LinearEncoding;
+ // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
+ //
+ // Also changing the encoding after already used by a Material will not automatically make the Material
+ // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
+ this.encoding = encoding !== undefined ? encoding : LinearEncoding;
- this.version = 0;
- this.onUpdate = null;
+ this.version = 0;
+ this.onUpdate = null;
- }
+ }
- Texture.DEFAULT_IMAGE = undefined;
- Texture.DEFAULT_MAPPING = UVMapping;
+ Texture.DEFAULT_IMAGE = undefined;
+ Texture.DEFAULT_MAPPING = UVMapping;
- Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
+ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
- constructor: Texture,
+ constructor: Texture,
- isTexture: true,
+ isTexture: true,
- updateMatrix: function () {
+ updateMatrix: function () {
- this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );
+ this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor().copy( this );
+ return new this.constructor().copy( this );
- },
+ },
- copy: function ( source ) {
+ copy: function ( source ) {
- this.name = source.name;
+ this.name = source.name;
- this.image = source.image;
- this.mipmaps = source.mipmaps.slice( 0 );
+ this.image = source.image;
+ this.mipmaps = source.mipmaps.slice( 0 );
- this.mapping = source.mapping;
+ this.mapping = source.mapping;
- this.wrapS = source.wrapS;
- this.wrapT = source.wrapT;
+ this.wrapS = source.wrapS;
+ this.wrapT = source.wrapT;
- this.magFilter = source.magFilter;
- this.minFilter = source.minFilter;
+ this.magFilter = source.magFilter;
+ this.minFilter = source.minFilter;
- this.anisotropy = source.anisotropy;
+ this.anisotropy = source.anisotropy;
- this.format = source.format;
- this.type = source.type;
+ this.format = source.format;
+ this.type = source.type;
- this.offset.copy( source.offset );
- this.repeat.copy( source.repeat );
- this.center.copy( source.center );
- this.rotation = source.rotation;
+ this.offset.copy( source.offset );
+ this.repeat.copy( source.repeat );
+ this.center.copy( source.center );
+ this.rotation = source.rotation;
- this.matrixAutoUpdate = source.matrixAutoUpdate;
- this.matrix.copy( source.matrix );
+ this.matrixAutoUpdate = source.matrixAutoUpdate;
+ this.matrix.copy( source.matrix );
- this.generateMipmaps = source.generateMipmaps;
- this.premultiplyAlpha = source.premultiplyAlpha;
- this.flipY = source.flipY;
- this.unpackAlignment = source.unpackAlignment;
- this.encoding = source.encoding;
+ this.generateMipmaps = source.generateMipmaps;
+ this.premultiplyAlpha = source.premultiplyAlpha;
+ this.flipY = source.flipY;
+ this.unpackAlignment = source.unpackAlignment;
+ this.encoding = source.encoding;
- return this;
+ return this;
- },
+ },
- toJSON: function ( meta ) {
+ toJSON: function ( meta ) {
- var isRootObject = ( meta === undefined || typeof meta === 'string' );
+ var isRootObject = ( meta === undefined || typeof meta === 'string' );
- if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {
+ if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {
- return meta.textures[ this.uuid ];
+ return meta.textures[ this.uuid ];
- }
+ }
- var output = {
+ var output = {
- metadata: {
- version: 4.5,
- type: 'Texture',
- generator: 'Texture.toJSON'
- },
+ metadata: {
+ version: 4.5,
+ type: 'Texture',
+ generator: 'Texture.toJSON'
+ },
- uuid: this.uuid,
- name: this.name,
+ uuid: this.uuid,
+ name: this.name,
- mapping: this.mapping,
+ mapping: this.mapping,
- repeat: [ this.repeat.x, this.repeat.y ],
- offset: [ this.offset.x, this.offset.y ],
- center: [ this.center.x, this.center.y ],
- rotation: this.rotation,
+ repeat: [ this.repeat.x, this.repeat.y ],
+ offset: [ this.offset.x, this.offset.y ],
+ center: [ this.center.x, this.center.y ],
+ rotation: this.rotation,
- wrap: [ this.wrapS, this.wrapT ],
+ wrap: [ this.wrapS, this.wrapT ],
- format: this.format,
- minFilter: this.minFilter,
- magFilter: this.magFilter,
- anisotropy: this.anisotropy,
+ format: this.format,
+ minFilter: this.minFilter,
+ magFilter: this.magFilter,
+ anisotropy: this.anisotropy,
- flipY: this.flipY
+ flipY: this.flipY
- };
+ };
- if ( this.image !== undefined ) {
+ if ( this.image !== undefined ) {
- // TODO: Move to THREE.Image
+ // TODO: Move to THREE.Image
- var image = this.image;
+ var image = this.image;
- if ( image.uuid === undefined ) {
+ if ( image.uuid === undefined ) {
- image.uuid = _Math.generateUUID(); // UGH
+ image.uuid = _Math.generateUUID(); // UGH
- }
+ }
- if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {
+ if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {
- var url;
+ var url;
- if ( Array.isArray( image ) ) {
+ if ( Array.isArray( image ) ) {
- // process array of images e.g. CubeTexture
+ // process array of images e.g. CubeTexture
- url = [];
+ url = [];
- for ( var i = 0, l = image.length; i < l; i ++ ) {
+ for ( var i = 0, l = image.length; i < l; i ++ ) {
- url.push( ImageUtils.getDataURL( image[ i ] ) );
+ url.push( ImageUtils.getDataURL( image[ i ] ) );
- }
+ }
- } else {
+ } else {
- // process single image
+ // process single image
- url = ImageUtils.getDataURL( image );
+ url = ImageUtils.getDataURL( image );
- }
+ }
- meta.images[ image.uuid ] = {
- uuid: image.uuid,
- url: url
- };
+ meta.images[ image.uuid ] = {
+ uuid: image.uuid,
+ url: url
+ };
- }
+ }
- output.image = image.uuid;
+ output.image = image.uuid;
- }
+ }
- if ( ! isRootObject ) {
+ if ( ! isRootObject ) {
- meta.textures[ this.uuid ] = output;
+ meta.textures[ this.uuid ] = output;
- }
+ }
- return output;
+ return output;
- },
+ },
- dispose: function () {
+ dispose: function () {
- this.dispatchEvent( { type: 'dispose' } );
+ this.dispatchEvent( { type: 'dispose' } );
- },
+ },
- transformUv: function ( uv ) {
+ transformUv: function ( uv ) {
- if ( this.mapping !== UVMapping ) return;
+ if ( this.mapping !== UVMapping ) return;
- uv.applyMatrix3( this.matrix );
+ uv.applyMatrix3( this.matrix );
- if ( uv.x < 0 || uv.x > 1 ) {
+ if ( uv.x < 0 || uv.x > 1 ) {
- switch ( this.wrapS ) {
+ switch ( this.wrapS ) {
- case RepeatWrapping:
+ case RepeatWrapping:
- uv.x = uv.x - Math.floor( uv.x );
- break;
+ uv.x = uv.x - Math.floor( uv.x );
+ break;
- case ClampToEdgeWrapping:
+ case ClampToEdgeWrapping:
- uv.x = uv.x < 0 ? 0 : 1;
- break;
+ uv.x = uv.x < 0 ? 0 : 1;
+ break;
- case MirroredRepeatWrapping:
+ case MirroredRepeatWrapping:
- if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {
+ if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {
- uv.x = Math.ceil( uv.x ) - uv.x;
+ uv.x = Math.ceil( uv.x ) - uv.x;
- } else {
+ } else {
- uv.x = uv.x - Math.floor( uv.x );
+ uv.x = uv.x - Math.floor( uv.x );
- }
- break;
+ }
+ break;
- }
+ }
- }
+ }
- if ( uv.y < 0 || uv.y > 1 ) {
+ if ( uv.y < 0 || uv.y > 1 ) {
- switch ( this.wrapT ) {
+ switch ( this.wrapT ) {
- case RepeatWrapping:
+ case RepeatWrapping:
- uv.y = uv.y - Math.floor( uv.y );
- break;
+ uv.y = uv.y - Math.floor( uv.y );
+ break;
- case ClampToEdgeWrapping:
+ case ClampToEdgeWrapping:
- uv.y = uv.y < 0 ? 0 : 1;
- break;
+ uv.y = uv.y < 0 ? 0 : 1;
+ break;
- case MirroredRepeatWrapping:
+ case MirroredRepeatWrapping:
- if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {
+ if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {
- uv.y = Math.ceil( uv.y ) - uv.y;
+ uv.y = Math.ceil( uv.y ) - uv.y;
- } else {
+ } else {
- uv.y = uv.y - Math.floor( uv.y );
+ uv.y = uv.y - Math.floor( uv.y );
- }
- break;
+ }
+ break;
- }
+ }
- }
+ }
- if ( this.flipY ) {
+ if ( this.flipY ) {
- uv.y = 1 - uv.y;
+ uv.y = 1 - uv.y;
- }
+ }
- }
+ }
- } );
+ } );
- Object.defineProperty( Texture.prototype, "needsUpdate", {
+ Object.defineProperty( Texture.prototype, "needsUpdate", {
- set: function ( value ) {
+ set: function ( value ) {
- if ( value === true ) this.version ++;
+ if ( value === true ) this.version ++;
- }
+ }
- } );
+ } );
- /**
- * @author supereggbert / http://www.paulbrunt.co.uk/
- * @author philogb / http://blog.thejit.org/
- * @author mikael emtinger / http://gomo.se/
- * @author egraether / http://egraether.com/
- * @author WestLangley / http://github.com/WestLangley
- */
+ /**
+ * @author supereggbert / http://www.paulbrunt.co.uk/
+ * @author philogb / http://blog.thejit.org/
+ * @author mikael emtinger / http://gomo.se/
+ * @author egraether / http://egraether.com/
+ * @author WestLangley / http://github.com/WestLangley
+ */
- function Vector4( x, y, z, w ) {
+ function Vector4( x, y, z, w ) {
- this.x = x || 0;
- this.y = y || 0;
- this.z = z || 0;
- this.w = ( w !== undefined ) ? w : 1;
+ this.x = x || 0;
+ this.y = y || 0;
+ this.z = z || 0;
+ this.w = ( w !== undefined ) ? w : 1;
- }
+ }
- Object.assign( Vector4.prototype, {
+ Object.assign( Vector4.prototype, {
- isVector4: true,
+ isVector4: true,
- set: function ( x, y, z, w ) {
+ set: function ( x, y, z, w ) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
- return this;
+ return this;
- },
+ },
- setScalar: function ( scalar ) {
+ setScalar: function ( scalar ) {
- this.x = scalar;
- this.y = scalar;
- this.z = scalar;
- this.w = scalar;
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
+ this.w = scalar;
- return this;
+ return this;
- },
+ },
- setX: function ( x ) {
+ setX: function ( x ) {
- this.x = x;
+ this.x = x;
- return this;
+ return this;
- },
+ },
- setY: function ( y ) {
+ setY: function ( y ) {
- this.y = y;
+ this.y = y;
- return this;
+ return this;
- },
+ },
- setZ: function ( z ) {
+ setZ: function ( z ) {
- this.z = z;
+ this.z = z;
- return this;
+ return this;
- },
+ },
- setW: function ( w ) {
+ setW: function ( w ) {
- this.w = w;
+ this.w = w;
- return this;
+ return this;
- },
+ },
- setComponent: function ( index, value ) {
+ setComponent: function ( index, value ) {
- switch ( index ) {
+ switch ( index ) {
- case 0: this.x = value; break;
- case 1: this.y = value; break;
- case 2: this.z = value; break;
- case 3: this.w = value; break;
- default: throw new Error( 'index is out of range: ' + index );
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ case 2: this.z = value; break;
+ case 3: this.w = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
- }
+ }
- return this;
+ return this;
- },
+ },
- getComponent: function ( index ) {
+ getComponent: function ( index ) {
- switch ( index ) {
+ switch ( index ) {
- case 0: return this.x;
- case 1: return this.y;
- case 2: return this.z;
- case 3: return this.w;
- default: throw new Error( 'index is out of range: ' + index );
+ case 0: return this.x;
+ case 1: return this.y;
+ case 2: return this.z;
+ case 3: return this.w;
+ default: throw new Error( 'index is out of range: ' + index );
- }
+ }
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor( this.x, this.y, this.z, this.w );
+ return new this.constructor( this.x, this.y, this.z, this.w );
- },
+ },
- copy: function ( v ) {
+ copy: function ( v ) {
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
- this.w = ( v.w !== undefined ) ? v.w : 1;
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ this.w = ( v.w !== undefined ) ? v.w : 1;
- return this;
+ return this;
- },
+ },
- add: function ( v, w ) {
+ add: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
- return this.addVectors( v, w );
+ console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
- }
+ }
- this.x += v.x;
- this.y += v.y;
- this.z += v.z;
- this.w += v.w;
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ this.w += v.w;
- return this;
+ return this;
- },
+ },
- addScalar: function ( s ) {
+ addScalar: function ( s ) {
- this.x += s;
- this.y += s;
- this.z += s;
- this.w += s;
+ this.x += s;
+ this.y += s;
+ this.z += s;
+ this.w += s;
- return this;
+ return this;
- },
+ },
- addVectors: function ( a, b ) {
+ 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;
+ 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;
+ return this;
- },
+ },
- addScaledVector: function ( v, s ) {
+ addScaledVector: function ( v, s ) {
- this.x += v.x * s;
- this.y += v.y * s;
- this.z += v.z * s;
- this.w += v.w * s;
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
+ this.w += v.w * s;
- return this;
+ return this;
- },
+ },
- sub: function ( v, w ) {
+ sub: function ( v, w ) {
- if ( w !== undefined ) {
+ if ( w !== undefined ) {
- console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
- return this.subVectors( v, w );
+ console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
- }
+ }
- this.x -= v.x;
- this.y -= v.y;
- this.z -= v.z;
- this.w -= v.w;
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+ this.w -= v.w;
- return this;
+ return this;
- },
+ },
- subScalar: function ( s ) {
+ subScalar: function ( s ) {
- this.x -= s;
- this.y -= s;
- this.z -= s;
- this.w -= s;
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
+ this.w -= s;
- return this;
+ return this;
- },
+ },
- subVectors: function ( a, b ) {
+ 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;
+ 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;
+ return this;
- },
+ },
- multiplyScalar: function ( scalar ) {
+ multiplyScalar: function ( scalar ) {
- this.x *= scalar;
- this.y *= scalar;
- this.z *= scalar;
- this.w *= scalar;
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
+ this.w *= scalar;
- return this;
+ return this;
- },
+ },
- applyMatrix4: function ( m ) {
+ applyMatrix4: function ( m ) {
- var x = this.x, y = this.y, z = this.z, w = this.w;
- var e = m.elements;
+ var x = this.x, y = this.y, z = this.z, w = this.w;
+ var e = m.elements;
- this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;
- this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;
- this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;
- this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;
+ this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;
+ this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;
+ this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;
+ this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;
- return this;
+ return this;
- },
+ },
- divideScalar: function ( scalar ) {
+ divideScalar: function ( scalar ) {
- return this.multiplyScalar( 1 / scalar );
+ return this.multiplyScalar( 1 / scalar );
- },
+ },
- setAxisAngleFromQuaternion: function ( q ) {
+ setAxisAngleFromQuaternion: function ( q ) {
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
- // q is assumed to be normalized
+ // q is assumed to be normalized
- this.w = 2 * Math.acos( q.w );
+ this.w = 2 * Math.acos( q.w );
- var s = Math.sqrt( 1 - q.w * q.w );
+ var s = Math.sqrt( 1 - q.w * q.w );
- if ( s < 0.0001 ) {
+ if ( s < 0.0001 ) {
- this.x = 1;
- this.y = 0;
- this.z = 0;
+ this.x = 1;
+ this.y = 0;
+ this.z = 0;
- } else {
+ } else {
- this.x = q.x / s;
- this.y = q.y / s;
- this.z = q.z / s;
+ this.x = q.x / s;
+ this.y = q.y / s;
+ this.z = q.z / s;
- }
+ }
- return this;
+ return this;
- },
+ },
- setAxisAngleFromRotationMatrix: function ( m ) {
+ setAxisAngleFromRotationMatrix: function ( m ) {
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
- // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
- var angle, x, y, z, // variables for result
- epsilon = 0.01, // margin to allow for rounding errors
- epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees
+ var angle, x, y, z, // variables for result
+ epsilon = 0.01, // margin to allow for rounding errors
+ epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees
- te = m.elements,
+ te = m.elements,
- m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
- m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
- m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
+ m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
+ m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
+ m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
- if ( ( Math.abs( m12 - m21 ) < epsilon ) &&
- ( Math.abs( m13 - m31 ) < epsilon ) &&
- ( Math.abs( m23 - m32 ) < epsilon ) ) {
+ if ( ( Math.abs( m12 - m21 ) < epsilon ) &&
+ ( Math.abs( m13 - m31 ) < epsilon ) &&
+ ( Math.abs( m23 - m32 ) < epsilon ) ) {
- // singularity found
- // first check for identity matrix which must have +1 for all terms
- // in leading diagonal and zero in other terms
+ // singularity found
+ // first check for identity matrix which must have +1 for all terms
+ // in leading diagonal and zero in other terms
- if ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&
- ( Math.abs( m13 + m31 ) < epsilon2 ) &&
- ( Math.abs( m23 + m32 ) < epsilon2 ) &&
- ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {
+ if ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&
+ ( Math.abs( m13 + m31 ) < epsilon2 ) &&
+ ( Math.abs( m23 + m32 ) < epsilon2 ) &&
+ ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {
- // this singularity is identity matrix so angle = 0
+ // this singularity is identity matrix so angle = 0
- this.set( 1, 0, 0, 0 );
+ this.set( 1, 0, 0, 0 );
- return this; // zero angle, arbitrary axis
+ return this; // zero angle, arbitrary axis
- }
+ }
- // otherwise this singularity is angle = 180
+ // otherwise this singularity is angle = 180
- angle = Math.PI;
+ angle = Math.PI;
- var xx = ( m11 + 1 ) / 2;
- var yy = ( m22 + 1 ) / 2;
- var zz = ( m33 + 1 ) / 2;
- var xy = ( m12 + m21 ) / 4;
- var xz = ( m13 + m31 ) / 4;
- var yz = ( m23 + m32 ) / 4;
+ var xx = ( m11 + 1 ) / 2;
+ var yy = ( m22 + 1 ) / 2;
+ var zz = ( m33 + 1 ) / 2;
+ var xy = ( m12 + m21 ) / 4;
+ var xz = ( m13 + m31 ) / 4;
+ var yz = ( m23 + m32 ) / 4;
- if ( ( xx > yy ) && ( xx > zz ) ) {
+ if ( ( xx > yy ) && ( xx > zz ) ) {
- // m11 is the largest diagonal term
+ // m11 is the largest diagonal term
- if ( xx < epsilon ) {
+ if ( xx < epsilon ) {
- x = 0;
- y = 0.707106781;
- z = 0.707106781;
+ x = 0;
+ y = 0.707106781;
+ z = 0.707106781;
- } else {
+ } else {
- x = Math.sqrt( xx );
- y = xy / x;
- z = xz / x;
+ x = Math.sqrt( xx );
+ y = xy / x;
+ z = xz / x;
- }
+ }
- } else if ( yy > zz ) {
+ } else if ( yy > zz ) {
- // m22 is the largest diagonal term
+ // m22 is the largest diagonal term
- if ( yy < epsilon ) {
+ if ( yy < epsilon ) {
- x = 0.707106781;
- y = 0;
- z = 0.707106781;
+ x = 0.707106781;
+ y = 0;
+ z = 0.707106781;
- } else {
+ } else {
- y = Math.sqrt( yy );
- x = xy / y;
- z = yz / y;
+ y = Math.sqrt( yy );
+ x = xy / y;
+ z = yz / y;
- }
+ }
- } else {
+ } else {
- // m33 is the largest diagonal term so base result on this
+ // m33 is the largest diagonal term so base result on this
- if ( zz < epsilon ) {
+ if ( zz < epsilon ) {
- x = 0.707106781;
- y = 0.707106781;
- z = 0;
+ x = 0.707106781;
+ y = 0.707106781;
+ z = 0;
- } else {
+ } else {
- z = Math.sqrt( zz );
- x = xz / z;
- y = yz / z;
+ z = Math.sqrt( zz );
+ x = xz / z;
+ y = yz / z;
- }
+ }
- }
+ }
- this.set( x, y, z, angle );
+ this.set( x, y, z, angle );
- return this; // return 180 deg rotation
+ return this; // return 180 deg rotation
- }
+ }
- // as we have reached here there are no singularities so we can handle normally
+ // as we have reached here there are no singularities so we can handle normally
- var s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +
- ( m13 - m31 ) * ( m13 - m31 ) +
- ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize
+ var s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +
+ ( m13 - m31 ) * ( m13 - m31 ) +
+ ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize
- if ( Math.abs( s ) < 0.001 ) s = 1;
+ if ( Math.abs( s ) < 0.001 ) s = 1;
- // prevent divide by zero, should not happen if matrix is orthogonal and should be
- // caught by singularity test above, but I've left it in just in case
+ // prevent divide by zero, should not happen if matrix is orthogonal and should be
+ // caught by singularity test above, but I've left it in just in case
- this.x = ( m32 - m23 ) / s;
- this.y = ( m13 - m31 ) / s;
- this.z = ( m21 - m12 ) / s;
- this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );
+ this.x = ( m32 - m23 ) / s;
+ this.y = ( m13 - m31 ) / s;
+ this.z = ( m21 - m12 ) / s;
+ this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );
- return this;
+ return this;
- },
+ },
- min: function ( v ) {
+ min: function ( v ) {
- this.x = Math.min( this.x, v.x );
- this.y = Math.min( this.y, v.y );
- this.z = Math.min( this.z, v.z );
- this.w = Math.min( this.w, v.w );
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+ this.z = Math.min( this.z, v.z );
+ this.w = Math.min( this.w, v.w );
- return this;
+ return this;
- },
+ },
- max: function ( v ) {
+ max: function ( v ) {
- this.x = Math.max( this.x, v.x );
- this.y = Math.max( this.y, v.y );
- this.z = Math.max( this.z, v.z );
- this.w = Math.max( this.w, v.w );
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+ this.z = Math.max( this.z, v.z );
+ this.w = Math.max( this.w, v.w );
- return this;
+ return this;
- },
+ },
- clamp: function ( min, max ) {
+ clamp: function ( min, max ) {
- // assumes min < max, componentwise
+ // assumes min < max, componentwise
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
- this.z = Math.max( min.z, Math.min( max.z, this.z ) );
- this.w = Math.max( min.w, Math.min( max.w, this.w ) );
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+ this.z = Math.max( min.z, Math.min( max.z, this.z ) );
+ this.w = Math.max( min.w, Math.min( max.w, this.w ) );
- return this;
+ return this;
- },
+ },
- clampScalar: function () {
+ clampScalar: function () {
- var min, max;
+ var min, max;
- return function clampScalar( minVal, maxVal ) {
+ return function clampScalar( minVal, maxVal ) {
- if ( min === undefined ) {
+ if ( min === undefined ) {
- min = new Vector4();
- max = new Vector4();
+ min = new Vector4();
+ max = new Vector4();
- }
+ }
- min.set( minVal, minVal, minVal, minVal );
- max.set( maxVal, maxVal, maxVal, maxVal );
+ min.set( minVal, minVal, minVal, minVal );
+ max.set( maxVal, maxVal, maxVal, maxVal );
- return this.clamp( min, max );
+ return this.clamp( min, max );
- };
+ };
- }(),
+ }(),
- clampLength: function ( min, max ) {
+ clampLength: function ( min, max ) {
- var length = this.length();
+ var length = this.length();
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
- },
+ },
- floor: function () {
+ floor: function () {
- this.x = Math.floor( this.x );
- this.y = Math.floor( this.y );
- this.z = Math.floor( this.z );
- this.w = Math.floor( this.w );
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+ this.z = Math.floor( this.z );
+ this.w = Math.floor( this.w );
- return this;
+ return this;
- },
+ },
- ceil: function () {
+ ceil: function () {
- this.x = Math.ceil( this.x );
- this.y = Math.ceil( this.y );
- this.z = Math.ceil( this.z );
- this.w = Math.ceil( this.w );
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+ this.z = Math.ceil( this.z );
+ this.w = Math.ceil( this.w );
- return this;
+ return this;
- },
+ },
- round: function () {
+ round: function () {
- this.x = Math.round( this.x );
- this.y = Math.round( this.y );
- this.z = Math.round( this.z );
- this.w = Math.round( this.w );
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+ this.z = Math.round( this.z );
+ this.w = Math.round( this.w );
- return this;
+ return this;
- },
+ },
- roundToZero: function () {
+ roundToZero: function () {
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
- this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+ this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+ this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
- return this;
+ return this;
- },
+ },
- negate: function () {
+ negate: function () {
- this.x = - this.x;
- this.y = - this.y;
- this.z = - this.z;
- this.w = - this.w;
+ this.x = - this.x;
+ this.y = - this.y;
+ this.z = - this.z;
+ this.w = - this.w;
- return this;
+ return this;
- },
+ },
- dot: function ( v ) {
+ dot: function ( v ) {
- return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
- },
+ },
- lengthSq: function () {
+ lengthSq: function () {
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
- },
+ },
- length: function () {
+ length: function () {
- return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
+ return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
- },
+ },
- manhattanLength: function () {
+ manhattanLength: function () {
- return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
+ return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
- },
+ },
- normalize: function () {
+ normalize: function () {
- return this.divideScalar( this.length() || 1 );
+ return this.divideScalar( this.length() || 1 );
- },
+ },
- setLength: function ( length ) {
+ setLength: function ( length ) {
- return this.normalize().multiplyScalar( length );
+ return this.normalize().multiplyScalar( length );
- },
+ },
- lerp: function ( v, alpha ) {
+ lerp: function ( v, alpha ) {
- this.x += ( v.x - this.x ) * alpha;
- this.y += ( v.y - this.y ) * alpha;
- this.z += ( v.z - this.z ) * alpha;
- this.w += ( v.w - this.w ) * alpha;
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+ this.z += ( v.z - this.z ) * alpha;
+ this.w += ( v.w - this.w ) * alpha;
- return this;
+ return this;
- },
+ },
- lerpVectors: function ( v1, v2, alpha ) {
+ lerpVectors: function ( v1, v2, alpha ) {
- return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+ return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
- },
+ },
- equals: function ( v ) {
+ equals: function ( v ) {
- return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
+ return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
- },
+ },
- fromArray: function ( array, offset ) {
+ fromArray: function ( array, offset ) {
- if ( offset === undefined ) offset = 0;
+ if ( offset === undefined ) offset = 0;
- this.x = array[ offset ];
- this.y = array[ offset + 1 ];
- this.z = array[ offset + 2 ];
- this.w = array[ offset + 3 ];
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+ this.z = array[ offset + 2 ];
+ this.w = array[ offset + 3 ];
- return this;
+ return this;
- },
+ },
- toArray: function ( array, offset ) {
+ toArray: function ( array, offset ) {
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- array[ offset ] = this.x;
- array[ offset + 1 ] = this.y;
- array[ offset + 2 ] = this.z;
- array[ offset + 3 ] = this.w;
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+ array[ offset + 2 ] = this.z;
+ array[ offset + 3 ] = this.w;
- return array;
+ return array;
- },
+ },
- fromBufferAttribute: function ( attribute, index, offset ) {
+ fromBufferAttribute: function ( attribute, index, offset ) {
- if ( offset !== undefined ) {
+ if ( offset !== undefined ) {
- console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );
+ console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );
- }
+ }
- this.x = attribute.getX( index );
- this.y = attribute.getY( index );
- this.z = attribute.getZ( index );
- this.w = attribute.getW( index );
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+ this.z = attribute.getZ( index );
+ this.w = attribute.getW( index );
- return this;
+ return this;
- }
+ }
- } );
+ } );
- /**
- * @author szimek / https://github.com/szimek/
- * @author alteredq / http://alteredqualia.com/
- * @author Marius Kintel / https://github.com/kintel
- */
+ /**
+ * @author szimek / https://github.com/szimek/
+ * @author alteredq / http://alteredqualia.com/
+ * @author Marius Kintel / https://github.com/kintel
+ */
- /*
- In options, we can specify:
- * Texture parameters for an auto-generated target texture
- * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
- */
- function WebGLRenderTarget( width, height, options ) {
+ /*
+ In options, we can specify:
+ * Texture parameters for an auto-generated target texture
+ * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
+ */
+ function WebGLRenderTarget( width, height, options ) {
- this.width = width;
- this.height = height;
+ this.width = width;
+ this.height = height;
- this.scissor = new Vector4( 0, 0, width, height );
- this.scissorTest = false;
+ this.scissor = new Vector4( 0, 0, width, height );
+ this.scissorTest = false;
- this.viewport = new Vector4( 0, 0, width, height );
+ this.viewport = new Vector4( 0, 0, width, height );
- options = options || {};
+ options = options || {};
- if ( options.minFilter === undefined ) options.minFilter = LinearFilter;
+ if ( options.minFilter === undefined ) options.minFilter = LinearFilter;
- this.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+ this.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
- this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : true;
+ this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : true;
- this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
- this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
- this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
+ this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
+ this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
+ this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
- }
+ }
- WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
+ WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
- constructor: WebGLRenderTarget,
+ constructor: WebGLRenderTarget,
- isWebGLRenderTarget: true,
+ isWebGLRenderTarget: true,
- setSize: function ( width, height ) {
+ setSize: function ( width, height ) {
- if ( this.width !== width || this.height !== height ) {
+ if ( this.width !== width || this.height !== height ) {
- this.width = width;
- this.height = height;
+ this.width = width;
+ this.height = height;
- this.dispose();
+ this.dispose();
- }
+ }
- this.viewport.set( 0, 0, width, height );
- this.scissor.set( 0, 0, width, height );
+ this.viewport.set( 0, 0, width, height );
+ this.scissor.set( 0, 0, width, height );
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor().copy( this );
+ return new this.constructor().copy( this );
- },
+ },
- copy: function ( source ) {
+ copy: function ( source ) {
- this.width = source.width;
- this.height = source.height;
+ this.width = source.width;
+ this.height = source.height;
- this.viewport.copy( source.viewport );
+ this.viewport.copy( source.viewport );
- this.texture = source.texture.clone();
+ this.texture = source.texture.clone();
- this.depthBuffer = source.depthBuffer;
- this.stencilBuffer = source.stencilBuffer;
- this.depthTexture = source.depthTexture;
+ this.depthBuffer = source.depthBuffer;
+ this.stencilBuffer = source.stencilBuffer;
+ this.depthTexture = source.depthTexture;
- return this;
+ return this;
- },
+ },
- dispose: function () {
+ dispose: function () {
- this.dispatchEvent( { type: 'dispose' } );
+ this.dispatchEvent( { type: 'dispose' } );
- }
+ }
- } );
+ } );
- /**
- * @author alteredq / http://alteredqualia.com
- */
+ /**
+ * @author alteredq / http://alteredqualia.com
+ */
- function WebGLRenderTargetCube( width, height, options ) {
+ function WebGLRenderTargetCube( width, height, options ) {
- WebGLRenderTarget.call( this, width, height, options );
+ WebGLRenderTarget.call( this, width, height, options );
- this.activeCubeFace = 0; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5
- this.activeMipMapLevel = 0;
+ this.activeCubeFace = 0; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5
+ this.activeMipMapLevel = 0;
- }
+ }
- WebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype );
- WebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube;
+ WebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype );
+ WebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube;
- WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true;
+ WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true;
- /**
- * @author alteredq / http://alteredqualia.com/
- */
+ /**
+ * @author alteredq / http://alteredqualia.com/
+ */
- function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
+ function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
- Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+ Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
- this.image = { data: data, width: width, height: height };
+ this.image = { data: data, width: width, height: height };
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
- this.generateMipmaps = false;
- this.flipY = false;
- this.unpackAlignment = 1;
+ this.generateMipmaps = false;
+ this.flipY = false;
+ this.unpackAlignment = 1;
- }
+ }
- DataTexture.prototype = Object.create( Texture.prototype );
- DataTexture.prototype.constructor = DataTexture;
+ DataTexture.prototype = Object.create( Texture.prototype );
+ DataTexture.prototype.constructor = DataTexture;
- DataTexture.prototype.isDataTexture = true;
+ DataTexture.prototype.isDataTexture = true;
- /**
- * @author bhouston / http://clara.io
- * @author WestLangley / http://github.com/WestLangley
- */
+ /**
+ * @author bhouston / http://clara.io
+ * @author WestLangley / http://github.com/WestLangley
+ */
- function Box3( min, max ) {
+ function Box3( min, max ) {
- this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );
- this.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );
+ this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );
+ this.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );
- }
+ }
- Object.assign( Box3.prototype, {
+ Object.assign( Box3.prototype, {
- isBox3: true,
+ isBox3: true,
- set: function ( min, max ) {
+ set: function ( min, max ) {
- this.min.copy( min );
- this.max.copy( max );
+ this.min.copy( min );
+ this.max.copy( max );
- return this;
+ return this;
- },
+ },
- setFromArray: function ( array ) {
+ setFromArray: function ( array ) {
- var minX = + Infinity;
- var minY = + Infinity;
- var minZ = + Infinity;
+ var minX = + Infinity;
+ var minY = + Infinity;
+ var minZ = + Infinity;
- var maxX = - Infinity;
- var maxY = - Infinity;
- var maxZ = - Infinity;
+ var maxX = - Infinity;
+ var maxY = - Infinity;
+ var maxZ = - Infinity;
- for ( var i = 0, l = array.length; i < l; i += 3 ) {
+ for ( var i = 0, l = array.length; i < l; i += 3 ) {
- var x = array[ i ];
- var y = array[ i + 1 ];
- var z = array[ i + 2 ];
+ var x = array[ i ];
+ var y = array[ i + 1 ];
+ var z = array[ i + 2 ];
- if ( x < minX ) minX = x;
- if ( y < minY ) minY = y;
- if ( z < minZ ) minZ = z;
+ if ( x < minX ) minX = x;
+ if ( y < minY ) minY = y;
+ if ( z < minZ ) minZ = z;
- if ( x > maxX ) maxX = x;
- if ( y > maxY ) maxY = y;
- if ( z > maxZ ) maxZ = z;
+ if ( x > maxX ) maxX = x;
+ if ( y > maxY ) maxY = y;
+ if ( z > maxZ ) maxZ = z;
- }
+ }
- this.min.set( minX, minY, minZ );
- this.max.set( maxX, maxY, maxZ );
+ this.min.set( minX, minY, minZ );
+ this.max.set( maxX, maxY, maxZ );
- return this;
+ return this;
- },
+ },
- setFromBufferAttribute: function ( attribute ) {
+ setFromBufferAttribute: function ( attribute ) {
- var minX = + Infinity;
- var minY = + Infinity;
- var minZ = + Infinity;
+ var minX = + Infinity;
+ var minY = + Infinity;
+ var minZ = + Infinity;
- var maxX = - Infinity;
- var maxY = - Infinity;
- var maxZ = - Infinity;
+ var maxX = - Infinity;
+ var maxY = - Infinity;
+ var maxZ = - Infinity;
- for ( var i = 0, l = attribute.count; i < l; i ++ ) {
+ for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- var x = attribute.getX( i );
- var y = attribute.getY( i );
- var z = attribute.getZ( i );
+ var x = attribute.getX( i );
+ var y = attribute.getY( i );
+ var z = attribute.getZ( i );
- if ( x < minX ) minX = x;
- if ( y < minY ) minY = y;
- if ( z < minZ ) minZ = z;
+ if ( x < minX ) minX = x;
+ if ( y < minY ) minY = y;
+ if ( z < minZ ) minZ = z;
- if ( x > maxX ) maxX = x;
- if ( y > maxY ) maxY = y;
- if ( z > maxZ ) maxZ = z;
+ if ( x > maxX ) maxX = x;
+ if ( y > maxY ) maxY = y;
+ if ( z > maxZ ) maxZ = z;
- }
+ }
- this.min.set( minX, minY, minZ );
- this.max.set( maxX, maxY, maxZ );
+ this.min.set( minX, minY, minZ );
+ this.max.set( maxX, maxY, maxZ );
- return this;
+ return this;
- },
+ },
- setFromPoints: function ( points ) {
+ setFromPoints: function ( points ) {
- this.makeEmpty();
+ this.makeEmpty();
- for ( var i = 0, il = points.length; i < il; i ++ ) {
+ for ( var i = 0, il = points.length; i < il; i ++ ) {
- this.expandByPoint( points[ i ] );
+ this.expandByPoint( points[ i ] );
- }
+ }
- return this;
+ return this;
- },
+ },
- setFromCenterAndSize: function () {
+ setFromCenterAndSize: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function setFromCenterAndSize( center, size ) {
+ return function setFromCenterAndSize( center, size ) {
- var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
+ var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
- this.min.copy( center ).sub( halfSize );
- this.max.copy( center ).add( halfSize );
+ this.min.copy( center ).sub( halfSize );
+ this.max.copy( center ).add( halfSize );
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- setFromObject: function ( object ) {
+ setFromObject: function ( object ) {
- this.makeEmpty();
+ this.makeEmpty();
- return this.expandByObject( object );
+ return this.expandByObject( object );
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor().copy( this );
+ return new this.constructor().copy( this );
- },
+ },
- copy: function ( box ) {
+ copy: function ( box ) {
- this.min.copy( box.min );
- this.max.copy( box.max );
+ this.min.copy( box.min );
+ this.max.copy( box.max );
- return this;
+ return this;
- },
+ },
- makeEmpty: function () {
+ makeEmpty: function () {
- this.min.x = this.min.y = this.min.z = + Infinity;
- this.max.x = this.max.y = this.max.z = - Infinity;
+ this.min.x = this.min.y = this.min.z = + Infinity;
+ this.max.x = this.max.y = this.max.z = - Infinity;
- return this;
+ return this;
- },
+ },
- isEmpty: function () {
+ isEmpty: function () {
- // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
+ // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
- return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );
+ return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );
- },
+ },
- getCenter: function ( target ) {
+ getCenter: function ( target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Box3: .getCenter() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Box3: .getCenter() target is now required' );
+ target = new Vector3();
- }
+ }
- return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
+ return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
- },
+ },
- getSize: function ( target ) {
+ getSize: function ( target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Box3: .getSize() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Box3: .getSize() target is now required' );
+ target = new Vector3();
- }
+ }
- return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );
+ return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );
- },
+ },
- expandByPoint: function ( point ) {
+ expandByPoint: function ( point ) {
- this.min.min( point );
- this.max.max( point );
+ this.min.min( point );
+ this.max.max( point );
- return this;
+ return this;
- },
+ },
- expandByVector: function ( vector ) {
+ expandByVector: function ( vector ) {
- this.min.sub( vector );
- this.max.add( vector );
+ this.min.sub( vector );
+ this.max.add( vector );
- return this;
+ return this;
- },
+ },
- expandByScalar: function ( scalar ) {
+ expandByScalar: function ( scalar ) {
- this.min.addScalar( - scalar );
- this.max.addScalar( scalar );
+ this.min.addScalar( - scalar );
+ this.max.addScalar( scalar );
- return this;
+ return this;
- },
+ },
- expandByObject: function () {
+ expandByObject: function () {
- // Computes the world-axis-aligned bounding box of an object (including its children),
- // accounting for both the object's, and children's, world transforms
+ // Computes the world-axis-aligned bounding box of an object (including its children),
+ // accounting for both the object's, and children's, world transforms
- var scope, i, l;
+ var scope, i, l;
- var v1 = new Vector3();
+ var v1 = new Vector3();
- function traverse( node ) {
+ function traverse( node ) {
- var geometry = node.geometry;
+ var geometry = node.geometry;
- if ( geometry !== undefined ) {
+ if ( geometry !== undefined ) {
- if ( geometry.isGeometry ) {
+ if ( geometry.isGeometry ) {
- var vertices = geometry.vertices;
+ var vertices = geometry.vertices;
- for ( i = 0, l = vertices.length; i < l; i ++ ) {
+ for ( i = 0, l = vertices.length; i < l; i ++ ) {
- v1.copy( vertices[ i ] );
- v1.applyMatrix4( node.matrixWorld );
+ v1.copy( vertices[ i ] );
+ v1.applyMatrix4( node.matrixWorld );
- scope.expandByPoint( v1 );
+ scope.expandByPoint( v1 );
- }
+ }
- } else if ( geometry.isBufferGeometry ) {
+ } else if ( geometry.isBufferGeometry ) {
- var attribute = geometry.attributes.position;
+ var attribute = geometry.attributes.position;
- if ( attribute !== undefined ) {
+ if ( attribute !== undefined ) {
- for ( i = 0, l = attribute.count; i < l; i ++ ) {
+ for ( i = 0, l = attribute.count; i < l; i ++ ) {
- v1.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
+ v1.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
- scope.expandByPoint( v1 );
+ scope.expandByPoint( v1 );
- }
+ }
- }
+ }
- }
+ }
- }
+ }
- }
+ }
- return function expandByObject( object ) {
+ return function expandByObject( object ) {
- scope = this;
+ scope = this;
- object.updateMatrixWorld( true );
+ object.updateMatrixWorld( true );
- object.traverse( traverse );
+ object.traverse( traverse );
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- containsPoint: function ( point ) {
+ containsPoint: function ( point ) {
- return point.x < this.min.x || point.x > this.max.x ||
- point.y < this.min.y || point.y > this.max.y ||
- point.z < this.min.z || point.z > this.max.z ? false : true;
+ return point.x < this.min.x || point.x > this.max.x ||
+ point.y < this.min.y || point.y > this.max.y ||
+ point.z < this.min.z || point.z > this.max.z ? false : true;
- },
+ },
- containsBox: function ( box ) {
+ containsBox: function ( box ) {
- return this.min.x <= box.min.x && box.max.x <= this.max.x &&
- this.min.y <= box.min.y && box.max.y <= this.max.y &&
- this.min.z <= box.min.z && box.max.z <= this.max.z;
+ return this.min.x <= box.min.x && box.max.x <= this.max.x &&
+ this.min.y <= box.min.y && box.max.y <= this.max.y &&
+ this.min.z <= box.min.z && box.max.z <= this.max.z;
- },
+ },
- getParameter: function ( point, target ) {
+ getParameter: function ( point, target ) {
- // This can potentially have a divide by zero if the box
- // has a size dimension of 0.
+ // This can potentially have a divide by zero if the box
+ // has a size dimension of 0.
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Box3: .getParameter() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Box3: .getParameter() target is now required' );
+ target = new Vector3();
- }
+ }
- return target.set(
- ( point.x - this.min.x ) / ( this.max.x - this.min.x ),
- ( point.y - this.min.y ) / ( this.max.y - this.min.y ),
- ( point.z - this.min.z ) / ( this.max.z - this.min.z )
- );
+ return target.set(
+ ( point.x - this.min.x ) / ( this.max.x - this.min.x ),
+ ( point.y - this.min.y ) / ( this.max.y - this.min.y ),
+ ( point.z - this.min.z ) / ( this.max.z - this.min.z )
+ );
- },
+ },
- intersectsBox: function ( box ) {
+ intersectsBox: function ( box ) {
- // using 6 splitting planes to rule out intersections.
- return box.max.x < this.min.x || box.min.x > this.max.x ||
- box.max.y < this.min.y || box.min.y > this.max.y ||
- box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
+ // using 6 splitting planes to rule out intersections.
+ return box.max.x < this.min.x || box.min.x > this.max.x ||
+ box.max.y < this.min.y || box.min.y > this.max.y ||
+ box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
- },
+ },
- intersectsSphere: ( function () {
+ intersectsSphere: ( function () {
- var closestPoint = new Vector3();
+ var closestPoint = new Vector3();
- return function intersectsSphere( sphere ) {
+ return function intersectsSphere( sphere ) {
- // Find the point on the AABB closest to the sphere center.
- this.clampPoint( sphere.center, closestPoint );
+ // Find the point on the AABB closest to the sphere center.
+ this.clampPoint( sphere.center, closestPoint );
- // If that point is inside the sphere, the AABB and sphere intersect.
- return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
+ // If that point is inside the sphere, the AABB and sphere intersect.
+ return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
- };
+ };
- } )(),
+ } )(),
- intersectsPlane: function ( plane ) {
+ intersectsPlane: function ( plane ) {
- // We compute the minimum and maximum dot product values. If those values
- // are on the same side (back or front) of the plane, then there is no intersection.
+ // We compute the minimum and maximum dot product values. If those values
+ // are on the same side (back or front) of the plane, then there is no intersection.
- var min, max;
+ var min, max;
- if ( plane.normal.x > 0 ) {
+ if ( plane.normal.x > 0 ) {
- min = plane.normal.x * this.min.x;
- max = plane.normal.x * this.max.x;
+ min = plane.normal.x * this.min.x;
+ max = plane.normal.x * this.max.x;
- } else {
+ } else {
- min = plane.normal.x * this.max.x;
- max = plane.normal.x * this.min.x;
+ min = plane.normal.x * this.max.x;
+ max = plane.normal.x * this.min.x;
- }
+ }
- if ( plane.normal.y > 0 ) {
+ if ( plane.normal.y > 0 ) {
- min += plane.normal.y * this.min.y;
- max += plane.normal.y * this.max.y;
+ min += plane.normal.y * this.min.y;
+ max += plane.normal.y * this.max.y;
- } else {
+ } else {
- min += plane.normal.y * this.max.y;
- max += plane.normal.y * this.min.y;
+ min += plane.normal.y * this.max.y;
+ max += plane.normal.y * this.min.y;
- }
+ }
- if ( plane.normal.z > 0 ) {
+ if ( plane.normal.z > 0 ) {
- min += plane.normal.z * this.min.z;
- max += plane.normal.z * this.max.z;
+ min += plane.normal.z * this.min.z;
+ max += plane.normal.z * this.max.z;
- } else {
+ } else {
- min += plane.normal.z * this.max.z;
- max += plane.normal.z * this.min.z;
+ min += plane.normal.z * this.max.z;
+ max += plane.normal.z * this.min.z;
- }
+ }
- return ( min <= plane.constant && max >= plane.constant );
+ return ( min <= plane.constant && max >= plane.constant );
- },
+ },
- intersectsTriangle: ( function () {
+ intersectsTriangle: ( function () {
- // triangle centered vertices
- var v0 = new Vector3();
- var v1 = new Vector3();
- var v2 = new Vector3();
+ // triangle centered vertices
+ var v0 = new Vector3();
+ var v1 = new Vector3();
+ var v2 = new Vector3();
- // triangle edge vectors
- var f0 = new Vector3();
- var f1 = new Vector3();
- var f2 = new Vector3();
+ // triangle edge vectors
+ var f0 = new Vector3();
+ var f1 = new Vector3();
+ var f2 = new Vector3();
- var testAxis = new Vector3();
+ var testAxis = new Vector3();
- var center = new Vector3();
- var extents = new Vector3();
+ var center = new Vector3();
+ var extents = new Vector3();
- var triangleNormal = new Vector3();
+ var triangleNormal = new Vector3();
- function satForAxes( axes ) {
+ function satForAxes( axes ) {
- var i, j;
+ var i, j;
- for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) {
+ for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) {
- testAxis.fromArray( axes, i );
- // project the aabb onto the seperating axis
- var r = extents.x * Math.abs( testAxis.x ) + extents.y * Math.abs( testAxis.y ) + extents.z * Math.abs( testAxis.z );
- // project all 3 vertices of the triangle onto the seperating axis
- var p0 = v0.dot( testAxis );
- var p1 = v1.dot( testAxis );
- var p2 = v2.dot( testAxis );
- // actual test, basically see if either of the most extreme of the triangle points intersects r
- if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
+ testAxis.fromArray( axes, i );
+ // project the aabb onto the seperating axis
+ var r = extents.x * Math.abs( testAxis.x ) + extents.y * Math.abs( testAxis.y ) + extents.z * Math.abs( testAxis.z );
+ // project all 3 vertices of the triangle onto the seperating axis
+ var p0 = v0.dot( testAxis );
+ var p1 = v1.dot( testAxis );
+ var p2 = v2.dot( testAxis );
+ // actual test, basically see if either of the most extreme of the triangle points intersects r
+ if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
- // points of the projected triangle are outside the projected half-length of the aabb
- // the axis is seperating and we can exit
- return false;
+ // points of the projected triangle are outside the projected half-length of the aabb
+ // the axis is seperating and we can exit
+ return false;
- }
+ }
- }
+ }
- return true;
+ return true;
- }
+ }
- return function intersectsTriangle( triangle ) {
+ return function intersectsTriangle( triangle ) {
- if ( this.isEmpty() ) {
+ if ( this.isEmpty() ) {
- return false;
+ return false;
- }
+ }
- // compute box center and extents
- this.getCenter( center );
- extents.subVectors( this.max, center );
+ // compute box center and extents
+ this.getCenter( center );
+ extents.subVectors( this.max, center );
- // translate triangle to aabb origin
- v0.subVectors( triangle.a, center );
- v1.subVectors( triangle.b, center );
- v2.subVectors( triangle.c, center );
+ // translate triangle to aabb origin
+ v0.subVectors( triangle.a, center );
+ v1.subVectors( triangle.b, center );
+ v2.subVectors( triangle.c, center );
- // compute edge vectors for triangle
- f0.subVectors( v1, v0 );
- f1.subVectors( v2, v1 );
- f2.subVectors( v0, v2 );
+ // compute edge vectors for triangle
+ f0.subVectors( v1, v0 );
+ f1.subVectors( v2, v1 );
+ f2.subVectors( v0, v2 );
- // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
- // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
- // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
- var axes = [
- 0, - f0.z, f0.y, 0, - f1.z, f1.y, 0, - f2.z, f2.y,
- f0.z, 0, - f0.x, f1.z, 0, - f1.x, f2.z, 0, - f2.x,
- - f0.y, f0.x, 0, - f1.y, f1.x, 0, - f2.y, f2.x, 0
- ];
- if ( ! satForAxes( axes ) ) {
+ // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
+ // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
+ // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
+ var axes = [
+ 0, - f0.z, f0.y, 0, - f1.z, f1.y, 0, - f2.z, f2.y,
+ f0.z, 0, - f0.x, f1.z, 0, - f1.x, f2.z, 0, - f2.x,
+ - f0.y, f0.x, 0, - f1.y, f1.x, 0, - f2.y, f2.x, 0
+ ];
+ if ( ! satForAxes( axes ) ) {
- return false;
+ return false;
- }
+ }
- // test 3 face normals from the aabb
- axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
- if ( ! satForAxes( axes ) ) {
+ // test 3 face normals from the aabb
+ axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
+ if ( ! satForAxes( axes ) ) {
- return false;
+ return false;
- }
+ }
- // finally testing the face normal of the triangle
- // use already existing triangle edge vectors here
- triangleNormal.crossVectors( f0, f1 );
- axes = [ triangleNormal.x, triangleNormal.y, triangleNormal.z ];
- return satForAxes( axes );
+ // finally testing the face normal of the triangle
+ // use already existing triangle edge vectors here
+ triangleNormal.crossVectors( f0, f1 );
+ axes = [ triangleNormal.x, triangleNormal.y, triangleNormal.z ];
+ return satForAxes( axes );
- };
+ };
- } )(),
+ } )(),
- clampPoint: function ( point, target ) {
+ clampPoint: function ( point, target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Box3: .clampPoint() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Box3: .clampPoint() target is now required' );
+ target = new Vector3();
- }
+ }
- return target.copy( point ).clamp( this.min, this.max );
+ return target.copy( point ).clamp( this.min, this.max );
- },
+ },
- distanceToPoint: function () {
+ distanceToPoint: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function distanceToPoint( point ) {
+ return function distanceToPoint( point ) {
- var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
- return clampedPoint.sub( point ).length();
+ var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
+ return clampedPoint.sub( point ).length();
- };
+ };
- }(),
+ }(),
- getBoundingSphere: function () {
+ getBoundingSphere: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function getBoundingSphere( target ) {
+ return function getBoundingSphere( target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Box3: .getBoundingSphere() target is now required' );
- target = new Sphere();
+ console.warn( 'THREE.Box3: .getBoundingSphere() target is now required' );
+ target = new Sphere();
- }
+ }
- this.getCenter( target.center );
+ this.getCenter( target.center );
- target.radius = this.getSize( v1 ).length() * 0.5;
+ target.radius = this.getSize( v1 ).length() * 0.5;
- return target;
+ return target;
- };
+ };
- }(),
+ }(),
- intersect: function ( box ) {
+ intersect: function ( box ) {
- this.min.max( box.min );
- this.max.min( box.max );
+ this.min.max( box.min );
+ this.max.min( box.max );
- // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.
- if ( this.isEmpty() ) this.makeEmpty();
+ // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.
+ if ( this.isEmpty() ) this.makeEmpty();
- return this;
+ return this;
- },
+ },
- union: function ( box ) {
+ union: function ( box ) {
- this.min.min( box.min );
- this.max.max( box.max );
+ this.min.min( box.min );
+ this.max.max( box.max );
- return this;
+ return this;
- },
+ },
- applyMatrix4: function ( matrix ) {
+ applyMatrix4: function ( matrix ) {
- // transform of empty box is an empty box.
- if ( this.isEmpty( ) ) return this;
+ // transform of empty box is an empty box.
+ if ( this.isEmpty( ) ) return this;
- var m = matrix.elements;
+ var m = matrix.elements;
- var xax = m[ 0 ] * this.min.x, xay = m[ 1 ] * this.min.x, xaz = m[ 2 ] * this.min.x;
- var xbx = m[ 0 ] * this.max.x, xby = m[ 1 ] * this.max.x, xbz = m[ 2 ] * this.max.x;
- var yax = m[ 4 ] * this.min.y, yay = m[ 5 ] * this.min.y, yaz = m[ 6 ] * this.min.y;
- var ybx = m[ 4 ] * this.max.y, yby = m[ 5 ] * this.max.y, ybz = m[ 6 ] * this.max.y;
- var zax = m[ 8 ] * this.min.z, zay = m[ 9 ] * this.min.z, zaz = m[ 10 ] * this.min.z;
- var zbx = m[ 8 ] * this.max.z, zby = m[ 9 ] * this.max.z, zbz = m[ 10 ] * this.max.z;
+ var xax = m[ 0 ] * this.min.x, xay = m[ 1 ] * this.min.x, xaz = m[ 2 ] * this.min.x;
+ var xbx = m[ 0 ] * this.max.x, xby = m[ 1 ] * this.max.x, xbz = m[ 2 ] * this.max.x;
+ var yax = m[ 4 ] * this.min.y, yay = m[ 5 ] * this.min.y, yaz = m[ 6 ] * this.min.y;
+ var ybx = m[ 4 ] * this.max.y, yby = m[ 5 ] * this.max.y, ybz = m[ 6 ] * this.max.y;
+ var zax = m[ 8 ] * this.min.z, zay = m[ 9 ] * this.min.z, zaz = m[ 10 ] * this.min.z;
+ var zbx = m[ 8 ] * this.max.z, zby = m[ 9 ] * this.max.z, zbz = m[ 10 ] * this.max.z;
- this.min.x = Math.min( xax, xbx ) + Math.min( yax, ybx ) + Math.min( zax, zbx ) + m[ 12 ];
- this.min.y = Math.min( xay, xby ) + Math.min( yay, yby ) + Math.min( zay, zby ) + m[ 13 ];
- this.min.z = Math.min( xaz, xbz ) + Math.min( yaz, ybz ) + Math.min( zaz, zbz ) + m[ 14 ];
- this.max.x = Math.max( xax, xbx ) + Math.max( yax, ybx ) + Math.max( zax, zbx ) + m[ 12 ];
- this.max.y = Math.max( xay, xby ) + Math.max( yay, yby ) + Math.max( zay, zby ) + m[ 13 ];
- this.max.z = Math.max( xaz, xbz ) + Math.max( yaz, ybz ) + Math.max( zaz, zbz ) + m[ 14 ];
+ this.min.x = Math.min( xax, xbx ) + Math.min( yax, ybx ) + Math.min( zax, zbx ) + m[ 12 ];
+ this.min.y = Math.min( xay, xby ) + Math.min( yay, yby ) + Math.min( zay, zby ) + m[ 13 ];
+ this.min.z = Math.min( xaz, xbz ) + Math.min( yaz, ybz ) + Math.min( zaz, zbz ) + m[ 14 ];
+ this.max.x = Math.max( xax, xbx ) + Math.max( yax, ybx ) + Math.max( zax, zbx ) + m[ 12 ];
+ this.max.y = Math.max( xay, xby ) + Math.max( yay, yby ) + Math.max( zay, zby ) + m[ 13 ];
+ this.max.z = Math.max( xaz, xbz ) + Math.max( yaz, ybz ) + Math.max( zaz, zbz ) + m[ 14 ];
- return this;
+ return this;
- },
+ },
- translate: function ( offset ) {
+ translate: function ( offset ) {
- this.min.add( offset );
- this.max.add( offset );
+ this.min.add( offset );
+ this.max.add( offset );
- return this;
+ return this;
- },
+ },
- equals: function ( box ) {
+ equals: function ( box ) {
- return box.min.equals( this.min ) && box.max.equals( this.max );
+ return box.min.equals( this.min ) && box.max.equals( this.max );
- }
+ }
- } );
+ } );
- /**
- * @author bhouston / http://clara.io
- * @author mrdoob / http://mrdoob.com/
- */
+ /**
+ * @author bhouston / http://clara.io
+ * @author mrdoob / http://mrdoob.com/
+ */
- function Sphere( center, radius ) {
+ function Sphere( center, radius ) {
- this.center = ( center !== undefined ) ? center : new Vector3();
- this.radius = ( radius !== undefined ) ? radius : 0;
+ this.center = ( center !== undefined ) ? center : new Vector3();
+ this.radius = ( radius !== undefined ) ? radius : 0;
- }
+ }
- Object.assign( Sphere.prototype, {
+ Object.assign( Sphere.prototype, {
- set: function ( center, radius ) {
+ set: function ( center, radius ) {
- this.center.copy( center );
- this.radius = radius;
+ this.center.copy( center );
+ this.radius = radius;
- return this;
+ return this;
- },
+ },
- setFromPoints: function () {
+ setFromPoints: function () {
- var box = new Box3();
+ var box = new Box3();
- return function setFromPoints( points, optionalCenter ) {
+ return function setFromPoints( points, optionalCenter ) {
- var center = this.center;
+ var center = this.center;
- if ( optionalCenter !== undefined ) {
+ if ( optionalCenter !== undefined ) {
- center.copy( optionalCenter );
+ center.copy( optionalCenter );
- } else {
+ } else {
- box.setFromPoints( points ).getCenter( center );
+ box.setFromPoints( points ).getCenter( center );
- }
+ }
- var maxRadiusSq = 0;
+ var maxRadiusSq = 0;
- for ( var i = 0, il = points.length; i < il; i ++ ) {
+ for ( var i = 0, il = points.length; i < il; i ++ ) {
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );
- }
+ }
- this.radius = Math.sqrt( maxRadiusSq );
+ this.radius = Math.sqrt( maxRadiusSq );
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- clone: function () {
+ clone: function () {
- return new this.constructor().copy( this );
+ return new this.constructor().copy( this );
- },
+ },
- copy: function ( sphere ) {
+ copy: function ( sphere ) {
- this.center.copy( sphere.center );
- this.radius = sphere.radius;
+ this.center.copy( sphere.center );
+ this.radius = sphere.radius;
- return this;
+ return this;
- },
+ },
- empty: function () {
+ empty: function () {
- return ( this.radius <= 0 );
+ return ( this.radius <= 0 );
- },
+ },
- containsPoint: function ( point ) {
+ containsPoint: function ( point ) {
- return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );
+ return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );
- },
+ },
- distanceToPoint: function ( point ) {
+ distanceToPoint: function ( point ) {
- return ( point.distanceTo( this.center ) - this.radius );
+ return ( point.distanceTo( this.center ) - this.radius );
- },
+ },
- intersectsSphere: function ( sphere ) {
+ intersectsSphere: function ( sphere ) {
- var radiusSum = this.radius + sphere.radius;
+ var radiusSum = this.radius + sphere.radius;
- return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );
+ return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );
- },
+ },
- intersectsBox: function ( box ) {
+ intersectsBox: function ( box ) {
- return box.intersectsSphere( this );
+ return box.intersectsSphere( this );
- },
+ },
- intersectsPlane: function ( plane ) {
+ intersectsPlane: function ( plane ) {
- return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;
+ return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;
- },
+ },
- clampPoint: function ( point, target ) {
+ clampPoint: function ( point, target ) {
- var deltaLengthSq = this.center.distanceToSquared( point );
+ var deltaLengthSq = this.center.distanceToSquared( point );
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Sphere: .clampPoint() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Sphere: .clampPoint() target is now required' );
+ target = new Vector3();
- }
+ }
- target.copy( point );
+ target.copy( point );
- if ( deltaLengthSq > ( this.radius * this.radius ) ) {
+ if ( deltaLengthSq > ( this.radius * this.radius ) ) {
- target.sub( this.center ).normalize();
- target.multiplyScalar( this.radius ).add( this.center );
+ target.sub( this.center ).normalize();
+ target.multiplyScalar( this.radius ).add( this.center );
- }
+ }
- return target;
+ return target;
- },
+ },
- getBoundingBox: function ( target ) {
+ getBoundingBox: function ( target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );
- target = new Box3();
+ console.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );
+ target = new Box3();
- }
+ }
- target.set( this.center, this.center );
- target.expandByScalar( this.radius );
+ target.set( this.center, this.center );
+ target.expandByScalar( this.radius );
- return target;
+ return target;
- },
+ },
- applyMatrix4: function ( matrix ) {
+ applyMatrix4: function ( matrix ) {
- this.center.applyMatrix4( matrix );
- this.radius = this.radius * matrix.getMaxScaleOnAxis();
+ this.center.applyMatrix4( matrix );
+ this.radius = this.radius * matrix.getMaxScaleOnAxis();
- return this;
+ return this;
- },
+ },
- translate: function ( offset ) {
+ translate: function ( offset ) {
- this.center.add( offset );
+ this.center.add( offset );
- return this;
+ return this;
- },
+ },
- equals: function ( sphere ) {
+ equals: function ( sphere ) {
- return sphere.center.equals( this.center ) && ( sphere.radius === this.radius );
+ return sphere.center.equals( this.center ) && ( sphere.radius === this.radius );
- }
+ }
- } );
+ } );
- /**
- * @author bhouston / http://clara.io
- */
+ /**
+ * @author bhouston / http://clara.io
+ */
- function Plane( normal, constant ) {
+ function Plane( normal, constant ) {
- // normal is assumed to be normalized
+ // normal is assumed to be normalized
- this.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );
- this.constant = ( constant !== undefined ) ? constant : 0;
+ this.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );
+ this.constant = ( constant !== undefined ) ? constant : 0;
- }
+ }
- Object.assign( Plane.prototype, {
+ Object.assign( Plane.prototype, {
- set: function ( normal, constant ) {
+ set: function ( normal, constant ) {
- this.normal.copy( normal );
- this.constant = constant;
+ this.normal.copy( normal );
+ this.constant = constant;
- return this;
+ return this;
- },
+ },
- setComponents: function ( x, y, z, w ) {
+ setComponents: function ( x, y, z, w ) {
- this.normal.set( x, y, z );
- this.constant = w;
+ this.normal.set( x, y, z );
+ this.constant = w;
- return this;
+ return this;
- },
+ },
- setFromNormalAndCoplanarPoint: function ( normal, point ) {
+ setFromNormalAndCoplanarPoint: function ( normal, point ) {
- this.normal.copy( normal );
- this.constant = - point.dot( this.normal );
+ this.normal.copy( normal );
+ this.constant = - point.dot( this.normal );
- return this;
+ return this;
- },
+ },
- setFromCoplanarPoints: function () {
+ setFromCoplanarPoints: function () {
- var v1 = new Vector3();
- var v2 = new Vector3();
+ var v1 = new Vector3();
+ var v2 = new Vector3();
- return function setFromCoplanarPoints( a, b, c ) {
+ return function setFromCoplanarPoints( a, b, c ) {
- var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
+ var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
- // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+ // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
- this.setFromNormalAndCoplanarPoint( normal, a );
+ this.setFromNormalAndCoplanarPoint( normal, a );
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- clone: function () {
+ clone: function () {
- return new this.constructor().copy( this );
+ return new this.constructor().copy( this );
- },
+ },
- copy: function ( plane ) {
+ copy: function ( plane ) {
- this.normal.copy( plane.normal );
- this.constant = plane.constant;
+ this.normal.copy( plane.normal );
+ this.constant = plane.constant;
- return this;
+ return this;
- },
+ },
- normalize: function () {
+ normalize: function () {
- // Note: will lead to a divide by zero if the plane is invalid.
+ // Note: will lead to a divide by zero if the plane is invalid.
- var inverseNormalLength = 1.0 / this.normal.length();
- this.normal.multiplyScalar( inverseNormalLength );
- this.constant *= inverseNormalLength;
+ var inverseNormalLength = 1.0 / this.normal.length();
+ this.normal.multiplyScalar( inverseNormalLength );
+ this.constant *= inverseNormalLength;
- return this;
+ return this;
- },
+ },
- negate: function () {
+ negate: function () {
- this.constant *= - 1;
- this.normal.negate();
+ this.constant *= - 1;
+ this.normal.negate();
- return this;
+ return this;
- },
+ },
- distanceToPoint: function ( point ) {
+ distanceToPoint: function ( point ) {
- return this.normal.dot( point ) + this.constant;
+ return this.normal.dot( point ) + this.constant;
- },
+ },
- distanceToSphere: function ( sphere ) {
+ distanceToSphere: function ( sphere ) {
- return this.distanceToPoint( sphere.center ) - sphere.radius;
+ return this.distanceToPoint( sphere.center ) - sphere.radius;
- },
+ },
- projectPoint: function ( point, target ) {
+ projectPoint: function ( point, target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Plane: .projectPoint() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Plane: .projectPoint() target is now required' );
+ target = new Vector3();
- }
+ }
- return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
+ return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
- },
+ },
- intersectLine: function () {
+ intersectLine: function () {
- var v1 = new Vector3();
+ var v1 = new Vector3();
- return function intersectLine( line, target ) {
+ return function intersectLine( line, target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Plane: .intersectLine() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Plane: .intersectLine() target is now required' );
+ target = new Vector3();
- }
+ }
- var direction = line.delta( v1 );
+ var direction = line.delta( v1 );
- var denominator = this.normal.dot( direction );
+ var denominator = this.normal.dot( direction );
- if ( denominator === 0 ) {
+ if ( denominator === 0 ) {
- // line is coplanar, return origin
- if ( this.distanceToPoint( line.start ) === 0 ) {
+ // line is coplanar, return origin
+ if ( this.distanceToPoint( line.start ) === 0 ) {
- return target.copy( line.start );
+ return target.copy( line.start );
- }
+ }
- // Unsure if this is the correct method to handle this case.
- return undefined;
+ // Unsure if this is the correct method to handle this case.
+ return undefined;
- }
+ }
- var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
+ var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
- if ( t < 0 || t > 1 ) {
+ if ( t < 0 || t > 1 ) {
- return undefined;
+ return undefined;
- }
+ }
- return target.copy( direction ).multiplyScalar( t ).add( line.start );
+ return target.copy( direction ).multiplyScalar( t ).add( line.start );
- };
+ };
- }(),
+ }(),
- intersectsLine: function ( line ) {
+ intersectsLine: function ( line ) {
- // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
+ // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
- var startSign = this.distanceToPoint( line.start );
- var endSign = this.distanceToPoint( line.end );
+ var startSign = this.distanceToPoint( line.start );
+ var endSign = this.distanceToPoint( line.end );
- return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );
+ return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );
- },
+ },
- intersectsBox: function ( box ) {
+ intersectsBox: function ( box ) {
- return box.intersectsPlane( this );
+ return box.intersectsPlane( this );
- },
+ },
- intersectsSphere: function ( sphere ) {
+ intersectsSphere: function ( sphere ) {
- return sphere.intersectsPlane( this );
+ return sphere.intersectsPlane( this );
- },
+ },
- coplanarPoint: function ( target ) {
+ coplanarPoint: function ( target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Plane: .coplanarPoint() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Plane: .coplanarPoint() target is now required' );
+ target = new Vector3();
- }
+ }
- return target.copy( this.normal ).multiplyScalar( - this.constant );
+ return target.copy( this.normal ).multiplyScalar( - this.constant );
- },
+ },
- applyMatrix4: function () {
+ applyMatrix4: function () {
- var v1 = new Vector3();
- var m1 = new Matrix3();
+ var v1 = new Vector3();
+ var m1 = new Matrix3();
- return function applyMatrix4( matrix, optionalNormalMatrix ) {
+ return function applyMatrix4( matrix, optionalNormalMatrix ) {
- var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
+ var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
- var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
+ var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
- var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+ var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
- this.constant = - referencePoint.dot( normal );
+ this.constant = - referencePoint.dot( normal );
- return this;
+ return this;
- };
+ };
- }(),
+ }(),
- translate: function ( offset ) {
+ translate: function ( offset ) {
- this.constant -= offset.dot( this.normal );
+ this.constant -= offset.dot( this.normal );
- return this;
+ return this;
- },
+ },
- equals: function ( plane ) {
+ equals: function ( plane ) {
- return plane.normal.equals( this.normal ) && ( plane.constant === this.constant );
+ return plane.normal.equals( this.normal ) && ( plane.constant === this.constant );
- }
+ }
- } );
+ } );
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author bhouston / http://clara.io
- */
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ * @author bhouston / http://clara.io
+ */
- function Frustum( p0, p1, p2, p3, p4, p5 ) {
+ function Frustum( p0, p1, p2, p3, p4, p5 ) {
- this.planes = [
+ this.planes = [
- ( p0 !== undefined ) ? p0 : new Plane(),
- ( p1 !== undefined ) ? p1 : new Plane(),
- ( p2 !== undefined ) ? p2 : new Plane(),
- ( p3 !== undefined ) ? p3 : new Plane(),
- ( p4 !== undefined ) ? p4 : new Plane(),
- ( p5 !== undefined ) ? p5 : new Plane()
+ ( p0 !== undefined ) ? p0 : new Plane(),
+ ( p1 !== undefined ) ? p1 : new Plane(),
+ ( p2 !== undefined ) ? p2 : new Plane(),
+ ( p3 !== undefined ) ? p3 : new Plane(),
+ ( p4 !== undefined ) ? p4 : new Plane(),
+ ( p5 !== undefined ) ? p5 : new Plane()
- ];
+ ];
- }
+ }
- Object.assign( Frustum.prototype, {
+ Object.assign( Frustum.prototype, {
- set: function ( p0, p1, p2, p3, p4, p5 ) {
+ set: function ( p0, p1, p2, p3, p4, p5 ) {
- var planes = this.planes;
+ var planes = this.planes;
- planes[ 0 ].copy( p0 );
- planes[ 1 ].copy( p1 );
- planes[ 2 ].copy( p2 );
- planes[ 3 ].copy( p3 );
- planes[ 4 ].copy( p4 );
- planes[ 5 ].copy( p5 );
+ planes[ 0 ].copy( p0 );
+ planes[ 1 ].copy( p1 );
+ planes[ 2 ].copy( p2 );
+ planes[ 3 ].copy( p3 );
+ planes[ 4 ].copy( p4 );
+ planes[ 5 ].copy( p5 );
- return this;
+ return this;
- },
+ },
- clone: function () {
+ clone: function () {
- return new this.constructor().copy( this );
+ return new this.constructor().copy( this );
- },
+ },
- copy: function ( frustum ) {
+ copy: function ( frustum ) {
- var planes = this.planes;
+ var planes = this.planes;
- for ( var i = 0; i < 6; i ++ ) {
+ for ( var i = 0; i < 6; i ++ ) {
- planes[ i ].copy( frustum.planes[ i ] );
+ planes[ i ].copy( frustum.planes[ i ] );
- }
+ }
- return this;
+ return this;
- },
+ },
- setFromMatrix: function ( m ) {
+ setFromMatrix: function ( m ) {
- var planes = this.planes;
- var me = m.elements;
- var me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];
- var me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];
- var me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];
- var me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];
+ var planes = this.planes;
+ var me = m.elements;
+ var me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];
+ var me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];
+ var me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];
+ var me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];
- planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();
- planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
- planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
- planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
- planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
- planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
+ planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();
+ planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
+ planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
+ planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
+ planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
+ planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
- return this;
+ return this;
- },
+ },
- intersectsObject: function () {
+ intersectsObject: function () {
- var sphere = new Sphere();
+ var sphere = new Sphere();
- return function intersectsObject( object ) {
+ return function intersectsObject( object ) {
- var geometry = object.geometry;
+ var geometry = object.geometry;
- if ( geometry.boundingSphere === null )
- geometry.computeBoundingSphere();
+ if ( geometry.boundingSphere === null )
+ geometry.computeBoundingSphere();
- sphere.copy( geometry.boundingSphere )
- .applyMatrix4( object.matrixWorld );
+ sphere.copy( geometry.boundingSphere )
+ .applyMatrix4( object.matrixWorld );
- return this.intersectsSphere( sphere );
+ return this.intersectsSphere( sphere );
- };
+ };
- }(),
+ }(),
- intersectsSprite: function () {
+ intersectsSprite: function () {
- var sphere = new Sphere();
+ var sphere = new Sphere();
- return function intersectsSprite( sprite ) {
+ return function intersectsSprite( sprite ) {
- sphere.center.set( 0, 0, 0 );
- sphere.radius = 0.7071067811865476;
- sphere.applyMatrix4( sprite.matrixWorld );
+ sphere.center.set( 0, 0, 0 );
+ sphere.radius = 0.7071067811865476;
+ sphere.applyMatrix4( sprite.matrixWorld );
- return this.intersectsSphere( sphere );
+ return this.intersectsSphere( sphere );
- };
+ };
- }(),
+ }(),
- intersectsSphere: function ( sphere ) {
+ intersectsSphere: function ( sphere ) {
- var planes = this.planes;
- var center = sphere.center;
- var negRadius = - sphere.radius;
+ var planes = this.planes;
+ var center = sphere.center;
+ var negRadius = - sphere.radius;
- for ( var i = 0; i < 6; i ++ ) {
+ for ( var i = 0; i < 6; i ++ ) {
- var distance = planes[ i ].distanceToPoint( center );
+ var distance = planes[ i ].distanceToPoint( center );
- if ( distance < negRadius ) {
+ if ( distance < negRadius ) {
- return false;
+ return false;
- }
+ }
- }
+ }
- return true;
+ return true;
- },
+ },
- intersectsBox: function () {
+ intersectsBox: function () {
- var p = new Vector3();
+ var p = new Vector3();
- return function intersectsBox( box ) {
+ return function intersectsBox( box ) {
- var planes = this.planes;
+ var planes = this.planes;
- for ( var i = 0; i < 6; i ++ ) {
+ for ( var i = 0; i < 6; i ++ ) {
- var plane = planes[ i ];
+ var plane = planes[ i ];
- // corner at max distance
+ // corner at max distance
- p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
- p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
- p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
+ p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
+ p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
+ p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
- if ( plane.distanceToPoint( p ) < 0 ) {
+ if ( plane.distanceToPoint( p ) < 0 ) {
- return false;
+ return false;
- }
+ }
- }
+ }
- return true;
+ return true;
- };
+ };
- }(),
+ }(),
- containsPoint: function ( point ) {
+ containsPoint: function ( point ) {
- var planes = this.planes;
+ var planes = this.planes;
- for ( var i = 0; i < 6; i ++ ) {
+ for ( var i = 0; i < 6; i ++ ) {
- if ( planes[ i ].distanceToPoint( point ) < 0 ) {
+ if ( planes[ i ].distanceToPoint( point ) < 0 ) {
- return false;
+ return false;
- }
+ }
- }
+ }
- return true;
+ return true;
- }
+ }
- } );
+ } );
- var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n";
+ var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n";
- var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n";
+ var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n";
- var alphatest_fragment = "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n";
+ var alphatest_fragment = "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n";
- var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n";
+ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n";
- var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
+ var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
- var begin_vertex = "\nvec3 transformed = vec3( position );\n";
+ var begin_vertex = "\nvec3 transformed = vec3( position );\n";
- var beginnormal_vertex = "\nvec3 objectNormal = vec3( normal );\n";
+ var beginnormal_vertex = "\nvec3 objectNormal = vec3( normal );\n";
- var bsdfs = "float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
+ var bsdfs = "float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
- var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
+ var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
- var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n";
+ var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n";
- var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n";
+ var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n";
- var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n";
+ var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n";
- var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n";
+ var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n";
- var color_fragment = "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif";
+ var color_fragment = "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif";
- var color_pars_fragment = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n";
+ var color_pars_fragment = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n";
- var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif";
+ var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif";
- var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif";
+ var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif";
- var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n";
+ var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n";
- var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
+ var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
- var defaultnormal_vertex = "vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n";
+ var defaultnormal_vertex = "vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n";
- var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n";
+ var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n";
- var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n";
+ var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n";
- var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n";
+ var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n";
- var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n";
+ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n";
- var encodings_fragment = " gl_FragColor = linearToOutputTexel( gl_FragColor );\n";
+ var encodings_fragment = " gl_FragColor = linearToOutputTexel( gl_FragColor );\n";
- var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
+ var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n";
- var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
+ var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
- var envmap_pars_fragment = "#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
+ var envmap_pars_fragment = "#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
- var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n";
+ var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n";
- var envmap_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n";
+ var envmap_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n";
- var fog_vertex = "\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif";
+ var fog_vertex = "\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif";
- var fog_pars_vertex = "#ifdef USE_FOG\n varying float fogDepth;\n#endif\n";
+ var fog_pars_vertex = "#ifdef USE_FOG\n varying float fogDepth;\n#endif\n";
- var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n";
+ var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n";
- var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n";
+ var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n";
- var gradientmap_pars_fragment = "#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n";
+ var gradientmap_pars_fragment = "#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n";
- var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n";
+ var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n";
- var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
+ var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
- var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
+ var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
- var lights_pars_begin = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n";
+ var lights_pars_begin = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n";
- var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
+ var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
- var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n";
+ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n";
- var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n";
+ var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n";
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n";
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n";
- var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n";
+ var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n";
- var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n";
+ var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n";
- var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n";
+ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n";
- var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n";
+ var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n";
- var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
+ var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
- var logdepthbuf_pars_fragment = "#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n";
+ var logdepthbuf_pars_fragment = "#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n";
- var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif";
+ var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif";
- var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n";
+ var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n";
- var map_fragment = "#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n";
+ var map_fragment = "#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n";
- var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n";
+ var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n";
- var map_particle_fragment = "#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n";
+ var map_particle_fragment = "#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n";
- var map_particle_pars_fragment = "#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n";
+ var map_particle_pars_fragment = "#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n";
- var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n";
+ var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n";
- var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
+ var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
- var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n";
+ var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n";
- var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif";
+ var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif";
- var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n";
+ var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n";
- var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n";
+ var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n";
- var normal_fragment_maps = "#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n";
+ var normal_fragment_maps = "#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n";
- var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n";
+ var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n";
- var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n";
+ var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n";
- var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n";
+ var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n";
- var project_vertex = "vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n";
+ var project_vertex = "vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n";
- var dithering_fragment = "#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n";
+ var dithering_fragment = "#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n";
- var dithering_pars_fragment = "#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n";
+ var dithering_pars_fragment = "#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n";
- var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n";
+ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n";
- var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
+ var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
- var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n";
+ var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n";
- var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n";
+ var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n";
- var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n";
+ var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n";
- var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n";
+ var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n";
- var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
+ var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
- var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
+ var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
- var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n";
+ var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n";
- var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n";
+ var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n";
- var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif";
+ var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif";
- var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";
+ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";
- var tonemapping_fragment = "#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n";
+ var tonemapping_fragment = "#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n";
- var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
+ var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
- var uv_pars_fragment = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif";
+ var uv_pars_fragment = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif";
- var uv_pars_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n";
+ var uv_pars_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n";
- var uv_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
+ var uv_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
- var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";
+ var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";
- var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif";
+ var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif";
- var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif";
+ var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif";
- var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n";
+ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n";
- var cube_frag = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n";
+ var cube_frag = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n";
- var cube_vert = "varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n";
+ var cube_vert = "varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n";
- var depth_frag = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n";
+ var depth_frag = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n";
- var depth_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
+ var depth_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
- var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n";
+ var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n";
- var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n";
+ var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n";
- var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n";
+ var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n";
- var equirect_vert = "varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n";
+ var equirect_vert = "varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n";
- var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
+ var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
- var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n";
+ var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n";
- var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
+ var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
- var meshbasic_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include