\n\n Here's the new load parameter for your GUI's constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI's constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
*/\n /** Controllers */ }\n .dg.main {\n /** Scrollbar */ }\n .dg.main::-webkit-scrollbar {\n width: 5px;\n background: #1a1a1a; }\n .dg.main::-webkit-scrollbar-corner {\n height: 0;\n display: none; }\n .dg.main::-webkit-scrollbar-thumb {\n border-radius: 5px;\n background: #676767; }\n .dg li:not(.folder) {\n background: #1a1a1a;\n border-bottom: 1px solid #2c2c2c; }\n .dg li.save-row {\n line-height: 25px;\n background: #dad5cb;\n border: 0; }\n .dg li.save-row select {\n margin-left: 5px;\n width: 108px; }\n .dg li.save-row .button {\n margin-left: 5px;\n margin-top: 1px;\n border-radius: 2px;\n font-size: 9px;\n line-height: 7px;\n padding: 4px 4px 5px 4px;\n background: #c5bdad;\n color: #fff;\n text-shadow: 0 1px 0 #b0a58f;\n box-shadow: 0 -1px 0 #b0a58f;\n cursor: pointer; }\n .dg li.save-row .button.gears {\n background: #c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;\n height: 7px;\n width: 8px; }\n .dg li.save-row .button:hover {\n background-color: #bab19e;\n box-shadow: 0 -1px 0 #b0a58f; }\n .dg li.folder {\n border-bottom: 0; }\n .dg li.title {\n padding-left: 16px;\n background: black url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;\n cursor: pointer;\n border-bottom: 1px solid rgba(255, 255, 255, 0.2); }\n .dg .closed li.title {\n background-image: url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==); }\n .dg .cr.boolean {\n border-left: 3px solid #806787; }\n .dg .cr.function {\n border-left: 3px solid #e61d5f; }\n .dg .cr.number {\n border-left: 3px solid #2fa1d6; }\n .dg .cr.number input[type=text] {\n color: #2fa1d6; }\n .dg .cr.string {\n border-left: 3px solid #1ed36f; }\n .dg .cr.string input[type=text] {\n color: #1ed36f; }\n .dg .cr.function:hover, .dg .cr.boolean:hover {\n background: #111; }\n .dg .c input[type=text] {\n background: #303030;\n outline: none; }\n .dg .c input[type=text]:hover {\n background: #3c3c3c; }\n .dg .c input[type=text]:focus {\n background: #494949;\n color: #fff; }\n .dg .c .slider {\n background: #303030;\n cursor: ew-resize; }\n .dg .c .slider-fg {\n background: #2fa1d6; }\n .dg .c .slider:hover {\n background: #3c3c3c; }\n .dg .c .slider:hover .slider-fg {\n background: #44abda; }\n",
-dat.controllers.factory = (function (OptionController, NumberControllerBox, NumberControllerSlider, StringController, FunctionController, BooleanController, common) {
-
- return function(object, property) {
-
- var initialValue = object[property];
-
- // Providing options?
- if (common.isArray(arguments[2]) || common.isObject(arguments[2])) {
- return new OptionController(object, property, arguments[2]);
- }
-
- // Providing a map?
-
- if (common.isNumber(initialValue)) {
-
- if (common.isNumber(arguments[2]) && common.isNumber(arguments[3])) {
-
- // Has min and max.
- return new NumberControllerSlider(object, property, arguments[2], arguments[3]);
-
- } else {
-
- return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] });
-
- }
-
- }
-
- if (common.isString(initialValue)) {
- return new StringController(object, property);
- }
-
- if (common.isFunction(initialValue)) {
- return new FunctionController(object, property, '');
- }
-
- if (common.isBoolean(initialValue)) {
- return new BooleanController(object, property);
- }
-
- }
-
- })(dat.controllers.OptionController,
-dat.controllers.NumberControllerBox,
-dat.controllers.NumberControllerSlider,
-dat.controllers.StringController = (function (Controller, dom, common) {
-
- /**
- * @class Provides a text input to alter the string property of an object.
- *
- * @extends dat.controllers.Controller
- *
- * @param {Object} object The object to be manipulated
- * @param {string} property The name of the property to be manipulated
- *
- * @member dat.controllers
- */
- var StringController = function(object, property) {
-
- StringController.superclass.call(this, object, property);
-
- var _this = this;
-
- this.__input = document.createElement('input');
- this.__input.setAttribute('type', 'text');
-
- dom.bind(this.__input, 'keyup', onChange);
- dom.bind(this.__input, 'change', onChange);
- dom.bind(this.__input, 'blur', onBlur);
- dom.bind(this.__input, 'keydown', function(e) {
- if (e.keyCode === 13) {
- this.blur();
- }
- });
-
-
- function onChange() {
- _this.setValue(_this.__input.value);
- }
-
- function onBlur() {
- if (_this.__onFinishChange) {
- _this.__onFinishChange.call(_this, _this.getValue());
- }
- }
-
- this.updateDisplay();
-
- this.domElement.appendChild(this.__input);
-
- };
-
- StringController.superclass = Controller;
-
- common.extend(
-
- StringController.prototype,
- Controller.prototype,
-
- {
-
- updateDisplay: function() {
- // Stops the caret from moving on account of:
- // keyup -> setValue -> updateDisplay
- if (!dom.isActive(this.__input)) {
- this.__input.value = this.getValue();
- }
- return StringController.superclass.prototype.updateDisplay.call(this);
- }
-
- }
-
- );
-
- return StringController;
-
-})(dat.controllers.Controller,
-dat.dom.dom,
-dat.utils.common),
-dat.controllers.FunctionController,
-dat.controllers.BooleanController,
-dat.utils.common),
-dat.controllers.Controller,
-dat.controllers.BooleanController,
-dat.controllers.FunctionController,
-dat.controllers.NumberControllerBox,
-dat.controllers.NumberControllerSlider,
-dat.controllers.OptionController,
-dat.controllers.ColorController = (function (Controller, dom, Color, interpret, common) {
-
- var ColorController = function(object, property) {
-
- ColorController.superclass.call(this, object, property);
-
- this.__color = new Color(this.getValue());
- this.__temp = new Color(0);
-
- var _this = this;
-
- this.domElement = document.createElement('div');
-
- dom.makeSelectable(this.domElement, false);
-
- this.__selector = document.createElement('div');
- this.__selector.className = 'selector';
-
- this.__saturation_field = document.createElement('div');
- this.__saturation_field.className = 'saturation-field';
-
- this.__field_knob = document.createElement('div');
- this.__field_knob.className = 'field-knob';
- this.__field_knob_border = '2px solid ';
-
- this.__hue_knob = document.createElement('div');
- this.__hue_knob.className = 'hue-knob';
-
- this.__hue_field = document.createElement('div');
- this.__hue_field.className = 'hue-field';
-
- this.__input = document.createElement('input');
- this.__input.type = 'text';
- this.__input_textShadow = '0 1px 1px ';
-
- dom.bind(this.__input, 'keydown', function(e) {
- if (e.keyCode === 13) { // on enter
- onBlur.call(this);
- }
- });
-
- dom.bind(this.__input, 'blur', onBlur);
-
- dom.bind(this.__selector, 'mousedown', function(e) {
-
- dom
- .addClass(this, 'drag')
- .bind(window, 'mouseup', function(e) {
- dom.removeClass(_this.__selector, 'drag');
- });
-
- });
-
- var value_field = document.createElement('div');
-
- common.extend(this.__selector.style, {
- width: '122px',
- height: '102px',
- padding: '3px',
- backgroundColor: '#222',
- boxShadow: '0px 1px 3px rgba(0,0,0,0.3)'
- });
-
- common.extend(this.__field_knob.style, {
- position: 'absolute',
- width: '12px',
- height: '12px',
- border: this.__field_knob_border + (this.__color.v < .5 ? '#fff' : '#000'),
- boxShadow: '0px 1px 3px rgba(0,0,0,0.5)',
- borderRadius: '12px',
- zIndex: 1
- });
-
- common.extend(this.__hue_knob.style, {
- position: 'absolute',
- width: '15px',
- height: '2px',
- borderRight: '4px solid #fff',
- zIndex: 1
- });
-
- common.extend(this.__saturation_field.style, {
- width: '100px',
- height: '100px',
- border: '1px solid #555',
- marginRight: '3px',
- display: 'inline-block',
- cursor: 'pointer'
- });
-
- common.extend(value_field.style, {
- width: '100%',
- height: '100%',
- background: 'none'
- });
-
- linearGradient(value_field, 'top', 'rgba(0,0,0,0)', '#000');
-
- common.extend(this.__hue_field.style, {
- width: '15px',
- height: '100px',
- display: 'inline-block',
- border: '1px solid #555',
- cursor: 'ns-resize'
- });
-
- hueGradient(this.__hue_field);
-
- common.extend(this.__input.style, {
- outline: 'none',
-// width: '120px',
- textAlign: 'center',
-// padding: '4px',
-// marginBottom: '6px',
- color: '#fff',
- border: 0,
- fontWeight: 'bold',
- textShadow: this.__input_textShadow + 'rgba(0,0,0,0.7)'
- });
-
- dom.bind(this.__saturation_field, 'mousedown', fieldDown);
- dom.bind(this.__field_knob, 'mousedown', fieldDown);
-
- dom.bind(this.__hue_field, 'mousedown', function(e) {
- setH(e);
- dom.bind(window, 'mousemove', setH);
- dom.bind(window, 'mouseup', unbindH);
- });
-
- function fieldDown(e) {
- setSV(e);
- // document.body.style.cursor = 'none';
- dom.bind(window, 'mousemove', setSV);
- dom.bind(window, 'mouseup', unbindSV);
- }
-
- function unbindSV() {
- dom.unbind(window, 'mousemove', setSV);
- dom.unbind(window, 'mouseup', unbindSV);
- // document.body.style.cursor = 'default';
- }
-
- function onBlur() {
- var i = interpret(this.value);
- if (i !== false) {
- _this.__color.__state = i;
- _this.setValue(_this.__color.toOriginal());
- } else {
- this.value = _this.__color.toString();
- }
- }
-
- function unbindH() {
- dom.unbind(window, 'mousemove', setH);
- dom.unbind(window, 'mouseup', unbindH);
- }
-
- this.__saturation_field.appendChild(value_field);
- this.__selector.appendChild(this.__field_knob);
- this.__selector.appendChild(this.__saturation_field);
- this.__selector.appendChild(this.__hue_field);
- this.__hue_field.appendChild(this.__hue_knob);
-
- this.domElement.appendChild(this.__input);
- this.domElement.appendChild(this.__selector);
-
- this.updateDisplay();
-
- function setSV(e) {
-
- e.preventDefault();
-
- var w = dom.getWidth(_this.__saturation_field);
- var o = dom.getOffset(_this.__saturation_field);
- var s = (e.clientX - o.left + document.body.scrollLeft) / w;
- var v = 1 - (e.clientY - o.top + document.body.scrollTop) / w;
-
- if (v > 1) v = 1;
- else if (v < 0) v = 0;
-
- if (s > 1) s = 1;
- else if (s < 0) s = 0;
-
- _this.__color.v = v;
- _this.__color.s = s;
-
- _this.setValue(_this.__color.toOriginal());
-
-
- return false;
-
- }
-
- function setH(e) {
-
- e.preventDefault();
-
- var s = dom.getHeight(_this.__hue_field);
- var o = dom.getOffset(_this.__hue_field);
- var h = 1 - (e.clientY - o.top + document.body.scrollTop) / s;
-
- if (h > 1) h = 1;
- else if (h < 0) h = 0;
-
- _this.__color.h = h * 360;
-
- _this.setValue(_this.__color.toOriginal());
-
- return false;
-
- }
-
- };
-
- ColorController.superclass = Controller;
-
- common.extend(
-
- ColorController.prototype,
- Controller.prototype,
-
- {
-
- updateDisplay: function() {
-
- var i = interpret(this.getValue());
-
- if (i !== false) {
-
- var mismatch = false;
-
- // Check for mismatch on the interpreted value.
-
- common.each(Color.COMPONENTS, function(component) {
- if (!common.isUndefined(i[component]) &&
- !common.isUndefined(this.__color.__state[component]) &&
- i[component] !== this.__color.__state[component]) {
- mismatch = true;
- return {}; // break
- }
- }, this);
-
- // If nothing diverges, we keep our previous values
- // for statefulness, otherwise we recalculate fresh
- if (mismatch) {
- common.extend(this.__color.__state, i);
- }
-
- }
-
- common.extend(this.__temp.__state, this.__color.__state);
-
- this.__temp.a = 1;
-
- var flip = (this.__color.v < .5 || this.__color.s > .5) ? 255 : 0;
- var _flip = 255 - flip;
-
- common.extend(this.__field_knob.style, {
- marginLeft: 100 * this.__color.s - 7 + 'px',
- marginTop: 100 * (1 - this.__color.v) - 7 + 'px',
- backgroundColor: this.__temp.toString(),
- border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip +')'
- });
-
- this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + 'px'
-
- this.__temp.s = 1;
- this.__temp.v = 1;
-
- linearGradient(this.__saturation_field, 'left', '#fff', this.__temp.toString());
-
- common.extend(this.__input.style, {
- backgroundColor: this.__input.value = this.__color.toString(),
- color: 'rgb(' + flip + ',' + flip + ',' + flip +')',
- textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip +',.7)'
- });
-
- }
-
- }
-
- );
-
- var vendors = ['-moz-','-o-','-webkit-','-ms-',''];
-
- function linearGradient(elem, x, a, b) {
- elem.style.background = '';
- common.each(vendors, function(vendor) {
- elem.style.cssText += 'background: ' + vendor + 'linear-gradient('+x+', '+a+' 0%, ' + b + ' 100%); ';
- });
- }
-
- function hueGradient(elem) {
- elem.style.background = '';
- elem.style.cssText += 'background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);'
- elem.style.cssText += 'background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
- elem.style.cssText += 'background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
- elem.style.cssText += 'background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
- elem.style.cssText += 'background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
- }
-
-
- return ColorController;
-
-})(dat.controllers.Controller,
-dat.dom.dom,
-dat.color.Color = (function (interpret, math, toString, common) {
-
- var Color = function() {
-
- this.__state = interpret.apply(this, arguments);
-
- if (this.__state === false) {
- throw 'Failed to interpret color arguments';
- }
-
- this.__state.a = this.__state.a || 1;
-
-
- };
-
- Color.COMPONENTS = ['r','g','b','h','s','v','hex','a'];
-
- common.extend(Color.prototype, {
-
- toString: function() {
- return toString(this);
- },
-
- toOriginal: function() {
- return this.__state.conversion.write(this);
- }
-
- });
-
- defineRGBComponent(Color.prototype, 'r', 2);
- defineRGBComponent(Color.prototype, 'g', 1);
- defineRGBComponent(Color.prototype, 'b', 0);
-
- defineHSVComponent(Color.prototype, 'h');
- defineHSVComponent(Color.prototype, 's');
- defineHSVComponent(Color.prototype, 'v');
-
- Object.defineProperty(Color.prototype, 'a', {
-
- get: function() {
- return this.__state.a;
- },
-
- set: function(v) {
- this.__state.a = v;
- }
-
- });
-
- Object.defineProperty(Color.prototype, 'hex', {
-
- get: function() {
-
- if (!this.__state.space !== 'HEX') {
- this.__state.hex = math.rgb_to_hex(this.r, this.g, this.b);
- }
-
- return this.__state.hex;
-
- },
-
- set: function(v) {
-
- this.__state.space = 'HEX';
- this.__state.hex = v;
-
- }
-
- });
-
- function defineRGBComponent(target, component, componentHexIndex) {
-
- Object.defineProperty(target, component, {
-
- get: function() {
-
- if (this.__state.space === 'RGB') {
- return this.__state[component];
- }
-
- recalculateRGB(this, component, componentHexIndex);
-
- return this.__state[component];
-
- },
-
- set: function(v) {
-
- if (this.__state.space !== 'RGB') {
- recalculateRGB(this, component, componentHexIndex);
- this.__state.space = 'RGB';
- }
-
- this.__state[component] = v;
-
- }
-
- });
-
- }
-
- function defineHSVComponent(target, component) {
-
- Object.defineProperty(target, component, {
-
- get: function() {
-
- if (this.__state.space === 'HSV')
- return this.__state[component];
-
- recalculateHSV(this);
-
- return this.__state[component];
-
- },
-
- set: function(v) {
-
- if (this.__state.space !== 'HSV') {
- recalculateHSV(this);
- this.__state.space = 'HSV';
- }
-
- this.__state[component] = v;
-
- }
-
- });
-
- }
-
- function recalculateRGB(color, component, componentHexIndex) {
-
- if (color.__state.space === 'HEX') {
-
- color.__state[component] = math.component_from_hex(color.__state.hex, componentHexIndex);
-
- } else if (color.__state.space === 'HSV') {
-
- common.extend(color.__state, math.hsv_to_rgb(color.__state.h, color.__state.s, color.__state.v));
-
- } else {
-
- throw 'Corrupted color state';
-
- }
-
- }
-
- function recalculateHSV(color) {
-
- var result = math.rgb_to_hsv(color.r, color.g, color.b);
-
- common.extend(color.__state,
- {
- s: result.s,
- v: result.v
- }
- );
-
- if (!common.isNaN(result.h)) {
- color.__state.h = result.h;
- } else if (common.isUndefined(color.__state.h)) {
- color.__state.h = 0;
- }
-
- }
-
- return Color;
-
-})(dat.color.interpret,
-dat.color.math = (function () {
-
- var tmpComponent;
-
- return {
-
- hsv_to_rgb: function(h, s, v) {
-
- var hi = Math.floor(h / 60) % 6;
-
- var f = h / 60 - Math.floor(h / 60);
- var p = v * (1.0 - s);
- var q = v * (1.0 - (f * s));
- var t = v * (1.0 - ((1.0 - f) * s));
- var c = [
- [v, t, p],
- [q, v, p],
- [p, v, t],
- [p, q, v],
- [t, p, v],
- [v, p, q]
- ][hi];
-
- return {
- r: c[0] * 255,
- g: c[1] * 255,
- b: c[2] * 255
- };
-
- },
-
- rgb_to_hsv: function(r, g, b) {
-
- var min = Math.min(r, g, b),
- max = Math.max(r, g, b),
- delta = max - min,
- h, s;
-
- if (max != 0) {
- s = delta / max;
- } else {
- return {
- h: NaN,
- s: 0,
- v: 0
- };
- }
-
- if (r == max) {
- h = (g - b) / delta;
- } else if (g == max) {
- h = 2 + (b - r) / delta;
- } else {
- h = 4 + (r - g) / delta;
- }
- h /= 6;
- if (h < 0) {
- h += 1;
- }
-
- return {
- h: h * 360,
- s: s,
- v: max / 255
- };
- },
-
- rgb_to_hex: function(r, g, b) {
- var hex = this.hex_with_component(0, 2, r);
- hex = this.hex_with_component(hex, 1, g);
- hex = this.hex_with_component(hex, 0, b);
- return hex;
- },
-
- component_from_hex: function(hex, componentIndex) {
- return (hex >> (componentIndex * 8)) & 0xFF;
- },
-
- hex_with_component: function(hex, componentIndex, value) {
- return value << (tmpComponent = componentIndex * 8) | (hex & ~ (0xFF << tmpComponent));
- }
-
- }
-
-})(),
-dat.color.toString,
-dat.utils.common),
-dat.color.interpret,
-dat.utils.common),
-dat.utils.requestAnimationFrame = (function () {
-
- /**
- * requirejs version of Paul Irish's RequestAnimationFrame
- * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
- */
-
- return window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function(callback, element) {
-
- window.setTimeout(callback, 1000 / 60);
-
- };
-})(),
-dat.dom.CenteredDiv = (function (dom, common) {
-
-
- var CenteredDiv = function() {
-
- this.backgroundElement = document.createElement('div');
- common.extend(this.backgroundElement.style, {
- backgroundColor: 'rgba(0,0,0,0.8)',
- top: 0,
- left: 0,
- display: 'none',
- zIndex: '1000',
- opacity: 0,
- WebkitTransition: 'opacity 0.2s linear',
- transition: 'opacity 0.2s linear'
-
- });
-
- dom.makeFullscreen(this.backgroundElement);
- this.backgroundElement.style.position = 'fixed';
-
- this.domElement = document.createElement('div');
- common.extend(this.domElement.style, {
- position: 'fixed',
- display: 'none',
- zIndex: '1001',
- opacity: 0,
- WebkitTransition: '-webkit-transform 0.2s ease-out, opacity 0.2s linear',
- transition: 'transform 0.2s ease-out, opacity 0.2s linear'
- });
-
-
- document.body.appendChild(this.backgroundElement);
- document.body.appendChild(this.domElement);
-
- var _this = this;
- dom.bind(this.backgroundElement, 'click', function() {
- _this.hide();
- });
-
-
- };
-
- CenteredDiv.prototype.show = function() {
-
- var _this = this;
-
-
-
- this.backgroundElement.style.display = 'block';
-
- this.domElement.style.display = 'block';
- this.domElement.style.opacity = 0;
-// this.domElement.style.top = '52%';
- this.domElement.style.webkitTransform = 'scale(1.1)';
-
- this.layout();
-
- common.defer(function() {
- _this.backgroundElement.style.opacity = 1;
- _this.domElement.style.opacity = 1;
- _this.domElement.style.webkitTransform = 'scale(1)';
- });
-
- };
-
- CenteredDiv.prototype.hide = function() {
-
- var _this = this;
-
- var hide = function() {
-
- _this.domElement.style.display = 'none';
- _this.backgroundElement.style.display = 'none';
-
- dom.unbind(_this.domElement, 'webkitTransitionEnd', hide);
- dom.unbind(_this.domElement, 'transitionend', hide);
- dom.unbind(_this.domElement, 'oTransitionEnd', hide);
-
- };
-
- dom.bind(this.domElement, 'webkitTransitionEnd', hide);
- dom.bind(this.domElement, 'transitionend', hide);
- dom.bind(this.domElement, 'oTransitionEnd', hide);
-
- this.backgroundElement.style.opacity = 0;
-// this.domElement.style.top = '48%';
- this.domElement.style.opacity = 0;
- this.domElement.style.webkitTransform = 'scale(1.1)';
-
- };
-
- CenteredDiv.prototype.layout = function() {
- this.domElement.style.left = window.innerWidth/2 - dom.getWidth(this.domElement) / 2 + 'px';
- this.domElement.style.top = window.innerHeight/2 - dom.getHeight(this.domElement) / 2 + 'px';
- };
-
- function lockScroll(e) {
- console.log(e);
- }
-
- return CenteredDiv;
-
-})(dat.dom.dom,
-dat.utils.common),
-dat.dom.dom,
-dat.utils.common);
\ No newline at end of file
diff --git a/app/static/app/js/vendor/hammer.js b/app/static/app/js/vendor/hammer.js
deleted file mode 100644
index ef45e39b..00000000
--- a/app/static/app/js/vendor/hammer.js
+++ /dev/null
@@ -1,2486 +0,0 @@
-/*! Hammer.JS - v2.0.4 - 2015-03-02
- * http://hammerjs.github.io/
- *
- * Copyright (c) 2015 Jorik Tangelder;
- * Licensed under the MIT license */
-( function ( window, document, exportName, undefined ) {
- 'use strict';
-
- var VENDOR_PREFIXES = [ '', 'webkit', 'moz', 'MS', 'ms', 'o' ];
- var TEST_ELEMENT = document.createElement( 'div' );
-
- var TYPE_FUNCTION = 'function';
-
- var round = Math.round;
- var abs = Math.abs;
- var now = Date.now;
-
- /**
- * set a timeout with a given scope
- * @param {Function} fn
- * @param {Number} timeout
- * @param {Object} context
- * @returns {number}
- */
- function setTimeoutContext( fn, timeout, context ) {
- return setTimeout( bindFn( fn, context ), timeout );
- }
-
- /**
- * if the argument is an array, we want to execute the fn on each entry
- * if it aint an array we don't want to do a thing.
- * this is used by all the methods that accept a single and array argument.
- * @param {*|Array} arg
- * @param {String} fn
- * @param {Object} [context]
- * @returns {Boolean}
- */
- function invokeArrayArg( arg, fn, context ) {
- if ( Array.isArray( arg ) ) {
- each( arg, context[ fn ], context );
- return true;
- }
- return false;
- }
-
- /**
- * walk objects and arrays
- * @param {Object} obj
- * @param {Function} iterator
- * @param {Object} context
- */
- function each( obj, iterator, context ) {
- var i;
-
- if ( !obj ) {
- return;
- }
-
- if ( obj.forEach ) {
- obj.forEach( iterator, context );
- } else if ( obj.length !== undefined ) {
- i = 0;
- while ( i < obj.length ) {
- iterator.call( context, obj[ i ], i, obj );
- i++;
- }
- } else {
- for ( i in obj ) {
- obj.hasOwnProperty( i ) && iterator.call( context, obj[ i ], i, obj );
- }
- }
- }
-
- /**
- * extend object.
- * means that properties in dest will be overwritten by the ones in src.
- * @param {Object} dest
- * @param {Object} src
- * @param {Boolean} [merge]
- * @returns {Object} dest
- */
- function extend( dest, src, merge ) {
- var keys = Object.keys( src );
- var i = 0;
- while ( i < keys.length ) {
- if ( !merge || ( merge && dest[ keys[ i ] ] === undefined ) ) {
- dest[ keys[ i ] ] = src[ keys[ i ] ];
- }
- i++;
- }
- return dest;
- }
-
- /**
- * merge the values from src in the dest.
- * means that properties that exist in dest will not be overwritten by src
- * @param {Object} dest
- * @param {Object} src
- * @returns {Object} dest
- */
- function merge( dest, src ) {
- return extend( dest, src, true );
- }
-
- /**
- * simple class inheritance
- * @param {Function} child
- * @param {Function} base
- * @param {Object} [properties]
- */
- function inherit( child, base, properties ) {
- var baseP = base.prototype,
- childP;
-
- childP = child.prototype = Object.create( baseP );
- childP.constructor = child;
- childP._super = baseP;
-
- if ( properties ) {
- extend( childP, properties );
- }
- }
-
- /**
- * simple function bind
- * @param {Function} fn
- * @param {Object} context
- * @returns {Function}
- */
- function bindFn( fn, context ) {
- return function boundFn() {
- return fn.apply( context, arguments );
- };
- }
-
- /**
- * let a boolean value also be a function that must return a boolean
- * this first item in args will be used as the context
- * @param {Boolean|Function} val
- * @param {Array} [args]
- * @returns {Boolean}
- */
- function boolOrFn( val, args ) {
- if ( typeof val == TYPE_FUNCTION ) {
- return val.apply( args ? args[ 0 ] || undefined : undefined, args );
- }
- return val;
- }
-
- /**
- * use the val2 when val1 is undefined
- * @param {*} val1
- * @param {*} val2
- * @returns {*}
- */
- function ifUndefined( val1, val2 ) {
- return ( val1 === undefined ) ? val2 : val1;
- }
-
- /**
- * addEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function addEventListeners( target, types, handler ) {
- each( splitStr( types ), function ( type ) {
- target.addEventListener( type, handler, false );
- } );
- }
-
- /**
- * removeEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function removeEventListeners( target, types, handler ) {
- each( splitStr( types ), function ( type ) {
- target.removeEventListener( type, handler, false );
- } );
- }
-
- /**
- * find if a node is in the given parent
- * @method hasParent
- * @param {HTMLElement} node
- * @param {HTMLElement} parent
- * @return {Boolean} found
- */
- function hasParent( node, parent ) {
- while ( node ) {
- if ( node == parent ) {
- return true;
- }
- node = node.parentNode;
- }
- return false;
- }
-
- /**
- * small indexOf wrapper
- * @param {String} str
- * @param {String} find
- * @returns {Boolean} found
- */
- function inStr( str, find ) {
- return str.indexOf( find ) > -1;
- }
-
- /**
- * split string on whitespace
- * @param {String} str
- * @returns {Array} words
- */
- function splitStr( str ) {
- return str.trim().split( /\s+/g );
- }
-
- /**
- * find if a array contains the object using indexOf or a simple polyFill
- * @param {Array} src
- * @param {String} find
- * @param {String} [findByKey]
- * @return {Boolean|Number} false when not found, or the index
- */
- function inArray( src, find, findByKey ) {
- if ( src.indexOf && !findByKey ) {
- return src.indexOf( find );
- } else {
- var i = 0;
- while ( i < src.length ) {
- if ( ( findByKey && src[ i ][ findByKey ] == find ) || ( !findByKey && src[ i ] === find ) ) {
- return i;
- }
- i++;
- }
- return -1;
- }
- }
-
- /**
- * convert array-like objects to real arrays
- * @param {Object} obj
- * @returns {Array}
- */
- function toArray( obj ) {
- return Array.prototype.slice.call( obj, 0 );
- }
-
- /**
- * unique array with objects based on a key (like 'id') or just by the array's value
- * @param {Array} src [{id:1},{id:2},{id:1}]
- * @param {String} [key]
- * @param {Boolean} [sort=False]
- * @returns {Array} [{id:1},{id:2}]
- */
- function uniqueArray( src, key, sort ) {
- var results = [];
- var values = [];
- var i = 0;
-
- while ( i < src.length ) {
- var val = key ? src[ i ][ key ] : src[ i ];
- if ( inArray( values, val ) < 0 ) {
- results.push( src[ i ] );
- }
- values[ i ] = val;
- i++;
- }
-
- if ( sort ) {
- if ( !key ) {
- results = results.sort();
- } else {
- results = results.sort( function sortUniqueArray( a, b ) {
- return a[ key ] > b[ key ];
- } );
- }
- }
-
- return results;
- }
-
- /**
- * get the prefixed property
- * @param {Object} obj
- * @param {String} property
- * @returns {String|Undefined} prefixed
- */
- function prefixed( obj, property ) {
- var prefix, prop;
- var camelProp = property[ 0 ].toUpperCase() + property.slice( 1 );
-
- var i = 0;
- while ( i < VENDOR_PREFIXES.length ) {
- prefix = VENDOR_PREFIXES[ i ];
- prop = ( prefix ) ? prefix + camelProp : property;
-
- if ( prop in obj ) {
- return prop;
- }
- i++;
- }
- return undefined;
- }
-
- /**
- * get a unique id
- * @returns {number} uniqueId
- */
- var _uniqueId = 1;
-
- function uniqueId() {
- return _uniqueId++;
- }
-
- /**
- * get the window object of an element
- * @param {HTMLElement} element
- * @returns {DocumentView|Window}
- */
- function getWindowForElement( element ) {
- var doc = element.ownerDocument || element;
- return ( doc.defaultView || doc.parentWindow || window );
- }
-
- var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
-
- var SUPPORT_TOUCH = ( 'ontouchstart' in window );
- var SUPPORT_POINTER_EVENTS = prefixed( window, 'PointerEvent' ) !== undefined;
- var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test( navigator.userAgent );
-
- var INPUT_TYPE_TOUCH = 'touch';
- var INPUT_TYPE_PEN = 'pen';
- var INPUT_TYPE_MOUSE = 'mouse';
- var INPUT_TYPE_KINECT = 'kinect';
-
- var COMPUTE_INTERVAL = 25;
-
- var INPUT_START = 1;
- var INPUT_MOVE = 2;
- var INPUT_END = 4;
- var INPUT_CANCEL = 8;
-
- var DIRECTION_NONE = 1;
- var DIRECTION_LEFT = 2;
- var DIRECTION_RIGHT = 4;
- var DIRECTION_UP = 8;
- var DIRECTION_DOWN = 16;
-
- var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
- var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
- var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
-
- var PROPS_XY = [ 'x', 'y' ];
- var PROPS_CLIENT_XY = [ 'clientX', 'clientY' ];
-
- /**
- * create new input type manager
- * @param {Manager} manager
- * @param {Function} callback
- * @returns {Input}
- * @constructor
- */
- function Input( manager, callback ) {
- var self = this;
- this.manager = manager;
- this.callback = callback;
- this.element = manager.element;
- this.target = manager.options.inputTarget;
-
- // smaller wrapper around the handler, for the scope and the enabled state of the manager,
- // so when disabled the input events are completely bypassed.
- this.domHandler = function ( ev ) {
- if ( boolOrFn( manager.options.enable, [ manager ] ) ) {
- self.handler( ev );
- }
- };
-
- this.init();
-
- }
-
- Input.prototype = {
- /**
- * should handle the inputEvent data and trigger the callback
- * @virtual
- */
- handler: function () {},
-
- /**
- * bind the events
- */
- init: function () {
- this.evEl && addEventListeners( this.element, this.evEl, this.domHandler );
- this.evTarget && addEventListeners( this.target, this.evTarget, this.domHandler );
- this.evWin && addEventListeners( getWindowForElement( this.element ), this.evWin, this.domHandler );
- },
-
- /**
- * unbind the events
- */
- destroy: function () {
- this.evEl && removeEventListeners( this.element, this.evEl, this.domHandler );
- this.evTarget && removeEventListeners( this.target, this.evTarget, this.domHandler );
- this.evWin && removeEventListeners( getWindowForElement( this.element ), this.evWin, this.domHandler );
- }
- };
-
- /**
- * create new input type manager
- * called by the Manager constructor
- * @param {Hammer} manager
- * @returns {Input}
- */
- function createInputInstance( manager ) {
- var Type;
- var inputClass = manager.options.inputClass;
-
- if ( inputClass ) {
- Type = inputClass;
- } else if ( SUPPORT_POINTER_EVENTS ) {
- Type = PointerEventInput;
- } else if ( SUPPORT_ONLY_TOUCH ) {
- Type = TouchInput;
- } else if ( !SUPPORT_TOUCH ) {
- Type = MouseInput;
- } else {
- Type = TouchMouseInput;
- }
- return new( Type )( manager, inputHandler );
- }
-
- /**
- * handle input events
- * @param {Manager} manager
- * @param {String} eventType
- * @param {Object} input
- */
- function inputHandler( manager, eventType, input ) {
- var pointersLen = input.pointers.length;
- var changedPointersLen = input.changedPointers.length;
- var isFirst = ( eventType & INPUT_START && ( pointersLen - changedPointersLen === 0 ) );
- var isFinal = ( eventType & ( INPUT_END | INPUT_CANCEL ) && ( pointersLen - changedPointersLen === 0 ) );
-
- input.isFirst = !!isFirst;
- input.isFinal = !!isFinal;
-
- if ( isFirst ) {
- manager.session = {};
- }
-
- // source event is the normalized value of the domEvents
- // like 'touchstart, mouseup, pointerdown'
- input.eventType = eventType;
-
- // compute scale, rotation etc
- computeInputData( manager, input );
-
- // emit secret event
- manager.emit( 'hammer.input', input );
-
- manager.recognize( input );
- manager.session.prevInput = input;
- }
-
- /**
- * extend the data with some usable properties like scale, rotate, velocity etc
- * @param {Object} manager
- * @param {Object} input
- */
- function computeInputData( manager, input ) {
- var session = manager.session;
- var pointers = input.pointers;
- var pointersLength = pointers.length;
-
- // store the first input to calculate the distance and direction
- if ( !session.firstInput ) {
- session.firstInput = simpleCloneInputData( input );
- }
-
- // to compute scale and rotation we need to store the multiple touches
- if ( pointersLength > 1 && !session.firstMultiple ) {
- session.firstMultiple = simpleCloneInputData( input );
- } else if ( pointersLength === 1 ) {
- session.firstMultiple = false;
- }
-
- var firstInput = session.firstInput;
- var firstMultiple = session.firstMultiple;
- var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
-
- var center = input.center = getCenter( pointers );
- input.timeStamp = now();
- input.deltaTime = input.timeStamp - firstInput.timeStamp;
-
- input.angle = getAngle( offsetCenter, center );
- input.distance = getDistance( offsetCenter, center );
-
- computeDeltaXY( session, input );
- input.offsetDirection = getDirection( input.deltaX, input.deltaY );
-
- input.scale = firstMultiple ? getScale( firstMultiple.pointers, pointers ) : 1;
- input.rotation = firstMultiple ? getRotation( firstMultiple.pointers, pointers ) : 0;
-
- computeIntervalInputData( session, input );
-
- // find the correct target
- var target = manager.element;
- if ( hasParent( input.srcEvent.target, target ) ) {
- target = input.srcEvent.target;
- }
- input.target = target;
- }
-
- function computeDeltaXY( session, input ) {
- var center = input.center;
- var offset = session.offsetDelta || {};
- var prevDelta = session.prevDelta || {};
- var prevInput = session.prevInput || {};
-
- if ( input.eventType === INPUT_START || prevInput.eventType === INPUT_END ) {
- prevDelta = session.prevDelta = {
- x: prevInput.deltaX || 0,
- y: prevInput.deltaY || 0
- };
-
- offset = session.offsetDelta = {
- x: center.x,
- y: center.y
- };
- }
-
- input.deltaX = prevDelta.x + ( center.x - offset.x );
- input.deltaY = prevDelta.y + ( center.y - offset.y );
- }
-
- /**
- * velocity is calculated every x ms
- * @param {Object} session
- * @param {Object} input
- */
- function computeIntervalInputData( session, input ) {
- var last = session.lastInterval || input,
- deltaTime = input.timeStamp - last.timeStamp,
- velocity, velocityX, velocityY, direction;
-
- if ( input.eventType != INPUT_CANCEL && ( deltaTime > COMPUTE_INTERVAL || last.velocity === undefined ) ) {
- var deltaX = last.deltaX - input.deltaX;
- var deltaY = last.deltaY - input.deltaY;
-
- var v = getVelocity( deltaTime, deltaX, deltaY );
- velocityX = v.x;
- velocityY = v.y;
- velocity = ( abs( v.x ) > abs( v.y ) ) ? v.x : v.y;
- direction = getDirection( deltaX, deltaY );
-
- session.lastInterval = input;
- } else {
- // use latest velocity info if it doesn't overtake a minimum period
- velocity = last.velocity;
- velocityX = last.velocityX;
- velocityY = last.velocityY;
- direction = last.direction;
- }
-
- input.velocity = velocity;
- input.velocityX = velocityX;
- input.velocityY = velocityY;
- input.direction = direction;
- }
-
- /**
- * create a simple clone from the input used for storage of firstInput and firstMultiple
- * @param {Object} input
- * @returns {Object} clonedInputData
- */
- function simpleCloneInputData( input ) {
- // make a simple copy of the pointers because we will get a reference if we don't
- // we only need clientXY for the calculations
- var pointers = [];
- var i = 0;
- while ( i < input.pointers.length ) {
- pointers[ i ] = {
- clientX: round( input.pointers[ i ].clientX ),
- clientY: round( input.pointers[ i ].clientY )
- };
- i++;
- }
-
- return {
- timeStamp: now(),
- pointers: pointers,
- center: getCenter( pointers ),
- deltaX: input.deltaX,
- deltaY: input.deltaY
- };
- }
-
- /**
- * get the center of all the pointers
- * @param {Array} pointers
- * @return {Object} center contains `x` and `y` properties
- */
- function getCenter( pointers ) {
- var pointersLength = pointers.length;
-
- // no need to loop when only one touch
- if ( pointersLength === 1 ) {
- return {
- x: round( pointers[ 0 ].clientX ),
- y: round( pointers[ 0 ].clientY )
- };
- }
-
- var x = 0,
- y = 0,
- i = 0;
- while ( i < pointersLength ) {
- x += pointers[ i ].clientX;
- y += pointers[ i ].clientY;
- i++;
- }
-
- return {
- x: round( x / pointersLength ),
- y: round( y / pointersLength )
- };
- }
-
- /**
- * calculate the velocity between two points. unit is in px per ms.
- * @param {Number} deltaTime
- * @param {Number} x
- * @param {Number} y
- * @return {Object} velocity `x` and `y`
- */
- function getVelocity( deltaTime, x, y ) {
- return {
- x: x / deltaTime || 0,
- y: y / deltaTime || 0
- };
- }
-
- /**
- * get the direction between two points
- * @param {Number} x
- * @param {Number} y
- * @return {Number} direction
- */
- function getDirection( x, y ) {
- if ( x === y ) {
- return DIRECTION_NONE;
- }
-
- if ( abs( x ) >= abs( y ) ) {
- return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
- }
- return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
- }
-
- /**
- * calculate the absolute distance between two points
- * @param {Object} p1 {x, y}
- * @param {Object} p2 {x, y}
- * @param {Array} [props] containing x and y keys
- * @return {Number} distance
- */
- function getDistance( p1, p2, props ) {
- if ( !props ) {
- props = PROPS_XY;
- }
- var x = p2[ props[ 0 ] ] - p1[ props[ 0 ] ],
- y = p2[ props[ 1 ] ] - p1[ props[ 1 ] ];
-
- return Math.sqrt( ( x * x ) + ( y * y ) );
- }
-
- /**
- * calculate the angle between two coordinates
- * @param {Object} p1
- * @param {Object} p2
- * @param {Array} [props] containing x and y keys
- * @return {Number} angle
- */
- function getAngle( p1, p2, props ) {
- if ( !props ) {
- props = PROPS_XY;
- }
- var x = p2[ props[ 0 ] ] - p1[ props[ 0 ] ],
- y = p2[ props[ 1 ] ] - p1[ props[ 1 ] ];
- return Math.atan2( y, x ) * 180 / Math.PI;
- }
-
- /**
- * calculate the rotation degrees between two pointersets
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} rotation
- */
- function getRotation( start, end ) {
- return getAngle( end[ 1 ], end[ 0 ], PROPS_CLIENT_XY ) - getAngle( start[ 1 ], start[ 0 ], PROPS_CLIENT_XY );
- }
-
- /**
- * calculate the scale factor between two pointersets
- * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} scale
- */
- function getScale( start, end ) {
- return getDistance( end[ 0 ], end[ 1 ], PROPS_CLIENT_XY ) / getDistance( start[ 0 ], start[ 1 ], PROPS_CLIENT_XY );
- }
-
- var MOUSE_INPUT_MAP = {
- mousedown: INPUT_START,
- mousemove: INPUT_MOVE,
- mouseup: INPUT_END
- };
-
- var MOUSE_ELEMENT_EVENTS = 'mousedown';
- var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
-
- /**
- * Mouse events input
- * @constructor
- * @extends Input
- */
- function MouseInput() {
- this.evEl = MOUSE_ELEMENT_EVENTS;
- this.evWin = MOUSE_WINDOW_EVENTS;
-
- this.allow = true; // used by Input.TouchMouse to disable mouse events
- this.pressed = false; // mousedown state
-
- Input.apply( this, arguments );
- }
-
- inherit( MouseInput, Input, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function MEhandler( ev ) {
- var eventType = MOUSE_INPUT_MAP[ ev.type ];
-
- // on start we want to have the left mouse button down
- if ( eventType & INPUT_START && ev.button === 0 ) {
- this.pressed = true;
- }
-
- if ( eventType & INPUT_MOVE && ev.which !== 1 ) {
- eventType = INPUT_END;
- }
-
- // mouse must be down, and mouse events are allowed (see the TouchMouse input)
- if ( !this.pressed || !this.allow ) {
- return;
- }
-
- if ( eventType & INPUT_END ) {
- this.pressed = false;
- }
-
- this.callback( this.manager, eventType, {
- pointers: [ ev ],
- changedPointers: [ ev ],
- pointerType: INPUT_TYPE_MOUSE,
- srcEvent: ev
- } );
- }
- } );
-
- var POINTER_INPUT_MAP = {
- pointerdown: INPUT_START,
- pointermove: INPUT_MOVE,
- pointerup: INPUT_END,
- pointercancel: INPUT_CANCEL,
- pointerout: INPUT_CANCEL
- };
-
- // in IE10 the pointer types is defined as an enum
- var IE10_POINTER_TYPE_ENUM = {
- 2: INPUT_TYPE_TOUCH,
- 3: INPUT_TYPE_PEN,
- 4: INPUT_TYPE_MOUSE,
- 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
- };
-
- var POINTER_ELEMENT_EVENTS = 'pointerdown';
- var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
-
- // IE10 has prefixed support, and case-sensitive
- if ( window.MSPointerEvent && !window.PointerEvent ) {
- POINTER_ELEMENT_EVENTS = 'MSPointerDown';
- POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
- }
-
- /**
- * Pointer events input
- * @constructor
- * @extends Input
- */
- function PointerEventInput() {
- this.evEl = POINTER_ELEMENT_EVENTS;
- this.evWin = POINTER_WINDOW_EVENTS;
-
- Input.apply( this, arguments );
-
- this.store = ( this.manager.session.pointerEvents = [] );
- }
-
- inherit( PointerEventInput, Input, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function PEhandler( ev ) {
- var store = this.store;
- var removePointer = false;
-
- var eventTypeNormalized = ev.type.toLowerCase().replace( 'ms', '' );
- var eventType = POINTER_INPUT_MAP[ eventTypeNormalized ];
- var pointerType = IE10_POINTER_TYPE_ENUM[ ev.pointerType ] || ev.pointerType;
-
- var isTouch = ( pointerType == INPUT_TYPE_TOUCH );
-
- // get index of the event in the store
- var storeIndex = inArray( store, ev.pointerId, 'pointerId' );
-
- // start and mouse must be down
- if ( eventType & INPUT_START && ( ev.button === 0 || isTouch ) ) {
- if ( storeIndex < 0 ) {
- store.push( ev );
- storeIndex = store.length - 1;
- }
- } else if ( eventType & ( INPUT_END | INPUT_CANCEL ) ) {
- removePointer = true;
- }
-
- // it not found, so the pointer hasn't been down (so it's probably a hover)
- if ( storeIndex < 0 ) {
- return;
- }
-
- // update the event in the store
- store[ storeIndex ] = ev;
-
- this.callback( this.manager, eventType, {
- pointers: store,
- changedPointers: [ ev ],
- pointerType: pointerType,
- srcEvent: ev
- } );
-
- if ( removePointer ) {
- // remove from the store
- store.splice( storeIndex, 1 );
- }
- }
- } );
-
- var SINGLE_TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
-
- var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
- var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
-
- /**
- * Touch events input
- * @constructor
- * @extends Input
- */
- function SingleTouchInput() {
- this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
- this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
- this.started = false;
-
- Input.apply( this, arguments );
- }
-
- inherit( SingleTouchInput, Input, {
- handler: function TEhandler( ev ) {
- var type = SINGLE_TOUCH_INPUT_MAP[ ev.type ];
-
- // should we handle the touch events?
- if ( type === INPUT_START ) {
- this.started = true;
- }
-
- if ( !this.started ) {
- return;
- }
-
- var touches = normalizeSingleTouches.call( this, ev, type );
-
- // when done, reset the started state
- if ( type & ( INPUT_END | INPUT_CANCEL ) && touches[ 0 ].length - touches[ 1 ].length === 0 ) {
- this.started = false;
- }
-
- this.callback( this.manager, type, {
- pointers: touches[ 0 ],
- changedPointers: touches[ 1 ],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- } );
- }
- } );
-
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function normalizeSingleTouches( ev, type ) {
- var all = toArray( ev.touches );
- var changed = toArray( ev.changedTouches );
-
- if ( type & ( INPUT_END | INPUT_CANCEL ) ) {
- all = uniqueArray( all.concat( changed ), 'identifier', true );
- }
-
- return [ all, changed ];
- }
-
- var TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
-
- var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
-
- /**
- * Multi-user touch events input
- * @constructor
- * @extends Input
- */
- function TouchInput() {
- this.evTarget = TOUCH_TARGET_EVENTS;
- this.targetIds = {};
-
- Input.apply( this, arguments );
- }
-
- inherit( TouchInput, Input, {
- handler: function MTEhandler( ev ) {
- var type = TOUCH_INPUT_MAP[ ev.type ];
- var touches = getTouches.call( this, ev, type );
- if ( !touches ) {
- return;
- }
-
- this.callback( this.manager, type, {
- pointers: touches[ 0 ],
- changedPointers: touches[ 1 ],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- } );
- }
- } );
-
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function getTouches( ev, type ) {
- var allTouches = toArray( ev.touches );
- var targetIds = this.targetIds;
-
- // when there is only one touch, the process can be simplified
- if ( type & ( INPUT_START | INPUT_MOVE ) && allTouches.length === 1 ) {
- targetIds[ allTouches[ 0 ].identifier ] = true;
- return [ allTouches, allTouches ];
- }
-
- var i,
- targetTouches,
- changedTouches = toArray( ev.changedTouches ),
- changedTargetTouches = [],
- target = this.target;
-
- // get target touches from touches
- targetTouches = allTouches.filter( function ( touch ) {
- return hasParent( touch.target, target );
- } );
-
- // collect touches
- if ( type === INPUT_START ) {
- i = 0;
- while ( i < targetTouches.length ) {
- targetIds[ targetTouches[ i ].identifier ] = true;
- i++;
- }
- }
-
- // filter changed touches to only contain touches that exist in the collected target ids
- i = 0;
- while ( i < changedTouches.length ) {
- if ( targetIds[ changedTouches[ i ].identifier ] ) {
- changedTargetTouches.push( changedTouches[ i ] );
- }
-
- // cleanup removed touches
- if ( type & ( INPUT_END | INPUT_CANCEL ) ) {
- delete targetIds[ changedTouches[ i ].identifier ];
- }
- i++;
- }
-
- if ( !changedTargetTouches.length ) {
- return;
- }
-
- return [
- // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
- uniqueArray( targetTouches.concat( changedTargetTouches ), 'identifier', true ),
- changedTargetTouches
- ];
- }
-
- /**
- * Combined touch and mouse input
- *
- * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
- * This because touch devices also emit mouse events while doing a touch.
- *
- * @constructor
- * @extends Input
- */
- function TouchMouseInput() {
- Input.apply( this, arguments );
-
- var handler = bindFn( this.handler, this );
- this.touch = new TouchInput( this.manager, handler );
- this.mouse = new MouseInput( this.manager, handler );
- }
-
- inherit( TouchMouseInput, Input, {
- /**
- * handle mouse and touch events
- * @param {Hammer} manager
- * @param {String} inputEvent
- * @param {Object} inputData
- */
- handler: function TMEhandler( manager, inputEvent, inputData ) {
- var isTouch = ( inputData.pointerType == INPUT_TYPE_TOUCH ),
- isMouse = ( inputData.pointerType == INPUT_TYPE_MOUSE );
-
- // when we're in a touch event, so block all upcoming mouse events
- // most mobile browser also emit mouseevents, right after touchstart
- if ( isTouch ) {
- this.mouse.allow = false;
- } else if ( isMouse && !this.mouse.allow ) {
- return;
- }
-
- // reset the allowMouse when we're done
- if ( inputEvent & ( INPUT_END | INPUT_CANCEL ) ) {
- this.mouse.allow = true;
- }
-
- this.callback( manager, inputEvent, inputData );
- },
-
- /**
- * remove the event listeners
- */
- destroy: function destroy() {
- this.touch.destroy();
- this.mouse.destroy();
- }
- } );
-
- var PREFIXED_TOUCH_ACTION = prefixed( TEST_ELEMENT.style, 'touchAction' );
- var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
-
- // magical touchAction value
- var TOUCH_ACTION_COMPUTE = 'compute';
- var TOUCH_ACTION_AUTO = 'auto';
- var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
- var TOUCH_ACTION_NONE = 'none';
- var TOUCH_ACTION_PAN_X = 'pan-x';
- var TOUCH_ACTION_PAN_Y = 'pan-y';
-
- /**
- * Touch Action
- * sets the touchAction property or uses the js alternative
- * @param {Manager} manager
- * @param {String} value
- * @constructor
- */
- function TouchAction( manager, value ) {
- this.manager = manager;
- this.set( value );
- }
-
- TouchAction.prototype = {
- /**
- * set the touchAction value on the element or enable the polyfill
- * @param {String} value
- */
- set: function ( value ) {
- // find out the touch-action by the event handlers
- if ( value == TOUCH_ACTION_COMPUTE ) {
- value = this.compute();
- }
-
- if ( NATIVE_TOUCH_ACTION && this.manager.element.style ) {
- this.manager.element.style[ PREFIXED_TOUCH_ACTION ] = value;
- }
- this.actions = value.toLowerCase().trim();
- },
-
- /**
- * just re-set the touchAction value
- */
- update: function () {
- this.set( this.manager.options.touchAction );
- },
-
- /**
- * compute the value for the touchAction property based on the recognizer's settings
- * @returns {String} value
- */
- compute: function () {
- var actions = [];
- each( this.manager.recognizers, function ( recognizer ) {
- if ( boolOrFn( recognizer.options.enable, [ recognizer ] ) ) {
- actions = actions.concat( recognizer.getTouchAction() );
- }
- } );
- return cleanTouchActions( actions.join( ' ' ) );
- },
-
- /**
- * this method is called on each input cycle and provides the preventing of the browser behavior
- * @param {Object} input
- */
- preventDefaults: function ( input ) {
- // not needed with native support for the touchAction property
- if ( NATIVE_TOUCH_ACTION ) {
- return;
- }
-
- var srcEvent = input.srcEvent;
- var direction = input.offsetDirection;
-
- // if the touch action did prevented once this session
- if ( this.manager.session.prevented ) {
- srcEvent.preventDefault();
- return;
- }
-
- var actions = this.actions;
- var hasNone = inStr( actions, TOUCH_ACTION_NONE );
- var hasPanY = inStr( actions, TOUCH_ACTION_PAN_Y );
- var hasPanX = inStr( actions, TOUCH_ACTION_PAN_X );
-
- if ( hasNone ||
- ( hasPanY && direction & DIRECTION_HORIZONTAL ) ||
- ( hasPanX && direction & DIRECTION_VERTICAL ) ) {
- return this.preventSrc( srcEvent );
- }
- },
-
- /**
- * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
- * @param {Object} srcEvent
- */
- preventSrc: function ( srcEvent ) {
- this.manager.session.prevented = true;
- srcEvent.preventDefault();
- }
- };
-
- /**
- * when the touchActions are collected they are not a valid value, so we need to clean things up. *
- * @param {String} actions
- * @returns {*}
- */
- function cleanTouchActions( actions ) {
- // none
- if ( inStr( actions, TOUCH_ACTION_NONE ) ) {
- return TOUCH_ACTION_NONE;
- }
-
- var hasPanX = inStr( actions, TOUCH_ACTION_PAN_X );
- var hasPanY = inStr( actions, TOUCH_ACTION_PAN_Y );
-
- // pan-x and pan-y can be combined
- if ( hasPanX && hasPanY ) {
- return TOUCH_ACTION_PAN_X + ' ' + TOUCH_ACTION_PAN_Y;
- }
-
- // pan-x OR pan-y
- if ( hasPanX || hasPanY ) {
- return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
- }
-
- // manipulation
- if ( inStr( actions, TOUCH_ACTION_MANIPULATION ) ) {
- return TOUCH_ACTION_MANIPULATION;
- }
-
- return TOUCH_ACTION_AUTO;
- }
-
- /**
- * Recognizer flow explained; *
- * All recognizers have the initial state of POSSIBLE when a input session starts.
- * The definition of a input session is from the first input until the last input, with all it's movement in it. *
- * Example session for mouse-input: mousedown -> mousemove -> mouseup
- *
- * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
- * which determines with state it should be.
- *
- * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
- * POSSIBLE to give it another change on the next cycle.
- *
- * Possible
- * |
- * +-----+---------------+
- * | |
- * +-----+-----+ |
- * | | |
- * Failed Cancelled |
- * +-------+------+
- * | |
- * Recognized Began
- * |
- * Changed
- * |
- * Ended/Recognized
- */
- var STATE_POSSIBLE = 1;
- var STATE_BEGAN = 2;
- var STATE_CHANGED = 4;
- var STATE_ENDED = 8;
- var STATE_RECOGNIZED = STATE_ENDED;
- var STATE_CANCELLED = 16;
- var STATE_FAILED = 32;
-
- /**
- * Recognizer
- * Every recognizer needs to extend from this class.
- * @constructor
- * @param {Object} options
- */
- function Recognizer( options ) {
- this.id = uniqueId();
-
- this.manager = null;
- this.options = merge( options || {}, this.defaults );
-
- // default is enable true
- this.options.enable = ifUndefined( this.options.enable, true );
-
- this.state = STATE_POSSIBLE;
-
- this.simultaneous = {};
- this.requireFail = [];
- }
-
- Recognizer.prototype = {
- /**
- * @virtual
- * @type {Object}
- */
- defaults: {},
-
- /**
- * set options
- * @param {Object} options
- * @return {Recognizer}
- */
- set: function ( options ) {
- extend( this.options, options );
-
- // also update the touchAction, in case something changed about the directions/enabled state
- this.manager && this.manager.touchAction.update();
- return this;
- },
-
- /**
- * recognize simultaneous with an other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- recognizeWith: function ( otherRecognizer ) {
- if ( invokeArrayArg( otherRecognizer, 'recognizeWith', this ) ) {
- return this;
- }
-
- var simultaneous = this.simultaneous;
- otherRecognizer = getRecognizerByNameIfManager( otherRecognizer, this );
- if ( !simultaneous[ otherRecognizer.id ] ) {
- simultaneous[ otherRecognizer.id ] = otherRecognizer;
- otherRecognizer.recognizeWith( this );
- }
- return this;
- },
-
- /**
- * drop the simultaneous link. it doesnt remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRecognizeWith: function ( otherRecognizer ) {
- if ( invokeArrayArg( otherRecognizer, 'dropRecognizeWith', this ) ) {
- return this;
- }
-
- otherRecognizer = getRecognizerByNameIfManager( otherRecognizer, this );
- delete this.simultaneous[ otherRecognizer.id ];
- return this;
- },
-
- /**
- * recognizer can only run when an other is failing
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- requireFailure: function ( otherRecognizer ) {
- if ( invokeArrayArg( otherRecognizer, 'requireFailure', this ) ) {
- return this;
- }
-
- var requireFail = this.requireFail;
- otherRecognizer = getRecognizerByNameIfManager( otherRecognizer, this );
- if ( inArray( requireFail, otherRecognizer ) === -1 ) {
- requireFail.push( otherRecognizer );
- otherRecognizer.requireFailure( this );
- }
- return this;
- },
-
- /**
- * drop the requireFailure link. it does not remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRequireFailure: function ( otherRecognizer ) {
- if ( invokeArrayArg( otherRecognizer, 'dropRequireFailure', this ) ) {
- return this;
- }
-
- otherRecognizer = getRecognizerByNameIfManager( otherRecognizer, this );
- var index = inArray( this.requireFail, otherRecognizer );
- if ( index > -1 ) {
- this.requireFail.splice( index, 1 );
- }
- return this;
- },
-
- /**
- * has require failures boolean
- * @returns {boolean}
- */
- hasRequireFailures: function () {
- return this.requireFail.length > 0;
- },
-
- /**
- * if the recognizer can recognize simultaneous with an other recognizer
- * @param {Recognizer} otherRecognizer
- * @returns {Boolean}
- */
- canRecognizeWith: function ( otherRecognizer ) {
- return !!this.simultaneous[ otherRecognizer.id ];
- },
-
- /**
- * You should use `tryEmit` instead of `emit` directly to check
- * that all the needed recognizers has failed before emitting.
- * @param {Object} input
- */
- emit: function ( input ) {
- var self = this;
- var state = this.state;
-
- function emit( withState ) {
- self.manager.emit( self.options.event + ( withState ? stateStr( state ) : '' ), input );
- }
-
- // 'panstart' and 'panmove'
- if ( state < STATE_ENDED ) {
- emit( true );
- }
-
- emit(); // simple 'eventName' events
-
- // panend and pancancel
- if ( state >= STATE_ENDED ) {
- emit( true );
- }
- },
-
- /**
- * Check that all the require failure recognizers has failed,
- * if true, it emits a gesture event,
- * otherwise, setup the state to FAILED.
- * @param {Object} input
- */
- tryEmit: function ( input ) {
- if ( this.canEmit() ) {
- return this.emit( input );
- }
- // it's failing anyway
- this.state = STATE_FAILED;
- },
-
- /**
- * can we emit?
- * @returns {boolean}
- */
- canEmit: function () {
- var i = 0;
- while ( i < this.requireFail.length ) {
- if ( !( this.requireFail[ i ].state & ( STATE_FAILED | STATE_POSSIBLE ) ) ) {
- return false;
- }
- i++;
- }
- return true;
- },
-
- /**
- * update the recognizer
- * @param {Object} inputData
- */
- recognize: function ( inputData ) {
- // make a new copy of the inputData
- // so we can change the inputData without messing up the other recognizers
- var inputDataClone = extend( {}, inputData );
-
- // is is enabled and allow recognizing?
- if ( !boolOrFn( this.options.enable, [ this, inputDataClone ] ) ) {
- this.reset();
- this.state = STATE_FAILED;
- return;
- }
-
- // reset when we've reached the end
- if ( this.state & ( STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED ) ) {
- this.state = STATE_POSSIBLE;
- }
-
- this.state = this.process( inputDataClone );
-
- // the recognizer has recognized a gesture
- // so trigger an event
- if ( this.state & ( STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED ) ) {
- this.tryEmit( inputDataClone );
- }
- },
-
- /**
- * return the state of the recognizer
- * the actual recognizing happens in this method
- * @virtual
- * @param {Object} inputData
- * @returns {Const} STATE
- */
- process: function ( inputData ) {}, // jshint ignore:line
-
- /**
- * return the preferred touch-action
- * @virtual
- * @returns {Array}
- */
- getTouchAction: function () {},
-
- /**
- * called when the gesture isn't allowed to recognize
- * like when another is being recognized or it is disabled
- * @virtual
- */
- reset: function () {}
- };
-
- /**
- * get a usable string, used as event postfix
- * @param {Const} state
- * @returns {String} state
- */
- function stateStr( state ) {
- if ( state & STATE_CANCELLED ) {
- return 'cancel';
- } else if ( state & STATE_ENDED ) {
- return 'end';
- } else if ( state & STATE_CHANGED ) {
- return 'move';
- } else if ( state & STATE_BEGAN ) {
- return 'start';
- }
- return '';
- }
-
- /**
- * direction cons to string
- * @param {Const} direction
- * @returns {String}
- */
- function directionStr( direction ) {
- if ( direction == DIRECTION_DOWN ) {
- return 'down';
- } else if ( direction == DIRECTION_UP ) {
- return 'up';
- } else if ( direction == DIRECTION_LEFT ) {
- return 'left';
- } else if ( direction == DIRECTION_RIGHT ) {
- return 'right';
- }
- return '';
- }
-
- /**
- * get a recognizer by name if it is bound to a manager
- * @param {Recognizer|String} otherRecognizer
- * @param {Recognizer} recognizer
- * @returns {Recognizer}
- */
- function getRecognizerByNameIfManager( otherRecognizer, recognizer ) {
- var manager = recognizer.manager;
- if ( manager ) {
- return manager.get( otherRecognizer );
- }
- return otherRecognizer;
- }
-
- /**
- * This recognizer is just used as a base for the simple attribute recognizers.
- * @constructor
- * @extends Recognizer
- */
- function AttrRecognizer() {
- Recognizer.apply( this, arguments );
- }
-
- inherit( AttrRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof AttrRecognizer
- */
- defaults: {
- /**
- * @type {Number}
- * @default 1
- */
- pointers: 1
- },
-
- /**
- * Used to check if it the recognizer receives valid input, like input.distance > 10.
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {Boolean} recognized
- */
- attrTest: function ( input ) {
- var optionPointers = this.options.pointers;
- return optionPointers === 0 || input.pointers.length === optionPointers;
- },
-
- /**
- * Process the input and return the state for the recognizer
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {*} State
- */
- process: function ( input ) {
- var state = this.state;
- var eventType = input.eventType;
-
- var isRecognized = state & ( STATE_BEGAN | STATE_CHANGED );
- var isValid = this.attrTest( input );
-
- // on cancel input and we've recognized before, return STATE_CANCELLED
- if ( isRecognized && ( eventType & INPUT_CANCEL || !isValid ) ) {
- return state | STATE_CANCELLED;
- } else if ( isRecognized || isValid ) {
- if ( eventType & INPUT_END ) {
- return state | STATE_ENDED;
- } else if ( !( state & STATE_BEGAN ) ) {
- return STATE_BEGAN;
- }
- return state | STATE_CHANGED;
- }
- return STATE_FAILED;
- }
- } );
-
- /**
- * Pan
- * Recognized when the pointer is down and moved in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function PanRecognizer() {
- AttrRecognizer.apply( this, arguments );
-
- this.pX = null;
- this.pY = null;
- }
-
- inherit( PanRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PanRecognizer
- */
- defaults: {
- event: 'pan',
- threshold: 10,
- pointers: 1,
- direction: DIRECTION_ALL
- },
-
- getTouchAction: function () {
- var direction = this.options.direction;
- var actions = [];
- if ( direction & DIRECTION_HORIZONTAL ) {
- actions.push( TOUCH_ACTION_PAN_Y );
- }
- if ( direction & DIRECTION_VERTICAL ) {
- actions.push( TOUCH_ACTION_PAN_X );
- }
- return actions;
- },
-
- directionTest: function ( input ) {
- var options = this.options;
- var hasMoved = true;
- var distance = input.distance;
- var direction = input.direction;
- var x = input.deltaX;
- var y = input.deltaY;
-
- // lock to axis?
- if ( !( direction & options.direction ) ) {
- if ( options.direction & DIRECTION_HORIZONTAL ) {
- direction = ( x === 0 ) ? DIRECTION_NONE : ( x < 0 ) ? DIRECTION_LEFT : DIRECTION_RIGHT;
- hasMoved = x != this.pX;
- distance = Math.abs( input.deltaX );
- } else {
- direction = ( y === 0 ) ? DIRECTION_NONE : ( y < 0 ) ? DIRECTION_UP : DIRECTION_DOWN;
- hasMoved = y != this.pY;
- distance = Math.abs( input.deltaY );
- }
- }
- input.direction = direction;
- return hasMoved && distance > options.threshold && direction & options.direction;
- },
-
- attrTest: function ( input ) {
- return AttrRecognizer.prototype.attrTest.call( this, input ) &&
- ( this.state & STATE_BEGAN || ( !( this.state & STATE_BEGAN ) && this.directionTest( input ) ) );
- },
-
- emit: function ( input ) {
- this.pX = input.deltaX;
- this.pY = input.deltaY;
-
- var direction = directionStr( input.direction );
- if ( direction ) {
- this.manager.emit( this.options.event + direction, input );
- }
-
- this._super.emit.call( this, input );
- }
- } );
-
- /**
- * Pinch
- * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
- * @constructor
- * @extends AttrRecognizer
- */
- function PinchRecognizer() {
- AttrRecognizer.apply( this, arguments );
- }
-
- inherit( PinchRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'pinch',
- threshold: 0,
- pointers: 2
- },
-
- getTouchAction: function () {
- return [ TOUCH_ACTION_NONE ];
- },
-
- attrTest: function ( input ) {
- return this._super.attrTest.call( this, input ) &&
- ( Math.abs( input.scale - 1 ) > this.options.threshold || this.state & STATE_BEGAN );
- },
-
- emit: function ( input ) {
- this._super.emit.call( this, input );
- if ( input.scale !== 1 ) {
- var inOut = input.scale < 1 ? 'in' : 'out';
- this.manager.emit( this.options.event + inOut, input );
- }
- }
- } );
-
- /**
- * Press
- * Recognized when the pointer is down for x ms without any movement.
- * @constructor
- * @extends Recognizer
- */
- function PressRecognizer() {
- Recognizer.apply( this, arguments );
-
- this._timer = null;
- this._input = null;
- }
-
- inherit( PressRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PressRecognizer
- */
- defaults: {
- event: 'press',
- pointers: 1,
- time: 500, // minimal time of the pointer to be pressed
- threshold: 5 // a minimal movement is ok, but keep it low
- },
-
- getTouchAction: function () {
- return [ TOUCH_ACTION_AUTO ];
- },
-
- process: function ( input ) {
- var options = this.options;
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTime = input.deltaTime > options.time;
-
- this._input = input;
-
- // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if ( !validMovement || !validPointers || ( input.eventType & ( INPUT_END | INPUT_CANCEL ) && !validTime ) ) {
- this.reset();
- } else if ( input.eventType & INPUT_START ) {
- this.reset();
- this._timer = setTimeoutContext( function () {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.time, this );
- } else if ( input.eventType & INPUT_END ) {
- return STATE_RECOGNIZED;
- }
- return STATE_FAILED;
- },
-
- reset: function () {
- clearTimeout( this._timer );
- },
-
- emit: function ( input ) {
- if ( this.state !== STATE_RECOGNIZED ) {
- return;
- }
-
- if ( input && ( input.eventType & INPUT_END ) ) {
- this.manager.emit( this.options.event + 'up', input );
- } else {
- this._input.timeStamp = now();
- this.manager.emit( this.options.event, this._input );
- }
- }
- } );
-
- /**
- * Rotate
- * Recognized when two or more pointer are moving in a circular motion.
- * @constructor
- * @extends AttrRecognizer
- */
- function RotateRecognizer() {
- AttrRecognizer.apply( this, arguments );
- }
-
- inherit( RotateRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof RotateRecognizer
- */
- defaults: {
- event: 'rotate',
- threshold: 0,
- pointers: 2
- },
-
- getTouchAction: function () {
- return [ TOUCH_ACTION_NONE ];
- },
-
- attrTest: function ( input ) {
- return this._super.attrTest.call( this, input ) &&
- ( Math.abs( input.rotation ) > this.options.threshold || this.state & STATE_BEGAN );
- }
- } );
-
- /**
- * Swipe
- * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function SwipeRecognizer() {
- AttrRecognizer.apply( this, arguments );
- }
-
- inherit( SwipeRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof SwipeRecognizer
- */
- defaults: {
- event: 'swipe',
- threshold: 10,
- velocity: 0.65,
- direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
- pointers: 1
- },
-
- getTouchAction: function () {
- return PanRecognizer.prototype.getTouchAction.call( this );
- },
-
- attrTest: function ( input ) {
- var direction = this.options.direction;
- var velocity;
-
- if ( direction & ( DIRECTION_HORIZONTAL | DIRECTION_VERTICAL ) ) {
- velocity = input.velocity;
- } else if ( direction & DIRECTION_HORIZONTAL ) {
- velocity = input.velocityX;
- } else if ( direction & DIRECTION_VERTICAL ) {
- velocity = input.velocityY;
- }
-
- return this._super.attrTest.call( this, input ) &&
- direction & input.direction &&
- input.distance > this.options.threshold &&
- abs( velocity ) > this.options.velocity && input.eventType & INPUT_END;
- },
-
- emit: function ( input ) {
- var direction = directionStr( input.direction );
- if ( direction ) {
- this.manager.emit( this.options.event + direction, input );
- }
-
- this.manager.emit( this.options.event, input );
- }
- } );
-
- /**
- * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
- * between the given interval and position. The delay option can be used to recognize multi-taps without firing
- * a single tap.
- *
- * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
- * multi-taps being recognized.
- * @constructor
- * @extends Recognizer
- */
- function TapRecognizer() {
- Recognizer.apply( this, arguments );
-
- // previous time and center,
- // used for tap counting
- this.pTime = false;
- this.pCenter = false;
-
- this._timer = null;
- this._input = null;
- this.count = 0;
- }
-
- inherit( TapRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'tap',
- pointers: 1,
- taps: 1,
- interval: 300, // max time between the multi-tap taps
- time: 250, // max time of the pointer to be down (like finger on the screen)
- threshold: 2, // a minimal movement is ok, but keep it low
- posThreshold: 10 // a multi-tap can be a bit off the initial position
- },
-
- getTouchAction: function () {
- return [ TOUCH_ACTION_MANIPULATION ];
- },
-
- process: function ( input ) {
- var options = this.options;
-
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTouchTime = input.deltaTime < options.time;
-
- this.reset();
-
- if ( ( input.eventType & INPUT_START ) && ( this.count === 0 ) ) {
- return this.failTimeout();
- }
-
- // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if ( validMovement && validTouchTime && validPointers ) {
- if ( input.eventType != INPUT_END ) {
- return this.failTimeout();
- }
-
- var validInterval = this.pTime ? ( input.timeStamp - this.pTime < options.interval ) : true;
- var validMultiTap = !this.pCenter || getDistance( this.pCenter, input.center ) < options.posThreshold;
-
- this.pTime = input.timeStamp;
- this.pCenter = input.center;
-
- if ( !validMultiTap || !validInterval ) {
- this.count = 1;
- } else {
- this.count += 1;
- }
-
- this._input = input;
-
- // if tap count matches we have recognized it,
- // else it has began recognizing...
- var tapCount = this.count % options.taps;
- if ( tapCount === 0 ) {
- // no failing requirements, immediately trigger the tap event
- // or wait as long as the multitap interval to trigger
- if ( !this.hasRequireFailures() ) {
- return STATE_RECOGNIZED;
- } else {
- this._timer = setTimeoutContext( function () {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.interval, this );
- return STATE_BEGAN;
- }
- }
- }
- return STATE_FAILED;
- },
-
- failTimeout: function () {
- this._timer = setTimeoutContext( function () {
- this.state = STATE_FAILED;
- }, this.options.interval, this );
- return STATE_FAILED;
- },
-
- reset: function () {
- clearTimeout( this._timer );
- },
-
- emit: function () {
- if ( this.state == STATE_RECOGNIZED ) {
- this._input.tapCount = this.count;
- this.manager.emit( this.options.event, this._input );
- }
- }
- } );
-
- /**
- * Simple way to create an manager with a default set of recognizers.
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Hammer( element, options ) {
- options = options || {};
- options.recognizers = ifUndefined( options.recognizers, Hammer.defaults.preset );
- return new Manager( element, options );
- }
-
- /**
- * @const {string}
- */
- Hammer.VERSION = '2.0.4';
-
- /**
- * default settings
- * @namespace
- */
- Hammer.defaults = {
- /**
- * set if DOM events are being triggered.
- * But this is slower and unused by simple implementations, so disabled by default.
- * @type {Boolean}
- * @default false
- */
- domEvents: false,
-
- /**
- * The value for the touchAction property/fallback.
- * When set to `compute` it will magically set the correct value based on the added recognizers.
- * @type {String}
- * @default compute
- */
- touchAction: TOUCH_ACTION_COMPUTE,
-
- /**
- * @type {Boolean}
- * @default true
- */
- enable: true,
-
- /**
- * EXPERIMENTAL FEATURE -- can be removed/changed
- * Change the parent input target element.
- * If Null, then it is being set the to main element.
- * @type {Null|EventTarget}
- * @default null
- */
- inputTarget: null,
-
- /**
- * force an input class
- * @type {Null|Function}
- * @default null
- */
- inputClass: null,
-
- /**
- * Default recognizer setup when calling `Hammer()`
- * When creating a new Manager these will be skipped.
- * @type {Array}
- */
- preset: [
- // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
- [ RotateRecognizer, {
- enable: false
- } ],
- [ PinchRecognizer, {
- enable: false
- },
- [ 'rotate' ]
- ],
- [ SwipeRecognizer, {
- direction: DIRECTION_HORIZONTAL
- } ],
- [ PanRecognizer, {
- direction: DIRECTION_HORIZONTAL
- },
- [ 'swipe' ]
- ],
- [ TapRecognizer ],
- [ TapRecognizer, {
- event: 'doubletap',
- taps: 2
- },
- [ 'tap' ]
- ],
- [ PressRecognizer ]
- ],
-
- /**
- * Some CSS properties can be used to improve the working of Hammer.
- * Add them to this method and they will be set when creating a new Manager.
- * @namespace
- */
- cssProps: {
- /**
- * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userSelect: 'none',
-
- /**
- * Disable the Windows Phone grippers when pressing an element.
- * @type {String}
- * @default 'none'
- */
- touchSelect: 'none',
-
- /**
- * Disables the default callout shown when you touch and hold a touch target.
- * On iOS, when you touch and hold a touch target such as a link, Safari displays
- * a callout containing information about the link. This property allows you to disable that callout.
- * @type {String}
- * @default 'none'
- */
- touchCallout: 'none',
-
- /**
- * Specifies whether zooming is enabled. Used by IE10>
- * @type {String}
- * @default 'none'
- */
- contentZooming: 'none',
-
- /**
- * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userDrag: 'none',
-
- /**
- * Overrides the highlight color shown when the user taps a link or a JavaScript
- * clickable element in iOS. This property obeys the alpha value, if specified.
- * @type {String}
- * @default 'rgba(0,0,0,0)'
- */
- tapHighlightColor: 'rgba(0,0,0,0)'
- }
- };
-
- var STOP = 1;
- var FORCED_STOP = 2;
-
- /**
- * Manager
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Manager( element, options ) {
- options = options || {};
-
- this.options = merge( options, Hammer.defaults );
- this.options.inputTarget = this.options.inputTarget || element;
-
- this.handlers = {};
- this.session = {};
- this.recognizers = [];
-
- this.element = element;
- this.input = createInputInstance( this );
- this.touchAction = new TouchAction( this, this.options.touchAction );
-
- toggleCssProps( this, true );
-
- each( options.recognizers, function ( item ) {
- var recognizer = this.add( new( item[ 0 ] )( item[ 1 ] ) );
- item[ 2 ] && recognizer.recognizeWith( item[ 2 ] );
- item[ 3 ] && recognizer.requireFailure( item[ 3 ] );
- }, this );
- }
-
- Manager.prototype = {
- /**
- * set options
- * @param {Object} options
- * @returns {Manager}
- */
- set: function ( options ) {
- extend( this.options, options );
-
- // Options that need a little more setup
- if ( options.touchAction ) {
- this.touchAction.update();
- }
- if ( options.inputTarget ) {
- // Clean up existing event listeners and reinitialize
- this.input.destroy();
- this.input.target = options.inputTarget;
- this.input.init();
- }
- return this;
- },
-
- /**
- * stop recognizing for this session.
- * This session will be discarded, when a new [input]start event is fired.
- * When forced, the recognizer cycle is stopped immediately.
- * @param {Boolean} [force]
- */
- stop: function ( force ) {
- this.session.stopped = force ? FORCED_STOP : STOP;
- },
-
- /**
- * run the recognizers!
- * called by the inputHandler function on every movement of the pointers (touches)
- * it walks through all the recognizers and tries to detect the gesture that is being made
- * @param {Object} inputData
- */
- recognize: function ( inputData ) {
- var session = this.session;
- if ( session.stopped ) {
- return;
- }
-
- // run the touch-action polyfill
- this.touchAction.preventDefaults( inputData );
-
- var recognizer;
- var recognizers = this.recognizers;
-
- // this holds the recognizer that is being recognized.
- // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
- // if no recognizer is detecting a thing, it is set to `null`
- var curRecognizer = session.curRecognizer;
-
- // reset when the last recognizer is recognized
- // or when we're in a new session
- if ( !curRecognizer || ( curRecognizer && curRecognizer.state & STATE_RECOGNIZED ) ) {
- curRecognizer = session.curRecognizer = null;
- }
-
- var i = 0;
- while ( i < recognizers.length ) {
- recognizer = recognizers[ i ];
-
- // find out if we are allowed try to recognize the input for this one.
- // 1. allow if the session is NOT forced stopped (see the .stop() method)
- // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
- // that is being recognized.
- // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
- // this can be setup with the `recognizeWith()` method on the recognizer.
- if ( session.stopped !== FORCED_STOP && ( // 1
- !curRecognizer || recognizer == curRecognizer || // 2
- recognizer.canRecognizeWith( curRecognizer ) ) ) { // 3
- recognizer.recognize( inputData );
- } else {
- recognizer.reset();
- }
-
- // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
- // current active recognizer. but only if we don't already have an active recognizer
- if ( !curRecognizer && recognizer.state & ( STATE_BEGAN | STATE_CHANGED | STATE_ENDED ) ) {
- curRecognizer = session.curRecognizer = recognizer;
- }
- i++;
- }
- },
-
- /**
- * get a recognizer by its event name.
- * @param {Recognizer|String} recognizer
- * @returns {Recognizer|Null}
- */
- get: function ( recognizer ) {
- if ( recognizer instanceof Recognizer ) {
- return recognizer;
- }
-
- var recognizers = this.recognizers;
- for ( var i = 0; i < recognizers.length; i++ ) {
- if ( recognizers[ i ].options.event == recognizer ) {
- return recognizers[ i ];
- }
- }
- return null;
- },
-
- /**
- * add a recognizer to the manager
- * existing recognizers with the same event name will be removed
- * @param {Recognizer} recognizer
- * @returns {Recognizer|Manager}
- */
- add: function ( recognizer ) {
- if ( invokeArrayArg( recognizer, 'add', this ) ) {
- return this;
- }
-
- // remove existing
- var existing = this.get( recognizer.options.event );
- if ( existing ) {
- this.remove( existing );
- }
-
- this.recognizers.push( recognizer );
- recognizer.manager = this;
-
- this.touchAction.update();
- return recognizer;
- },
-
- /**
- * remove a recognizer by name or instance
- * @param {Recognizer|String} recognizer
- * @returns {Manager}
- */
- remove: function ( recognizer ) {
- if ( invokeArrayArg( recognizer, 'remove', this ) ) {
- return this;
- }
-
- var recognizers = this.recognizers;
- recognizer = this.get( recognizer );
- recognizers.splice( inArray( recognizers, recognizer ), 1 );
-
- this.touchAction.update();
- return this;
- },
-
- /**
- * bind event
- * @param {String} events
- * @param {Function} handler
- * @returns {EventEmitter} this
- */
- on: function ( events, handler ) {
- var handlers = this.handlers;
- each( splitStr( events ), function ( event ) {
- handlers[ event ] = handlers[ event ] || [];
- handlers[ event ].push( handler );
- } );
- return this;
- },
-
- /**
- * unbind event, leave emit blank to remove all handlers
- * @param {String} events
- * @param {Function} [handler]
- * @returns {EventEmitter} this
- */
- off: function ( events, handler ) {
- var handlers = this.handlers;
- each( splitStr( events ), function ( event ) {
- if ( !handler ) {
- delete handlers[ event ];
- } else {
- handlers[ event ].splice( inArray( handlers[ event ], handler ), 1 );
- }
- } );
- return this;
- },
-
- /**
- * emit event to the listeners
- * @param {String} event
- * @param {Object} data
- */
- emit: function ( event, data ) {
- // we also want to trigger dom events
- if ( this.options.domEvents ) {
- triggerDomEvent( event, data );
- }
-
- // no handlers, so skip it all
- var handlers = this.handlers[ event ] && this.handlers[ event ].slice();
- if ( !handlers || !handlers.length ) {
- return;
- }
-
- data.type = event;
- data.preventDefault = function () {
- data.srcEvent.preventDefault();
- };
-
- var i = 0;
- while ( i < handlers.length ) {
- handlers[ i ]( data );
- i++;
- }
- },
-
- /**
- * destroy the manager and unbinds all events
- * it doesn't unbind dom events, that is the user own responsibility
- */
- destroy: function () {
- this.element && toggleCssProps( this, false );
-
- this.handlers = {};
- this.session = {};
- this.input.destroy();
- this.element = null;
- }
- };
-
- /**
- * add/remove the css properties as defined in manager.options.cssProps
- * @param {Manager} manager
- * @param {Boolean} add
- */
- function toggleCssProps( manager, add ) {
- var element = manager.element;
- if ( !element.style ) {
- return;
- }
- each( manager.options.cssProps, function ( value, name ) {
- element.style[ prefixed( element.style, name ) ] = add ? value : '';
- } );
- }
-
- /**
- * trigger dom event
- * @param {String} event
- * @param {Object} data
- */
- function triggerDomEvent( event, data ) {
- var gestureEvent = document.createEvent( 'Event' );
- gestureEvent.initEvent( event, true, true );
- gestureEvent.gesture = data;
- data.target.dispatchEvent( gestureEvent );
- }
-
- extend( Hammer, {
- INPUT_START: INPUT_START,
- INPUT_MOVE: INPUT_MOVE,
- INPUT_END: INPUT_END,
- INPUT_CANCEL: INPUT_CANCEL,
-
- STATE_POSSIBLE: STATE_POSSIBLE,
- STATE_BEGAN: STATE_BEGAN,
- STATE_CHANGED: STATE_CHANGED,
- STATE_ENDED: STATE_ENDED,
- STATE_RECOGNIZED: STATE_RECOGNIZED,
- STATE_CANCELLED: STATE_CANCELLED,
- STATE_FAILED: STATE_FAILED,
-
- DIRECTION_NONE: DIRECTION_NONE,
- DIRECTION_LEFT: DIRECTION_LEFT,
- DIRECTION_RIGHT: DIRECTION_RIGHT,
- DIRECTION_UP: DIRECTION_UP,
- DIRECTION_DOWN: DIRECTION_DOWN,
- DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
- DIRECTION_VERTICAL: DIRECTION_VERTICAL,
- DIRECTION_ALL: DIRECTION_ALL,
-
- Manager: Manager,
- Input: Input,
- TouchAction: TouchAction,
-
- TouchInput: TouchInput,
- MouseInput: MouseInput,
- PointerEventInput: PointerEventInput,
- TouchMouseInput: TouchMouseInput,
- SingleTouchInput: SingleTouchInput,
-
- Recognizer: Recognizer,
- AttrRecognizer: AttrRecognizer,
- Tap: TapRecognizer,
- Pan: PanRecognizer,
- Swipe: SwipeRecognizer,
- Pinch: PinchRecognizer,
- Rotate: RotateRecognizer,
- Press: PressRecognizer,
-
- on: addEventListeners,
- off: removeEventListeners,
- each: each,
- merge: merge,
- extend: extend,
- inherit: inherit,
- bindFn: bindFn,
- prefixed: prefixed
- } );
-
- if ( typeof define == TYPE_FUNCTION && define.amd ) {
- define( function () {
- return Hammer;
- } );
- } else if ( typeof module != 'undefined' && module.exports ) {
- module.exports = Hammer;
- } else {
- window[ exportName ] = Hammer;
- }
-
-} )( window, document, 'Hammer' );
diff --git a/app/static/app/js/vendor/npm.js b/app/static/app/js/vendor/npm.js
deleted file mode 100644
index bf6aa806..00000000
--- a/app/static/app/js/vendor/npm.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
-require('../../js/transition.js')
-require('../../js/alert.js')
-require('../../js/button.js')
-require('../../js/carousel.js')
-require('../../js/collapse.js')
-require('../../js/dropdown.js')
-require('../../js/modal.js')
-require('../../js/tooltip.js')
-require('../../js/popover.js')
-require('../../js/scrollspy.js')
-require('../../js/tab.js')
-require('../../js/affix.js')
\ No newline at end of file
diff --git a/app/static/app/js/vendor/osgjs/OSG.js b/app/static/app/js/vendor/osgjs/OSG.js
deleted file mode 100644
index 6199a3b5..00000000
--- a/app/static/app/js/vendor/osgjs/OSG.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict';
-var osgNameSpace = require( 'osgNameSpace' );
-var osg = require( 'osg/osg' );
-var osgAnimation = require( 'osgAnimation/osgAnimation' );
-var osgDB = require( 'osgDB/osgDB' );
-var osgGA = require( 'osgGA/osgGA' );
-var osgUtil = require( 'osgUtil/osgUtil' );
-var osgViewer = require( 'osgViewer/osgViewer' );
-var osgShader = require( 'osgShader/osgShader' );
-var osgShadow = require( 'osgShadow/osgShadow' );
-var osgText = require( 'osgText/osgText' );
-var osgWrappers = require( 'osgWrappers/osgWrappers' );
-var osgPlugins = require( 'osgPlugins/osgPlugins' );
-
-
-var openSceneGraph = osgNameSpace;
-
-openSceneGraph.osg = osg;
-openSceneGraph.osgAnimation = osgAnimation;
-openSceneGraph.osgDB = osgDB;
-openSceneGraph.osgGA = osgGA;
-openSceneGraph.osgUtil = osgUtil;
-openSceneGraph.osgViewer = osgViewer;
-openSceneGraph.osgShader = osgShader;
-openSceneGraph.osgShadow = osgShadow;
-openSceneGraph.osgText = osgText;
-openSceneGraph.osgWrappers = osgWrappers;
-openSceneGraph.osgPlugins = osgPlugins;
-
-var namespaces = [ 'osg', 'osgAnimation', 'osgDB', 'osgGA', 'osgUtil', 'osgViewer', 'osgShader', 'osgShadow', 'osgText', 'osgWrappers', 'osgPlugins' ];
-
-
-// for backward compatibility
-openSceneGraph.globalify = function () {
- namespaces.forEach( function ( namespace ) {
- window[ namespace ] = openSceneGraph[ namespace ];
- } );
-};
-
-module.exports = openSceneGraph;
diff --git a/app/static/app/js/vendor/osgjs/config.js b/app/static/app/js/vendor/osgjs/config.js
deleted file mode 100644
index 5b932c08..00000000
--- a/app/static/app/js/vendor/osgjs/config.js
+++ /dev/null
@@ -1,5 +0,0 @@
-'use strict';
-
-module.exports = {
- ArrayType: Float64Array
-};
diff --git a/app/static/app/js/vendor/osgjs/osg/AutoTransform.js b/app/static/app/js/vendor/osgjs/osg/AutoTransform.js
deleted file mode 100644
index cd6c9300..00000000
--- a/app/static/app/js/vendor/osgjs/osg/AutoTransform.js
+++ /dev/null
@@ -1,332 +0,0 @@
-'use strict';
-
-var MACROUTILS = require( 'osg/Utils' );
-var Transform = require( 'osg/Transform' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var quat = require( 'osg/glMatrix' ).quat;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var TransformEnums = require( 'osg/transformEnums' );
-var Node = require( 'osg/Node' );
-
-/** AutoTransform is a derived form of Transform that automatically
- * scales or rotates to keep its children aligned with screen coordinates.
- * W.r.t. AutorotateModes only rotate to screen is supported right now.
- * More AutorotateModes modes should be addressed in the future.
- * @class AutoTransform
- */
-
-var AutoTransform = function () {
- Transform.call( this );
- this._matrix = mat4.create();
- this._position = vec3.create();
- this._matrixDirty = true;
- this._scale = vec3.fromValues( 1.0, 1.0, 1.0 );
- this._minimumScale = 0;
- this._maximumScale = Number.MAX_VALUE;
- this._rotation = quat.create();
- this._pivotPoint = vec3.create();
- this._autoScaleToScreen = false;
- this._autoRotateToScreen = false;
- this._cachedMatrix = mat4.create();
- this._firstTimeToInitEyePoint = true;
- this._autoScaleTransitionWidthRatio = 0.25;
- this._billboardAttribute = undefined;
- this._previousWidth = 0.0;
- this._previousHeight = 0.0;
- this._previousProjection = mat4.create();
- this._previousModelView = mat4.create();
- this._previousPosition = vec3.create();
-};
-
-/** @lends Autotransform.prototype */
-AutoTransform.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Transform.prototype, {
-
- getMatrix: function () {
- return this._matrix;
- },
-
- setMatrix: function ( m ) {
- this._matrix = m;
- this.dirtyBound();
- },
-
- setPosition: function ( pos ) {
- this._position = pos;
- this._matrixDirty = true;
- this.dirtyBound();
- },
- getPosition: function () {
- return this._position;
- },
-
- setRotation: function ( q ) {
- this._rotation = q;
- this._matrixDirty = true;
- this.dirtyBound();
- },
-
- getRotation: function () {
- return this._rotation;
- },
-
- setScale: function ( scale ) {
- this.setScaleFromvec3( vec3.fromValues( scale, scale, scale ) );
- },
-
- setScaleFromvec3: function ( scaleVec ) {
- this._scale = scaleVec;
- this._matrixDirty = true;
- this.dirtyBound();
- },
-
- getScale: function () {
- return this._scale;
- },
-
- setMinimumScale: function ( minimumScale ) {
- this._minimumScale = minimumScale;
- },
-
- getMinimumScale: function () {
- return this._minimumScale;
- },
-
- setMaximumScale: function ( maximumScale ) {
- this._maximumScale = maximumScale;
- },
-
- getMaximumScale: function () {
- return this._maximumScale;
- },
-
- setAutoScaleToScreen: function ( autoScaleToScreen ) {
- this._autoScaleToScreen = autoScaleToScreen;
- this._matrixDirty = true;
- },
-
- getAutoScaleToScreen: function () {
- return this._autoScaleToScreen;
- },
-
- setAutoRotateToScreen: function ( value ) {
- this._autoRotateToScreen = value;
- },
-
- getAutoRotateToScreen: function () {
- return this._autoRotateToScreen;
- },
-
- setAutoScaleTransitionWidthRatio: function ( autoScaleTransitionWidthRatio ) {
- this._autoScaleTransitionWidthRatio = autoScaleTransitionWidthRatio;
- },
-
- getAutoScaleTransitionWidthRatio: function () {
- return this._autoScaleTransitionWidthRatio;
- },
-
- // local to "local world" (not Global World)
- computeLocalToWorldMatrix: function ( matrix /*, nodeVisitor */ ) {
- if ( this._matrixDirty ) this.computeMatrix();
- if ( this.referenceFrame === TransformEnums.RELATIVE_RF ) {
- mat4.mul( matrix, matrix, this._matrix );
- } else {
- mat4.copy( matrix, this._matrix );
- }
- },
-
- computeMatrix: ( function () {
- var neg = vec3.create();
- var tmpMat = mat4.create();
- return function () {
- if ( !this._matrixDirty ) return;
- mat4.fromQuat( this._matrix, this._rotation );
-
- mat4.fromTranslation( tmpMat, this._position );
- mat4.mul( this._matrix, tmpMat, this._matrix );
- mat4.scale( this._matrix, this._matrix, this._scale );
- mat4.translate( this._matrix, this._matrix, vec3.neg( neg, this._pivotPoint ) );
- this._matrixDirty = false;
- };
-
- } )(),
-
- computeWorldToLocalMatrix: ( function () {
- var neg = vec3.create();
- var rotInverse = quat.create();
- var scaleInverse = vec3.create();
- var tmpMat = mat4.create();
-
- return function ( matrix /*, nodeVisitor */ ) {
- if ( this.scale[ 0 ] === 0.0 && this.scale[ 1 ] === 0.0 && this.scale[ 2 ] === 0.0 ) {
- return false;
- }
- scaleInverse[ 0 ] = 1.0 / this._scale[ 0 ];
- scaleInverse[ 1 ] = 1.0 / this._scale[ 1 ];
- scaleInverse[ 2 ] = 1.0 / this._scale[ 2 ];
- if ( this.referenceFrame === TransformEnums.RELATIVE_RF ) {
-
- mat4.fromTranslation( tmpMat, vec3.neg( neg, this._position ) );
- mat4.mul( matrix, tmpMat, matrix );
-
- if ( !quat.zeroRotation( this._rotation ) ) {
- mat4.fromQuat( tmpMat, quat.invert( rotInverse, this._rotation ) );
- mat4.mul( matrix, tmpMat, matrix );
- }
- mat4.fromScaling( tmpMat, scaleInverse );
- mat4.mul( matrix, tmpMat, matrix );
-
- mat4.fromTranslation( tmpMat, this._pivotPoint );
- mat4.mul( matrix, tmpMat, matrix );
-
- } else { // absolute
- mat4.fromQuat( this._matrix, quat.invert( rotInverse, this._rotation ) );
- mat4.translate( matrix, matrix, vec3.neg( neg, this._position ) );
-
- mat4.fromScaling( tmpMat, scaleInverse );
- mat4.mul( matrix, tmpMat, matrix );
-
- mat4.fromTranslation( tmpMat, this._pivotPoint );
- mat4.mul( matrix, tmpMat, matrix );
-
- }
- return true;
- };
- } )(),
-
- computeBound: ( function () {
- var matrix = mat4.create();
- return function ( bSphere ) {
- if ( this._autoScaleToScreen && this._firstTimeToInitEyePoint )
- return bSphere;
- Node.prototype.computeBound.call( this, bSphere );
- if ( !bSphere.valid() ) {
- return bSphere;
- }
- mat4.identity( matrix );
- // local to local world (not Global World)
- this.computeLocalToWorldMatrix( matrix );
- //Matrix.transformBoundingSphere( matrix, bSphere, bSphere );
- bSphere.transformMat4( bSphere, matrix );
- return bSphere;
- };
- } )(),
-
- accept: ( function () {
-
- return function ( visitor ) {
- if ( visitor.getVisitorType() === NodeVisitor.CULL_VISITOR ) {
-
- var width = visitor.getViewport().width();
- var height = visitor.getViewport().height();
- var projMat = visitor.getCurrentProjectionMatrix();
- var modelViewMat = visitor.getCurrentModelViewMatrix();
- var position = this._position;
- var doUpdate = this._firstTimeToInitEyePoint;
- if ( !this._firstTimeToInitEyePoint ) {
- if ( width !== this._previousWidth || height !== this._previousHeight ) {
- doUpdate = true;
- } else if ( !mat4.exactEquals( projMat, this._previousProjection ) ) {
- doUpdate = true;
- } else if ( !mat4.exactEquals( modelViewMat, this._previousModelView ) ) {
- doUpdate = true;
- } else if ( !vec3.exactEquals( position, this._previousPosition ) ) {
- doUpdate = true;
- }
- }
- this._firstTimeToInitEyePoint = false;
- if ( doUpdate ) {
- if ( this._autoScaleToScreen ) {
- var viewport = visitor.getViewport();
- var psvector = this.computePixelSizeVector( viewport, projMat, modelViewMat );
- var v = vec4.fromValues( this._position[ 0 ], this._position[ 1 ], this._position[ 2 ], 1.0 );
- var pixelSize = vec4.dot( v, psvector );
- pixelSize = 0.48 / pixelSize;
- var size = 1.0 / pixelSize;
- if ( this._autoScaleTransitionWidthRatio > 0.0 ) {
- var c, b, a;
- if ( this._minimumScale > 0.0 ) {
- var j = this._minimumScale;
- var i = ( this._maximumScale < Number.MAX_VALUE ) ?
- this._minimumScale + ( this._maximumScale - this._minimumScale ) * this._autoScaleTransitionWidthRatio :
- this._minimumScale * ( 1.0 + this._autoScaleTransitionWidthRatio );
- c = 1.0 / ( 4.0 * ( i - j ) );
- b = 1.0 - 2.0 * c * i;
- a = j + b * b / ( 4.0 * c );
- var k = -b / ( 2.0 * c );
- if ( size < k ) size = this._minimumScale;
- else if ( size < i ) size = a + b * size + c * ( size * size );
- }
- if ( this._maximumScale < Number.MAX_VALUE ) {
- var n = this._maximumScale;
- var m = ( this._minimumScale > 0.0 ) ?
- this._maximumScale + ( this._minimumScale - this._maximumScale ) * this._autoScaleTransitionWidthRatio :
- this._maximumScale * ( 1.0 - this._autoScaleTransitionWidthRatio );
- c = 1.0 / ( 4.0 * ( m - n ) );
- b = 1.0 - 2.0 * c * m;
- a = n + b * b / ( 4.0 * c );
- var p = -b / ( 2.0 * c );
-
- if ( size > p ) size = this._maximumScale;
- else if ( size > m ) size = a + b * size + c * ( size * size );
- }
- }
- this.setScale( size );
- }
- if ( this._autoRotateToScreen ) {
- var rotation = quat.create();
- mat4.getRotation( rotation, modelViewMat );
- this.setRotation( quat.invert( rotation, rotation ) );
- }
- this._previousWidth = width;
- this._previousHeight = height;
- vec3.copy( this._previousPosition, position );
- mat4.copy( this._previousProjection, projMat );
- mat4.copy( this._previousModelView, modelViewMat );
- }
- }
-
- Node.prototype.accept.call( this, visitor );
- };
- } )(),
-
- computePixelSizeVector: ( function () {
- var scale00 = vec3.create();
- var scale10 = vec3.create();
- return function ( W, P, M ) {
- // Where W = viewport, P = ProjectionMatrix, M = ModelViewMatrix
- // Comment from OSG:
- // pre adjust P00,P20,P23,P33 by multiplying them by the viewport window matrix.
- // here we do it in short hand with the knowledge of how the window matrix is formed
- // note P23,P33 are multiplied by an implicit 1 which would come from the window matrix.
-
- // scaling for horizontal pixels
- var P00 = P[ 0 ] * W.width() * 0.5;
- var P20_00 = P[ 8 ] * W.width() * 0.5 + P[ 11 ] * W.width() * 0.5;
- vec3.set( scale00, M[ 0 ] * P00 + M[ 2 ] * P20_00,
- M[ 4 ] * P00 + M[ 6 ] * P20_00,
- M[ 8 ] * P00 + M[ 10 ] * P20_00 );
-
- // scaling for vertical pixels
- var P10 = P[ 5 ] * W.height() * 0.5;
- var P20_10 = P[ 9 ] * W.height() * 0.5 + P[ 11 ] * W.height() * 0.5;
- vec3.set( scale10, M[ 1 ] * P10 + M[ 2 ] * P20_10,
- M[ 5 ] * P10 + M[ 6 ] * P20_10,
- M[ 9 ] * P10 + M[ 10 ] * P20_10 );
-
- var P23 = P[ 11 ];
- var P33 = P[ 15 ];
- var pixelSizeVector = vec4.fromValues( M[ 2 ] * P23, M[ 6 ] * P23, M[ 10 ] * P23, M[ 14 ] * P23 + M[ 15 ] * P33 );
-
- var scaleRatio = 0.7071067811 / Math.sqrt( vec3.sqrLen( scale00 ) + vec3.sqrLen( scale10 ) );
- vec4.scale( pixelSizeVector, pixelSizeVector, scaleRatio );
- return pixelSizeVector;
- };
- } )()
-
-
-} ), 'osg', 'AutoTransform' );
-MACROUTILS.setTypeID( AutoTransform );
-
-module.exports = AutoTransform;
diff --git a/app/static/app/js/vendor/osgjs/osg/BillboardAttribute.js b/app/static/app/js/vendor/osgjs/osg/BillboardAttribute.js
deleted file mode 100644
index e11713d6..00000000
--- a/app/static/app/js/vendor/osgjs/osg/BillboardAttribute.js
+++ /dev/null
@@ -1,31 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-
-
-var BillboardAttribute = function () {
- StateAttribute.call( this );
- this._attributeEnable = false;
-};
-
-BillboardAttribute.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Billboard',
-
- cloneType: function () {
- return new BillboardAttribute();
- },
-
- setEnabled: function ( state ) {
- this._attributeEnable = state;
- },
-
- isEnabled: function () {
- return this._attributeEnable;
- },
-
- apply: function () {}
-
-} ), 'osg', 'Billboard' );
-
-module.exports = BillboardAttribute;
diff --git a/app/static/app/js/vendor/osgjs/osg/BlendColor.js b/app/static/app/js/vendor/osgjs/osg/BlendColor.js
deleted file mode 100644
index 16d20128..00000000
--- a/app/static/app/js/vendor/osgjs/osg/BlendColor.js
+++ /dev/null
@@ -1,49 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-
-/**
- * Manage BlendColor attribute
- * @class
- * @memberOf osg
- * @extends StateAttribute
- */
-var BlendColor = function ( color ) {
- StateAttribute.call( this );
- this._constantColor = vec4.create();
- vec4.set( this._constantColor, 1.0, 1.0, 1.0, 1.0 );
- if ( color !== undefined ) {
- this.setConstantColor( color );
- }
-};
-
-/**
- * @lends BlendColor.prototype
- */
-BlendColor.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
- attributeType: 'BlendColor',
- cloneType: function () {
- return new BlendColor();
- },
-
- /**
- *
- * @param {} color
- */
- setConstantColor: function ( color ) {
- vec4.copy( this._constantColor, color );
- },
- getConstantColor: function () {
- return this._constantColor;
- },
- apply: function ( state ) {
- var gl = state.getGraphicContext();
- gl.blendColor( this._constantColor[ 0 ],
- this._constantColor[ 1 ],
- this._constantColor[ 2 ],
- this._constantColor[ 3 ] );
- }
-} ), 'osg', 'BlendColor' );
-
-module.exports = BlendColor;
diff --git a/app/static/app/js/vendor/osgjs/osg/BlendFunc.js b/app/static/app/js/vendor/osgjs/osg/BlendFunc.js
deleted file mode 100644
index d9ae54c1..00000000
--- a/app/static/app/js/vendor/osgjs/osg/BlendFunc.js
+++ /dev/null
@@ -1,155 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-
-/**
- * Manage Blending mode
- * @class BlendFunc
- */
-var BlendFunc = function ( sourceRGB, destinationRGB, sourceAlpha, destinationAlpha ) {
- StateAttribute.call( this );
- this._sourceFactor = BlendFunc.DISABLE;
- this._destinationFactor = BlendFunc.DISABLE;
- this._sourceFactorAlpha = this._sourceFactor;
- this._destinationFactorAlpha = this._destinationFactor;
- this._separate = false;
- if ( sourceRGB !== undefined ) {
- this.setSource( sourceRGB );
- }
- if ( destinationRGB !== undefined ) {
- this.setDestination( destinationRGB );
- }
-
- if ( sourceAlpha !== undefined ) {
- this.setSourceAlpha( sourceAlpha );
- }
- if ( destinationAlpha !== undefined ) {
- this.setDestinationAlpha( destinationAlpha );
- }
-};
-
-BlendFunc.DISABLE = -1;
-BlendFunc.ZERO = 0;
-BlendFunc.ONE = 1;
-BlendFunc.SRC_COLOR = 0x0300;
-BlendFunc.ONE_MINUS_SRC_COLOR = 0x0301;
-BlendFunc.SRC_ALPHA = 0x0302;
-BlendFunc.ONE_MINUS_SRC_ALPHA = 0x0303;
-BlendFunc.DST_ALPHA = 0x0304;
-BlendFunc.ONE_MINUS_DST_ALPHA = 0x0305;
-BlendFunc.DST_COLOR = 0x0306;
-BlendFunc.ONE_MINUS_DST_COLOR = 0x0307;
-BlendFunc.SRC_ALPHA_SATURATE = 0x0308;
-
-/* Separate Blend Functions */
-BlendFunc.BLEND_DST_RGB = 0x80C8;
-BlendFunc.BLEND_SRC_RGB = 0x80C9;
-BlendFunc.BLEND_DST_ALPHA = 0x80CA;
-BlendFunc.BLEND_SRC_ALPHA = 0x80CB;
-BlendFunc.CONSTANT_COLOR = 0x8001;
-BlendFunc.ONE_MINUS_CONSTANT_COLOR = 0x8002;
-BlendFunc.CONSTANT_ALPHA = 0x8003;
-BlendFunc.ONE_MINUS_CONSTANT_ALPHA = 0x8004;
-BlendFunc.BLEND_COLOR = 0x8005;
-
-
-/** @lends BlendFunc.prototype */
-BlendFunc.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
- /**
- StateAttribute type of BlendFunc
- @type String
- */
- attributeType: 'BlendFunc',
- /**
- Create an instance of this StateAttribute
- */
- cloneType: function () /**BlendFunc*/ {
- return new BlendFunc();
- },
- setSource: function ( f ) {
- this.setSourceRGB( f );
- this.setSourceAlpha( f );
- },
- getSource: function () {
- return this._sourceFactor;
- },
- setDestination: function ( f ) {
- this.setDestinationRGB( f );
- this.setDestinationAlpha( f );
- },
- getDestination: function () {
- return this._destinationFactor;
- },
- getSeparate: function () {
- return this._separate;
- },
- checkSeparate: function () {
- return ( this._sourceFactor !== this._sourceFactorAlpha ||
- this._destinationFactor !== this._destinationFactorAlpha );
- },
- setSourceRGB: function ( f ) {
- if ( typeof f === 'string' ) {
- this._sourceFactor = BlendFunc[ f ];
- } else {
- this._sourceFactor = f;
- }
- this._separate = this.checkSeparate();
- },
- getSourceRGB: function () {
- return this._sourceFactor;
- },
- setSourceAlpha: function ( f ) {
- if ( typeof f === 'string' ) {
- this._sourceFactorAlpha = BlendFunc[ f ];
- } else {
- this._sourceFactorAlpha = f;
- }
- this._separate = this.checkSeparate();
- },
- getSourceAlpha: function () {
- return this._sourceFactorAlpha;
- },
- setDestinationRGB: function ( f ) {
- if ( typeof f === 'string' ) {
- this._destinationFactor = BlendFunc[ f ];
- } else {
- this._destinationFactor = f;
- }
- this._separate = this.checkSeparate();
- },
- getDestinationRGB: function () {
- return this._destinationFactor;
- },
- setDestinationAlpha: function ( f ) {
- if ( typeof f === 'string' ) {
- this._destinationFactorAlpha = BlendFunc[ f ];
- } else {
- this._destinationFactorAlpha = f;
- }
- this._separate = this.checkSeparate();
- },
- getDestinationAlpha: function () {
- return this._destinationFactorAlpha;
- },
-
- /**
- Apply the mode, must be called in the draw traversal
- @param state
- */
- apply: function ( state ) {
- var gl = state.getGraphicContext();
- if ( this._sourceFactor === BlendFunc.DISABLE || this._destinationFactor === BlendFunc.DISABLE ) {
- gl.disable( gl.BLEND );
- } else {
- gl.enable( gl.BLEND );
- if ( this._separate ) {
- gl.blendFuncSeparate( this._sourceFactor, this._destinationFactor,
- this._sourceFactorAlpha, this._destinationFactorAlpha );
- } else {
- gl.blendFunc( this._sourceFactor, this._destinationFactor );
- }
- }
- }
-} ), 'osg', 'BlendFunc' );
-
-module.exports = BlendFunc;
diff --git a/app/static/app/js/vendor/osgjs/osg/BoundingBox.js b/app/static/app/js/vendor/osgjs/osg/BoundingBox.js
deleted file mode 100644
index 32567f4b..00000000
--- a/app/static/app/js/vendor/osgjs/osg/BoundingBox.js
+++ /dev/null
@@ -1,228 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-
-
-var BoundingBox = function () {
- this._min = vec3.create();
- this._max = vec3.create();
- this.init();
-};
-BoundingBox.prototype = MACROUTILS.objectLibraryClass( {
-
- init: function () {
- vec3.copy( this._min, vec3.INFINITY );
- vec3.copy( this._max, vec3.NEGATIVE_INFINITY );
- },
-
- copy: function ( bbox ) {
- var min = this._min;
- var bmin = bbox._min;
- min[ 0 ] = bmin[ 0 ];
- min[ 1 ] = bmin[ 1 ];
- min[ 2 ] = bmin[ 2 ];
-
- var max = this._max;
- var bmax = bbox._max;
- max[ 0 ] = bmax[ 0 ];
- max[ 1 ] = bmax[ 1 ];
- max[ 2 ] = bmax[ 2 ];
- },
-
- valid: function () {
- return ( this._max[ 0 ] >= this._min[ 0 ] && this._max[ 1 ] >= this._min[ 1 ] && this._max[ 2 ] >= this._min[ 2 ] );
- },
-
- expandByBoundingSphere: function ( bs ) {
- if ( !bs.valid() ) {
- return;
- }
- var max = this._max;
- var min = this._min;
- var radius = bs._radius;
- var x = bs._center[ 0 ];
- var y = bs._center[ 1 ];
- var z = bs._center[ 2 ];
- min[ 0 ] = Math.min( min[ 0 ], x - radius );
- min[ 1 ] = Math.min( min[ 1 ], y - radius );
- min[ 2 ] = Math.min( min[ 2 ], z - radius );
-
- max[ 0 ] = Math.max( max[ 0 ], x + radius );
- max[ 1 ] = Math.max( max[ 1 ], y + radius );
- max[ 2 ] = Math.max( max[ 2 ], z + radius );
- },
-
- expandBySphere: function ( bs ) {
- Notify.log( 'BoundingBox.expandBySphere is deprecated, use instead BoundBox.expandByBoundingSphere' );
- return this.expandByBoundingSphere( bs );
- },
-
- expandByvec3: function ( v ) {
- var min = this._min;
- var max = this._max;
- min[ 0 ] = Math.min( min[ 0 ], v[ 0 ] );
- min[ 1 ] = Math.min( min[ 1 ], v[ 1 ] );
- min[ 2 ] = Math.min( min[ 2 ], v[ 2 ] );
-
- max[ 0 ] = Math.max( max[ 0 ], v[ 0 ] );
- max[ 1 ] = Math.max( max[ 1 ], v[ 1 ] );
- max[ 2 ] = Math.max( max[ 2 ], v[ 2 ] );
- },
-
- expandByBoundingBox: function ( bb ) {
- if ( !bb.valid() )
- return;
-
- var min = this._min;
- var max = this._max;
- var bbmin = bb._min;
- var bbmax = bb._max;
-
- if ( bbmin[ 0 ] < min[ 0 ] ) min[ 0 ] = bbmin[ 0 ];
- if ( bbmax[ 0 ] > max[ 0 ] ) max[ 0 ] = bbmax[ 0 ];
-
- if ( bbmin[ 1 ] < min[ 1 ] ) min[ 1 ] = bbmin[ 1 ];
- if ( bbmax[ 1 ] > max[ 1 ] ) max[ 1 ] = bbmax[ 1 ];
-
- if ( bbmin[ 2 ] < min[ 2 ] ) min[ 2 ] = bbmin[ 2 ];
- if ( bbmax[ 2 ] > max[ 2 ] ) max[ 2 ] = bbmax[ 2 ];
- },
-
- center: function ( result ) {
- var min = this._min;
- var max = this._max;
- result[ 0 ] = ( min[ 0 ] + max[ 0 ] ) * 0.5;
- result[ 1 ] = ( min[ 1 ] + max[ 1 ] ) * 0.5;
- result[ 2 ] = ( min[ 2 ] + max[ 2 ] ) * 0.5;
- return result;
- },
-
- radius: function () {
- return Math.sqrt( this.radius2() );
- },
-
- radius2: function () {
- var min = this._min;
- var max = this._max;
- var dx = max[ 0 ] - min[ 0 ];
- var dy = max[ 1 ] - min[ 1 ];
- var dz = max[ 2 ] - min[ 2 ];
- return 0.25 * ( dx * dx + dy * dy + dz * dz );
- },
-
- getMin: function () {
- return this._min;
- },
-
- getMax: function () {
- return this._max;
- },
-
- setMin: function ( min ) {
- vec3.copy( this._min, min );
- return this;
- },
-
- setMax: function ( max ) {
- vec3.copy( this._max, max );
- return this;
- },
-
- xMax: function () {
- return this._max[ 0 ];
- },
-
- yMax: function () {
- return this._max[ 1 ];
- },
-
- zMax: function () {
- return this._max[ 2 ];
- },
-
- xMin: function () {
- return this._min[ 0 ];
- },
-
- yMin: function () {
- return this._min[ 1 ];
- },
-
- zMin: function () {
- return this._min[ 2 ];
- },
-
- corner: function ( pos, ret ) {
- /*jshint bitwise: false */
- if ( pos & 1 ) {
- ret[ 0 ] = this._max[ 0 ];
- } else {
- ret[ 0 ] = this._min[ 0 ];
- }
- if ( pos & 2 ) {
- ret[ 1 ] = this._max[ 1 ];
- } else {
- ret[ 1 ] = this._min[ 1 ];
- }
- if ( pos & 4 ) {
- ret[ 2 ] = this._max[ 2 ];
- } else {
- ret[ 2 ] = this._min[ 2 ];
- }
- return ret;
- /*jshint bitwise: true */
- },
-
- // http://dev.theomader.com/transform-bounding-boxes/
- // https://github.com/erich666/GraphicsGems/blob/master/gems/TransBox.c
- transformMat4: ( function () {
- var tmpMin = vec3.create();
- var tmpMax = vec3.create();
- return function ( out, m ) {
-
- var inMin = this.getMin();
- var inMax = this.getMax();
-
- /* Take care of translation by beginning at T. */
- mat4.getTranslation( tmpMin, m );
- vec3.copy( tmpMax, tmpMin );
-
- /* Now find the extreme points by considering the product of the */
- /* min and max with each component of M. */
- for ( var i = 0; i < 3; ++i ) {
- var i4 = i * 4;
- var mini = inMin[ i ];
- var maxi = inMax[ i ];
- for ( var j = 0; j < 3; ++j ) {
- var cm = m[ i4 + j ];
- var a = cm * maxi;
- var b = cm * mini;
- if ( a < b ) {
- tmpMin[ j ] += a;
- tmpMax[ j ] += b;
- } else {
- tmpMin[ j ] += b;
- tmpMax[ j ] += a;
- }
- }
- }
- var outMax = out.getMax();
- var outMin = out.getMin();
-
- outMax[ 0 ] = tmpMax[ 0 ];
- outMax[ 1 ] = tmpMax[ 1 ];
- outMax[ 2 ] = tmpMax[ 2 ];
-
- outMin[ 0 ] = tmpMin[ 0 ];
- outMin[ 1 ] = tmpMin[ 1 ];
- outMin[ 2 ] = tmpMin[ 2 ];
-
- return out;
- };
- } )()
-
-}, 'osg', 'BoundingBox' );
-
-module.exports = BoundingBox;
diff --git a/app/static/app/js/vendor/osgjs/osg/BoundingSphere.js b/app/static/app/js/vendor/osgjs/osg/BoundingSphere.js
deleted file mode 100644
index 7962eb6b..00000000
--- a/app/static/app/js/vendor/osgjs/osg/BoundingSphere.js
+++ /dev/null
@@ -1,195 +0,0 @@
-'use strict';
-var BoundingBox = require( 'osg/BoundingBox' );
-var Notify = require( 'osg/notify' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-
-
-var BoundingSphere = function () {
- this._center = vec3.create();
- this._radius = -1.0;
-};
-
-BoundingSphere.prototype = {
- init: function () {
- vec3.init( this._center );
- this._radius = -1.0;
- },
- valid: function () {
- return this._radius >= 0.0;
- },
- set: function ( center, radius ) {
- this._center = center;
- this._radius = radius;
- },
- center: function () {
- return this._center;
- },
- radius: function () {
- return this._radius;
- },
- radius2: function () {
- return this._radius * this._radius;
- },
-
- expandByBoundingBox: ( function () {
- var v = vec3.create();
- var newbb = new BoundingBox();
-
- return function ( bb ) {
- if ( !bb.valid() )
- return;
-
- if ( this.valid() ) {
- vec3.copy( newbb._min, bb._min );
- vec3.copy( newbb._max, bb._max );
-
- for ( var i = 0; i < 8; i++ ) {
- vec3.sub( v, bb.corner( i, v ), this._center ); // get the direction vector from corner
- vec3.normalize( v, v ); // normalise it.
- vec3.scaleAndAdd( v, this._center, v, -this._radius ); // move the vector in the opposite direction distance radius.
- newbb.expandByvec3( v ); // add it into the new bounding box.
- }
-
- newbb.center( this._center );
- this._radius = newbb.radius();
- } else {
- bb.center( this._center );
- this._radius = bb.radius();
- }
- };
- } )(),
-
- expandByBox: function ( bb ) {
- Notify.log( 'BoundingSphere.expandByBox is deprecated, use instead BoundingSphere.expandByBoundingBox' );
- return this.expandByBoundingBox( bb );
- },
-
- expandByvec3: ( function () {
- var dv = vec3.create();
- return function ( v ) {
- if ( this.valid() ) {
- vec3.sub( dv, v, this.center( dv ) );
- var r = vec3.length( dv );
- if ( r > this.radius() ) {
- var dr = ( r - this.radius() ) * 0.5;
- this._center[ 0 ] += dv[ 0 ] * ( dr / r );
- this._center[ 1 ] += dv[ 1 ] * ( dr / r );
- this._center[ 2 ] += dv[ 2 ] * ( dr / r );
- this._radius += dr;
- }
- } else {
- this._center[ 0 ] = v[ 0 ];
- this._center[ 1 ] = v[ 1 ];
- this._center[ 2 ] = v[ 2 ];
- this._radius = 0.0;
- }
- };
- } )(),
-
- expandRadiusBySphere: function ( sh ) {
- if ( sh.valid() ) {
- if ( this.valid() ) {
- var r = vec3.distance( this._center, sh._center ) + sh._radius;
- if ( r > this._radius ) {
- this._radius = r;
- }
- // else do nothing as vertex is within sphere.
- } else {
- vec3.copy( this._center, sh._center );
- this._radius = sh._radius;
- }
- }
- },
-
- expandBy: function ( bs ) {
- Notify.log( 'BoundingSphere.expandBy is deprecated, use instead BoundingSphere.expandByBoundingSphere' );
- this.expandByBoundingSphere( bs );
- },
-
- expandByBoundingSphere: function ( sh ) {
- // ignore operation if incomming BoundingSphere is invalid.
- if ( !sh.valid() ) {
- return;
- }
-
- // This sphere is not set so use the inbound sphere
- if ( !this.valid() ) {
- this._center[ 0 ] = sh._center[ 0 ];
- this._center[ 1 ] = sh._center[ 1 ];
- this._center[ 2 ] = sh._center[ 2 ];
- this._radius = sh.radius();
-
- return;
- }
-
- // Calculate d == The distance between the sphere centers
- var d = vec3.distance( sh.center(), this.center() );
-
- // New sphere is already inside this one
- if ( d + sh.radius() <= this.radius() ) {
- return;
- }
-
- // New sphere completely contains this one
- if ( d + this.radius() <= sh.radius() ) {
- this._center[ 0 ] = sh._center[ 0 ];
- this._center[ 1 ] = sh._center[ 1 ];
- this._center[ 2 ] = sh._center[ 2 ];
- this._radius = sh._radius;
- return;
- }
-
-
- // Build a new sphere that completely contains the other two:
- //
- // The center point lies halfway along the line between the furthest
- // points on the edges of the two spheres.
- //
- // Computing those two points is ugly - so we'll use similar triangles
- var newRadius = ( this.radius() + d + sh.radius() ) * 0.5;
- var ratio = ( newRadius - this.radius() ) / d;
-
- this._center[ 0 ] += ( sh._center[ 0 ] - this._center[ 0 ] ) * ratio;
- this._center[ 1 ] += ( sh._center[ 1 ] - this._center[ 1 ] ) * ratio;
- this._center[ 2 ] += ( sh._center[ 2 ] - this._center[ 2 ] ) * ratio;
-
- this._radius = newRadius;
- },
- contains: function ( v ) {
- if ( !this.valid() )
- return false;
- return vec3.sqrDist( this.center(), v ) <= this.radius2();
- },
- intersects: function ( bs ) {
- if ( !this.valid() || !bs.valid() )
- return false;
- var r = this.radius() + bs.radius();
- return vec3.sqrDist( bs.center(), this.center() ) <= r * r;
- },
-
- transformMat4: ( function () {
- var scaleVec = vec3.create();
- return function ( out, matrix ) {
- if ( !this.valid() ) return out;
-
- if ( out._center !== this._center ) {
- vec3.copy( out._center, this._center );
- out._radius = this._radius;
- }
- var sphCenter = out._center;
- var sphRadius = out._radius;
-
- mat4.getSqrScale( scaleVec, matrix );
- var scale = Math.sqrt( Math.max( Math.max( scaleVec[ 0 ], scaleVec[ 1 ] ), scaleVec[ 2 ] ) );
- sphRadius = sphRadius * scale;
- out._radius = sphRadius;
- vec3.transformMat4( sphCenter, sphCenter, matrix );
-
- return out;
- };
- } )()
-
-};
-
-module.exports = BoundingSphere;
diff --git a/app/static/app/js/vendor/osgjs/osg/BufferArray.js b/app/static/app/js/vendor/osgjs/osg/BufferArray.js
deleted file mode 100644
index 96adc8da..00000000
--- a/app/static/app/js/vendor/osgjs/osg/BufferArray.js
+++ /dev/null
@@ -1,179 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Notify = require( 'osg/notify' );
-var Object = require( 'osg/Object' );
-var GLObject = require( 'osg/GLObject' );
-var Timer = require( 'osg/Timer' );
-
-
-var getAttributeType = function ( array ) {
- var type;
-
- if ( array instanceof MACROUTILS.Float32Array ) type = 0x1406;
- if ( array instanceof MACROUTILS.Uint32Array ) type = 0x1405;
- if ( array instanceof MACROUTILS.Uint16Array ) type = 0x1403;
- if ( array instanceof MACROUTILS.Uint8Array ) type = 0x1401;
-
- return type;
-};
-
-/**
- * BufferArray manage vertex / normal / ... array used by webgl.
- * osgjs automatically converts array buffers to Float32Array and
- * element array buffers to Uint16Array if not said explicitly with
- * preserveArrayType variable in constructor.
- * @class BufferArray
- */
-
-var BufferArray = function ( target, elements, itemSize, preserveArrayType ) {
-
- GLObject.call( this );
- // maybe could inherit from Object
- this._instanceID = Object.getInstanceID();
-
- this.dirty();
-
- this._itemSize = itemSize;
- this._target = typeof target === 'string' ? BufferArray[ target ] : target;
-
- // initialized by setElements
- this._type = undefined;
- this._normalize = false;
-
- if ( elements !== undefined ) {
- var typedArray = elements;
- if ( !preserveArrayType ) {
- if ( this._target === BufferArray.ELEMENT_ARRAY_BUFFER ) {
- typedArray = elements instanceof MACROUTILS.Uint16Array ? elements : new MACROUTILS.Uint16Array( elements );
- } else {
- typedArray = elements instanceof MACROUTILS.Float32Array ? elements : new MACROUTILS.Float32Array( elements );
- }
- }
- this.setElements( typedArray );
- }
-};
-
-BufferArray.ELEMENT_ARRAY_BUFFER = 0x8893;
-BufferArray.ARRAY_BUFFER = 0x8892;
-
-// static cache of glBuffers flagged for deletion, which will actually
-// be deleted in the correct GL context.
-BufferArray._sDeletedGLBufferArrayCache = new window.Map();
-
-// static method to delete Program
-BufferArray.deleteGLBufferArray = function ( gl, buffer ) {
- if ( !BufferArray._sDeletedGLBufferArrayCache.has( gl ) )
- BufferArray._sDeletedGLBufferArrayCache.set( gl, [] );
- BufferArray._sDeletedGLBufferArrayCache.get( gl ).push( buffer );
-};
-
-// static method to flush all the cached glPrograms which need to be deleted in the GL context specified
-BufferArray.flushDeletedGLBufferArrays = function ( gl, availableTime ) {
- // if no time available don't try to flush objects.
- if ( availableTime <= 0.0 ) return availableTime;
- if ( !BufferArray._sDeletedGLBufferArrayCache.has( gl ) ) return availableTime;
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- var deleteList = BufferArray._sDeletedGLBufferArrayCache.get( gl );
- var numBuffers = deleteList.length;
- for ( var i = numBuffers - 1; i >= 0 && elapsedTime < availableTime; i-- ) {
- gl.deleteBuffer( deleteList[ i ] );
- deleteList.splice( i, 1 );
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- }
- return availableTime - elapsedTime;
-};
-
-BufferArray.flushAllDeletedGLBufferArrays = function ( gl ) {
- if ( !BufferArray._sDeletedGLBufferArrayCache.has( gl ) ) return;
- var deleteList = BufferArray._sDeletedGLBufferArrayCache.get( gl );
- var numBuffers = deleteList.length;
- for ( var i = numBuffers - 1; i >= 0; i-- ) {
- gl.deleteBuffer( deleteList[ i ] );
- deleteList.splice( i, 1 );
- }
-};
-
-/** @lends BufferArray.prototype */
-BufferArray.prototype = MACROUTILS.objectInherit( GLObject.prototype, {
- getInstanceID: function () {
- return this._instanceID;
- },
- setItemSize: function ( size ) {
- this._itemSize = size;
- },
- isValid: function () {
- if ( this._buffer !== undefined ||
- this._elements !== undefined ) {
- return true;
- }
- return false;
- },
-
- releaseGLObjects: function () {
- if ( this._buffer !== undefined && this._buffer !== null && this._gl !== undefined ) {
- BufferArray.deleteGLBufferArray( this._gl, this._buffer );
- }
- this._buffer = undefined;
- },
-
- setNormalize: function ( normalize ) {
- this._normalize = normalize;
- },
-
- getNormalize: function () {
- return this._normalize;
- },
-
- bind: function ( gl ) {
- if ( !this._gl ) this.setGraphicContext( gl );
- var target = this._target;
- var buffer = this._buffer;
-
- if ( buffer ) {
- gl.bindBuffer( target, buffer );
- return;
- }
-
- if ( !buffer && this._elements.length > 0 ) {
- this._buffer = gl.createBuffer();
- this._numItems = this._elements.length / this._itemSize;
- gl.bindBuffer( target, this._buffer );
- }
- },
- getItemSize: function () {
- return this._itemSize;
- },
- dirty: function () {
- this._dirty = true;
- },
- isDirty: function () {
- return this._dirty;
- },
- compile: function ( gl ) {
- if ( this._dirty ) {
- MACROUTILS.timeStamp( 'osgjs.metrics:bufferData' );
- gl.bufferData( this._target, this._elements, gl.STATIC_DRAW );
- this._dirty = false;
- }
- },
- getElements: function () {
- return this._elements;
- },
- setElements: function ( elements ) {
- this._elements = elements;
- this._type = getAttributeType( elements );
- this._dirty = true;
- },
- getType: function () {
- return this._type;
- }
-
-} );
-
-BufferArray.create = function ( type, elements, itemSize ) {
- Notify.log( 'BufferArray.create is deprecated, use new BufferArray with same arguments instead' );
- return new BufferArray( type, elements, itemSize );
-};
-
-module.exports = BufferArray;
diff --git a/app/static/app/js/vendor/osgjs/osg/BufferArrayProxy.js b/app/static/app/js/vendor/osgjs/osg/BufferArrayProxy.js
deleted file mode 100644
index 34c43b38..00000000
--- a/app/static/app/js/vendor/osgjs/osg/BufferArrayProxy.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict';
-var BufferArray = require( 'osg/BufferArray' );
-
-
-var BufferArrayProxy = function ( bufferArray ) {
-
- this._initialBufferArray = undefined;
- this._bufferArray = undefined;
- if ( bufferArray ) {
- this.setBufferArray( bufferArray );
- this.setInitialBufferArray( bufferArray );
- }
-
-};
-
-var prototype = {
- setInitialBufferArray: function ( bufferArray ) {
- this._initialBufferArray = bufferArray;
- },
- getInitialBufferArray: function () {
- return this._initialBufferArray;
- },
- setBufferArray: function ( bufferArray ) {
- this._bufferArray = bufferArray.getBufferArray ? bufferArray.getBufferArray() : bufferArray;
- },
- getBufferArray: function () {
- return this._bufferArray;
- }
-};
-
-// adds original method of BufferArray prototype for the proxy for convenient usage
-var keys = window.Object.keys( BufferArray.prototype );
-keys.forEach( function ( methodName ) {
- prototype[ methodName ] = function () {
- return BufferArray.prototype[ methodName ].apply( this._bufferArray, arguments );
- };
-} );
-
-BufferArrayProxy.prototype = prototype;
-module.exports = BufferArrayProxy;
diff --git a/app/static/app/js/vendor/osgjs/osg/Camera.js b/app/static/app/js/vendor/osgjs/osg/Camera.js
deleted file mode 100644
index 3a813082..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Camera.js
+++ /dev/null
@@ -1,252 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Transform = require( 'osg/Transform' );
-var CullSettings = require( 'osg/CullSettings' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Texture = require( 'osg/Texture' );
-var TransformEnums = require( 'osg/transformEnums' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-
-
-/**
- * Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
- * @class Camera
- * @inherits Transform CullSettings
- */
-var Camera = function () {
- Transform.call( this );
- CullSettings.call( this );
-
- this.viewport = undefined;
- this._graphicContext = undefined;
- this.setClearColor( vec4.fromValues( 0, 0, 0, 1.0 ) );
- this.setClearDepth( 1.0 );
-
- /*jshint bitwise: false */
- this.setClearMask( Camera.COLOR_BUFFER_BIT | Camera.DEPTH_BUFFER_BIT );
- /*jshint bitwise: true */
-
- this.setViewMatrix( mat4.create() );
- this.setProjectionMatrix( mat4.create() );
- this.renderOrder = Camera.NESTED_RENDER;
- this.renderOrderNum = 0;
-
- this._view = undefined;
- this._renderer = undefined;
- this._attachments = {};
-};
-
-Camera.PRE_RENDER = 0;
-Camera.NESTED_RENDER = 1;
-Camera.POST_RENDER = 2;
-
-Camera.COLOR_BUFFER_BIT = 0x00004000;
-Camera.DEPTH_BUFFER_BIT = 0x00000100;
-Camera.STENCIL_BUFFER_BIT = 0x00000400;
-
-/** @lends Camera.prototype */
-Camera.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit(
- CullSettings.prototype,
- MACROUTILS.objectInherit( Transform.prototype, {
- // at which view this camera is attached
- getView: function () {
- return this._view;
- },
-
- setView: function ( view ) {
- this._view = view;
- },
-
- getRenderer: function () {
- return this._renderer;
- },
-
- setRenderer: function ( renderer ) {
- this._renderer = renderer;
- },
-
- // Set the final draw callback for custom operations
- // to be done after the drawing of
- // the camera's subgraph and pre render stages.
- setFinalDrawCallback: function ( cb ) {
-
- this._finalDrawCallback = cb;
-
- },
-
- getFinalDrawCallback: function () {
-
- return this._finalDrawCallback;
-
- },
-
- // Set the initial draw callback for custom operations
- // to be done before the drawing of
- // the camera's subgraph and pre render stages.
- setInitialDrawCallback: function ( cb ) {
-
- this._initialDrawCallback = cb;
-
- },
-
- getInitialDrawCallback: function () {
-
- return this._initialDrawCallback;
-
- },
-
-
- getAttachments: function () {
- return this._attachments;
- },
-
- setGraphicContext: function ( gc ) {
- this._graphicContext = gc;
- },
- getGraphicContext: function () {
- return this._graphicContext;
- },
- setClearDepth: function ( depth ) {
- this.clearDepth = depth;
- },
- getClearDepth: function () {
- return this.clearDepth;
- },
-
- setClearMask: function ( mask ) {
- this.clearMask = mask;
- },
- getClearMask: function () {
- return this.clearMask;
- },
-
- setClearColor: function ( color ) {
- this.clearColor = color;
- },
- getClearColor: function () {
- return this.clearColor;
- },
-
- setViewport: function ( vp ) {
- this.viewport = vp;
- this.getOrCreateStateSet().setAttributeAndModes( vp );
- },
- getViewport: function () {
- return this.viewport;
- },
-
-
- setViewMatrix: function ( matrix ) {
- this.modelviewMatrix = matrix;
- },
- setViewMatrixAsLookAt: function ( eye, center, up ) {
- mat4.lookAt( this.getViewMatrix(), eye, center, up );
- },
- setProjectionMatrix: function ( matrix ) {
- this.projectionMatrix = matrix;
- },
-
- /** Set to an orthographic projection. See OpenGL glOrtho for documentation further details.*/
- setProjectionMatrixAsOrtho: function ( left, right,
- bottom, top,
- zNear, zFar ) {
- mat4.ortho( this.getProjectionMatrix(), left, right, bottom, top, zNear, zFar );
- },
- isRenderToTextureCamera: function () {
- return window.Object.keys( this._attachments ).length > 0;
- },
-
- getViewMatrix: function () {
- return this.modelviewMatrix;
- },
- getProjectionMatrix: function () {
- return this.projectionMatrix;
- },
- getRenderOrder: function () {
- return this.renderOrder;
- },
- setRenderOrder: function ( order, orderNum ) {
- this.renderOrder = order;
- this.renderOrderNum = orderNum;
- },
-
- detachAll: function () {
- this._attachments = {};
-
- if ( this.frameBufferObject ) {
- this.frameBufferObject.dirty();
- }
- },
-
- // TODO: fix in case of shared fbo
- // TODO: fix adding a resize case
- resetAttachments: function () {
-
-
- if ( this.frameBufferObject ) {
-
- this.frameBufferObject.reset();
- // remove framebuffer
- this.frameBufferObject = 0;
- }
-
- // removes camera attachement
- this._attachments = {};
-
- },
-
- attachTexture: function ( bufferComponent, texture, textureTarget ) {
- if ( this.frameBufferObject ) {
- this.frameBufferObject.dirty();
- }
-
- // because before the argument was level and the spec says
- // it must always be 0 ! is valid for 0 or undefined
- if ( !textureTarget ) {
- textureTarget = Texture.TEXTURE_2D;
- }
-
- this._attachments[ bufferComponent ] = {
- 'attachment': bufferComponent,
- 'texture': texture,
- 'textureTarget': textureTarget
- };
- },
-
- attachRenderBuffer: function ( bufferComponent, internalFormat ) {
- if ( this.frameBufferObject ) {
- this.frameBufferObject.dirty();
- }
- this._attachments[ bufferComponent ] = {
- 'format': internalFormat,
- 'attachment': bufferComponent
- };
- },
-
- computeLocalToWorldMatrix: function ( matrix /*,nodeVisitor*/ ) {
- if ( this.referenceFrame === TransformEnums.RELATIVE_RF ) {
- mat4.mul( matrix, matrix, this.modelviewMatrix );
- } else { // absolute
- mat4.copy( matrix, this.modelviewMatrix );
- }
- return true;
- },
-
- computeWorldToLocalMatrix: ( function () {
- var minverse = mat4.create();
- return function ( matrix /*, nodeVisitor */ ) {
- mat4.invert( minverse, this.modelviewMatrix );
- if ( this.referenceFrame === TransformEnums.RELATIVE_RF ) {
- mat4.mul( matrix, minverse, matrix );
- } else {
- mat4.copy( matrix, minverse );
- }
- return true;
- };
- } )()
-
- } ) ), 'osg', 'Camera' );
-
-MACROUTILS.setTypeID( Camera );
-
-module.exports = Camera;
diff --git a/app/static/app/js/vendor/osgjs/osg/ColorMask.js b/app/static/app/js/vendor/osgjs/osg/ColorMask.js
deleted file mode 100644
index 6fd84fed..00000000
--- a/app/static/app/js/vendor/osgjs/osg/ColorMask.js
+++ /dev/null
@@ -1,44 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-
-
-var ColorMask = function ( red, green, blue, alpha ) {
-
- StateAttribute.call( this );
-
- this._colorMask = [ true, true, true, true ];
- this.setMask( red, green, blue, alpha );
-};
-
-ColorMask.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'ColorMask',
-
- cloneType: function () {
- return new ColorMask();
- },
-
- setMask: function ( red, green, blue, alpha ) {
-
- if ( red !== undefined &&
- green !== undefined &&
- blue !== undefined &&
- alpha !== undefined ) {
-
- this._colorMask[ 0 ] = red;
- this._colorMask[ 1 ] = green;
- this._colorMask[ 2 ] = blue;
- this._colorMask[ 3 ] = alpha;
- }
- },
-
- apply: function ( state ) {
- var gl = state.getGraphicContext();
- var colorMask = this._colorMask;
- gl.colorMask( colorMask[ 0 ], colorMask[ 1 ], colorMask[ 2 ], colorMask[ 3 ] );
- }
-
-} ), 'osg', 'ColorMask' );
-
-module.exports = ColorMask;
diff --git a/app/static/app/js/vendor/osgjs/osg/ComputeBoundsVisitor.js b/app/static/app/js/vendor/osgjs/osg/ComputeBoundsVisitor.js
deleted file mode 100644
index 1b6a3503..00000000
--- a/app/static/app/js/vendor/osgjs/osg/ComputeBoundsVisitor.js
+++ /dev/null
@@ -1,109 +0,0 @@
-'use strict';
-var BoundingBox = require( 'osg/BoundingBox' );
-var Geometry = require( 'osg/Geometry' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixMemoryPool = require( 'osg/MatrixMemoryPool' );
-var Transform = require( 'osg/Transform' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var MACROUTILS = require( 'osg/Utils' );
-
-
-var ComputeBoundsVisitor = function ( traversalMode ) {
- NodeVisitor.call( this, traversalMode );
-
- // keep a matrix in memory to avoid to create matrix
- this._reservedMatrixStack = new MatrixMemoryPool();
-
- // Matrix stack along path traversal
- this._matrixStack = [];
- this._bb = new BoundingBox();
-};
-
-ComputeBoundsVisitor.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( NodeVisitor.prototype, {
-
- reset: function () {
- this._reservedMatrixStack.reset();
- this._matrixStack.length = 0;
- this._bb.init();
- },
-
- getBoundingBox: function () {
- return this._bb;
- },
-
- // not implemented
- //void getPolytope(osg::Polytope& polytope, float margin=0.1) const;
- //void getBase(osg::Polytope& polytope, float margin=0.1) const;
-
- //applyDrawable: function ( drawable ) {},
-
- applyTransform: function ( transform ) {
-
- var matrix = this._reservedMatrixStack.get();
- var stackLength = this._matrixStack.length;
-
- if ( stackLength )
- mat4.copy( matrix, this._matrixStack[ stackLength - 1 ] );
- else
- mat4.identity( matrix );
-
- transform.computeLocalToWorldMatrix( matrix, this );
-
- this.pushMatrix( matrix );
-
- this.traverse( transform );
-
- this.popMatrix();
- },
-
- apply: function ( node ) {
-
- if ( node instanceof Transform ) {
- this.applyTransform( node );
- return;
-
- } else if ( node instanceof Geometry ) {
- this.applyBoundingBox( node.getBoundingBox() );
- return;
- }
-
- this.traverse( node );
-
- },
-
- pushMatrix: function ( matrix ) {
- this._matrixStack.push( matrix );
- },
-
- popMatrix: function () {
- this._matrixStack.pop();
- },
-
-
- applyBoundingBox: ( function () {
- var bbOut = new BoundingBox();
-
- return function ( bbox ) {
-
- var stackLength = this._matrixStack.length;
-
- if ( !stackLength )
- this._bb.expandByBoundingBox( bbox );
- else if ( bbox.valid() ) {
- var matrix = this._matrixStack[ stackLength - 1 ];
- //Matrix.transformBoundingBox( matrix, bbox, bbOut );
- bbox.transformMat4( bbOut, matrix );
- this._bb.expandByBoundingBox( bbOut );
- }
-
- };
- } )(),
-
- getMatrixStack: function () {
- return this._matrixStack;
- }
-
-
-} ), 'osg', 'ComputeBoundsVisitor' );
-
-module.exports = ComputeBoundsVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osg/CullFace.js b/app/static/app/js/vendor/osgjs/osg/CullFace.js
deleted file mode 100644
index 4d822d53..00000000
--- a/app/static/app/js/vendor/osgjs/osg/CullFace.js
+++ /dev/null
@@ -1,51 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-
-
-/**
- * Manage CullFace attribute
- * @class CullFace
- */
-var CullFace = function ( mode ) {
- StateAttribute.call( this );
- this.setMode( mode !== undefined ? mode : CullFace.BACK );
-};
-
-CullFace.DISABLE = 0x0;
-CullFace.FRONT = 0x0404;
-CullFace.BACK = 0x0405;
-CullFace.FRONT_AND_BACK = 0x0408;
-
-/** @lends CullFace.prototype */
-CullFace.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'CullFace',
-
- cloneType: function () {
- return new CullFace();
- },
-
- setMode: function ( mode ) {
- var value = mode;
- if ( typeof value === 'string' ) value = CullFace[ value ];
- this._mode = value;
- },
-
- getMode: function () {
- return this._mode;
- },
-
- apply: function ( state ) {
- var gl = state.getGraphicContext();
- if ( this._mode === CullFace.DISABLE ) {
- gl.disable( gl.CULL_FACE );
- } else {
- gl.enable( gl.CULL_FACE );
- gl.cullFace( this._mode );
- }
-
- }
-} ), 'osg', 'CullFace' );
-
-module.exports = CullFace;
diff --git a/app/static/app/js/vendor/osgjs/osg/CullSettings.js b/app/static/app/js/vendor/osgjs/osg/CullSettings.js
deleted file mode 100644
index 8e925635..00000000
--- a/app/static/app/js/vendor/osgjs/osg/CullSettings.js
+++ /dev/null
@@ -1,95 +0,0 @@
-'use strict';
-
-
-var CullSettings = function () {
-
- // Not doing a this.reset()
- // because of multiple inheritance
- // it will call the wrong reset
- // cullstack reset for isntance()
- CullSettings.prototype.reset.call( this );
-
-};
-
-CullSettings.prototype = {
- reset: function () {
-
- this._computeNearFar = true;
- this._nearFarRatio = 0.005;
-
- // Magic numbers 3 & 4
- this.bbCornerFar = 3;
- this.bbCornerNear = 4;
- // see code below for for the
- // Code simplification origin
- // var vec3 = require( 'osg/glMatrix' ).vec3;
- // var lookVector = vec3.fromValues( 0.0, 0.0, -1.0 );
- // /*jshint bitwise: false */
- // this.bbCornerFar = ( lookVector[ 0 ] >= 0 ? 1 : 0 ) | ( lookVector[ 1 ] >= 0 ? 2 : 0 ) | ( lookVector[ 2 ] >= 0 ? 4 : 0 );
- // this.bbCornerNear = ( ~this.bbCornerFar ) & 7;
- // /*jshint bitwise: true */
- // is equivalent to
-
- this._enableFrustumCulling = false;
-
- // who sets the parameter
- // if it's cullvisitor
- // it's an OVERRIDER for enableFrustumCulling
- // allowing for global EnableFrustimCulling
- this._settingsSourceOverrider = this;
- //LOD bias for the CullVisitor to use
- this._LODScale = 1.0;
- // Custom clampProjectionMatrix
- this._clampProjectionMatrixCallback = undefined;
- },
-
- setCullSettings: function ( settings ) {
- this._computeNearFar = settings._computeNearFar;
- this._nearFarRatio = settings._nearFarRatio;
- this._enableFrustumCulling = settings._enableFrustumCulling;
- this._settingsSourceOverrider = settings._settingsSourceOverrider;
- this._clampProjectionMatrixCallback = settings._clampProjectionMatrixCallback;
- },
-
- setNearFarRatio: function ( ratio ) {
- this._nearFarRatio = ratio;
- },
- getNearFarRatio: function () {
- return this._nearFarRatio;
- },
- setComputeNearFar: function ( value ) {
- this._computeNearFar = value;
- },
- getComputeNearFar: function () {
- return this._computeNearFar;
- },
-
- setEnableFrustumCulling: function ( value ) {
- this._enableFrustumCulling = value;
- },
- getEnableFrustumCulling: function () {
- return this._enableFrustumCulling;
- },
-
- getSettingSourceOverrider: function () {
- return this._settingsSourceOverrider;
- },
-
- setClampProjectionMatrixCallback: function ( callback ) {
- this._clampProjectionMatrixCallback = callback;
- },
-
- getClampProjectionMatrixCallback: function () {
- return this._clampProjectionMatrixCallback;
- },
-
- setLODScale: function ( scale ) {
- this._LODScale = scale;
- },
- getLODScale: function () {
- return this._LODScale;
- }
-
-};
-
-module.exports = CullSettings;
diff --git a/app/static/app/js/vendor/osgjs/osg/CullStack.js b/app/static/app/js/vendor/osgjs/osg/CullStack.js
deleted file mode 100644
index ddce0fdc..00000000
--- a/app/static/app/js/vendor/osgjs/osg/CullStack.js
+++ /dev/null
@@ -1,394 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var BoundingSphere = require( 'osg/BoundingSphere' );
-var Camera = require( 'osg/Camera' );
-var ComputeMatrixFromNodePath = require( 'osg/computeMatrixFromNodePath' );
-var CullSettings = require( 'osg/CullSettings' );
-var CullingSet = require( 'osg/CullingSet' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Plane = require( 'osg/Plane' );
-var MatrixMemoryPool = require( 'osg/MatrixMemoryPool' );
-var Transform = require( 'osg/Transform' );
-var Notify = require( 'osg/notify' );
-var TransformEnums = require( 'osg/transformEnums' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-var CullStack = function () {
-
- this._modelViewMatrixStack = [];
- this._projectionMatrixStack = [];
- this._viewportStack = [];
- this._cullingSetStack = [];
- this._frustumVolume = -1.0;
- this._bbCornerFar = 0;
- this._bbCornerNear = 0;
-
- // keep a matrix in memory to avoid to create matrix
- this._reservedMatrixStack = new MatrixMemoryPool();
-
- this._reserveCullingSetStack = [
- new CullingSet()
- ];
- this._reserveCullingSetStack.current = 0;
-
-
- // data for caching camera matrix inverse for computation of world/view
- // contains index of the camera node in the nodepath
- this._cameraIndexStack = [];
- // contains index of the camera modelview matrix in the modelViewMatrixStack
- this._cameraModelViewIndexStack = [];
-
- // contains the id has a key to computed Inverse Matrix
- this._cameraMatrixInverse = [];
- this._cameraMatrixInverseRoot = undefined;
-
-};
-
-CullStack.prototype = MACROUTILS.objectInherit( CullSettings.prototype, {
-
- _getReservedCullingSet: function () {
- var m = this._reserveCullingSetStack[ this._reserveCullingSetStack.current++ ];
- if ( this._reserveCullingSetStack.current === this._reserveCullingSetStack.length ) {
- this._reserveCullingSetStack.push( new CullingSet() );
- }
- return m;
- },
- reset: function () {
- this._modelViewMatrixStack.length = 0;
- this._projectionMatrixStack.length = 0;
- this._cullingSetStack.length = 0;
-
- this._reservedMatrixStack.reset();
- this._reserveCullingSetStack.current = 0;
-
- this._cameraModelViewIndexStack.length = 0;
- this._cameraIndexStack.length = 0;
- this._cameraMatrixInverse.length = 0;
- this._cameraMatrixInverseRoot = undefined;
- },
-
- getProjectionMatrixStack: function () {
- return this._projectionMatrixStack;
- },
- getCurrentProjectionMatrix: function () {
- return this._projectionMatrixStack[ this._projectionMatrixStack.length - 1 ];
- },
-
- getCurrentModelViewMatrix: function () {
- return this._modelViewMatrixStack[ this._modelViewMatrixStack.length - 1 ];
- },
-
- getCurrentModelviewMatrix: function () {
- Notify.warn( 'deprecated switch to getCurrentModelViewMatrix' );
- return this.getCurrentModelViewMatrix();
- },
-
- getCameraInverseMatrix: function () {
-
- // Return or compute and cache the MatrixInverse of the last
- // active camera in absolute reference
-
- // if no index the camera inverse is the root with an fake id
- if ( !this._cameraIndexStack.length )
- return this._cameraMatrixInverseRoot;
-
- var idx = this._cameraIndexStack[ this._cameraIndexStack.length - 1 ];
-
- // get the camera node
- var camera = this.getNodePath()[ idx ];
- var id = camera.getInstanceID();
-
- if ( this._cameraMatrixInverse[ id ] === undefined ) {
- var indexInModelViewMatrixStack = this._cameraModelViewIndexStack[ this._cameraModelViewIndexStack.length - 1 ];
- var mat = this._modelViewMatrixStack[ indexInModelViewMatrixStack ];
- var matInverse = this._reservedMatrixStack.get();
- mat4.invert( matInverse, mat );
- this._cameraMatrixInverse[ id ] = matInverse;
- }
- return this._cameraMatrixInverse[ id ];
- },
-
- getCurrentModelMatrix: function () {
- // Improvment could be to cache more things
- // and / or use this method only if the shader use it
- var invMatrix = this.getCameraInverseMatrix();
- var m = this._reservedMatrixStack.get();
- var world = mat4.mul( m, invMatrix, this.getCurrentModelViewMatrix() );
- return world;
- },
-
- getCurrentViewMatrix: function () {
- // Improvment could be to cache more things
- // and / or use this method only if the shader use it
- if ( !this._cameraIndexStack.length )
- return this._modelViewMatrixStack[ 0 ];
-
- // also we could keep the index of the current to avoid lenght-1 at each access
- // it's implemented in osg like that:
- // https://github.com/openscenegraph/osg/blob/master/include/osg/fast_back_stack
- var idx = this._cameraModelViewIndexStack[ this._cameraModelViewIndexStack.length - 1 ];
- return this._modelViewMatrixStack[ idx ];
- },
-
- getViewport: function () {
- if ( this._viewportStack.length === 0 ) {
- return undefined;
- }
- return this._viewportStack[ this._viewportStack.length - 1 ];
- },
- getLookVectorLocal: function ( outLookVector ) {
- var lookVectorLocal = this.getCurrentModelViewMatrix();
- return vec3.set( outLookVector, -lookVectorLocal[ 2 ], -lookVectorLocal[ 6 ], -lookVectorLocal[ 10 ] );
- },
- pushViewport: function ( vp ) {
- this._viewportStack.push( vp );
- },
- popViewport: function () {
- this._viewportStack.pop();
- },
-
- getFrustumPlanes: ( function () {
-
- var mvp = mat4.create();
-
- return function ( out, projection, view, withNearFar ) {
- mat4.mul( mvp, projection, view );
-
- var computeNearFar = !!withNearFar;
-
- // Right clipping plane.
- var right = out[ 0 ];
- right[ 0 ] = mvp[ 3 ] - mvp[ 0 ];
- right[ 1 ] = mvp[ 7 ] - mvp[ 4 ];
- right[ 2 ] = mvp[ 11 ] - mvp[ 8 ];
- right[ 3 ] = mvp[ 15 ] - mvp[ 12 ];
-
- // Left clipping plane.
- var left = out[ 1 ];
- left[ 0 ] = mvp[ 3 ] + mvp[ 0 ];
- left[ 1 ] = mvp[ 7 ] + mvp[ 4 ];
- left[ 2 ] = mvp[ 11 ] + mvp[ 8 ];
- left[ 3 ] = mvp[ 15 ] + mvp[ 12 ];
-
- // Bottom clipping plane.
- var bottom = out[ 2 ];
- bottom[ 0 ] = mvp[ 3 ] + mvp[ 1 ];
- bottom[ 1 ] = mvp[ 7 ] + mvp[ 5 ];
- bottom[ 2 ] = mvp[ 11 ] + mvp[ 9 ];
- bottom[ 3 ] = mvp[ 15 ] + mvp[ 13 ];
-
- // Top clipping plane.
- var top = out[ 3 ];
- top[ 0 ] = mvp[ 3 ] - mvp[ 1 ];
- top[ 1 ] = mvp[ 7 ] - mvp[ 5 ];
- top[ 2 ] = mvp[ 11 ] - mvp[ 9 ];
- top[ 3 ] = mvp[ 15 ] - mvp[ 13 ];
-
- if ( computeNearFar ) {
- // Far clipping plane.
- var far = out[ 4 ];
- far[ 0 ] = mvp[ 3 ] - mvp[ 2 ];
- far[ 1 ] = mvp[ 7 ] - mvp[ 6 ];
- far[ 2 ] = mvp[ 11 ] - mvp[ 10 ];
- far[ 3 ] = mvp[ 15 ] - mvp[ 14 ];
-
- // Near clipping plane.
- var near = out[ 5 ];
- near[ 0 ] = mvp[ 3 ] + mvp[ 2 ];
- near[ 1 ] = mvp[ 7 ] + mvp[ 6 ];
- near[ 2 ] = mvp[ 11 ] + mvp[ 10 ];
- near[ 3 ] = mvp[ 15 ] + mvp[ 14 ];
- }
-
- //Normalize the planes
- var j = withNearFar ? 6 : 4;
- for ( var i = 0; i < j; i++ ) {
- Plane.normalizeEquation( out[ i ] );
- }
-
- };
- } )(),
-
- pushCullingSet: function () {
- var cs = this._getReservedCullingSet();
- if ( this._enableFrustumCulling ) {
- mat4.getFrustumPlanes( cs.getFrustum().getPlanes(), this.getCurrentProjectionMatrix(), this.getCurrentModelViewMatrix(), false );
- // TODO: no far no near.
- // should check if we have them
- // should add at least a near 0 clip if not
- cs.getFrustum().setupMask( 4 );
- }
-
- this._cullingSetStack.push( cs );
- },
- popCullingSet: function () {
- return this._cullingSetStack.pop();
- },
- getCurrentCullingSet: function () {
- return this._cullingSetStack[ this._cullingSetStack.length - 1 ];
- },
-
-
- pushCurrentMask: function () {
- var cs = this.getCurrentCullingSet();
- if ( cs ) cs.pushCurrentMask();
- },
- popCurrentMask: function () {
- var cs = this.getCurrentCullingSet();
- if ( cs ) cs.popCurrentMask();
- },
-
- isVerticesCulled: function ( vertices ) {
- if ( !this._enableFrustumCulling )
- return false;
- return this.getCurrentCullingSet().isVerticesCulled( vertices );
- },
-
- isBoundingBoxCulled: function ( bb ) {
- if ( !this._enableFrustumCulling )
- return false;
- return bb.valid() && this.getCurrentCullingSet().isBoundingBoxCulled( bb );
- },
-
- isBoundingSphereCulled: function ( bs ) {
- if ( !this._enableFrustumCulling )
- return false;
- return bs.valid() && this.getCurrentCullingSet().isBoundingSphereCulled( bs );
- },
-
- isCulled: ( function () {
- var bsWorld = new BoundingSphere();
- return function ( node, nodePath ) {
- if ( !this._enableFrustumCulling )
- return false;
- if ( node.isCullingActive() ) {
- if ( this.getCurrentCullingSet().getCurrentResultMask() === 0 )
- return false; // father bounding sphere totally inside
-
- var matrix = this._reservedMatrixStack.get();
- mat4.identity( matrix );
-
- // TODO: Perf just get World Matrix at each node transform
- // store it in a World Transform Node Path (only world matrix change)
- // so that it's computed once and reused for each further node getCurrentModel
- // otherwise, it's 1 mult for each node, each matrix node, and each geometry
- //matrix = this.getCurrentModelMatrix();
- // tricky: change push be before isculled, and pop in case of culling
- // strange bug for now on frustum culling sample with that
-
- if ( node instanceof Transform ) {
-
- // tricky: MatrixTransform getBound is already transformed to
- // its local space whereas nodepath also have its matrix ...
- // so to get world space, you HAVE to remove that matrix from nodePATH
- // TODO: GC Perf of array slice creating new array
- matrix = ComputeMatrixFromNodePath.computeLocalToWorld( nodePath.slice( 0, nodePath.length - 1 ), true, matrix );
-
- } else {
-
- matrix = ComputeMatrixFromNodePath.computeLocalToWorld( nodePath, true, matrix );
-
- }
-
- // Matrix.transformBoundingSphere( matrix, node.getBound(), bsWorld );
- node.getBound().transformMat4( bsWorld, matrix );
-
- return this.getCurrentCullingSet().isBoundingSphereCulled( bsWorld );
- } else {
- this.getCurrentCullingSet().resetCullingMask();
- return false;
- }
- };
- } )(),
-
-
-
- pushModelViewMatrix: ( function () {
- var lookVector = vec3.create();
- return function ( matrix ) {
-
- // When pushing a matrix, it can be a transform or camera. To compute
- // differents matrix type in shader ( ViewMatrix/ModelMatrix/ModelViewMatrix )
- // we track camera node when using pushModelViewMatrix
- // To detect a camera, we check on the nodepath the type of the node and if the
- // camera is relatif or absolute.
- // When we detect an absolute camera we keep it's index to get it when needed to
- // compute the World/View matrix
- // Th ere is an exception for the root camera, the root camera is not pushed on the
- // CullVisitor but only its matrixes, so to handle this we compute the inverse camera
- // when the nodepath has a lenght of 0
- // To avoid to compute too much inverse matrix, we keep a cache of them during the
- // traverse and store the result under the instanceID key, except for the root
- var np = this.getNodePath();
- var length = np.length;
- if ( !length ) { // root
- var matInverse = this._reservedMatrixStack.get();
- mat4.invert( matInverse, matrix );
- this._cameraMatrixInverseRoot = matInverse;
- } else {
- var index = length - 1;
- if ( np[ index ].getTypeID() === Camera.getTypeID() && np[ index ].getReferenceFrame() === TransformEnums.ABSOLUTE_RF ) {
- this._cameraIndexStack.push( index );
- this._cameraModelViewIndexStack.push( this._modelViewMatrixStack.length );
- }
- }
-
- this._modelViewMatrixStack.push( matrix );
- this.getLookVectorLocal( lookVector );
-
- /*jshint bitwise: false */
- this._bbCornerFar = ( lookVector[ 0 ] >= 0 ? 1 : 0 ) | ( lookVector[ 1 ] >= 0 ? 2 : 0 ) | ( lookVector[ 2 ] >= 0 ? 4 : 0 );
- this._bbCornerNear = ( ~this._bbCornerFar ) & 7;
- /*jshint bitwise: true */
-
- };
- } )(),
- popModelViewMatrix: ( function () {
- var lookVector = vec3.create();
-
- return function () {
-
- // if same index it's a camera and we have to pop it
- var np = this.getNodePath();
- var index = np.length - 1;
- if ( this._cameraIndexStack.length && index === this._cameraIndexStack[ this._cameraIndexStack.length - 1 ] ) {
- this._cameraIndexStack.pop();
- this._cameraModelViewIndexStack.pop();
- }
-
- this._modelViewMatrixStack.pop();
-
- if ( this._modelViewMatrixStack.length !== 0 ) {
- this.getLookVectorLocal( lookVector );
- } else {
- vec3.set( lookVector, 0.0, 0.0, -1.0 );
- }
-
- /*jshint bitwise: false */
- this._bbCornerFar = ( lookVector[ 0 ] >= 0.0 ? 1.0 : 0.0 ) | ( lookVector[ 1 ] >= 0 ? 2.0 : 0.0 ) | ( lookVector[ 2 ] >= 0 ? 4.0 : 0.0 );
- this._bbCornerNear = ( ~this._bbCornerFar ) & 7;
- /*jshint bitwise: true */
- };
- } )(),
-
- pushProjectionMatrix: function ( matrix ) {
- this._projectionMatrixStack.push( matrix );
-
- // need to recompute frustum volume.
- this._frustumVolume = -1.0;
-
- this.pushCullingSet();
- },
- popProjectionMatrix: function () {
- this._projectionMatrixStack.pop();
-
- // need to recompute frustum volume.
- this._frustumVolume = -1.0;
-
- this.popCullingSet();
- }
-
-
-} );
-
-module.exports = CullStack;
diff --git a/app/static/app/js/vendor/osgjs/osg/CullVisitor.js b/app/static/app/js/vendor/osgjs/osg/CullVisitor.js
deleted file mode 100644
index 9d7c3d8d..00000000
--- a/app/static/app/js/vendor/osgjs/osg/CullVisitor.js
+++ /dev/null
@@ -1,761 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var osgMath = require( 'osg/math' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var CullSettings = require( 'osg/CullSettings' );
-var CullStack = require( 'osg/CullStack' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var AutoTransform = require( 'osg/AutoTransform' );
-var Projection = require( 'osg/Projection' );
-var LightSource = require( 'osg/LightSource' );
-var osgPool = require( 'osgUtil/osgPool' );
-var Geometry = require( 'osg/Geometry' );
-var RenderLeaf = require( 'osg/RenderLeaf' );
-var RenderBin = require( 'osg/RenderBin' );
-var RenderStage = require( 'osg/RenderStage' );
-var Node = require( 'osg/Node' );
-var Lod = require( 'osg/Lod' );
-var PagedLOD = require( 'osg/PagedLOD' );
-var Camera = require( 'osg/Camera' );
-var TransformEnums = require( 'osg/transformEnums' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var Skeleton = require( 'osgAnimation/Skeleton' );
-var RigGeometry = require( 'osgAnimation/RigGeometry' );
-var Bone = require( 'osgAnimation/Bone' );
-var MorphGeometry = require( 'osgAnimation/MorphGeometry' );
-
-/**
- * CullVisitor traverse the tree and collect Matrix/State for the rendering traverse
- * @class CullVisitor
- */
-var CullVisitor = function () {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ACTIVE_CHILDREN );
- CullSettings.call( this );
- CullStack.call( this );
-
- this._rootStateGraph = undefined;
- this._currentStateGraph = undefined;
- this._currentRenderBin = undefined;
- this._currentRenderStage = undefined;
- this._rootRenderStage = undefined;
- this._computedNear = Number.POSITIVE_INFINITY;
- this._computedFar = Number.NEGATIVE_INFINITY;
-
- var lookVector = vec3.fromValues( 0.0, 0.0, -1.0 );
- this._camera = undefined;
- /*jshint bitwise: false */
- this._bbCornerFar = ( lookVector[ 0 ] >= 0 ? 1 : 0 ) | ( lookVector[ 1 ] >= 0 ? 2 : 0 ) | ( lookVector[ 2 ] >= 0 ? 4 : 0 );
- this._bbCornerNear = ( ~this._bbCornerFar ) & 7;
- /*jshint bitwise: true */
-
- this._reserveLeafStack = [ new RenderLeaf() ];
- this._reserveLeafStackCurrent = 0;
-
- this._reserveRenderStageStacks = {};
-
- this._reserveCullSettingsStack = [ new CullSettings() ];
- this._reserveCullSettingsStackCurrent = 0;
-
- this._renderBinStack = [];
- this.visitorType = NodeVisitor.CULL_VISITOR;
-
- this._identityMatrix = mat4.create();
-
- this._renderer = undefined;
- this._renderStageType = RenderStage;
-
- this._numCamera = 0;
- this._numMatrixTransform = 0;
- this._numProjection = 0;
- this._numNode = 0;
- this._numLightSource = 0;
- this._numGeometry = 0;
-
-};
-
-/** @lends CullVisitor.prototype */
-CullVisitor.prototype = MACROUTILS.objectInherit( CullStack.prototype, MACROUTILS.objectInherit( NodeVisitor.prototype, {
- distance: function ( coord, matrix ) {
- return -( coord[ 0 ] * matrix[ 2 ] + coord[ 1 ] * matrix[ 6 ] + coord[ 2 ] * matrix[ 10 ] + matrix[ 14 ] );
- },
-
- getComputedNear: function () {
- return this._computedNear;
- },
-
- getComputedFar: function () {
- return this._computedFar;
- },
-
- resetStats: function () {
- this._numCamera = 0;
- this._numMatrixTransform = 0;
- this._numProjection = 0;
- this._numNode = 0;
- this._numLightSource = 0;
- this._numGeometry = 0;
- },
-
- handleCullCallbacksAndTraverse: function ( node ) {
- var ccb = node.getCullCallback();
- if ( ccb && !ccb.cull( node, this ) )
- return;
- this.traverse( node );
- },
-
- getCurrentCamera: function () {
- return this._currentRenderBin.getStage().getCamera();
- },
-
- updateCalculatedNearFar: ( function () {
- var nearVec = vec3.create();
- var farVec = vec3.create();
-
- return function ( matrix, drawable ) {
-
- var bb = drawable.getBoundingBox();
- var dNear, dFar;
-
- // efficient computation of near and far, only taking into account the nearest and furthest
- // corners of the bounding box.
- dNear = this.distance( bb.corner( this._bbCornerNear, nearVec ), matrix );
- dFar = this.distance( bb.corner( this._bbCornerFar, farVec ), matrix );
-
- if ( dNear > dFar ) {
- var tmp = dNear;
- dNear = dFar;
- dFar = tmp;
- }
-
- if ( dFar < 0.0 ) {
- // whole object behind the eye point so discard
- return false;
- }
-
- if ( dNear < this._computedNear ) {
- this._computedNear = dNear;
- }
-
- if ( dFar > this._computedFar ) {
- this._computedFar = dFar;
- }
-
- return true;
-
- };
- } )(),
-
-
- setStateGraph: function ( sg ) {
- this._rootStateGraph = sg;
- this._currentStateGraph = sg;
- },
- setRenderStage: function ( rg ) {
- this._rootRenderStage = rg;
- this._currentRenderBin = rg;
- },
- setRenderer: function ( renderer ) {
- this._renderer = renderer;
- },
- getRenderer: function () {
- return this._renderer;
- },
-
- reset: function () {
- CullStack.prototype.reset.call( this );
- // Reset the stack before reseting the current leaf index.
- // Reseting elements and refilling them later is faster than create new elements
- // That's the reason to have a leafStack, see http://jsperf.com/refill/2
- this.resetRenderLeafStack();
- this._reserveLeafStackCurrent = 0;
-
- this.resetCullSettingsStack();
- this._reserveCullSettingsStackCurrent = 0;
-
- // renderstage / renderbin pools
- var resetStages = window.Object.keys( this._reserveRenderStageStacks );
- for ( var i = 0, l = resetStages.length; i < l; i++ ) {
- var key = resetStages[ i ];
- this._reserveRenderStageStacks[ key ].reset();
- }
- RenderBin.resetStack();
-
- this._computedNear = Number.POSITIVE_INFINITY;
- this._computedFar = Number.NEGATIVE_INFINITY;
- },
-
- getCurrentRenderBin: function () {
- return this._currentRenderBin;
- },
-
- setCurrentRenderBin: function ( rb ) {
- this._currentRenderBin = rb;
- },
-
- // mimic the osg implementation
- // in osg you can push 0, in this case an identity matrix will be loaded
- addPositionedAttribute: function ( matrix, attribute ) {
-
- var m = matrix ? matrix : this._identityMatrix;
- this._currentRenderBin.getStage().positionedAttribute.push( [ m, attribute ] );
-
- },
-
- pushStateSet: function ( stateset ) {
- this._currentStateGraph = this._currentStateGraph.findOrInsert( stateset );
- if ( stateset.getBinName() !== undefined ) {
- var renderBinStack = this._renderBinStack;
- var currentRenderBin = this._currentRenderBin;
- renderBinStack.push( currentRenderBin );
- this._currentRenderBin = currentRenderBin.getStage().findOrInsert( stateset.getBinNumber(), stateset.getBinName() );
- }
- },
-
- /** Pop the top state set and hence associated state group.
- * Move the current state group to the parent of the popped
- * state group.
- */
- popStateSet: function () {
- var currentStateGraph = this._currentStateGraph;
- var stateset = currentStateGraph.getStateSet();
- this._currentStateGraph = currentStateGraph.parent;
- if ( stateset.getBinName() !== undefined ) {
- var renderBinStack = this._renderBinStack;
- if ( renderBinStack.length === 0 ) {
- this._currentRenderBin = this._currentRenderBin.getStage();
- } else {
- this._currentRenderBin = renderBinStack.pop();
- }
- }
- },
-
- popProjectionMatrix: function () {
- if ( this._computeNearFar === true && this._computedFar >= this._computedNear ) {
- var m = this.getCurrentProjectionMatrix();
- if ( this._clampProjectionMatrixCallback !== undefined ) {
- this._clampProjectionMatrixCallback( m, this._computedNear, this._computedFar, this._nearFarRatio );
- } else {
- this.clampProjectionMatrix( m, this._computedNear, this._computedFar, this._nearFarRatio );
- }
- }
- CullStack.prototype.popProjectionMatrix.call( this );
- },
-
-
- clampProjectionMatrix: function ( projection, znear, zfar, nearFarRatio, resultNearFar ) {
- var epsilon = 1e-6;
- if ( zfar < znear - epsilon ) {
- Notify.log( 'clampProjectionMatrix not applied, invalid depth range, znear = ' + znear + ' zfar = ' + zfar, false, true );
- return false;
- }
-
- var desiredZnear, desiredZfar;
- if ( zfar < znear + epsilon ) {
- // znear and zfar are too close together and could cause divide by zero problems
- // late on in the clamping code, so move the znear and zfar apart.
- var average = ( znear + zfar ) * 0.5;
- znear = average - epsilon;
- zfar = average + epsilon;
- // OSG_INFO << '_clampProjectionMatrix widening znear and zfar to '<= 0 && elapsedTime < availableTime; i-- ) {
- gl.deleteFramebuffer( deleteList[ i ] );
- deleteList.splice( i, 1 );
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- }
-
- return availableTime - elapsedTime;
-};
-
-FrameBufferObject.flushAllDeletedGLFrameBuffers = function ( gl ) {
-
- if ( !FrameBufferObject._sDeletedGLFrameBufferCache.has( gl ) ) return;
-
- var deleteList = FrameBufferObject._sDeletedGLFrameBufferCache.get( gl );
- var numBuffers = deleteList.length;
-
- for ( var i = numBuffers - 1; i >= 0; i-- ) {
- gl.deleteFramebuffer( deleteList[ i ] );
- deleteList.splice( i, 1 );
- }
-};
-
-
-// static cache of glRenderBuffer flagged for deletion, which will actually
-// be deleted in the correct GL context.
-FrameBufferObject._sDeletedGLRenderBufferCache = new window.Map();
-
-// static method to delete RenderBuffers
-FrameBufferObject.deleteGLRenderBuffer = function ( gl, fb ) {
-
- if ( !FrameBufferObject._sDeletedGLRenderBufferCache.has( gl ) )
- FrameBufferObject._sDeletedGLRenderBufferCache.set( gl, [] );
-
- FrameBufferObject._sDeletedGLRenderBufferCache.get( gl ).push( fb );
-};
-
-
-// static method to flush all the cached glRenderBuffers which need to be deleted in the GL context specified
-FrameBufferObject.flushDeletedGLRenderBuffers = function ( gl, availableTime ) {
-
- // if no time available don't try to flush objects.
- if ( availableTime <= 0.0 ) return availableTime;
-
- if ( !FrameBufferObject._sDeletedGLRenderBufferCache.has( gl ) ) return availableTime;
-
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- var deleteList = FrameBufferObject._sDeletedGLRenderBufferCache.get( gl );
- var numBuffers = deleteList.length;
-
- for ( var i = numBuffers - 1; i >= 0 && elapsedTime < availableTime; i-- ) {
- gl.deleteRenderbuffer( deleteList[ i ] );
- deleteList.splice( i, 1 );
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- }
-
- return availableTime - elapsedTime;
-};
-
-FrameBufferObject.flushAllDeletedGLRenderBuffers = function ( gl ) {
-
- if ( !FrameBufferObject._sDeletedGLRenderBufferCache.has( gl ) ) return;
-
- var deleteList = FrameBufferObject._sDeletedGLRenderBufferCache.get( gl );
- var numBuffers = deleteList.length;
-
- for ( var i = numBuffers - 1; i >= 0; i-- ) {
- gl.deleteRenderbuffer( deleteList[ i ] );
- deleteList.splice( i, 1 );
- }
-};
-
-/** @lends FrameBufferObject.prototype */
-FrameBufferObject.prototype = MACROUTILS.objectInherit( GLObject.prototype, MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'FrameBufferObject',
-
- cloneType: function () {
- return new FrameBufferObject();
- },
-
- dirty: function () {
- this._dirty = true;
- },
-
- isDirty: function () {
- return this._dirty;
- },
-
- setAttachment: function ( attachment ) {
- this._attachments.push( attachment );
- },
-
- releaseGLObjects: function () {
-
- if ( this._fbo !== undefined && this._gl !== undefined ) {
- FrameBufferObject.deleteGLFrameBuffer( this._gl, this._fbo );
- }
- this._fbo = undefined;
-
- if ( this._rbo !== undefined && this._gl !== undefined ) {
- FrameBufferObject.deleteGLRenderBuffer( this._gl, this._rbo );
- }
- this._rbo = undefined;
-
- },
-
- _reportFrameBufferError: function ( code ) {
- switch ( code ) {
- case 0x8CD6:
- Notify.debug( 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT' );
- break;
- case 0x8CD7:
- Notify.debug( 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT' );
- break;
- case 0x8CD9:
- Notify.debug( 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS' );
- break;
- case 0x8CDD:
- Notify.debug( 'FRAMEBUFFER_UNSUPPORTED' );
- break;
- default:
- Notify.debug( 'FRAMEBUFFER unknown error ' + code.toString( 16 ) );
- }
- },
-
- reset: function () {
- this.releaseGLObjects();
- this._attachments = [];
- },
-
- getFrameBufferObject: function () {
- return this._fbo;
- },
-
- createFrameBufferObject: function ( state ) {
- this.setGraphicContext( state.getGraphicContext() );
- this._fbo = this._gl.createFramebuffer();
- },
-
- createRenderBuffer: function ( format, width, height ) {
- var gl = this._gl;
- var renderBuffer = gl.createRenderbuffer();
- gl.bindRenderbuffer( gl.RENDERBUFFER, renderBuffer );
- gl.renderbufferStorage( gl.RENDERBUFFER, format, width, height );
-
- return renderBuffer;
- },
-
- framebufferRenderBuffer: function ( attachment, renderBuffer ) {
-
- var gl = this._gl;
- gl.bindRenderbuffer( gl.RENDERBUFFER, renderBuffer );
- gl.framebufferRenderbuffer( gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderBuffer );
-
- /* develblock:start */
- // only visible with webgl-insector enabled
- if ( gl.rawgl !== undefined ) {
- Notify.log( 'FBO: renderBuffer: ' + this._fbo.trackedObject.defaultName );
- }
- /* develblock:end */
- },
-
- framebufferTexture2D: function ( state, attachment, textureTarget, texture ) {
-
- var gl = this._gl;
-
- // apply on unit 1 to init it
- // make sure we do bind it whatever state stack
- // texture is cached
- state.applyTextureAttribute( 1, texture );
-
- if ( texture.isDirty() || !texture.getTextureObject() ) {
- // image wasn't ready, texture not allocated due to lack of gpu MEM
- return false;
- }
-
- gl.framebufferTexture2D( gl.FRAMEBUFFER, attachment, textureTarget, texture.getTextureObject().id(), 0 );
-
- /* develblock:start */
- // only visible with webgl-insector enabled
- // allow trace debug (fb<->texture link)
- if ( gl.rawgl !== undefined ) {
- Notify.log( 'FBO: texture: ' + texture.getName() + ' : ' + texture.getTextureObject().id().trackedObject.defaultName + ' fbo: ' + this._fbo.trackedObject.defaultName );
- }
- /* develblock:end */
-
- return true;
- },
-
- bindFrameBufferObject: function () {
- var gl = this._gl;
- gl.bindFramebuffer( gl.FRAMEBUFFER, this._fbo );
- },
-
- checkStatus: function () {
-
- var gl = this._gl;
- var status = gl.checkFramebufferStatus( gl.FRAMEBUFFER );
- if ( status !== 0x8CD5 ) {
- this._reportFrameBufferError( status );
- }
-
- },
-
- _checkAllowedSize: function ( w, h ) {
-
- var maxSize = WebglCaps.instance().getWebGLParameter( 'MAX_RENDERBUFFER_SIZE' );
-
- if ( w === 0 || h === 0 || h > maxSize || w > maxSize ) {
- Notify.error( 'width (' + w + ') or height (' + w + ') makes frame buffer not bindable. Max RenderBuffer is "' + maxSize + '"' );
- return false;
- }
-
- return true;
-
- },
-
- apply: function ( state ) {
-
- if ( !this._gl ) this.setGraphicContext( state.getGraphicContext() );
- var gl = this._gl;
-
- var attachments = this._attachments;
-
- // if the fbo is created manually, we want to just bind it
- if ( attachments.length > 0 || this._fbo ) {
-
- if ( this.isDirty() ) {
-
- if ( !this._fbo )
- this.createFrameBufferObject( state );
-
- this.bindFrameBufferObject();
-
- var hasRenderBuffer = false;
-
- for ( var i = 0, l = attachments.length; i < l; ++i ) {
-
- var attachment = attachments[ i ];
-
- // render buffer
- if ( !attachment.texture ) {
-
- if ( !this._checkAllowedSize( attachment.width, attachment.height ) ) {
- this.releaseGLObjects();
- return;
- }
-
- this._rbo = this.createRenderBuffer( attachment.format, attachment.width, attachment.height );
- this.framebufferRenderBuffer( attachment.attachment, this._rbo );
- hasRenderBuffer = true;
-
- } else {
-
- // use texture
- var texture = attachment.texture;
-
- if ( !this._checkAllowedSize( texture.getWidth(), texture.getHeight() ) ) {
- this.releaseGLObjects();
- return;
- }
-
- if ( !this.framebufferTexture2D( state, attachment.attachment, attachment.textureTarget, texture ) ) {
- this.releaseGLObjects();
- return;
-
- }
-
-
- }
-
- }
-
- this.checkStatus();
-
- // set it to null only if used renderbuffer
- if ( hasRenderBuffer )
- gl.bindRenderbuffer( gl.RENDERBUFFER, null );
-
- this._dirty = false;
-
- } else {
-
- gl.bindFramebuffer( gl.FRAMEBUFFER, this._fbo );
-
- if ( Notify.reportWebGLError === true )
- this.checkStatus();
-
- }
-
- } else {
- gl.bindFramebuffer( gl.FRAMEBUFFER, null );
- }
- }
-} ) );
-
-
-module.exports = FrameBufferObject;
diff --git a/app/static/app/js/vendor/osgjs/osg/FrameStamp.js b/app/static/app/js/vendor/osgjs/osg/FrameStamp.js
deleted file mode 100644
index f4e62fe0..00000000
--- a/app/static/app/js/vendor/osgjs/osg/FrameStamp.js
+++ /dev/null
@@ -1,37 +0,0 @@
-'use strict';
-
-var FrameStamp = function () {
- this._frame = 0;
- this._startSimulation = 0.0;
- this._currentSimulation = 0.0;
- this._deltaTime = 0.0; // last time elapsed since the next traversal
-};
-
-FrameStamp.prototype = {
- setReferenceTime: function ( s ) {
- this._startSimulation = s;
- },
- getReferenceTime: function () {
- return this._startSimulation;
- },
- setSimulationTime: function ( s ) {
- this._currentSimulation = s;
- },
- getSimulationTime: function () {
- return this._currentSimulation;
- },
- setDeltaTime: function ( d ) {
- this._deltaTime = d;
- },
- getDeltaTime: function () {
- return this._deltaTime;
- },
- setFrameNumber: function ( n ) {
- this._frame = n;
- },
- getFrameNumber: function () {
- return this._frame;
- }
-};
-
-module.exports = FrameStamp;
diff --git a/app/static/app/js/vendor/osgjs/osg/GLObject.js b/app/static/app/js/vendor/osgjs/osg/GLObject.js
deleted file mode 100644
index cfc50774..00000000
--- a/app/static/app/js/vendor/osgjs/osg/GLObject.js
+++ /dev/null
@@ -1,19 +0,0 @@
-'use strict';
-
-// Base class for GLResources: Textures, Buffers, Programs, Shaders, FrameBuffers and RenderBuffers
-// It holds a reference to the graphic context that is needed for resource deletion
-
-var GLObject = function () {
- this._gl = undefined;
-};
-
-GLObject.prototype = {
- setGraphicContext: function ( gl ) {
- this._gl = gl;
- },
- getGraphicContext: function () {
- return this._gl;
- }
-};
-
-module.exports = GLObject;
diff --git a/app/static/app/js/vendor/osgjs/osg/Geometry.js b/app/static/app/js/vendor/osgjs/osg/Geometry.js
deleted file mode 100644
index 22ecd4ee..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Geometry.js
+++ /dev/null
@@ -1,474 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Node = require( 'osg/Node' );
-var Notify = require( 'osg/notify' );
-var WebGLCaps = require( 'osg/WebGLCaps' );
-var DrawElements = require( 'osg/DrawElements' );
-var BufferArrayProxy = require( 'osg/BufferArrayProxy' );
-
-/**
- * Geometry manage array and primitives to draw a geometry.
- * @class Geometry
- */
-
-var Geometry = function () {
-
- Node.call( this );
-
- // Use proxy to detect change in vertex attributes
- // you should use setVertexAttribute but if you dont
- if ( window.Proxy ) {
-
- var self = this;
-
- this._attributes = {};
- this._primitives = [];
- this.attributes = new Proxy( this._attributes, {
- set: function ( obj, prop, value ) {
- var old = obj[ prop ];
- if ( old !== value ) {
- obj[ prop ] = value;
- self.dirty();
- }
- return true;
- }
- } );
-
- var push = function () {
- this.push.apply( this, arguments );
- self.dirty();
-
- }.bind( this._primitives );
-
- var pop = function () {
- this.pop();
- self.dirty();
-
- }.bind( this._primitives );
-
- this.primitives = new Proxy( this._primitives, {
- get: function ( obj, key ) {
- if ( key === 'push' ) return push;
- if ( key === 'pop' ) return pop;
- return obj[ key ];
- }
- } );
-
- } else {
-
- this.attributes = {};
- this.primitives = [];
- this._primitives = this.primitives;
- this._attributes = this.attributes;
-
- }
-
- // function is generated for each Shader Program ID
- // which generates a a special "draw"
- // TODO: could be upon hash of combination of attributes
- // (as multiple shader Programs can use same combination of attributes)
- this._cacheDrawCall = {};
-
- // VAO cached data, per combination of vertex buffer
- // program id also the cache key
- this._extVAO = undefined;
- this._vao = {};
- this._cacheVertexAttributeBufferList = {};
-
- // null means the kdTree builder will skip the kdTree creation
- this._shape = undefined;
-
-};
-
-/**
- * enableVAO flag
- * We rely on Proxy to detect changes in vertextes attributes list or in primitives
- * list. If you dont have Proxy and you still want to use the VAO code path, replace
- * OSG.osg.Geometry.enableVAO = true at the begining of your application, but be sure to
- * not change vertexes attributes without calling dirty after.
- */
-Geometry.enableVAO = Boolean( window.Proxy );
-if ( Geometry.enableVAO ) Notify.info( 'enable VAO' );
-
-
-/** @lends Geometry.prototype */
-Geometry.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Node.prototype, {
-
- releaseGLObjects: function () {
-
- if ( this.stateset !== undefined ) this.stateset.releaseGLObjects();
-
- var keys = window.Object.keys( this._attributes );
- var value;
- var i, l;
-
- for ( i = 0, l = keys.length; i < l; i++ ) {
- value = this._attributes[ keys[ i ] ];
- value.releaseGLObjects();
- }
-
- for ( var j = 0, h = this._primitives.length; j < h; j++ ) {
- var prim = this._primitives[ j ];
- if ( prim.getIndices !== undefined ) {
- if ( prim.getIndices() !== undefined && prim.getIndices() !== null ) {
- prim.indices.releaseGLObjects();
- }
- }
- }
-
- this.releaseVAO();
-
- },
-
- releaseVAO: function () {
-
- if ( !this._extVAO ) return;
-
- var keys = window.Object.keys( this._vao );
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- var prgID = keys[ i ];
- if ( this._vao[ prgID ] ) {
- var vao = this._vao[ prgID ];
- this._extVAO.deleteVertexArrayOES( vao );
- this._vao[ prgID ] = undefined;
- }
- }
- },
-
- dirty: function () {
- this._cacheDrawCall = {};
- this.releaseVAO();
- },
-
- getPrimitives: function () {
- // Notify.warn( 'deprecated use instead getPrimitiveSetList' );
- return this.getPrimitiveSetList();
- },
-
- getAttributes: function () {
- // Notify.warn( 'deprecated use instead getVertexAttributeList' );
- return this.getVertexAttributeList();
- },
-
- getShape: function () {
- return this._shape;
- },
-
- setShape: function ( shape ) {
- this._shape = shape;
- },
-
- getVertexAttributeList: function () {
- return this.attributes;
- },
-
- /**
- * Return the primitiveset list
- * If you modify something inside this array
- * you must call dirty() on the Geometry
- */
- getPrimitiveSetList: function () {
- return this.primitives;
- },
-
- /**
- * Set the buffer array on the attribute name key
- * key is often something like Vertex, Normal, Color, ...
- * for classic geometry
- *
- * if you change a buffer a dirty will be automatically
- * called to rebuild the VAO if needed.
- */
- setVertexAttribArray: function ( key, array ) {
- if ( this._attributes[ key ] !== array ) {
- this._attributes[ key ] = array;
- this.dirty();
- }
- },
-
- _generateVertexSetup: function ( validAttributeKeyList, validAttributeIndexList, includeFirstIndexBuffer ) {
-
- // generate setup for vertex attribute
- // will be used as setup for vao or as is without vao
- var vertexAttributeSetup = [ '//generated by Geometry::implementation',
- 'state.lazyDisablingOfVertexAttributes();',
- 'var attr;'
- ];
-
- for ( var i = 0, l = validAttributeKeyList.length; i < l; i++ ) {
-
- vertexAttributeSetup.push( 'attr = this._attributes[\'' + validAttributeKeyList[ i ] + '\'];' );
- vertexAttributeSetup.push( 'if ( attr.BufferArrayProxy ) attr = attr.getBufferArray();' );
- vertexAttributeSetup.push( 'if ( !attr.isValid() ) return;' );
- vertexAttributeSetup.push( 'state.setVertexAttribArray(' + validAttributeIndexList[ i ] + ', attr, attr.getNormalize() );' );
-
- }
-
- vertexAttributeSetup.push( 'state.applyDisablingOfVertexAttributes();' );
-
- if ( includeFirstIndexBuffer )
- vertexAttributeSetup.push( 'state.setIndexArray( this._primitives[ 0 ].getIndices() );' );
-
- return vertexAttributeSetup;
- },
-
- _generatePrimitive: function ( primitives, hasVertexColor, optimizeVAO ) {
-
- var primitiveSetup = [
- hasVertexColor ? 'state.enableVertexColor();' : 'state.disableVertexColor();'
- ];
-
- if ( optimizeVAO ) {
- return primitiveSetup.concat( [
- 'var primitive = this._primitives[ 0 ];',
- 'var indexes = primitive.getIndices();',
- 'if ( indexes.isDirty() ) {;',
- ' indexes.bind( gl );',
- ' indexes.compile( gl );',
- '};',
- 'primitive.drawElements( state );'
- ] );
- }
-
-
- primitiveSetup.push( 'var primitives = this._primitives;' );
- for ( var j = 0, m = primitives.length; j < m; j++ )
- primitiveSetup.push( 'primitives[' + j + '].draw(state);' );
-
- return primitiveSetup;
- },
-
- /**
- * Generate a function specific to the Geometry/Program
- * two version one using VAO and a regular one
- */
- generateDrawCommand: ( function () {
-
- var validAttributeList = [];
- var validAttributeKeyList = [];
-
- return function ( state, program, prgID ) {
-
- var attributesCacheKeys = program._attributesCache.getKeys();
- var attributesCacheMap = program._attributesCache;
- var geometryVertexAttributes = this.getVertexAttributeList();
-
- validAttributeKeyList.length = 0;
- validAttributeList.length = 0;
-
- // 1 - register valid vertex attributes and color flag
-
- var attribute, i, l, j, m, key, attr;
-
- var extVAO = this._extVAO;
- var listVABuff = extVAO ? [] : undefined;
-
- var hasVertexColor = false;
-
- for ( i = 0, l = attributesCacheKeys.length; i < l; i++ ) {
-
- key = attributesCacheKeys[ i ];
- attribute = attributesCacheMap[ key ];
- attr = geometryVertexAttributes[ key ];
-
- if ( attr === undefined ) continue;
-
- var attributeBuffer = this._attributes[ key ];
-
- // dont use VAO if we have BufferArrayProxy
- // typically used for morphing
- if ( attributeBuffer instanceof BufferArrayProxy ) {
- attributeBuffer = attributeBuffer.getBufferArray();
- extVAO = false;
- }
-
- if ( !attributeBuffer.isValid() ) return undefined;
-
- // store for later usage at draw time/update
- if ( extVAO ) listVABuff.push( attributeBuffer );
-
- if ( !hasVertexColor && key === 'Color' )
- hasVertexColor = true;
-
- validAttributeKeyList.push( key );
- validAttributeList.push( attribute );
- }
-
-
- var autogeneratedFunction;
- var functionName;
-
- // generate specific function using VAO or standard
- if ( extVAO ) {
-
- this._cacheVertexAttributeBufferList[ prgID ] = listVABuff;
-
- // if there is only one drawElement we can put the index buffer
- // in the vao
- var optimizeIndexBufferVAO = ( this._primitives.length === 1 && this._primitives[ 0 ] instanceof DrawElements );
-
- var vertexAttributeSetup = this._generateVertexSetup( validAttributeKeyList, validAttributeList, optimizeIndexBufferVAO );
-
- state.clearVertexAttribCache();
- var vao = this._extVAO.createVertexArrayOES();
- state.setVertexArrayObject( vao );
- this._vao[ prgID ] = vao;
-
- // evaluate the vertexAttribute setup to register into the vao
- /*jshint evil: true */
- var vertexSetupCommand = new Function( 'state', vertexAttributeSetup.join( '\n' ) );
- /*jshint evil: false */
- vertexSetupCommand.call( this, state );
-
- // setup the program
- var vaoSetup = [
- 'var gl = state.getGraphicContext();',
- 'var vao = this._vao[ ' + prgID + ' ] ',
- 'var hasChanged = state.setVertexArrayObject( vao );',
- 'if ( hasChanged ) {',
- ' var vaList = this._cacheVertexAttributeBufferList[ ' + prgID + ' ];',
- ' var va;'
- ];
- for ( j = 0, m = listVABuff.length; j < m; j++ ) {
- vaoSetup.push( ' va = vaList[ ' + j + '];' );
- vaoSetup.push( ' if ( va.isDirty() ) {;' );
- vaoSetup.push( ' va.bind( gl );' );
- vaoSetup.push( ' va.compile( gl );' );
- vaoSetup.push( ' };' );
- }
- vaoSetup.push( '}' );
-
- autogeneratedFunction = vaoSetup.concat( this._generatePrimitive( this._primitives, hasVertexColor, optimizeIndexBufferVAO ) ).join( '\n' );
- functionName = 'GeometryDrawImplementationCacheVAO';
-
- } else {
-
- autogeneratedFunction = this._generateVertexSetup( validAttributeKeyList, validAttributeList, false ).concat( this._generatePrimitive( this._primitives, hasVertexColor, false ) ).join( '\n' );
- functionName = 'GeometryDrawImplementationCache';
-
- }
-
- /*jshint evil: true */
- // name the function
- // http://stackoverflow.com/questions/5905492/dynamic-function-name-in-javascript
- var drawCommand = ( new Function( 'state', 'return function ' + functionName + '( state ) { ' + autogeneratedFunction + '}' ) )();
- /*jshint evil: false */
-
- this._cacheDrawCall[ prgID ] = drawCommand;
- return drawCommand;
- };
-
- } )(),
-
- drawImplementation: function ( state ) {
-
- var program = state.getLastProgramApplied();
- var prgID = program.getInstanceID();
-
- var cachedDraw = this._cacheDrawCall[ prgID ];
-
- // most of the time we should use vao
- if ( this._extVAO && !this._vao[ prgID ] ) state.setVertexArrayObject( null );
-
- if ( cachedDraw === undefined ) {
-
- if ( !this._primitives.length ) return;
-
- // no cache for this combination of vertex attributes
- // compute new Draw Call
-
- if ( this._extVAO === undefined && Geometry.enableVAO ) { // will be null if not supported
- var extVAO = WebGLCaps.instance( state.getGraphicContext() ).getWebGLExtension( 'OES_vertex_array_object' );
- this._extVAO = extVAO;
- }
-
- cachedDraw = this.generateDrawCommand( state, program, prgID );
- }
-
- cachedDraw.call( this, state );
-
- },
-
- setBound: function ( bb ) {
- this._boundingBox = bb;
- this._boundingBoxComputed = true;
- },
-
- computeBoundingBox: function ( boundingBox ) {
-
- boundingBox.init();
-
- var vertexArray = this.getVertexAttributeList().Vertex;
- if ( vertexArray && vertexArray.getElements() && vertexArray.getItemSize() > 2 ) {
- var vertexes = vertexArray.getElements();
- var itemSize = vertexArray.getItemSize();
-
- var min = boundingBox.getMin();
- var max = boundingBox.getMax();
-
- var minx = min[ 0 ];
- var miny = min[ 1 ];
- var minz = min[ 2 ];
- var maxx = max[ 0 ];
- var maxy = max[ 1 ];
- var maxz = max[ 2 ];
-
- // if the box is un-initialized min=Inf and max=-Inf
- // we can't simply write if(x > min) [...] else (x < max) [...]
- // most of the time the else condition is run so it's a kinda useless
- // optimization anyway
- for ( var idx = 0, l = vertexes.length; idx < l; idx += itemSize ) {
- var v1 = vertexes[ idx ];
- var v2 = vertexes[ idx + 1 ];
- var v3 = vertexes[ idx + 2 ];
- if ( v1 < minx ) minx = v1;
- if ( v1 > maxx ) maxx = v1;
- if ( v2 < miny ) miny = v2;
- if ( v2 > maxy ) maxy = v2;
- if ( v3 < minz ) minz = v3;
- if ( v3 > maxz ) maxz = v3;
- }
-
- min[ 0 ] = minx;
- min[ 1 ] = miny;
- min[ 2 ] = minz;
- max[ 0 ] = maxx;
- max[ 1 ] = maxy;
- max[ 2 ] = maxz;
- }
-
- return boundingBox;
- },
-
- computeBoundingSphere: function ( boundingSphere ) {
- boundingSphere.init();
- var bb = this.getBoundingBox();
- boundingSphere.expandByBoundingBox( bb );
- return boundingSphere;
- }
-
-
-} ), 'osg', 'Geometry' );
-
-Geometry.appendVertexAttributeToList = function ( from, to, postfix ) {
-
- var keys = window.Object.keys( from );
- var key, keyPostFix;
-
- for ( var i = 0, l = keys.length; i < l; i++ ) {
-
- key = keys[ i ];
- keyPostFix = key;
- if ( postfix !== undefined )
- keyPostFix += '_' + postfix;
-
- to[ keyPostFix ] = from[ key ];
-
- }
-
-};
-
-
-MACROUTILS.setTypeID( Geometry );
-
-module.exports = Geometry;
diff --git a/app/static/app/js/vendor/osgjs/osg/Image.js b/app/static/app/js/vendor/osgjs/osg/Image.js
deleted file mode 100644
index 4efd7db1..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Image.js
+++ /dev/null
@@ -1,241 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-
-var ImageBitmap = window.ImageBitmap || function () {};
-
-var ImageObject = function ( image ) {
- Object.call( this );
-
- this._imageObject = undefined;
- this._url = undefined;
- this._width = undefined;
- this._height = undefined;
- this._dirty = true;
- this._mipmap = [];
-
- if ( image ) {
- this.setImage( image );
- }
-
- this._isGreyscale = undefined;
-};
-
-ImageObject.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- dirty: function () {
- this._isGreyscale = undefined;
- this._dirty = true;
- },
-
- isDirty: function () {
- return this._dirty;
- },
-
- setDirty: function ( bool ) {
- this._dirty = bool;
- },
-
- getImage: function () {
- return ( this._imageObject instanceof ImageObject ) ? this._imageObject.getImage() : this._imageObject;
- },
-
- getURL: function () {
- return this._url;
- },
-
- setURL: function ( url ) {
- this._url = url;
- },
-
- useOrCreateImage: function ( img ) {
- return ( img instanceof( ImageObject ) === false ) ? new ImageObject( img ) : img;
- },
-
- setImage: function ( img ) {
- if ( !this._url && img && ( img.src || img.currentSrc ) ) {
- // TODO what is currentSrc ?
- this._url = img.src || img.currentSrc;
- }
-
- this._mipmap.length = 0;
-
- // img can be an image or an array of image if specify the
- // all mipmap levels
- if ( Array.isArray( img ) ) {
- for ( var i = 0, nbImg = img.length; i < nbImg; i++ ) {
- this._mipmap.push( this.useOrCreateImage( img[ i ] ) );
- }
- this.setWidth( this._mipmap[ 0 ].getWidth() );
- this.setHeight( this._mipmap[ 0 ].getHeight() );
- } else {
- this._mipmap.push( img );
- }
-
- this._imageObject = this._mipmap[ 0 ];
- this.dirty();
- },
-
- isCanvas: function () {
- return this.getImage() instanceof window.HTMLCanvasElement;
- },
-
- isBitmap: function () {
- return this.getImage() instanceof ImageBitmap;
- },
-
- isVideo: function () {
- return this.getImage() instanceof window.HTMLVideoElement;
- },
-
- isImage: function () {
- return this.getImage() instanceof window.Image;
- },
-
- isTypedArray: function () {
- var img = this.getImage();
- return img instanceof Uint8Array || img instanceof Float32Array || img instanceof Uint16Array;
- },
-
- setWidth: function ( w ) {
- this._width = w;
- },
-
- setHeight: function ( h ) {
- this._height = h;
- },
-
- getWidth: function () {
- var img = this.getImage();
- if ( this.isImage() ) {
- return img.naturalWidth;
- } else if ( this.isVideo() ) {
- return img.videoWidth;
- } else if ( this.isCanvas() || this.isBitmap() ) {
- return img.width;
- }
- return this._width;
- },
-
- getHeight: function () {
- var img = this.getImage();
- if ( this.isImage() ) {
- return img.naturalHeight;
- } else if ( this.isVideo() ) {
- return img.videoHeight;
- } else if ( this.isCanvas() || this.isBitmap() ) {
- return img.height;
- }
- return this._height;
- },
-
- isGreyscale: function ( nbSamples ) {
- if ( this._isGreyscale !== undefined )
- return this._isGreyscale;
-
- if ( this._imageObject !== undefined && this.isReady() && this._isGreyscale === undefined ) {
-
- var canvas = this._imageObject;
- if ( !this.isCanvas() ) {
- canvas = document.createElement( 'canvas' );
- }
- var ctx = canvas.getContext( '2d' );
- canvas.width = this._imageObject.width;
- canvas.height = this._imageObject.height;
- ctx.drawImage( this._imageObject, 0, 0 );
-
- var sampleX, sampleY;
- // cap sample if needed
- if ( !nbSamples ) {
- sampleX = canvas.width;
- sampleY = canvas.height;
- }
- if ( nbSamples > 0 ) {
- nbSamples = Math.min( Math.min( canvas.width, canvas.height ), nbSamples );
- sampleX = sampleY = nbSamples;
- }
-
- var isGreyscale = true;
- var xFactor = canvas.width / ( sampleX );
- var yFactor = canvas.height / ( sampleY );
- for ( var i = 0; i < sampleX; i++ ) {
- for ( var j = 0; j < sampleY; j++ ) {
- var x = Math.floor( xFactor * ( i + 0.5 ) ),
- y = Math.floor( yFactor * ( j + 0.5 ) );
- var data = ctx.getImageData( x, y, 1, 1 ).data;
- if ( !( data[ 0 ] === data[ 1 ] && data[ 0 ] === data[ 2 ] ) ) {
- isGreyscale = false;
- break;
- }
- }
- }
- this._isGreyscale = isGreyscale;
- }
-
- return this._isGreyscale;
- },
-
- isReady: function () {
-
- // image is a osgImage
- if ( this._imageObject && this._imageObject instanceof ImageObject ) {
- return this._imageObject.isReady();
- }
-
-
- // image are ready for static data
- if ( this.isCanvas() || this.isTypedArray() || this.isBitmap() ) {
- return true;
- }
-
- if ( this.isImage() ) {
- var image = this.getImage();
- if ( image.complete ) {
- if ( image.naturalWidth !== undefined && image.naturalWidth === 0 ) {
- return false;
- }
-
- return true;
- }
- }
-
- if ( this.isVideo() ) {
- if ( this.getWidth() !== 0 ) return true;
- }
-
- // here means we have something but we don't know what
- // Check if the object is not a image
- // by "feature" detect it
- var imageTry = this.getImage();
- if ( imageTry.complete ) {
- if ( imageTry.naturalWidth !== undefined && imageTry.naturalWidth === 0 ) {
- return false;
- }
- return true;
- }
-
- // It's not something we recognise
- /*develblock:start*/
- Notify.warn( 'Warning can\'t detect image object ' );
- /*develblock:end*/
- return false;
- },
-
- getMipmap: function () {
- return this._mipmap;
- },
-
- hasMipmap: function () {
- return this._mipmap.length > 1;
- },
-
- release: function () {
- this._mipmap.length = 0;
- this._imageObject = undefined;
- }
-} ), 'osg', 'Image' );
-
-MACROUTILS.setTypeID( ImageObject );
-
-module.exports = ImageObject;
diff --git a/app/static/app/js/vendor/osgjs/osg/ImageStream.js b/app/static/app/js/vendor/osgjs/osg/ImageStream.js
deleted file mode 100644
index 5ec738ca..00000000
--- a/app/static/app/js/vendor/osgjs/osg/ImageStream.js
+++ /dev/null
@@ -1,68 +0,0 @@
-'use strict';
-var P = require( 'bluebird' );
-var MACROUTILS = require( 'osg/Utils' );
-var Image = require( 'osg/Image' );
-
-
-var ImageStream = function ( video ) {
- Image.call( this, video );
- this._canPlayDefered = undefined;
-};
-
-ImageStream.PAUSE = 0;
-ImageStream.PLAYING = 1;
-
-ImageStream.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Image.prototype, {
-
- isDirty: function () {
- return this._status === ImageStream.PLAYING; // video is dirty if playing
- },
-
- setImage: function ( video ) {
- Image.prototype.setImage.call( this, video );
-
- this._status = ImageStream.STOP;
-
- // event at the end of the stream
- video.addEventListener( 'ended', function () {
- if ( !this._imageObject.loop )
- this.stop();
- }.bind( this ), true );
-
- this.dirty();
- },
-
- setLooping: function ( bool ) {
- this._imageObject.loop = bool;
- },
-
- play: function () {
- this._imageObject.play();
- this._status = ImageStream.PLAYING;
- },
-
- stop: function () {
- this._imageObject.pause();
- this._status = ImageStream.PAUSE;
- },
-
- whenReady: function () {
-
- if ( !this._imageObject ) {
- return P.reject();
- }
-
- if ( !this._canPlayDefered ) {
- this._canPlayDefered = P.defer();
- this._imageObject.addEventListener( 'canplaythrough', this._canPlayDefered.resolve.bind( this._canPlayDefered, this ), true );
- }
-
- return this._canPlayDefered.promise;
- }
-
-
-} ), 'osg', 'ImageStream' );
-
-MACROUTILS.setTypeID( ImageStream );
-
-module.exports = ImageStream;
diff --git a/app/static/app/js/vendor/osgjs/osg/KdTree.js b/app/static/app/js/vendor/osgjs/osg/KdTree.js
deleted file mode 100644
index 9f289372..00000000
--- a/app/static/app/js/vendor/osgjs/osg/KdTree.js
+++ /dev/null
@@ -1,432 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var BoundingBox = require( 'osg/BoundingBox' );
-var TriangleIndexFunctor = require( 'osg/TriangleIndexFunctor' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var KdTreeRayIntersector = require( 'osg/KdTreeRayIntersector' );
-var KdTreeSphereIntersector = require( 'osg/KdTreeSphereIntersector' );
-
-
-// **** GENERAL INFO ON KDTREE ****
-// A KdTree is a Spatial Partitionning Tree (http://en.wikipedia.org/wiki/Space_partitioning)
-// The type of tree is sort of defined by the splitting axis method:
-// - Per Axis split (octree/ kdtree)
-// - Arbritrary direction split (bsp)
-
-// The algorithm used for splitting, the name for finding best split is 'Surface Area Heuristic (SAH)'
-// Octree divide the space in 8 subspace (one box -> 8 sub boxes)
-// whereas kdtree does it by splitting population number in two equal group
-
-// Kd Tree http://en.wikipedia.org/wiki/K-d_tree
-// a given set of points is sorted along one Axis (e.g. X).
-// The sorted list is split at the median.
-// The result are two sets, one for each half-space (left and right).
-
-// Then, for the current node, the splitting-plane position (or the median-point) and depth is saved.
-// Finally, if the point-set has more than n point and the tree depth is below m
-// (with n,m chosen by the user, as build options), two child-nodes (L/R one for each point-set)
-// are created which themselfs repeat the pocedure.
-
-// The split-axis gets alternated at each depth, the split order is computed by checking the main
-// bounding box the length of its axis
-// **** GENERAL INFO ON KDTREE ****
-
-// The KdTree implemented here is flattened, ie, a node and its children all lie in the same array
-// The most important thing is the understanding of the variables first and second for each node
-// Their semantic depend if the node is a leaf or not
-// if it's a leaf :
-// first and second defines a range in the triangles array (triangles in the cell)
-// if it's not a leaf :
-// - first and second respectively represents the left and right sub children
-// We know that a node is a leaf if first is negative, in that case the range will be defined by
-// [ -first - 1, -first-1 + second ]
-var KdNode = function ( first, second ) {
- this._bb = new BoundingBox();
- this._first = first;
- this._second = second;
- // These variables represent the local clipped ray (for intersection test)
- // They are mostly temporary because they are recomputed for each intersection test
- this._nodeRayStart = vec3.create();
- this._nodeRayEnd = vec3.create();
-};
-
-var BuildKdTree = function ( kdTree ) {
- this._kdTree = kdTree;
- this._bb = new BoundingBox();
- this._primitiveIndices = null; // Uint32Array
- this._centers = null; // Float32Array
- this._axisOrder = vec3.create();
- this._stackLength = 0;
-};
-
-BuildKdTree.prototype = {
- build: function ( options, geom ) {
- var targetTris = options._targetNumTrianglesPerLeaf;
- var vertexAttrib = geom.getVertexAttributeList().Vertex;
- if ( !vertexAttrib )
- return false;
- var vertices = vertexAttrib.getElements();
- if ( !vertices )
- return false;
- var nbVertices = vertices.length / 3;
- if ( nbVertices < targetTris )
- return false;
-
- this._bb.copy( geom.getBoundingBox() );
- this._kdTree.setVertices( vertices );
-
- this.computeDivisions( options );
- options._numVerticesProcessed += nbVertices;
-
- this.computeTriangles( geom );
-
- var node = new KdNode( -1, this._primitiveIndices.length );
- node._bb.copy( this._bb );
- var nodeNum = this._kdTree.addNode( node );
-
- var bb = new BoundingBox();
- bb.copy( this._bb );
- nodeNum = this.divide( options, bb, nodeNum, 0 );
-
- // Here we re-order the triangle list so that we can have a flat tree
- // _primitiveIndices is the ordered array of the triangle indices
- var triangles = this._kdTree.getTriangles();
- var primitives = this._primitiveIndices;
- var nbPrimitives = primitives.length;
- var triangleOrdered = new MACROUTILS.Uint32Array( triangles.length );
- for ( var i = 0, j = 0; i < nbPrimitives; ++i, j += 3 ) {
- var id = primitives[ i ] * 3;
- triangleOrdered[ j ] = triangles[ id ];
- triangleOrdered[ j + 1 ] = triangles[ id + 1 ];
- triangleOrdered[ j + 2 ] = triangles[ id + 2 ];
- }
- this._kdTree.setTriangles( triangleOrdered );
- return this._kdTree.getNodes().length > 0;
- },
- // The function first gather all the triangles of the geometry
- // It then computes the centroid for each triangle and initialize
- // of triangles indices that will refer to the main triangles array
- computeTriangles: function ( geom ) {
- var kdTree = this._kdTree;
-
- var totalLenArray = 0;
- var geomPrimitives = geom.primitives;
- var nbPrimitives = geomPrimitives.length;
- var i = 0;
- for ( i = 0; i < nbPrimitives; i++ ) {
- var prim = geomPrimitives[ i ];
- var mode = prim.getMode();
- // ignore points and line stuffs
- if ( mode === PrimitiveSet.TRIANGLES )
- totalLenArray += prim.getCount();
- else if ( mode === PrimitiveSet.TRIANGLE_STRIP || mode === PrimitiveSet.TRIANGLE_FAN )
- totalLenArray += ( prim.getCount() - 2 ) * 3;
- }
- var indices = new MACROUTILS.Uint32Array( totalLenArray );
- var next = 0;
- var cb = function ( i1, i2, i3 ) {
- if ( i1 === i2 || i1 === i3 || i2 === i3 )
- return;
- indices[ next ] = i1;
- indices[ next + 1 ] = i2;
- indices[ next + 2 ] = i3;
- next += 3;
- };
-
-
- var tif = new TriangleIndexFunctor();
- tif.init( geom, cb );
- tif.apply();
-
- indices = indices.subarray( 0, next );
-
- var nbTriangles = indices.length;
- kdTree.setTriangles( indices );
-
- var vertices = kdTree.getVertices();
-
- this._centers = new MACROUTILS.Float32Array( nbTriangles );
- var centers = this._centers;
- this._primitiveIndices = new MACROUTILS.Uint32Array( nbTriangles / 3 );
- var primitives = this._primitiveIndices;
-
- var j = 0;
- for ( i = 0, j = 0; i < nbTriangles; i += 3, ++j ) {
- var iv0 = indices[ i ];
- var iv1 = indices[ i + 1 ];
- var iv2 = indices[ i + 2 ];
-
- // discard degenerate points
- if ( iv0 === iv1 || iv1 === iv2 || iv0 === iv2 )
- return;
-
- iv0 *= 3;
- iv1 *= 3;
- iv2 *= 3;
-
- var v0x = vertices[ iv0 ];
- var v0y = vertices[ iv0 + 1 ];
- var v0z = vertices[ iv0 + 2 ];
-
- var v1x = vertices[ iv1 ];
- var v1y = vertices[ iv1 + 1 ];
- var v1z = vertices[ iv1 + 2 ];
-
- var v2x = vertices[ iv2 ];
- var v2y = vertices[ iv2 + 1 ];
- var v2z = vertices[ iv2 + 2 ];
-
- var minx = Math.min( v0x, Math.min( v1x, v2x ) );
- var miny = Math.min( v0y, Math.min( v1y, v2y ) );
- var minz = Math.min( v0z, Math.min( v1z, v2z ) );
-
- var maxx = Math.max( v0x, Math.max( v1x, v2x ) );
- var maxy = Math.max( v0y, Math.max( v1y, v2y ) );
- var maxz = Math.max( v0z, Math.max( v1z, v2z ) );
- centers[ i ] = ( minx + maxx ) * 0.5;
- centers[ i + 1 ] = ( miny + maxy ) * 0.5;
- centers[ i + 2 ] = ( minz + maxz ) * 0.5;
- primitives[ j ] = j;
- }
- },
- computeDivisions: function ( options ) {
- this._stackLength = options._maxNumLevels;
- var max = this._bb._max;
- var min = this._bb._min;
- var dx = max[ 0 ] - min[ 0 ];
- var dy = max[ 1 ] - min[ 1 ];
- var dz = max[ 2 ] - min[ 2 ];
- var axisOrder = this._axisOrder;
-
- // We set the cutting order (longest edge aabb first)
- axisOrder[ 0 ] = ( dx >= dy && dx >= dz ) ? 0 : ( dy >= dz ) ? 1 : 2;
- axisOrder[ 2 ] = ( dx < dy && dx < dz ) ? 0 : ( dy < dz ) ? 1 : 2;
- var sum = axisOrder[ 0 ] + axisOrder[ 2 ];
- axisOrder[ 1 ] = sum === 3 ? 0 : sum === 2 ? 1 : 2;
- },
- // The core function of the kdtree building
- // It checks if the node need to be subdivide or not
- // If it decides it's a leaf, it computes the final bounding box of the node
- // and it ends here
- // If it's a node, then it puts the splitting axis position on the median population
- // On the same time it reorder the triangle index array
- divide: function ( options, bb, nodeIndex, level ) {
- var kdTree = this._kdTree;
- var primitives = this._primitiveIndices;
- var nodes = kdTree.getNodes();
- var node = nodes[ nodeIndex ];
-
- var first = node._first;
- var second = node._second;
-
- var needToDivide = level < this._stackLength && first < 0 && second > options._targetNumTrianglesPerLeaf;
- var istart = -first - 1;
- var iend = istart + second - 1;
-
- if ( !needToDivide ) {
- if ( first < 0 ) {
- // leaf is done, now compute bound on it.
- this.computeNodeBox( node, istart, iend );
- }
- return nodeIndex;
- }
-
- if ( first >= 0 )
- return nodeIndex;
- // leaf node as first < 0, so look at dividing it.
-
- var axis = this._axisOrder[ level % 3 ];
- var originalMin = bb._min[ axis ];
- var originalMax = bb._max[ axis ];
-
- var mid = ( originalMin + originalMax ) * 0.5;
-
- var originalLeftChildIndex = 0;
- var originalRightChildIndex = 0;
- var insitueDivision = false;
-
- var left = istart;
- var right = iend;
-
- var centers = this._centers;
- while ( left < right ) {
- while ( left < right && ( centers[ primitives[ left ] * 3 + axis ] <= mid ) ) {
- ++left;
- }
-
- while ( left < right && ( centers[ primitives[ right ] * 3 + axis ] > mid ) ) {
- --right;
- }
-
- if ( left < right ) {
- var tmp = primitives[ left ];
- primitives[ left ] = primitives[ right ];
- primitives[ right ] = tmp;
- ++left;
- --right;
- }
- }
-
- if ( left === right ) {
- if ( centers[ primitives[ left ] * 3 + axis ] <= mid ) ++left;
- else --right;
- }
-
- if ( ( right - istart ) <= -1 ) {
- originalLeftChildIndex = 0;
- originalRightChildIndex = nodeIndex;
- insitueDivision = true;
- } else if ( ( iend - left ) <= -1 ) {
- originalLeftChildIndex = nodeIndex;
- originalRightChildIndex = 0;
- insitueDivision = true;
- } else {
- originalLeftChildIndex = kdTree.addNode( new KdNode( -istart - 1, ( right - istart ) + 1 ) );
- originalRightChildIndex = kdTree.addNode( new KdNode( -left - 1, ( iend - left ) + 1 ) );
- }
-
-
- var restore = bb._max[ axis ];
- bb._max[ axis ] = mid;
-
- var leftChildIndex = originalLeftChildIndex !== 0 ? this.divide( options, bb, originalLeftChildIndex, level + 1 ) : 0;
-
- bb._max[ axis ] = restore;
-
- restore = bb._min[ axis ];
- bb._min[ axis ] = mid;
-
- var rightChildIndex = originalRightChildIndex !== 0 ? this.divide( options, bb, originalRightChildIndex, level + 1 ) : 0;
-
- bb._min[ axis ] = restore;
-
- if ( !insitueDivision ) {
- node._first = leftChildIndex;
- node._second = rightChildIndex;
-
- insitueDivision = true;
-
- var bnode = node._bb;
- bnode.init();
- if ( leftChildIndex !== 0 ) bnode.expandByBoundingBox( nodes[ leftChildIndex ]._bb );
- if ( rightChildIndex !== 0 ) bnode.expandByBoundingBox( nodes[ rightChildIndex ]._bb );
- }
- return nodeIndex;
- },
- // It computes the bounding box of the node so that the box contains all the triangles
- // of the cell
- computeNodeBox: function ( node, istart, iend ) {
- var minx = Infinity,
- miny = Infinity,
- minz = Infinity,
- maxx = -Infinity,
- maxy = -Infinity,
- maxz = -Infinity;
- var triangles = this._kdTree.getTriangles();
- var vertices = this._kdTree.getVertices();
- var primitives = this._primitiveIndices;
- for ( var i = istart; i <= iend; ++i ) {
- var id = primitives[ i ] * 3;
- var iv0 = triangles[ id ] * 3;
- var iv1 = triangles[ id + 1 ] * 3;
- var iv2 = triangles[ id + 2 ] * 3;
-
- var v0x = vertices[ iv0 ];
- var v0y = vertices[ iv0 + 1 ];
- var v0z = vertices[ iv0 + 2 ];
-
- var v1x = vertices[ iv1 ];
- var v1y = vertices[ iv1 + 1 ];
- var v1z = vertices[ iv1 + 2 ];
-
- var v2x = vertices[ iv2 ];
- var v2y = vertices[ iv2 + 1 ];
- var v2z = vertices[ iv2 + 2 ];
-
- minx = Math.min( minx, Math.min( v0x, Math.min( v1x, v2x ) ) );
- miny = Math.min( miny, Math.min( v0y, Math.min( v1y, v2y ) ) );
- minz = Math.min( minz, Math.min( v0z, Math.min( v1z, v2z ) ) );
-
- maxx = Math.max( maxx, Math.max( v0x, Math.max( v1x, v2x ) ) );
- maxy = Math.max( maxy, Math.max( v0y, Math.max( v1y, v2y ) ) );
- maxz = Math.max( maxz, Math.max( v0z, Math.max( v1z, v2z ) ) );
- }
- var epsilon = 1E-6;
- var bnode = node._bb;
- var bmin = bnode._min;
- var bmax = bnode._max;
- bmin[ 0 ] = minx - epsilon;
- bmin[ 1 ] = miny - epsilon;
- bmin[ 2 ] = minz - epsilon;
- bmax[ 0 ] = maxx + epsilon;
- bmax[ 1 ] = maxy + epsilon;
- bmax[ 2 ] = maxz + epsilon;
- }
-};
-
-var KdTree = function () {
- this._vertices = null;
- this._kdNodes = [];
- this._triangles = null; // Float32Array
-};
-
-KdTree.prototype = MACROUTILS.objectLibraryClass( {
- getVertices: function () {
- return this._vertices;
- },
- setVertices: function ( vertices ) {
- this._vertices = vertices;
- },
- getNodes: function () {
- return this._kdNodes;
- },
- getTriangles: function () {
- return this._triangles;
- },
- setTriangles: function ( triangles ) {
- this._triangles = triangles;
- },
- addNode: function ( node ) {
- this._kdNodes.push( node );
- return this._kdNodes.length - 1;
- },
- build: function ( options, geom ) {
- var buildTree = new BuildKdTree( this );
- return buildTree.build( options, geom );
- },
- intersectRay: function ( start, end, intersections, nodePath ) {
- if ( this._kdNodes.length === 0 ) {
- return false;
- }
-
- var numIntersectionsBefore = intersections.length;
-
- if ( !this._rayIntersector ) {
- this._rayIntersector = new KdTreeRayIntersector();
- this._rayIntersector.setKdtree( this._vertices, this._kdNodes, this._triangles );
- }
- this._rayIntersector.init( intersections, start, end, nodePath );
- this._rayIntersector.intersect( this.getNodes()[ 0 ], start, end );
-
- return numIntersectionsBefore !== intersections.length;
- },
- intersectSphere: function ( center, radius, intersections, nodePath ) {
- if ( this._kdNodes.length === 0 ) {
- return false;
- }
-
- var numIntersectionsBefore = intersections.length;
-
- if ( !this._sphereIntersector ) {
- this._sphereIntersector = new KdTreeSphereIntersector();
- this._sphereIntersector.setKdtree( this._vertices, this._kdNodes, this._triangles );
- }
- this._sphereIntersector.init( intersections, center, radius, nodePath );
- this._sphereIntersector.intersect( this.getNodes()[ 0 ] );
-
- return numIntersectionsBefore !== intersections.length;
- }
-}, 'osg', 'KdTree' );
-
-module.exports = KdTree;
diff --git a/app/static/app/js/vendor/osgjs/osg/KdTreeBuilder.js b/app/static/app/js/vendor/osgjs/osg/KdTreeBuilder.js
deleted file mode 100644
index 5ee43e18..00000000
--- a/app/static/app/js/vendor/osgjs/osg/KdTreeBuilder.js
+++ /dev/null
@@ -1,32 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var KdTree = require( 'osg/KdTree' );
-
-
-var KdTreeBuilder = function ( options ) {
- NodeVisitor.call( this );
- this._buildOptions = options !== undefined ? options : {
- _numVerticesProcessed: 0,
- _targetNumTrianglesPerLeaf: 50,
- _maxNumLevels: 20
- };
-};
-
-KdTreeBuilder.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- apply: function ( node ) {
- if ( node.getShape ) {
- var shape = node.getShape();
- // we test if the kdTree is already built and if we can build it (null means we skip it)
- if ( shape === undefined ) {
- var kdTree = new KdTree();
- if ( kdTree.build( this._buildOptions, node ) ) {
- node.setShape( kdTree );
- }
- }
- }
- this.traverse( node );
- }
-} );
-
-module.exports = KdTreeBuilder;
diff --git a/app/static/app/js/vendor/osgjs/osg/KdTreeRayIntersector.js b/app/static/app/js/vendor/osgjs/osg/KdTreeRayIntersector.js
deleted file mode 100644
index 30201f9f..00000000
--- a/app/static/app/js/vendor/osgjs/osg/KdTreeRayIntersector.js
+++ /dev/null
@@ -1,231 +0,0 @@
-'use strict';
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var TriangleIntersector = require( 'osgUtil/TriangleIntersector' );
-var Notify = require( 'osg/notify' );
-
-var KdTreeRayIntersector = function () {
-
- if ( arguments && arguments.length ) {
- Notify.warn( 'using ctor as initialiser is deprecated, use init(intersections, start, end, nodePath) and/or setKdtree: function ( vertices, nodes, triangles )' );
- }
-
- this._intersector = new TriangleIntersector();
- this._dInvX = vec3.create();
- this._dInvY = vec3.create();
- this._dInvZ = vec3.create();
-
-};
-
-KdTreeRayIntersector.prototype = {
- setKdtree: function ( vertices, nodes, triangles ) {
- this._vertices = vertices;
- this._kdNodes = nodes;
- this._triangles = triangles;
- },
- init: ( function () {
-
- var dir = vec3.create();
-
- return function ( intersections, start, end, nodePath ) {
- var d = vec3.sub( dir, end, start );
- var len = vec3.length( d );
- var invLen = 0.0;
- if ( len !== 0.0 )
- invLen = 1.0 / len;
- vec3.scale( d, d, invLen );
- if ( d[ 0 ] !== 0.0 ) vec3.scale( this._dInvX, d, 1.0 / d[ 0 ] );
- if ( d[ 1 ] !== 0.0 ) vec3.scale( this._dInvY, d, 1.0 / d[ 1 ] );
- if ( d[ 2 ] !== 0.0 ) vec3.scale( this._dInvZ, d, 1.0 / d[ 2 ] );
-
- this._intersector._intersections = intersections;
- this._intersector.setNodePath( nodePath );
- this._intersector.set( start, end );
- };
- } )(),
- // Classic ray intersection test
- // If it's a leaf it does ray-triangles intersection with the triangles in the cell
- // If it's not a leaf, it descend in the tree in a recursive way as long as the ray
- // intersects the boundinbox of the nodes
- intersect: ( function () {
-
- var v0 = vec3.create();
- var v1 = vec3.create();
- var v2 = vec3.create();
-
- return function ( node, ls, le ) {
- var first = node._first;
- var second = node._second;
- var triangles = this._triangles;
- var vertices = this._vertices;
-
- if ( first < 0 ) {
- // treat as a leaf
- var istart = -first - 1;
- var iend = istart + second;
- var intersector = this._intersector;
- intersector.index = istart;
-
- for ( var i = istart; i < iend; ++i ) {
- var id = i * 3;
- var iv0 = triangles[ id ];
- var iv1 = triangles[ id + 1 ];
- var iv2 = triangles[ id + 2 ];
-
- var j = iv0 * 3;
- v0[ 0 ] = vertices[ j ];
- v0[ 1 ] = vertices[ j + 1 ];
- v0[ 2 ] = vertices[ j + 2 ];
-
- j = iv1 * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
-
- j = iv2 * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
-
- intersector.intersect( v0, v1, v2, iv0, iv1, iv2 );
- }
- } else {
- var s = node._nodeRayStart;
- var e = node._nodeRayEnd;
- var kNodes = this._kdNodes;
-
- var kNode;
- vec3.copy( s, ls );
- vec3.copy( e, le );
- if ( first > 0 ) {
- kNode = kNodes[ first ];
- if ( this.intersectAndClip( s, e, kNode._bb ) ) {
- this.intersect( kNode, s, e );
- }
- }
- if ( second > 0 ) {
- vec3.copy( s, ls );
- vec3.copy( e, le );
- kNode = kNodes[ second ];
- if ( this.intersectAndClip( s, e, kNode._bb ) ) {
- this.intersect( kNode, s, e );
- }
- }
- }
- };
- } )(),
- // This method do 2 things
- // It test if the ray intersects the node
- // If so... it clip the ray so that the start and end point of the ray are
- // snapped to the bounding box of the nodes
- intersectAndClip: ( function () {
-
- return function ( s, e, bb ) {
- var min = bb._min;
- var xmin = min[ 0 ];
- var ymin = min[ 1 ];
- var zmin = min[ 2 ];
-
- var max = bb._max;
- var xmax = max[ 0 ];
- var ymax = max[ 1 ];
- var zmax = max[ 2 ];
-
- var invX = this._dInvX;
- var invY = this._dInvY;
- var invZ = this._dInvZ;
-
- if ( s[ 0 ] <= e[ 0 ] ) {
- // trivial reject of segment wholely outside.
- if ( e[ 0 ] < xmin ) return false;
- if ( s[ 0 ] > xmax ) return false;
-
- if ( s[ 0 ] < xmin ) {
- // clip s to xMin.
- vec3.scaleAndAdd( s, s, invX, xmin - s[ 0 ] );
- }
-
- if ( e[ 0 ] > xmax ) {
- // clip e to xMax.
- vec3.scaleAndAdd( e, s, invX, xmax - s[ 0 ] );
- }
- } else {
- if ( s[ 0 ] < xmin ) return false;
- if ( e[ 0 ] > xmax ) return false;
-
- if ( e[ 0 ] < xmin ) {
- // clip s to xMin.
- vec3.scaleAndAdd( e, s, invX, xmin - s[ 0 ] );
- }
-
- if ( s[ 0 ] > xmax ) {
- // clip e to xMax.
- vec3.scaleAndAdd( s, s, invX, xmax - s[ 0 ] );
- }
- }
-
- // compate s and e against the yMin to yMax range of bb.
- if ( s[ 1 ] <= e[ 1 ] ) {
-
- // trivial reject of segment wholely outside.
- if ( e[ 1 ] < ymin ) return false;
- if ( s[ 1 ] > ymax ) return false;
-
- if ( s[ 1 ] < ymin ) {
- // clip s to yMin.
- vec3.scaleAndAdd( s, s, invY, ymin - s[ 1 ] );
- }
-
- if ( e[ 1 ] > ymax ) {
- // clip e to yMax.
- vec3.scaleAndAdd( e, s, invY, ymax - s[ 1 ] );
- }
- } else {
- if ( s[ 1 ] < ymin ) return false;
- if ( e[ 1 ] > ymax ) return false;
-
- if ( e[ 1 ] < ymin ) {
- // clip s to yMin.
- vec3.scaleAndAdd( e, s, invY, ymin - s[ 1 ] );
- }
-
- if ( s[ 1 ] > ymax ) {
- // clip e to yMax.
- vec3.scaleAndAdd( s, s, invY, ymax - s[ 1 ] );
- }
- }
-
- // compate s and e against the zMin to zMax range of bb.
- if ( s[ 2 ] <= e[ 2 ] ) {
- // trivial reject of segment wholely outside.
- if ( e[ 2 ] < zmin ) return false;
- if ( s[ 2 ] > zmax ) return false;
-
- if ( s[ 2 ] < zmin ) {
- // clip s to zMin.
- vec3.scaleAndAdd( s, s, invZ, zmin - s[ 2 ] );
- }
-
- if ( e[ 2 ] > zmax ) {
- // clip e to zMax.
- vec3.scaleAndAdd( e, s, invZ, zmax - s[ 2 ] );
- }
- } else {
- if ( s[ 2 ] < zmin ) return false;
- if ( e[ 2 ] > zmax ) return false;
-
- if ( e[ 2 ] < zmin ) {
- // clip s to zMin.
- vec3.scaleAndAdd( e, s, invZ, zmin - s[ 2 ] );
- }
-
- if ( s[ 2 ] > zmax ) {
- // clip e to zMax.
- vec3.scaleAndAdd( s, s, invZ, zmax - s[ 2 ] );
- }
- }
- return true;
- };
- } )()
-};
-
-module.exports = KdTreeRayIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osg/KdTreeSphereIntersector.js b/app/static/app/js/vendor/osgjs/osg/KdTreeSphereIntersector.js
deleted file mode 100644
index c4eef172..00000000
--- a/app/static/app/js/vendor/osgjs/osg/KdTreeSphereIntersector.js
+++ /dev/null
@@ -1,91 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var KdTreeRayIntersector = require( 'osg/KdTreeRayIntersector' );
-var TriangleSphereIntersector = require( 'osgUtil/TriangleSphereIntersector' );
-
-
-var KdTreeSphereIntersector = function () {
-
- this._intersector = new TriangleSphereIntersector();
-
-};
-
-KdTreeSphereIntersector.prototype = MACROUTILS.objectInherit( KdTreeRayIntersector.prototype, {
-
- init: function ( intersections, center, radius, nodePath ) {
-
- this._intersector._intersections = intersections;
- this._intersector.setNodePath( nodePath );
- this._intersector.set( center, radius );
- this._center = center;
- this._radius = radius;
-
- },
-
- intersect: ( function () {
-
- var v0 = vec3.create();
- var v1 = vec3.create();
- var v2 = vec3.create();
-
- return function ( node ) {
- var first = node._first;
- var second = node._second;
- var triangles = this._triangles;
- var vertices = this._vertices;
-
- if ( first < 0 ) {
- // treat as a leaf
- var istart = -first - 1;
- var iend = istart + second;
- var intersector = this._intersector;
- intersector.index = istart;
-
- for ( var i = istart; i < iend; ++i ) {
- var id = i * 3;
- var iv0 = triangles[ id ];
- var iv1 = triangles[ id + 1 ];
- var iv2 = triangles[ id + 2 ];
-
- var j = iv0 * 3;
- v0[ 0 ] = vertices[ j ];
- v0[ 1 ] = vertices[ j + 1 ];
- v0[ 2 ] = vertices[ j + 2 ];
-
- j = iv1 * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
-
- j = iv2 * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
-
- intersector.intersect( v0, v1, v2, iv0, iv1, iv2 );
- }
- } else {
- if ( first > 0 ) {
- if ( this.intersectSphere( this._kdNodes[ first ]._bb ) ) {
- this.intersect( this._kdNodes[ first ] );
- }
- }
- if ( second > 0 ) {
- if ( this.intersectSphere( this._kdNodes[ second ]._bb ) ) {
- this.intersect( this._kdNodes[ second ] );
- }
- }
- }
- };
- } )(),
- intersectSphere: ( function () {
- var tmp = vec3.create();
- return function ( bb ) {
- var r = this._radius + bb.radius();
- return vec3.sqrDist( bb.center( tmp ), this._center ) <= r * r;
- };
- } )()
-} );
-
-module.exports = KdTreeSphereIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osg/Light.js b/app/static/app/js/vendor/osgjs/osg/Light.js
deleted file mode 100644
index cb587347..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Light.js
+++ /dev/null
@@ -1,335 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var Uniform = require( 'osg/Uniform' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var Map = require( 'osg/Map' );
-var Notify = require( 'osg/notify' );
-
-
-// use the same kind of opengl lights
-// see http://www.glprogramming.com/red/chapter05.html
-
-
-var Light = function ( lightNum, disable ) {
- StateAttribute.call( this );
-
- var lightNumber = lightNum !== undefined ? lightNum : 0;
-
- this._ambient = vec4.fromValues( 0.2, 0.2, 0.2, 1.0 );
- this._diffuse = vec4.fromValues( 0.8, 0.8, 0.8, 1.0 );
- this._specular = vec4.fromValues( 0.2, 0.2, 0.2, 1.0 );
-
- // Default is directional as postion[3] is 0
- this._position = vec4.fromValues( 0.0, 0.0, 1.0, 0.0 );
- this._direction = vec3.fromValues( 0.0, 0.0, -1.0 );
-
- // TODO : refactor lights management w=1.0 (isHemi), w=-1.0
- // (isNotHemi) _ground contains the color but w says if it's
- // an hemi or not
- this._ground = vec4.fromValues( 0.2, 0.2, 0.2, -1.0 );
-
- this._spotCutoff = 180.0;
- this._spotBlend = 0.01;
-
- // the array contains constant, linear, quadratic factor
- this._attenuation = vec4.fromValues( 1.0, 0.0, 0.0, 0.0 );
-
- this._lightUnit = lightNumber;
-
- this._invMatrix = mat4.create();
-
- this._enable = !disable;
-
-};
-
-Light.DIRECTION = 'DIRECTION';
-Light.SPOT = 'SPOT';
-Light.POINT = 'POINT';
-Light.HEMI = 'HEMI';
-
-Light.uniforms = {};
-Light.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Light',
-
- cloneType: function () {
- return new Light( this._lightUnit, true );
- },
-
- getTypeMember: function () {
- return this.attributeType + this._lightUnit;
- },
-
- getUniformName: function ( name ) {
- var prefix = this.getType() + this._lightUnit.toString();
- return 'u' + prefix + '_' + name;
- },
-
- getHash: function () {
- return this.getTypeMember() + this.getLightType() + this.isEnabled().toString();
- },
-
- getOrCreateUniforms: function () {
-
- var obj = Light;
- var typeMember = this.getTypeMember();
-
- if ( obj.uniforms[ typeMember ] ) return obj.uniforms[ typeMember ];
-
- var uniforms = {
- ambient: Uniform.createFloat4( this.getUniformName( 'ambient' ) ),
- diffuse: Uniform.createFloat4( this.getUniformName( 'diffuse' ) ),
- specular: Uniform.createFloat4( this.getUniformName( 'specular' ) ),
- attenuation: Uniform.createFloat4( this.getUniformName( 'attenuation' ) ),
- position: Uniform.createFloat4( this.getUniformName( 'position' ) ),
- direction: Uniform.createFloat3( this.getUniformName( 'direction' ) ),
- spotCutOff: Uniform.createFloat1( this.getUniformName( 'spotCutOff' ) ),
- spotBlend: Uniform.createFloat1( this.getUniformName( 'spotBlend' ) ),
- ground: Uniform.createFloat4( this.getUniformName( 'ground' ) ),
- matrix: Uniform.createMatrix4( this.getUniformName( 'matrix' ) ),
- invMatrix: Uniform.createMatrix4( this.getUniformName( 'invMatrix' ) )
- };
-
- obj.uniforms[ typeMember ] = new Map( uniforms );
-
- return obj.uniforms[ typeMember ];
- },
-
- // enable / disable is not implemented in uniform
- // we should add it
- isEnabled: function () {
- return this._enable;
- },
-
- setEnabled: function ( bool ) {
- this._enable = bool;
- },
-
- // Deprecated methods, should be removed in the future
- isEnable: function () {
- Notify.log( 'Light.isEnable() is deprecated, use isEnabled instead' );
- return this.isEnabled();
- },
-
- setEnable: function ( bool ) {
- Notify.log( 'Light.setEnable() is deprecated, use setEnabled instead' );
- this.setEnabled( bool );
- },
-
- // colors
- setAmbient: function ( a ) {
- vec4.copy( this._ambient, a );
- },
-
- getAmbient: function () {
- return this._ambient;
- },
-
- setDiffuse: function ( a ) {
- vec4.copy( this._diffuse, a );
- },
-
- getDiffuse: function () {
- return this._diffuse;
- },
-
- setSpecular: function ( a ) {
- vec4.copy( this._specular, a );
- },
-
- getSpecular: function () {
- return this._specular;
- },
-
-
- // position, also used for directional light
- // position[3] === 0 means directional
- // see creating lightsources http://www.glprogramming.com/red/chapter05.html
- setPosition: function ( a ) {
- vec4.copy( this._position, a );
- },
-
- getPosition: function () {
- return this._position;
- },
-
- // unused for directional
- setDirection: function ( a ) {
- vec3.copy( this._direction, a );
- },
-
- getDirection: function () {
- return this._direction;
- },
-
-
- setSpotCutoff: function ( a ) {
- this._spotCutoff = a;
- },
-
- getSpotCutoff: function () {
- return this._spotCutoff;
- },
-
- setSpotBlend: function ( a ) {
- this._spotBlend = a;
- },
-
- getSpotBlend: function () {
- return this._spotBlend;
- },
-
- // set/get the color of the ground
- setGround: function ( a ) {
- vec3.copy( this._ground, a );
- },
-
- getGround: function () {
- return this._ground;
- },
-
- // attenuation coeff
- setConstantAttenuation: function ( value ) {
- this._attenuation[ 0 ] = value;
- },
-
- getConstantAttenuation: function () {
- return this._attenuation[ 0 ];
- },
-
- setLinearAttenuation: function ( value ) {
- this._attenuation[ 1 ] = value;
- },
-
- getLinearAttenuation: function () {
- return this._attenuation[ 1 ];
- },
-
- setQuadraticAttenuation: function ( value ) {
- this._attenuation[ 2 ] = value;
- },
-
- getQuadraticAttenuation: function () {
- return this._attenuation[ 2 ];
- },
-
- setLightType: function ( type ) {
- if ( type === Light.DIRECTION )
- return this.setLightAsDirection();
- else if ( type === Light.SPOT )
- return this.setLightAsSpot();
- else if ( type === Light.HEMI )
- return this.setLightAsHemi();
- return this.setLightAsPoint();
- },
-
- getLightType: function () {
- if ( this.isDirectionLight() )
- return Light.DIRECTION;
- else if ( this.isSpotLight() )
- return Light.SPOT;
- else if ( this.isHemiLight() )
- return Light.HEMI;
- return Light.POINT;
- },
-
- setLightAsSpot: function () {
- vec4.set( this._position, 0.0, 0.0, 0.0, 1.0 );
- vec3.set( this._direction, 0.0, 0.0, -1.0 );
- this._ground[ 3 ] = -1.0;
- this._spotCutoff = 90;
- },
-
- setLightAsPoint: function () {
- vec4.set( this._position, 0.0, 0.0, 0.0, 1.0 );
- vec3.set( this._direction, 0.0, 0.0, -1.0 );
- this._ground[ 3 ] = -1.0;
- },
-
- setLightAsDirection: function () {
- vec4.set( this._position, 0.0, 0.0, 1.0, 0.0 );
- this._spotCutoff = 180;
- this._ground[ 3 ] = -1.0;
- },
-
- setLightAsHemi: function () {
- vec4.set( this._position, 0.0, 0.0, 1.0, 0.0 );
- this._spotCutoff = 180;
- this._ground[ 3 ] = 1.0;
- },
-
- setLightNumber: function ( unit ) {
- this._lightUnit = unit;
- },
-
- getLightNumber: function () {
- return this._lightUnit;
- },
-
- // internal helper
- isSpotLight: function () {
- return this._spotCutoff < 180.0;
- },
-
- isDirectionLight: function () {
- return this._position[ 3 ] === 0.0 && this._ground[ 3 ] === -1.0;
- },
-
- isHemiLight: function () {
- return this._ground[ 3 ] === 1.0;
- },
-
- // matrix is current model view, which can mean:
- // world (node refAbsolute)
- // world+camera (camera is refAbsolute)
- // world+camera+camera+... (camera relative...)
- applyPositionedUniform: function ( matrix ) {
-
- var uniformMap = this.getOrCreateUniforms();
-
- var matrixArray = uniformMap.matrix.getInternalArray();
- var invMatrixArray = uniformMap.invMatrix.getInternalArray();
-
- mat4.copy( matrixArray, matrix );
- mat4.copy( invMatrixArray, matrix );
-
- invMatrixArray[ 12 ] = 0.0;
- invMatrixArray[ 13 ] = 0.0;
- invMatrixArray[ 14 ] = 0.0;
-
- mat4.invert( invMatrixArray, invMatrixArray );
- mat4.transpose( invMatrixArray, invMatrixArray );
- },
-
- apply: function () {
-
- if ( !this._enable ) return;
-
- var uniformMap = this.getOrCreateUniforms();
-
- uniformMap.position.setFloat4( this._position );
-
- if ( this.isSpotLight() ) {
- var spotsize = Math.cos( this._spotCutoff * Math.PI / 180.0 );
- uniformMap.spotCutOff.setFloat( spotsize );
- uniformMap.spotBlend.setFloat( ( 1.0 - spotsize ) * this._spotBlend );
- uniformMap.direction.setFloat3( this._direction );
- }
-
- if ( this.isHemiLight() )
- uniformMap.ground.setFloat4( this._ground );
-
- uniformMap.attenuation.setFloat4( this._attenuation );
- uniformMap.diffuse.setFloat4( this._diffuse );
- uniformMap.specular.setFloat4( this._specular );
- uniformMap.ambient.setFloat4( this._ambient );
- }
-
-} ), 'osg', 'Light' );
-
-MACROUTILS.setTypeID( Light );
-
-module.exports = Light;
diff --git a/app/static/app/js/vendor/osgjs/osg/LightSource.js b/app/static/app/js/vendor/osgjs/osg/LightSource.js
deleted file mode 100644
index dc9a34bb..00000000
--- a/app/static/app/js/vendor/osgjs/osg/LightSource.js
+++ /dev/null
@@ -1,53 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Node = require( 'osg/Node' );
-var TransformEnums = require( 'osg/transformEnums' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-/**
- * LightSource is a positioned node to use with StateAttribute Light
- * @class LightSource
- */
-var LightSource = function () {
- Node.call( this );
- this._light = undefined;
- this._referenceFrame = TransformEnums.RELATIVE_RF;
-};
-
-/** @lends LightSource.prototype */
-LightSource.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Node.prototype, {
- getLight: function () {
- return this._light;
- },
- setLight: function ( light ) {
- this._light = light;
- },
- setReferenceFrame: function ( value ) {
- this._referenceFrame = value;
- },
- getReferenceFrame: function () {
- return this._referenceFrame;
- },
- computeBoundingSphere: ( function () {
- var tmp = vec3.create();
-
- return function ( bsphere ) {
- Node.prototype.computeBoundingSphere.call( this, bsphere );
-
- if ( this._light !== undefined && this._referenceFrame === TransformEnums.RELATIVE_RF ) {
- var position = this._light.getPosition();
-
- if ( position[ 3 ] !== 0.0 ) {
- bsphere.expandByvec3( vec3.scale( tmp, position, 1.0 / position[ 3 ] ) );
- }
- }
-
- return bsphere;
- };
- } )()
-
-} ), 'osg', 'LightSource' );
-
-MACROUTILS.setTypeID( LightSource );
-
-module.exports = LightSource;
diff --git a/app/static/app/js/vendor/osgjs/osg/LineWidth.js b/app/static/app/js/vendor/osgjs/osg/LineWidth.js
deleted file mode 100644
index 0dcfe716..00000000
--- a/app/static/app/js/vendor/osgjs/osg/LineWidth.js
+++ /dev/null
@@ -1,22 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-
-var LineWidth = function ( lineWidth ) {
- StateAttribute.call( this );
- this.lineWidth = 1.0;
- if ( lineWidth !== undefined ) {
- this.lineWidth = lineWidth;
- }
-};
-LineWidth.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
- attributeType: 'LineWidth',
- cloneType: function () {
- return new LineWidth();
- },
- apply: function ( state ) {
- state.getGraphicContext().lineWidth( this.lineWidth );
- }
-} ), 'osg', 'LineWidth' );
-
-module.exports = LineWidth;
diff --git a/app/static/app/js/vendor/osgjs/osg/Lod.js b/app/static/app/js/vendor/osgjs/osg/Lod.js
deleted file mode 100644
index b011a565..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Lod.js
+++ /dev/null
@@ -1,177 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Node = require( 'osg/Node' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec2 = require( 'osg/glMatrix' ).vec2;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var BoundingSphere = require( 'osg/BoundingSphere' );
-
-/**
- * Lod that can contains child node
- * @class Lod
- */
-var Lod = function () {
- Node.call( this );
- this._radius = -1;
- this._range = [];
- this._rangeMode = Lod.DISTANCE_FROM_EYE_POINT;
- this._userDefinedCenter = [];
- this._centerMode = Lod.USE_BOUNDING_SPHERE_CENTER;
-};
-
-Lod.DISTANCE_FROM_EYE_POINT = 0;
-Lod.PIXEL_SIZE_ON_SCREEN = 1;
-
-Lod.USE_BOUNDING_SPHERE_CENTER = 0;
-Lod.USER_DEFINED_CENTER = 1;
-Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED = 2;
-
-/** @lends Lod.prototype */
-Lod.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Node.prototype, {
- // Functions here
- getRadius: function () {
- return this._radius;
- },
-
- /** Set the object-space reference radius of the volume enclosed by the LOD.
- * Used to determine the bounding sphere of the LOD in the absence of any children.*/
- setRadius: function ( radius ) {
- this._radius = radius;
- },
-
- setCenter: function ( center ) {
- if ( this._centerMode !== Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED )
- this._centerMode = Lod.USER_DEFINED_CENTER;
- this._userDefinedCenter = center;
- },
-
- getCenter: function () {
- if ( ( this._centerMode === Lod.USER_DEFINED_CENTER ) || ( this._centerMode === Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED ) )
- return this._userDefinedCenter;
- else return this.getBound().center();
- },
-
- setCenterMode: function ( centerMode ) {
- this._centerMode = centerMode;
- },
-
- computeBoundingSphere: function ( bsphere ) {
- if ( this._centerMode === Lod.USER_DEFINED_CENTER && this._radius >= 0.0 ) {
- bsphere.set( this._userDefinedCenter, this._radius );
- return bsphere;
- } else if ( this._centerMode === Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED && this._radius >= 0.0 ) {
- bsphere.set( this._userDefinedCenter, this._radius );
- var bs = new BoundingSphere();
- bsphere.expandByBoundingSphere( Node.prototype.computeBoundingSphere.call( this, bs ) );
- return bsphere;
- } else {
- Node.prototype.computeBoundingSphere.call( this, bsphere );
- return bsphere;
- }
- },
-
- projectBoundingSphere: ( function () {
- // from http://www.iquilezles.org/www/articles/sphereproj/sphereproj.htm
- // Sample code at http://www.shadertoy.com/view/XdBGzd?
- var o = vec3.create();
- return function ( sph, camMatrix, fle ) {
- vec3.transformMat4( o, sph.center(), camMatrix );
- var r2 = sph.radius2();
- var z2 = o[ 2 ] * o[ 2 ];
- var l2 = vec3.sqrLen( o );
- var area = -Math.PI * fle * fle * r2 * Math.sqrt( Math.abs( ( l2 - r2 ) / ( r2 - z2 ) ) ) / ( r2 - z2 );
- return area;
- };
- } )(),
-
- setRangeMode: function ( mode ) {
- //TODO: check if mode is correct
- this._rangeMode = mode;
- },
-
- addChildNode: function ( node ) {
-
- Node.prototype.addChild.call( this, node );
- if ( this.children.length > this._range.length ) {
- var r = [];
- var max = 0.0;
- if ( this._range.lenght > 0 )
- max = this._range[ this._range.length - 1 ][ 1 ];
- r.push( vec2.fromValues( max, max ) );
- this._range.push( r );
- }
- return true;
- },
-
- addChild: function ( node, min, max ) {
- Node.prototype.addChild.call( this, node );
-
- if ( this.children.length > this._range.length ) {
- var r = [];
- r.push( vec2.fromValues( min, min ) );
- this._range.push( r );
- }
- this._range[ this.children.length - 1 ][ 0 ] = min;
- this._range[ this.children.length - 1 ][ 1 ] = max;
- return true;
- },
-
- traverse: ( function () {
-
- // avoid to generate variable on the heap to limit garbage collection
- // instead create variable and use the same each time
- var zeroVector = vec3.create();
- var eye = vec3.create();
- var viewModel = mat4.create();
-
- return function ( visitor ) {
- var traversalMode = visitor.traversalMode;
-
- switch ( traversalMode ) {
-
- case NodeVisitor.TRAVERSE_ALL_CHILDREN:
-
- for ( var index = 0; index < this.children.length; index++ ) {
- this.children[ index ].accept( visitor );
- }
- break;
-
- case ( NodeVisitor.TRAVERSE_ACTIVE_CHILDREN ):
- var requiredRange = 0;
- var matrix = visitor.getCurrentModelViewMatrix();
- mat4.invert( viewModel, matrix );
- // Calculate distance from viewpoint
- if ( this._rangeMode === Lod.DISTANCE_FROM_EYE_POINT ) {
- vec3.transformMat4( eye, zeroVector, viewModel );
- var d = vec3.distance( this.getBound().center(), eye );
- requiredRange = d * visitor.getLODScale();
- } else {
- // Let's calculate pixels on screen
- var projmatrix = visitor.getCurrentProjectionMatrix();
- // focal lenght is the value stored in projmatrix[0]
- requiredRange = this.projectBoundingSphere( this.getBound(), matrix, projmatrix[ 0 ] );
- // Multiply by a factor to get the real area value
- requiredRange = ( ( requiredRange * visitor.getViewport().width() * visitor.getViewport().width() ) * 0.25 ) / visitor.getLODScale();
- }
-
- var numChildren = this.children.length;
- if ( this._range.length < numChildren ) numChildren = this._range.length;
-
- for ( var j = 0; j < numChildren; ++j ) {
- if ( this._range[ j ][ 0 ] <= requiredRange && requiredRange < this._range[ j ][ 1 ] ) {
- this.children[ j ].accept( visitor );
- }
- }
- break;
-
- default:
- break;
- }
- };
- } )()
-
-} ), 'osg', 'Lod' );
-
-MACROUTILS.setTypeID( Lod );
-module.exports = Lod;
diff --git a/app/static/app/js/vendor/osgjs/osg/Map.js b/app/static/app/js/vendor/osgjs/osg/Map.js
deleted file mode 100644
index f8460b91..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Map.js
+++ /dev/null
@@ -1,67 +0,0 @@
-'use strict';
-
-var Map = function ( obj ) {
-
- window.Object.defineProperty( this, '_dirty', {
- configurable: true,
- enumerable: false,
- writable: true,
- value: true
- } );
-
- window.Object.defineProperty( this, '_keys', {
- configurable: true,
- enumerable: false,
- writable: true,
- value: undefined
- } );
-
- if ( obj ) this.setMap( obj );
-};
-
-Map.prototype = {
-
- getKeys: function () {
- if ( this._dirty ) {
- this._keys = window.Object.keys( this );
- this._dirty = false;
- }
- return this._keys;
- },
-
- dirty: function () {
- this._dirty = true;
- },
-
- remove: function ( key ) {
- //this[ key ] = undefined;
- delete this[ key ];
- this.dirty();
- this.getKeys();
- },
-
- setMap: function ( map ) {
-
- var i, l;
- // remove all
- var keys = window.Object.keys( this );
- if ( keys.length > 0 ) {
- for ( i = 0, l = keys.length; i < l; i++ )
- delete this[ keys[ i ] ];
- }
-
- // add new
- keys = window.Object.keys( map );
- if ( keys.length > 0 ) {
- for ( i = 0, l = keys.length; i < l; i++ ) {
- var key = keys[ i ];
- this[ key ] = map[ key ];
- }
- }
-
- this.dirty();
- }
-
-};
-
-module.exports = Map;
diff --git a/app/static/app/js/vendor/osgjs/osg/Material.js b/app/static/app/js/vendor/osgjs/osg/Material.js
deleted file mode 100644
index 657182be..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Material.js
+++ /dev/null
@@ -1,108 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var Uniform = require( 'osg/Uniform' );
-var Map = require( 'osg/Map' );
-
-// Define a material attribute
-var Material = function () {
- StateAttribute.call( this );
- this._ambient = vec4.fromValues( 0.2, 0.2, 0.2, 1.0 );
- this._diffuse = vec4.fromValues( 0.8, 0.8, 0.8, 1.0 );
- this._specular = vec4.fromValues( 0.0, 0.0, 0.0, 1.0 );
- this._emission = vec4.fromValues( 0.0, 0.0, 0.0, 1.0 );
- this._shininess = 12.5;
-};
-
-Material.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Material',
-
- cloneType: function () {
- return new Material();
- },
-
- getParameterName: function ( name ) {
- return 'u' + this.getType() + '_' + name;
- },
-
- getOrCreateUniforms: function () {
- var obj = Material;
- if ( obj.uniforms ) return obj.uniforms;
-
- var uniformList = {
- ambient: Uniform.createFloat4( 'uMaterialAmbient' ),
- diffuse: Uniform.createFloat4( 'uMaterialDiffuse' ),
- specular: Uniform.createFloat4( 'uMaterialSpecular' ),
- emission: Uniform.createFloat4( 'uMaterialEmission' ),
- shininess: Uniform.createFloat1( 'uMaterialShininess' )
- };
-
- obj.uniforms = new Map( uniformList );
- return obj.uniforms;
- },
-
- setEmission: function ( a ) {
- vec4.copy( this._emission, a );
- },
-
- getEmission: function () {
- return this._emission;
- },
-
- setAmbient: function ( a ) {
- vec4.copy( this._ambient, a );
- },
-
- getAmbient: function () {
- return this._ambient;
- },
-
- setSpecular: function ( a ) {
- vec4.copy( this._specular, a );
- },
-
- getSpecular: function () {
- return this._specular;
- },
-
- setDiffuse: function ( a ) {
- vec4.copy( this._diffuse, a );
- },
-
- getDiffuse: function () {
- return this._diffuse;
- },
-
- setShininess: function ( a ) {
- this._shininess = a;
- },
-
- getShininess: function () {
- return this._shininess;
- },
-
- setTransparency: function ( a ) {
- this._diffuse[ 3 ] = 1.0 - a;
- },
-
- getTransparency: function () {
- return this._diffuse[ 3 ];
- },
-
- apply: function () {
- var uniforms = this.getOrCreateUniforms();
-
- uniforms.ambient.setFloat4( this._ambient );
- uniforms.diffuse.setFloat4( this._diffuse );
- uniforms.specular.setFloat4( this._specular );
- uniforms.emission.setFloat4( this._emission );
- uniforms.shininess.setFloat( this._shininess );
-
- }
-
-
-} ), 'osg', 'Material' );
-
-module.exports = Material;
diff --git a/app/static/app/js/vendor/osgjs/osg/Matrix.js b/app/static/app/js/vendor/osgjs/osg/Matrix.js
deleted file mode 100644
index ba191841..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Matrix.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require( 'osg/deprecated-MatrixVector/Matrix' );
diff --git a/app/static/app/js/vendor/osgjs/osg/MatrixMemoryPool.js b/app/static/app/js/vendor/osgjs/osg/MatrixMemoryPool.js
deleted file mode 100644
index 28121092..00000000
--- a/app/static/app/js/vendor/osgjs/osg/MatrixMemoryPool.js
+++ /dev/null
@@ -1,45 +0,0 @@
-'use strict';
-var mat4 = require( 'osg/glMatrix' ).mat4;
-
-
-/**
- * Prevents Memory fragmentation, GC heavy usage
- * using pre-allocated memory segment
- * allowing reuse of memory
- * @class MatrixMemoryPool
- */
-var MatrixMemoryPool = function () {
-
- this._stack = [ mat4.create() ];
- this._current = 0;
-
-};
-
-
-/** @lends MatrixMemoryPool.prototype */
-MatrixMemoryPool.prototype = {
-
- // start reuse the stack
- reset: function () {
-
- this._current = 0;
-
- },
-
- get: function () {
-
- var m = this._stack[ this._current++ ];
-
- if ( this._current === this._stack.length ) {
-
- this._stack.push( mat4.create() );
-
- }
-
- return m;
-
- }
-
-};
-
-module.exports = MatrixMemoryPool;
diff --git a/app/static/app/js/vendor/osgjs/osg/MatrixTransform.js b/app/static/app/js/vendor/osgjs/osg/MatrixTransform.js
deleted file mode 100644
index ef80d8d1..00000000
--- a/app/static/app/js/vendor/osgjs/osg/MatrixTransform.js
+++ /dev/null
@@ -1,56 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Transform = require( 'osg/Transform' );
-var TransformEnums = require( 'osg/transformEnums' );
-
-
-/**
- * MatrixTransform is a Transform Node that can be customized with user matrix
- * @class MatrixTransform
- */
-var MatrixTransform = function () {
- Transform.call( this );
- this.matrix = mat4.create();
-};
-
-/** @lends MatrixTransform.prototype */
-MatrixTransform.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Transform.prototype, {
-
- getMatrix: function () {
- return this.matrix;
- },
-
- setMatrix: function ( m ) {
- this.matrix = m;
- this.dirtyBound();
- },
-
- // local to "local world" (not Global World)
- computeLocalToWorldMatrix: function ( matrix /*, nodeVisitor */ ) {
-
- if ( this.referenceFrame === TransformEnums.RELATIVE_RF ) {
- mat4.mul( matrix, matrix, this.matrix );
- } else {
- mat4.copy( matrix, this.matrix );
- }
- return true;
- },
-
- computeWorldToLocalMatrix: ( function () {
- var minverse = mat4.create();
- return function ( matrix /*, nodeVisitor */ ) {
-
- mat4.invert( minverse, this.matrix );
- if ( this.referenceFrame === TransformEnums.RELATIVE_RF ) {
- mat4.mul( matrix, minverse, matrix );
- } else { // absolute
- mat4.copy( matrix, minverse );
- }
- return true;
- };
- } )()
-} ), 'osg', 'MatrixTransform' );
-MACROUTILS.setTypeID( MatrixTransform );
-
-module.exports = MatrixTransform;
diff --git a/app/static/app/js/vendor/osgjs/osg/Node.js b/app/static/app/js/vendor/osgjs/osg/Node.js
deleted file mode 100644
index 3420c1c5..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Node.js
+++ /dev/null
@@ -1,544 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var BoundingBox = require( 'osg/BoundingBox' );
-var BoundingSphere = require( 'osg/BoundingSphere' );
-var StateSet = require( 'osg/StateSet' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Notify = require( 'osg/notify' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixMemoryPool = require( 'osg/MatrixMemoryPool' );
-var ComputeMatrixFromNodePath = require( 'osg/computeMatrixFromNodePath' );
-var TransformEnums = require( 'osg/transformEnums' );
-
-
-/**
- * Node that can contains child node
- * @class Node
- */
-var Node = function () {
- Object.call( this );
-
- this.children = [];
- this._parents = [];
- /*jshint bitwise: false */
- this.nodeMask = ~0;
- /*jshint bitwise: true */
-
- this._boundingSphere = new BoundingSphere();
- this._boundingSphereComputed = false;
-
- this._boundingBox = new BoundingBox();
- this._boundingBoxComputed = false;
-
- this._updateCallbacks = [];
- this._cullCallback = undefined;
- this._cullingActive = true;
- this._numChildrenWithCullingDisabled = 0;
- this._numChildrenRequiringUpdateTraversal = 0;
-
- // it's a tmp object for internal use, do not use
- this._tmpBox = new BoundingBox();
-};
-
-Node._reservedMatrixStack = new MatrixMemoryPool();
-var nodeGetMat = function () {
- var mat = Node._reservedMatrixStack.get.bind( Node._reservedMatrixStack );
- return mat4.identity( mat );
-};
-
-/** @lends Node.prototype */
-Node.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- /**
- Return StateSet and create it if it does not exist yet
- @type StateSet
- */
- getOrCreateStateSet: function () {
- if ( !this.stateset ) this.setStateSet( new StateSet() );
- return this.stateset;
- },
-
- getStateSet: function () {
- return this.stateset;
- },
-
- accept: function ( nv ) {
- if ( nv.validNodeMask( this ) ) {
- nv.pushOntoNodePath( this );
- nv.apply( this );
- nv.popFromNodePath();
- }
- },
-
- dirtyBound: function () {
- if ( this._boundingSphereComputed === true || this._boundingBoxComputed === true ) {
- this._boundingSphereComputed = false;
- this._boundingBoxComputed = false;
- var parents = this._parents;
- for ( var i = 0, l = parents.length; i < l; i++ ) {
- parents[ i ].dirtyBound();
- }
- }
- },
-
- setNodeMask: function ( mask ) {
- this.nodeMask = mask;
- },
-
- getNodeMask: function () {
- return this.nodeMask;
- },
-
- setStateSet: function ( stateSet ) {
-
- if ( this.stateset === stateSet ) return;
-
- var deltaUpdate = 0;
-
- if ( this.stateset ) {
- if ( this.stateset.requiresUpdateTraversal() ) deltaUpdate--;
- this.stateset.removeParent( this );
- }
-
- if ( stateSet ) {
- stateSet.addParent( this );
- if ( stateSet.requiresUpdateTraversal() ) ++deltaUpdate;
- }
-
- if ( deltaUpdate !== 0 )
- this.setNumChildrenRequiringUpdateTraversal( this.getNumChildrenRequiringUpdateTraversal() + deltaUpdate );
-
- this.stateset = stateSet;
- },
-
- _updateNumChildrenRequeringUpdateTraversal: function ( delta ) {
-
- if ( this._numChildrenRequiringUpdateTraversal === 0 && this._parents.length ) {
- // the number of callbacks has changed, need to pass this
- // on to parents so they know whether app traversal is
- // required on this subgraph.
- for ( var i = 0, l = this._parents.length; i < l; i++ ) {
- var parent = this._parents[ i ];
- var num = parent.getNumChildrenRequiringUpdateTraversal();
- parent.setNumChildrenRequiringUpdateTraversal( num + delta );
- }
- }
- },
-
- setNumChildrenRequiringUpdateTraversal: function ( num ) {
-
- // if no changes just return.
- if ( this._numChildrenRequiringUpdateTraversal === num ) return;
-
- // note, if _updateCallback is set then the
- // parents won't be affected by any changes to
- // _numChildrenRequiringUpdateTraversal so no need to inform them.
- if ( !this._updateCallbacks.length && this._parents.length ) {
-
- // need to pass on changes to parents.
- var delta = 0;
- if ( this._numChildrenRequiringUpdateTraversal > 0 ) --delta;
- if ( num > 0 ) ++delta;
-
- if ( delta !== 0 ) {
- // the number of callbacks has changed, need to pass this
- // on to parents so they know whether app traversal is
- // required on this subgraph.
- var parents = this._parents;
- for ( var i = 0, l = parents.length; i < l; i++ ) {
- var parent = parents[ i ];
- var parentNum = parent.getNumChildrenRequiringUpdateTraversal();
- parent.setNumChildrenRequiringUpdateTraversal( parentNum + delta );
- }
- }
- }
-
- // finally update this objects value.
- this._numChildrenRequiringUpdateTraversal = num;
-
- },
-
- getNumChildrenRequiringUpdateTraversal: function () {
- return this._numChildrenRequiringUpdateTraversal;
- },
-
- /**
-
- Set update node callback, called during update traversal.
- The Object must have the following method
- update(node, nodeVisitor) {}
- note, callback is responsible for scenegraph traversal so
- they must call traverse(node,nv) to ensure that the
- scene graph subtree (and associated callbacks) are traversed.
-
-
- Here a dummy UpdateCallback example
-
- @example
- var DummyUpdateCallback = function() {};
- DummyUpdateCallback.prototype = {
- update: function(node, nodeVisitor) {
- return true;
- }
- };
-
- @param Oject callback
- */
- setUpdateCallback: function ( cb ) {
- Notify.warn( 'deprecated use instead addUpdateCallback/removeUpdateCallback' );
- if ( cb === this._updateCallbacks[ 0 ] || !cb ) return;
-
- var hasExistingCallback = Boolean( this._updateCallbacks.length );
- if ( !this._updateCallbacks.length )
- this.addUpdateCallback( cb );
- else
- this._updateCallbacks[ 0 ] = cb;
-
- if ( !hasExistingCallback )
- this._updateNumChildrenRequeringUpdateTraversal( 1 );
- },
-
- /** Get update node callback, called during update traversal.
- @type Oject
- */
- getUpdateCallback: function () {
- return this._updateCallbacks[ 0 ];
- },
-
- addUpdateCallback: function ( cb ) {
- var hasExistingCallback = Boolean( this._updateCallbacks.length );
- this._updateCallbacks.push( cb );
-
- // send the signal on first add
- if ( !hasExistingCallback )
- this._updateNumChildrenRequeringUpdateTraversal( 1 );
- },
-
- removeUpdateCallback: function ( cb ) {
- var arrayIdx = this._updateCallbacks.indexOf( cb );
- if ( arrayIdx === -1 ) return;
- this._updateCallbacks.splice( arrayIdx, 1 );
-
- // send the signal when no more callback
- if ( !this._updateCallbacks.length )
- this._updateNumChildrenRequeringUpdateTraversal( -1 );
-
- },
- getUpdateCallbackList: function () {
- return this._updateCallbacks;
- },
-
-
- /**
-
- Set cull node callback, called during cull traversal.
- The Object must have the following method
- cull(node, nodeVisitor) {}
- note, callback is responsible for scenegraph traversal so
- they must return true to traverse.
-
-
- Here a dummy CullCallback example
-
- @example
- var DummyCullCallback = function() {};
- DummyCullCallback.prototype = {
- cull: function(node, nodeVisitor) {
- return true;
- }
- };
-
- @param Oject callback
- */
- setCullCallback: function ( cb ) {
- this._cullCallback = cb;
- },
- getCullCallback: function () {
- return this._cullCallback;
- },
-
- hasChild: function ( child ) {
- for ( var i = 0, l = this.children.length; i < l; i++ ) {
- if ( this.children[ i ] === child ) {
- return true;
- }
- }
- return false;
- },
-
- addChild: function ( child ) {
-
- if ( this.children.indexOf( child ) !== -1 ) return undefined;
-
- this.children.push( child );
- child.addParent( this );
- this.dirtyBound();
-
- // could now require app traversal thanks to the new subgraph,
- // so need to check and update if required.
- if ( child.getNumChildrenRequiringUpdateTraversal() > 0 ||
- child.getUpdateCallbackList().length ) {
- this.setNumChildrenRequiringUpdateTraversal(
- this.getNumChildrenRequiringUpdateTraversal() + 1
- );
- }
-
- return child;
- },
-
- getChildren: function () {
- return this.children;
- },
- getNumChildren: function () {
- return this.children.length;
- },
- getChild: function ( num ) {
- return this.children[ num ];
- },
- getParents: function () {
- return this._parents;
- },
-
- addParent: function ( parent ) {
- this._parents.push( parent );
- },
-
- removeParent: function ( parent ) {
- var idx = this._parents.indexOf( parent );
- if ( idx === -1 ) return;
- this._parents.splice( idx, 1 );
- },
-
- removeChildren: function () {
- var children = this.children;
- var nbChildren = children.length;
- if ( !nbChildren ) return;
-
- var updateCallbackRemoved = 0;
-
- for ( var i = 0; i < nbChildren; i++ ) {
- var child = children[ i ];
- child.removeParent( this );
- if ( child.getNumChildrenRequiringUpdateTraversal() > 0 || child.getUpdateCallbackList().length ) ++updateCallbackRemoved;
- }
-
- children.length = 0;
- if ( updateCallbackRemoved )
- this.setNumChildrenRequiringUpdateTraversal( this.getNumChildrenRequiringUpdateTraversal() - updateCallbackRemoved );
-
- this.dirtyBound();
- },
-
- // preserve order
- removeChild: function ( child ) {
-
- var children = this.children;
- var id = children.indexOf( child );
- if ( id === -1 ) return;
-
- child.removeParent( this );
- children.splice( id, 1 );
-
- if ( child.getNumChildrenRequiringUpdateTraversal() > 0 || child.getUpdateCallbackList().length )
- this.setNumChildrenRequiringUpdateTraversal( this.getNumChildrenRequiringUpdateTraversal() - 1 );
-
- },
-
- traverse: function ( visitor ) {
- var children = this.children;
- for ( var i = 0, l = children.length; i < l; i++ ) {
- var child = children[ i ];
- child.accept( visitor );
- }
- },
-
- ascend: function ( visitor ) {
- var parents = this._parents;
- for ( var i = 0, l = parents.length; i < l; i++ ) {
- var parent = parents[ i ];
- parent.accept( visitor );
- }
- },
-
- getBoundingBox: function () {
- if ( !this._boundingBoxComputed ) {
- this.computeBoundingBox( this._boundingBox );
- this._boundingBoxComputed = true;
- }
- return this._boundingBox;
- },
-
- computeBoundingBox: function ( bbox ) {
-
- // circular dependency... not sure if the global visitor instance should be instancied here
- var ComputeBoundsVisitor = require( 'osg/ComputeBoundsVisitor' );
- var cbv = ComputeBoundsVisitor.instance = ComputeBoundsVisitor.instance || new ComputeBoundsVisitor();
- cbv.setNodeMaskOverride( ~0x0 ); // traverse everything to be consistent with computeBoundingSphere
- cbv.reset();
-
- cbv.apply( this );
- bbox.copy( cbv.getBoundingBox() );
- return bbox;
- },
-
- getBoundingSphere: function () {
- return this.getBound();
- },
-
- getBound: function () {
- if ( !this._boundingSphereComputed ) {
- this.computeBoundingSphere( this._boundingSphere );
- this._boundingSphereComputed = true;
- }
- return this._boundingSphere;
- },
-
- computeBoundingSphere: function ( bSphere ) {
-
- var children = this.children;
- var l = children.length;
-
- bSphere.init();
- if ( l === 0 ) return bSphere;
-
- var cc, i;
- var bb = this._tmpBox;
- bb.init();
- for ( i = 0; i < l; i++ ) {
- cc = children[ i ];
- if ( cc.referenceFrame !== TransformEnums.ABSOLUTE_RF ) {
- bb.expandByBoundingSphere( cc.getBound() );
- }
- }
- if ( !bb.valid() ) return bSphere;
-
- bSphere.set( bb.center( bSphere.center() ), 0.0 );
- for ( i = 0; i < l; i++ ) {
- cc = children[ i ];
- if ( cc.referenceFrame !== TransformEnums.ABSOLUTE_RF ) {
- bSphere.expandRadiusBySphere( cc.getBound() );
- }
- }
- return bSphere;
- },
-
- // matrixCreate allow user handling of garbage collection of matrices
- getWorldMatrices: ( function () {
- var CollectParentPaths = function () {
- this.nodePaths = [];
- this.halt = undefined;
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_PARENTS );
- };
- CollectParentPaths.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- reset: function () {
- this.nodePath.length = 0;
- this.nodePaths.length = 0;
- },
- apply: function ( node ) {
- if ( node._parents.length === 0 || node === this.halt || node.referenceFrame === TransformEnums.ABSOLUTE_RF ) {
- // copy
- this.nodePaths.push( this.nodePath.slice( 0 ) );
- } else {
- this.traverse( node );
- }
- }
- } );
- var collected = new CollectParentPaths();
- collected.setNodeMaskOverride( ~0x0 ); // traverse everything
-
- return function computeLocalToWorldList( halt, matrixCreate ) {
- collected.reset();
- collected.halt = halt;
-
- this.accept( collected );
- var matrixList = [];
-
- var matrixGenerator = matrixCreate || mat4.create;
- for ( var i = 0, l = collected.nodePaths.length; i < l; i++ ) {
- var np = collected.nodePaths[ i ];
- var m = matrixGenerator();
- if ( np.length !== 0 ) {
- ComputeMatrixFromNodePath.computeLocalToWorld( np, true, m );
- }
- matrixList.push( m );
- }
-
- return matrixList;
- };
-
- } )(),
-
- // same as getWorldMatrices GC: Perf WIN
- getWorldMatrix: function ( halt, matrix ) {
-
- // pass allocator on master
- var matrixList = this.getWorldMatrices( halt, nodeGetMat );
-
- if ( matrixList.length === 0 ) {
-
- mat4.identity( matrix );
-
- } else {
-
- mat4.copy( matrix, matrixList[ 0 ] );
-
- }
-
- Node._reservedMatrixStack.reset();
- return matrix;
-
- },
-
- setCullingActive: function ( value ) {
- if ( this._cullingActive === value ) return;
- if ( this._numChildrenWithCullingDisabled === 0 && this._parents.length > 0 ) {
- var delta = 0;
- if ( !this._cullingActive ) --delta;
- if ( !value ) ++delta;
- if ( delta !== 0 ) {
- for ( var i = 0, k = this._parents.length; i < k; i++ ) {
- this._parents[ i ].setNumChildrenWithCullingDisabled( this._parents[ i ].getNumChildrenWithCullingDisabled() + delta );
- }
- }
- }
- this._cullingActive = value;
- },
-
- getCullingActive: function () {
- return this._cullingActive;
- },
-
- isCullingActive: function () {
- return this._numChildrenWithCullingDisabled === 0 && this._cullingActive && this.getBound().valid();
- },
-
- setNumChildrenWithCullingDisabled: function ( num ) {
- if ( this._numChildrenWithCullingDisabled === num ) return;
- if ( this._cullingActive && this._parents.length > 0 ) {
- var delta = 0;
- if ( this._numChildrenWithCullingDisabled > 0 ) --delta;
- if ( num > 0 ) ++delta;
- if ( delta !== 0 ) {
- for ( var i = 0, k = this._parents.length; i < k; i++ ) {
- this._parents[ i ].setNumChildrenWithCullingDisabled( this._parents[ i ].getNumChildrenWithCullingDisabled() + delta );
- }
- }
- }
- this._numChildrenWithCullingDisabled = num;
- },
-
- getNumChildrenWithCullingDisabled: function () {
- return this._numChildrenWithCullingDisabled;
- },
-
- releaseGLObjects: function () {
- if ( this.stateset !== undefined ) this.stateset.releaseGLObjects();
- }
-
-
-} ), 'osg', 'Node' );
-MACROUTILS.setTypeID( Node );
-
-
-module.exports = Node;
diff --git a/app/static/app/js/vendor/osgjs/osg/NodeVisitor.js b/app/static/app/js/vendor/osgjs/osg/NodeVisitor.js
deleted file mode 100644
index 6f6ee1e2..00000000
--- a/app/static/app/js/vendor/osgjs/osg/NodeVisitor.js
+++ /dev/null
@@ -1,144 +0,0 @@
-'use strict';
-
-var NodeVisitor = function ( traversalMode ) {
- /*jshint bitwise: false */
- this.traversalMask = ~0x0;
- /*jshint bitwise: true */
- this.nodeMaskOverride = 0;
- this.traversalMode = traversalMode;
- if ( traversalMode === undefined ) {
- this.traversalMode = NodeVisitor.TRAVERSE_ALL_CHILDREN;
- }
- this.nodePath = [];
- this.visitorType = NodeVisitor.NODE_VISITOR;
- this._databaseRequestHandler = undefined;
- this._frameStamp = undefined;
-
- this.traverse = NodeVisitor._traversalFunctions[ this.traversalMode ];
- this.pushOntoNodePath = NodeVisitor._pushOntoNodePath[ this.traversalMode ];
- this.popFromNodePath = NodeVisitor._popFromNodePath[ this.traversalMode ];
-};
-
-//NodeVisitor.TRAVERSE_NONE = 0;
-NodeVisitor.TRAVERSE_PARENTS = 1;
-NodeVisitor.TRAVERSE_ALL_CHILDREN = 2;
-NodeVisitor.TRAVERSE_ACTIVE_CHILDREN = 3;
-
-NodeVisitor.NODE_VISITOR = 0;
-NodeVisitor.UPDATE_VISITOR = 1;
-NodeVisitor.CULL_VISITOR = 2;
-
-// =================== Traversal functions ===============
-var traverseParents = function traverseParents( node ) {
- node.ascend( this );
-};
-
-var traverseChildren = function traverseAllChildren( node ) {
- node.traverse( this );
-};
-
-// must be sync with TRAVERSE_ENUMS
-NodeVisitor._traversalFunctions = [
- undefined,
- traverseParents,
- traverseChildren,
- traverseChildren
-];
-
-// =================== PushOntoNodePath functions ===============
-var pushOntoNodePathParents = function ( node ) {
- this.nodePath.unshift( node );
-};
-
-var pushOntoNodePathChildren = function ( node ) {
- this.nodePath.push( node );
-};
-
-NodeVisitor._pushOntoNodePath = [
- undefined,
- pushOntoNodePathParents,
- pushOntoNodePathChildren,
- pushOntoNodePathChildren
-];
-
-// =================== PopOntoNodePath functions ===============
-var popFromNodePathParents = function () {
- return this.nodePath.shift();
-};
-
-var popFromNodePathChildren = function () {
- this.nodePath.pop();
-};
-
-NodeVisitor._popFromNodePath = [
- undefined,
- popFromNodePathParents,
- popFromNodePathChildren,
- popFromNodePathChildren
-];
-
-
-NodeVisitor.prototype = {
-
- reset: function () {
- // to be used when you want to re-use a nv
- this.nodePath.length = 0;
- },
-
- setFrameStamp: function ( frameStamp ) {
- this._frameStamp = frameStamp;
- },
-
- getFrameStamp: function () {
- return this._frameStamp;
- },
-
-
- setNodeMaskOverride: function ( m ) {
- this.nodeMaskOverride = m;
- },
- getNodeMaskOverride: function () {
- return this.nodeMaskOverride;
- },
-
- setTraversalMask: function ( m ) {
- this.traversalMask = m;
- },
- getTraversalMask: function () {
- return this.traversalMask;
- },
-
- getNodePath: function () {
- return this.nodePath;
- },
-
- pushOntoNodePath: function ( node ) {
- NodeVisitor._pushOntoNodePath[ this.traversalMode ].call( this, node );
- },
- popFromNodePath: function () {
- NodeVisitor._popFromNodePath[ this.traversalMode ].call( this );
- },
- validNodeMask: function ( node ) {
- var nm = node.getNodeMask();
- /*jshint bitwise: false */
- return ( ( this.traversalMask & ( this.nodeMaskOverride | nm ) ) !== 0 );
- /*jshint bitwise: true */
- },
- apply: function ( node ) {
- this.traverse( node );
- },
- traverse: function ( node ) {
- NodeVisitor._traversalFunctions[ this.traversalMode ].call( this, node );
- },
- getVisitorType: function () {
- return this.visitorType;
- },
- setDatabaseRequestHandler: function ( dbpager ) {
- this._databaseRequestHandler = dbpager;
- },
- getDatabaseRequestHandler: function () {
- return this._databaseRequestHandler;
- }
-};
-
-module.exports = NodeVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osg/Object.js b/app/static/app/js/vendor/osgjs/osg/Object.js
deleted file mode 100644
index 8cde5595..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Object.js
+++ /dev/null
@@ -1,53 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-
-/**
- * Object class
- * @class Object
- */
-var Object = function () {
- this._name = undefined;
- this._userdata = undefined;
- this._instanceID = Object.getInstanceID();
-};
-
-/** @lends Object.prototype */
-Object.prototype = MACROUTILS.objectLibraryClass( {
-
- // this method works only if constructor is set correctly
- // see issue https://github.com/cedricpinson/osgjs/issues/494
- cloneType: function () {
- var Constructor = this.constructor;
- return new Constructor();
- },
-
- getInstanceID: function () {
- return this._instanceID;
- },
-
- setName: function ( name ) {
- this._name = name;
- },
-
- getName: function () {
- return this._name;
- },
-
- setUserData: function ( data ) {
- this._userdata = data;
- },
-
- getUserData: function () {
- return this._userdata;
- }
-}, 'osg', 'Object' );
-
-
-// get an instanceID for each object
-var instanceID = 0;
-Object.getInstanceID = function () {
- instanceID += 1;
- return instanceID;
-};
-
-module.exports = Object;
diff --git a/app/static/app/js/vendor/osgjs/osg/Options.js b/app/static/app/js/vendor/osgjs/osg/Options.js
deleted file mode 100644
index bb28f852..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Options.js
+++ /dev/null
@@ -1,54 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-
-var OptionsDefault = {
- 'antialias': true, // activate MSAA
- //'overrideDevicePixelRatio': 1, // if specified override the device pixel ratio
- 'fullscreen': true,
- 'enableFrustumCulling': false,
- 'stats': false, // display canvas with stats for the viewer
- 'scrollwheel': true,
- 'webgl2': false
-};
-
-var Options = function () {
-
- window.Object.keys( OptionsDefault ).forEach( function ( key ) {
- this[ key ] = OptionsDefault[ key ];
- }.bind( this ) );
-
-};
-
-
-Options.prototype = {
-
- extend: function ( options ) {
- MACROUTILS.objectMix( this, options );
- return this;
- },
-
- get: function ( key ) {
- return this[ key ];
- },
-
- getBoolean: function ( key ) {
- var val = this.getString( key );
- if ( val ) return ( val !== 'false' && val !== '0' );
- return undefined;
- },
-
- getNumber: function ( key ) {
- var val = this[ key ];
- if ( val ) return Number( val );
- return undefined;
- },
-
- getString: function ( key ) {
- var val = this[ key ];
- if ( val !== undefined ) return this[ key ].toString();
- return undefined;
- }
-
-};
-
-module.exports = Options;
diff --git a/app/static/app/js/vendor/osgjs/osg/PagedLOD.js b/app/static/app/js/vendor/osgjs/osg/PagedLOD.js
deleted file mode 100644
index c9e7b757..00000000
--- a/app/static/app/js/vendor/osgjs/osg/PagedLOD.js
+++ /dev/null
@@ -1,244 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Lod = require( 'osg/Lod' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-
-/**
- * PagedLOD that can contains paged child nodes
- * @class PagedLod
- */
-var PagedLOD = function () {
- Lod.call( this );
- this._perRangeDataList = [];
- this._loading = false;
- this._expiryTime = 0.0;
- this._expiryFrame = 0;
- this._centerMode = Lod.USER_DEFINED_CENTER;
- this._frameNumberOfLastTraversal = 0;
- this._databasePath = '';
- this._numChildrenThatCannotBeExpired = 0;
-};
-
-/**
- * PerRangeData utility structure to store per range values
- * @class PerRangeData
- */
-var PerRangeData = function () {
- this.filename = '';
- this.function = undefined;
- this.loaded = false;
- this.timeStamp = 0.0;
- this.frameNumber = 0;
- this.frameNumberOfLastTraversal = 0;
- this.dbrequest = undefined;
-};
-
-/** @lends PagedLOD.prototype */
-PagedLOD.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Lod.prototype, {
- // Functions here
- setRange: function ( childNo, min, max ) {
- if ( childNo >= this._range.length ) {
- var r = [];
- r.push( [ min, min ] );
- this._range.push( r );
- }
- this._range[ childNo ][ 0 ] = min;
- this._range[ childNo ][ 1 ] = max;
- },
-
- setExpiryTime: function ( expiryTime ) {
- this._expiryTime = expiryTime;
- },
-
- setDatabasePath: function ( path ) {
- this._databasePath = path;
- },
-
- getDatabasePath: function () {
- return this._databasePath;
- },
-
- setFileName: function ( childNo, filename ) {
- // May we should expand the vector first?
- if ( childNo >= this._perRangeDataList.length ) {
- var rd = new PerRangeData();
- rd.filename = filename;
- this._perRangeDataList.push( rd );
- } else {
- this._perRangeDataList[ childNo ].filename = filename;
- }
- },
- setFunction: function ( childNo, func ) {
- if ( childNo >= this._perRangeDataList.length ) {
- var rd = new PerRangeData();
- rd.function = func;
- this._perRangeDataList.push( rd );
- } else {
- this._perRangeDataList[ childNo ].function = func;
- }
- },
-
- addChild: function ( node, min, max ) {
- Lod.prototype.addChild.call( this, node, min, max );
- this._perRangeDataList.push( new PerRangeData() );
- },
-
- addChildNode: function ( node ) {
- Lod.prototype.addChildNode.call( this, node );
- },
-
- setFrameNumberOfLastTraversal: function ( frameNumber ) {
- this._frameNumberOfLastTraversal = frameNumber;
- },
-
- getFrameNumberOfLastTraversal: function () {
- return this._frameNumberOfLastTraversal;
- },
- setTimeStamp: function ( childNo, timeStamp ) {
- this._perRangeDataList[ childNo ].timeStamp = timeStamp;
- },
- setFrameNumber: function ( childNo, frameNumber ) {
- this._perRangeDataList[ childNo ].frameNumber = frameNumber;
- },
- setNumChildrenThatCannotBeExpired: function ( num ) {
- this._numChildrenThatCannotBeExpired = num;
- },
- getNumChildrenThatCannotBeExpired: function () {
- return this._numChildrenThatCannotBeExpired;
- },
- getDatabaseRequest: function ( childNo ) {
- return this._perRangeDataList[ childNo ].dbrequest;
- },
- removeExpiredChildren: function ( expiryTime, expiryFrame, removedChildren ) {
- if ( this.children.length <= this._numChildrenThatCannotBeExpired ) return;
- var i = this.children.length - 1;
- var timed, framed;
- timed = this._perRangeDataList[ i ].timeStamp + this._expiryTime;
- framed = this._perRangeDataList[ i ].frameNumber + this._expiryFrame;
- if ( timed < expiryTime && framed < expiryFrame && ( this._perRangeDataList[ i ].filename.length > 0 ||
- this._perRangeDataList[ i ].function !== undefined ) ) {
- removedChildren.push( this.children[ i ] );
- this.removeChild( this.children[ i ] );
- this._perRangeDataList[ i ].loaded = false;
- if ( this._perRangeDataList[ i ].dbrequest !== undefined ) {
- this._perRangeDataList[ i ].dbrequest._groupExpired = true;
- }
- }
- },
-
- traverse: ( function () {
-
- // avoid to generate variable on the heap to limit garbage collection
- // instead create variable and use the same each time
- var zeroVector = vec3.create();
- var eye = vec3.create();
- var viewModel = mat4.create();
-
- return function ( visitor ) {
-
- var traversalMode = visitor.traversalMode;
- var updateTimeStamp = false;
-
- if ( visitor.getVisitorType() === NodeVisitor.CULL_VISITOR ) {
- this._frameNumberOfLastTraversal = visitor.getFrameStamp().getFrameNumber();
- updateTimeStamp = true;
- }
-
- switch ( traversalMode ) {
-
- case NodeVisitor.TRAVERSE_ALL_CHILDREN:
-
- for ( var index = 0; index < this.children.length; index++ ) {
- this.children[ index ].accept( visitor );
- }
- break;
-
- case ( NodeVisitor.TRAVERSE_ACTIVE_CHILDREN ):
- var requiredRange = 0;
-
- // Calculate distance from viewpoint
- var matrix = visitor.getCurrentModelViewMatrix();
- mat4.invert( viewModel, matrix );
- if ( this._rangeMode === Lod.DISTANCE_FROM_EYE_POINT ) {
- vec3.transformMat4( eye, zeroVector, viewModel );
- var d = vec3.distance( this.getBound().center(), eye );
- requiredRange = d * visitor.getLODScale();
- } else {
- // Calculate pixels on screen
- var projmatrix = visitor.getCurrentProjectionMatrix();
- // focal lenght is the value stored in projmatrix[0]
- requiredRange = this.projectBoundingSphere( this.getBound(), matrix, projmatrix[ 0 ] );
- // Get the real area value and apply LODScale
- requiredRange = ( ( requiredRange * visitor.getViewport().width() * visitor.getViewport().width() ) * 0.25 ) / visitor.getLODScale();
- if ( requiredRange < 0 ) requiredRange = this._range[ this._range.length - 1 ][ 0 ];
- }
-
- var needToLoadChild = false;
- var lastChildTraversed = -1;
- for ( var j = 0; j < this._range.length; ++j ) {
- if ( this._range[ j ][ 0 ] <= requiredRange && requiredRange < this._range[ j ][ 1 ] ) {
- if ( j < this.children.length ) {
-
- if ( updateTimeStamp ) {
- this._perRangeDataList[ j ].timeStamp = visitor.getFrameStamp().getSimulationTime();
- this._perRangeDataList[ j ].frameNumber = visitor.getFrameStamp().getFrameNumber();
- }
-
- this.children[ j ].accept( visitor );
- lastChildTraversed = j;
- } else {
- needToLoadChild = true;
- }
- }
- }
- if ( needToLoadChild ) {
- var numChildren = this.children.length;
- if ( numChildren > 0 && ( ( numChildren - 1 ) !== lastChildTraversed ) ) {
-
- if ( updateTimeStamp ) {
- this._perRangeDataList[ numChildren - 1 ].timeStamp = visitor.getFrameStamp().getSimulationTime();
- this._perRangeDataList[ numChildren - 1 ].frameNumber = visitor.getFrameStamp().getFrameNumber();
- }
-
- this.children[ numChildren - 1 ].accept( visitor );
- }
- // now request the loading of the next unloaded child.
- if ( numChildren < this._perRangeDataList.length ) {
- // compute priority from where abouts in the required range the distance falls.
- var priority = ( this._range[ numChildren ][ 0 ] - requiredRange ) / ( this._range[ numChildren ][ 1 ] - this._range[ numChildren ][ 0 ] );
- if ( this._rangeMode === Lod.PIXEL_SIZE_ON_SCREEN ) {
- priority = -priority;
- }
- // Here we do the request
- var group = visitor.nodePath[ visitor.nodePath.length - 1 ];
- if ( this._perRangeDataList[ numChildren ].loaded === false ) {
- this._perRangeDataList[ numChildren ].loaded = true;
- var dbhandler = visitor.getDatabaseRequestHandler();
- this._perRangeDataList[ numChildren ].dbrequest = dbhandler.requestNodeFile( this._perRangeDataList[ numChildren ].function, this._databasePath + this._perRangeDataList[ numChildren ].filename, group, visitor.getFrameStamp().getSimulationTime(), priority );
- } else {
- // Update timestamp of the request.
- if ( this._perRangeDataList[ numChildren ].dbrequest !== undefined ) {
- this._perRangeDataList[ numChildren ].dbrequest._timeStamp = visitor.getFrameStamp().getSimulationTime();
- this._perRangeDataList[ numChildren ].dbrequest._priority = priority;
- } else {
- // The DB request is undefined, so the DBPager was not accepting requests, we need to ask for the child again.
- this._perRangeDataList[ numChildren ].loaded = false;
- }
- }
- }
- }
- break;
- default:
- break;
- }
- };
- } )()
-
-
-} ), 'osg', 'PagedLOD' );
-
-MACROUTILS.setTypeID( PagedLOD );
-module.exports = PagedLOD;
diff --git a/app/static/app/js/vendor/osgjs/osg/Plane.js b/app/static/app/js/vendor/osgjs/osg/Plane.js
deleted file mode 100644
index 1a04d3f6..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Plane.js
+++ /dev/null
@@ -1,143 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-
-/** @class Plane Operations */
-var Plane = MACROUTILS.objectInherit( vec4, {
- // Many case (frustum, convexity)
- // needs to know where from a plane it stands,
- // not just boolean intersection
- INSIDE: 1,
- INTERSECT: 2,
- OUTSIDE: 3,
- /* Transform the plane */
- transformProvidingInverse: function () {
- var iplane = Plane.create();
- return function ( p, m ) {
- //Matrix.transformVec4PostMult( matrix, plane, iplane );
- var x = p[ 0 ];
- var y = p[ 1 ];
- var z = p[ 2 ];
- var w = p[ 3 ];
-
- iplane[ 0 ] = m[ 0 ] * x + m[ 1 ] * y + m[ 2 ] * z + m[ 3 ] * w;
- iplane[ 1 ] = m[ 4 ] * x + m[ 5 ] * y + m[ 6 ] * z + m[ 7 ] * w;
- iplane[ 2 ] = m[ 8 ] * x + m[ 9 ] * y + m[ 10 ] * z + m[ 11 ] * w;
- iplane[ 3 ] = m[ 12 ] * x + m[ 13 ] * y + m[ 14 ] * z + m[ 15 ] * w;
-
- Plane.normalizeEquation( iplane );
- Plane.copy( iplane, p );
- return p;
- };
- },
-
- normalizeEquation: function ( plane ) {
- // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.
- var inv = 1.0 / Math.sqrt( plane[ 0 ] * plane[ 0 ] + plane[ 1 ] * plane[ 1 ] + plane[ 2 ] * plane[ 2 ] );
- plane[ 0 ] *= inv;
- plane[ 1 ] *= inv;
- plane[ 2 ] *= inv;
- plane[ 3 ] *= inv;
- },
- /*only the normal Component*/
- getNormal: function ( plane, result ) {
- result[ 0 ] = plane[ 0 ];
- result[ 1 ] = plane[ 1 ];
- result[ 2 ] = plane[ 2 ];
- return result;
- },
- setNormal: function ( plane, normal ) {
- plane[ 0 ] = normal[ 0 ];
- plane[ 1 ] = normal[ 1 ];
- plane[ 2 ] = normal[ 2 ];
- },
- /* only the distance getter*/
- getDistance: function ( plane ) {
- return plane[ 3 ];
- },
- setDistance: function ( plane, distance ) {
- plane[ 3 ] = distance;
- },
-
- /* using the plane equation, compute distance to plane of a point*/
- distanceToPlane: function ( plane, position ) {
- return plane[ 0 ] * position[ 0 ] + plane[ 1 ] * position[ 1 ] + plane[ 2 ] * position[ 2 ] + plane[ 3 ];
- },
-
-
- intersectsOrContainsBoundingSphere: function ( plane, bSphere ) {
- if ( !bSphere.valid() ) return Plane.OUTSIDE;
- var position = bSphere.center();
- var radius = bSphere.radius();
- var d = this.distanceToPlane( plane, position );
- if ( d < -radius ) {
- return Plane.OUTSIDE;
- } else if ( d <= radius ) {
- return Plane.INTERSECT;
- }
- return Plane.INSIDE;
- },
-
- instersectsBoundingSphere: function ( plane, bSphere ) {
- return this.intersectsOrContainsBoundingSphere( plane, bSphere ) === Plane.INTERSECT;
- },
-
- // absPlane optional paramter is an optimisation for the
- // DOD case: on plane, many bounding boxes
- intersectsOrContainsBoundingBox: function () {
- var center = vec3.create();
- var extent = vec3.create();
- var absTemp = vec3.create();
- return function ( plane, bbox, absPlane ) {
- vec3.add( center, bbox.getMax(), bbox.getMin() );
- vec3.scale( center, center, 0.5 );
-
- vec3.sub( center, bbox.getMax(), bbox.getMin() );
- vec3.scale( extent, extent, 0.5 );
-
- var d = vec3.dot( center, plane );
- if ( !absPlane ) {
- absPlane = absTemp;
- absPlane[ 0 ] = Math.abs( plane[ 0 ] );
- absPlane[ 1 ] = Math.abs( plane[ 1 ] );
- absPlane[ 2 ] = Math.abs( plane[ 2 ] );
- }
- var r = vec3.dot( extent, absPlane );
- if ( d + r > 0 ) return Plane.INTERSECT; // partially inside
- if ( d - r >= 0 ) return Plane.INSIDE; // fully inside
- return Plane.OUTSIDE;
- };
- },
-
- intersectsBoundingBox: function ( plane, bbox, absPlane ) {
- return this.intersectsOrContainsBoundingBox( plane, bbox, absPlane ) === Plane.INTERSECT;
- },
-
- intersectOrContainsVertices: function ( plane, vertices ) {
- var side = -1;
- // all points must be on one side only
- for ( var i = 0; i < vertices.length; i++ ) {
- var d = this.distanceToPlane( plane, vertices[ i ] );
- if ( d < 0.0 ) {
- if ( side === 1 ) return Plane.INTERSECT;
- side = 2;
- } else if ( d > 0.0 ) {
- if ( side === 2 ) return Plane.INTERSECT;
- side = 1;
- } else { //if ( d === 0.0 )
- return Plane.INTERSECT;
- }
- }
- return ( side > 0 ) ? Plane.INSIDE : Plane.OUTSIDE;
-
- },
- intersectVertices: function ( plane, vertices ) {
- return this.intersectOrContainsVertices( plane, vertices ) === Plane.INTERSECT;
- }
-
-
-} );
-
-module.exports = Plane;
diff --git a/app/static/app/js/vendor/osgjs/osg/Polytope.js b/app/static/app/js/vendor/osgjs/osg/Polytope.js
deleted file mode 100644
index c9cd11e7..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Polytope.js
+++ /dev/null
@@ -1,349 +0,0 @@
-'use strict';
-var Object = require( 'osg/Object' );
-var Plane = require( 'osg/Plane' );
-var MACROUTILS = require( 'osg/Utils' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-/*jshint bitwise: false */
-/**
- * Polytope class for representing convex clipping volumes made up of a set of planes.
- * When adding planes, their normals should point inwards (into the volume)
- * @class Polytope
- */
-var Polytope = function () {
-
- this._clippingMask = 0x0;
-
- this._planeList = [ Plane.create(), Plane.create(), Plane.create(), Plane.create(), Plane.create(), Plane.create() ];
- this._vertexList = [];
-
- // stack of clipping masks
- this._maskStack = [];
-
- // init with a clear mask
- this._resultMask = 0;
- this._maskStack.push( this._resultMask );
-};
-
-Polytope.prototype = MACROUTILS.objectInherit( Object.prototype, {
-
-
- getPlanes: function () {
- return this._planeList;
- },
-
- setPlanes: function ( pl ) {
- this._planeList = pl;
- this.setupMask();
- },
-
- clear: function () {
-
- this._clippingMask = 0x0;
- if ( this._planeList ) {
- for ( var i = 0, l = this._planeList.length; i < l; ++i ) {
- Plane.init( this._planeList[ i ] );
- }
- }
- this._vertexList = [];
- this.setupMask();
-
- },
-
- /** Create a Polytope which is a cube, centered at 0,0,0, with sides of 2 units.*/
- setToUnitFrustum: function ( withNear, withFar ) {
- if ( withNear === undefined ) withNear = true;
-
- if ( withFar === undefined ) withFar = true;
-
- this._planeList.length = 0;
- this._planeList.push( vec4.set( Plane.create(), 1.0, 0.0, 0.0, 1.0 ) ); // left plane.
- this._planeList.push( vec4.set( Plane.create(), -1.0, 0.0, 0.0, 1.0 ) ); // right plane.
- this._planeList.push( vec4.set( Plane.create(), 0.0, 1.0, 0.0, 1.0 ) ); // bottom plane.
- this._planeList.push( vec4.set( Plane.create(), 0.0, -1.0, 0.0, 1.0 ) ); // top plane.
- if ( withNear ) this._planeList.push( vec4.set( Plane.create(), 0.0, 0.0, 1.0, 1.0 ) ); // near plane
- if ( withFar ) this._planeList.push( vec4.set( Plane.create(), 0.0, 0.0, -1.0, 1.0 ) ); // far plane
- this.setupMask();
- },
-
-
- /** Create a Polytope which is a equivalent to BoundingBox.*/
- setToBoundingBox: function ( bb ) {
- this._planeList.length = 0;
- this._planeList.push( vec4.set( Plane.create(), 1.0, 0.0, 0.0, -bb.getMin()[ 0 ] ) ); // left plane.
- this._planeList.push( vec4.set( Plane.create(), -1.0, 0.0, 0.0, bb.getMax()[ 0 ] ) ); // right plane.
- this._planeList.push( vec4.set( Plane.create(), 0.0, 1.0, 0.0, -bb.getMin()[ 1 ] ) ); // bottom plane.
- this._planeList.push( vec4.set( Plane.create(), 0.0, -1.0, 0.0, bb.getMax()[ 1 ] ) ); // top plane.
- this._planeList.push( vec4.set( Plane.create(), 0.0, 0.0, 1.0, -bb.getMin()[ 2 ] ) ); // near plane
- this._planeList.push( vec4.set( Plane.create(), 0.0, 0.0, -1.0, bb.getMax()[ 2 ] ) ); // far plane
- this.setupMask();
- },
-
- setAndTransformProvidingInverse: function ( pt, matrix ) {
- this._referenceVertexList = pt._referenceVertexList;
- var resultMask = pt._maskStack[ this._maskStack.length - 1 ];
- if ( resultMask === 0 ) {
- this._maskStack[ this._maskStack.length - 1 ] = 0;
- this._resultMask = 0;
- this._planeList.length = 0;
- return;
- }
- var selectorMask = 0x1;
-
- var numActivePlanes = 0;
- // count number of active planes.
- var i;
- for ( i = 0; i !== pt._planeList.length; ++i ) {
- if ( resultMask & selectorMask ) ++numActivePlanes;
- selectorMask <<= 1;
- }
-
- this._planeList.length = numActivePlanes;
- this._resultMask = 0;
- selectorMask = 0x1;
- var index = 0;
- for ( i = 0; i !== pt._planeList.length; ++i ) {
- if ( resultMask & selectorMask ) {
- this._planeList[ index ] = pt._planeList[ i ];
- Plane.transformProvidingInverse( this._planeList[ index++ ], matrix );
- this._resultMask = ( this._resultMask << 1 ) | 1;
- }
- selectorMask <<= 1;
- }
-
- this._maskStack[ this._maskStack.length - 1 ] = this._resultMask;
- },
-
- voidset: function ( pl ) {
- this._planeList = pl;
- this.setupMask();
- },
-
-
- add: function ( pl ) {
- this._planeList.push( pl );
- this.setupMask();
- },
-
- empty: function () {
- return this._planeList.length === 0;
- },
-
- getPlaneList: function () {
- return this._planeList;
- },
-
- setReferenceVertexList: function ( vertices ) {
- this._referenceVertexList = vertices;
- },
-
- getReferenceVertexList: function () {
- return this._referenceVertexList;
- },
-
- setupMask: function ( plength ) {
- this._resultMask = 0;
- var pMasklength = ( plength !== undefined ) ? plength : this._planeList.length;
- for ( var i = 0; i < pMasklength; ++i ) {
- this._resultMask = ( this._resultMask << 1 ) | 1;
- }
- this._maskStack = [];
- this._maskStack.push( this._resultMask );
- },
-
- getCurrentMask: function () {
- return this._maskStack[ this._maskStack.length - 1 ];
- },
-
- setResultMask: function ( mask ) {
- this._resultMask = mask;
- },
-
- getResultMask: function () {
- return this._resultMask;
- },
-
- getMaskStack: function () {
- return this._maskStack;
- },
-
-
- // push but keep current mask
- pushCurrentMask: function () {
- this._maskStack.push( this._resultMask );
- },
- // pop and restore previous mask
- popCurrentMask: function () {
- return this._maskStack.pop();
- },
-
-
- /** Check whether a vertex is contained within clipping set.*/
- containsVertex: function ( v ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] ) return true;
-
- var selectorMask = 0x1;
- for ( var i = 0; i < this._planeList.length; ++i ) {
- if ( ( this._maskStack[ this._maskStack.length - 1 ] & selectorMask ) && ( Plane.distanceToPlane( this._planeList[ i ], v ) < 0.0 ) ) {
- return false;
- }
- selectorMask <<= 1;
- }
- return true;
- },
-
- /** Check whether any part of vertex list is contained within clipping set.*/
- containsVertices: function ( vertices ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] ) return true;
-
- this._resultMask = this._maskStack[ this._maskStack.length - 1 ];
-
- for ( var k = 0; k < vertices.length; ++k ) {
- var v = vertices[ k ];
- var outside = false;
- var selectorMask = 0x1;
- for ( var i = 0; !outside && i < this._planeList.length; ++i ) {
- if ( ( this._maskStack[ this._maskStack.length - 1 ] & selectorMask ) && ( Plane.distanceToPlane( this._planeList[ i ], v ) < 0.0 ) ) {
- outside = true;
- }
- selectorMask <<= 1;
- }
-
- if ( !outside ) return true;
- }
- return false;
- },
-
- /** Check whether any part of a bounding sphere is contained within clipping set.
- Using a mask to determine which planes should be used for the check, and
- modifying the mask to turn off planes which wouldn't contribute to clipping
- of any internal objects. This feature is used in osgUtil::CullVisitor
- to prevent redundant plane checking.*/
- containsBoundingSphere: function ( bs ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] || !bs.valid() ) return true;
-
- this._resultMask = this._maskStack[ this._maskStack.length - 1 ];
- var selectorMask = 0x1;
-
- for ( var i = 0; i < this._planeList.length; ++i ) {
- if ( this._resultMask & selectorMask ) {
- var res = Plane.intersectsOrContainsBoundingSphere( this._planeList[ i ], bs );
- if ( Plane.OUTSIDE === res ) {
- // totally outside a clipping set.
- return false;
- } else if ( Plane.INSIDE === res ) {
- // subsequent checks against this plane not required.
- this._resultMask ^= selectorMask;
- }
- // else if ( Plane.INTERSECT === res ) { // last possible case
- // can say nothing.
- // subsequent checks against this plane needed.
- //}
- }
- selectorMask <<= 1;
- }
- return true;
- },
-
- /** Check whether any part of a bounding box is contained within clipping set.
- Using a mask to determine which planes should be used for the check, and
- modifying the mask to turn off planes which wouldn't contribute to clipping
- of any internal objects. This feature is used in osgUtil::CullVisitor
- to prevent redundant plane checking.*/
- containsBoundingBox: function ( bb ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] ) return true;
-
- this._resultMask = this._maskStack[ this._maskStack.length - 1 ];
- var selectorMask = 0x1;
-
- for ( var i = 0; i < this._planeList.length; ++i ) {
- if ( this._resultMask & selectorMask ) {
- var res = Plane.intersectsOrContainsBoundingBox( this._planeList[ i ], bb );
- if ( Plane.OUTSIDE === res ) return false; // outside clipping set.
- else if ( Plane.INSIDE === res ) this._resultMask ^= selectorMask; // subsequent checks against this plane not required.
- // else if ( Plane.INTERSECT === res ) the last case need
- // no test here but further tests
- }
- selectorMask <<= 1;
- }
- // correct frustum culling should double check now for
- // http://www.iquilezles.org/www/articles/frustumcorrect/frustumcorrect.htm
- // which is inside one "plane", but outside the convex plane intersection
- return true;
- },
-
- /** Check whether all of vertex list is contained with clipping set.*/
- containsAllOfVertices: function ( vertices ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] ) return false;
-
- this._resultMask = this._maskStack[ this._maskStack.length - 1 ];
- var selectorMask = 0x1;
-
- for ( var i = 0; i < this._planeList.length; ++i ) {
- if ( this._resultMask & selectorMask ) {
- var res = Plane.intersectsOrContainsVertices( this._planeList[ i ], vertices );
- if ( res < 1 ) return false; // intersects, or is below plane.
- this._resultMask ^= selectorMask; // subsequent checks against this plane not required.
- }
- selectorMask <<= 1;
- }
- return true;
- },
-
- /** Check whether the entire bounding sphere is contained within clipping set.*/
- containsAllOfBoundingSphere: function ( bs ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] ) return false;
-
- this._resultMask = this._maskStack[ this._maskStack.length - 1 ];
- var selectorMask = 0x1;
-
- for ( var i = 0; i < this._planeList.length; ++i ) {
- if ( this._resultMask & selectorMask ) {
- var res = Plane.intersectsOrContainsBoundingSphere( this._planeList[ i ], bs );
- if ( res < 1 ) return false; // intersects, or is below plane.
- this._resultMask ^= selectorMask; // subsequent checks against this plane not required.
- }
- selectorMask <<= 1;
- }
- return true;
- },
-
- /** Check whether the entire bounding box is contained within clipping set.*/
- containsAllOfBoundingBox: function ( bbox ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] ) return false;
-
- this._resultMask = this._maskStack[ this._maskStack.length - 1 ];
- var selectorMask = 0x1;
-
- for ( var i = 0; i < this._planeList.length; ++i ) {
- if ( this._resultMask & selectorMask ) {
- var res = Plane.intersectsOrContainsBoundingBox( this._planeList[ i ], bbox );
- if ( res < 1 ) return false; // intersects, or is below plane.
- this._resultMask ^= selectorMask; // subsequent checks against this plane not required.
- }
- selectorMask <<= 1;
- }
- return true;
- },
-
- /** Transform the clipping set by provide a pre inverted matrix.
- * see transform for details. */
- transformProvidingInverse: function ( matrix ) {
- if ( !this._maskStack[ this._maskStack.length - 1 ] ) return;
-
- this._resultMask = this._maskStack[ this._maskStack.length - 1 ];
- var selectorMask = 0x1;
- for ( var i = 0; i < this._planeList.length; ++i ) {
- if ( this._resultMask & selectorMask ) {
- Plane.transformProvidingInverse( this._planeList[ i ], matrix );
- selectorMask <<= 1;
- }
- }
- }
-
-
-
-} );
-
-/*jshint bitwise: true */
-
-module.exports = Polytope;
diff --git a/app/static/app/js/vendor/osgjs/osg/PrimitiveFunctor.js b/app/static/app/js/vendor/osgjs/osg/PrimitiveFunctor.js
deleted file mode 100644
index 40853125..00000000
--- a/app/static/app/js/vendor/osgjs/osg/PrimitiveFunctor.js
+++ /dev/null
@@ -1,387 +0,0 @@
-'use strict';
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var DrawElements = require( 'osg/DrawElements' );
-var DrawArrays = require( 'osg/DrawArrays' );
-
-/**
- * PrimitiveFunctor emulates the TemplatePrimitiveFunctor class in OSG and can
- * be used to get access to the vertices that compose the things drawn by osgjs.
- * Feed it with a callback that will be called for geometry.
- * The callback must be a closure and have the next structure:
- *
- * var myCallback = function( ) {
- * return {
- * operatorPoint : function ( v ) { }, // Do your point operations here
- * operatorLine : function ( v1, v2 ){ }, // Do you line operations here
- * operatorTriangle : function ( v1, v2, v3 ) { } // Do your triangle operations here
- * }
- * };
- *
- * Important Note: You should take into account that you are accesing the actual vertices of the primitive
- * you might want to do a copy of these values in your callback to avoid to modify the primitive geometry
- * @class PrimitiveFunctor
- */
-
-var PrimitiveFunctor = function ( geom, cb, vertices ) {
- this._geom = geom;
- this._cb = cb;
- this._vertices = vertices;
-};
-
-var functorDrawElements = PrimitiveFunctor.functorDrawElements = [];
-var functorDrawArrays = PrimitiveFunctor.functorDrawArrays = [];
-
-functorDrawElements[ PrimitiveSet.POINTS ] = ( function () {
- var v = vec3.create();
- return function ( offset, count, indexes, cb, vertices ) {
-
- var end = offset + count;
- for ( var i = offset; i < end; ++i ) {
- var j = indexes[ i ] * 3;
- v[ 0 ] = vertices[ j ];
- v[ 1 ] = vertices[ j + 1 ];
- v[ 2 ] = vertices[ j + 2 ];
- cb.operatorPoint( v );
- }
- };
-} )();
-
-functorDrawElements[ PrimitiveSet.LINES ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- return function ( offset, count, indexes, cb, vertices ) {
-
- var end = offset + count;
- for ( var i = offset; i < end - 1; i += 2 ) {
- var j = indexes[ i ] * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = indexes[ i + 1 ] * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- cb.operatorLine( v1, v2 );
- }
- };
-} )();
-
-functorDrawElements[ PrimitiveSet.LINE_STRIP ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- return function ( offset, count, indexes, cb, vertices ) {
-
- var end = offset + count;
- for ( var i = offset; i < end - 1; ++i ) {
- var j = indexes[ i ] * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = indexes[ i + 1 ] * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- cb.operatorLine( v1, v2 );
- }
- };
-} )();
-
-functorDrawElements[ PrimitiveSet.LINE_LOOP ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- return function ( offset, count, indexes, cb, vertices ) {
-
- var last = offset + count - 1;
- for ( var i = offset; i < last; ++i ) {
- var j = indexes[ i ] * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = indexes[ i + 1 ] * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- cb.operatorLine( v1, v2 );
- }
- last = indexes[ last ] * 3;
- v1[ 0 ] = vertices[ last ];
- v1[ 1 ] = vertices[ last + 1 ];
- v1[ 2 ] = vertices[ last + 2 ];
- var first = indexes[ 0 ] * 3;
- v2[ 0 ] = vertices[ first ];
- v2[ 1 ] = vertices[ first + 1 ];
- v2[ 2 ] = vertices[ first + 2 ];
- cb.operatorLine( v1, v2 );
- };
-} )();
-
-functorDrawElements[ PrimitiveSet.TRIANGLES ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
- return function ( offset, count, indexes, cb, vertices ) {
-
- var end = offset + count;
- for ( var i = offset; i < end; i += 3 ) {
- var j = indexes[ i ] * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = indexes[ i + 1 ] * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- j = indexes[ i + 2 ] * 3;
- v3[ 0 ] = vertices[ j ];
- v3[ 1 ] = vertices[ j + 1 ];
- v3[ 2 ] = vertices[ j + 2 ];
- cb.operatorTriangle( v1, v2, v3 );
- }
- };
-} )();
-
-functorDrawElements[ PrimitiveSet.TRIANGLE_STRIP ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
- return function ( offset, count, indexes, cb, vertices ) {
-
- for ( var i = 2, pos = offset; i < count; ++i, ++pos ) {
- var j = indexes[ pos ] * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = indexes[ pos + 1 ] * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- j = indexes[ pos + 2 ] * 3;
- v3[ 0 ] = vertices[ j ];
- v3[ 1 ] = vertices[ j + 1 ];
- v3[ 2 ] = vertices[ j + 2 ];
- if ( i % 2 ) {
- cb.operatorTriangle( v1, v3, v2 );
- } else {
- cb.operatorTriangle( v1, v2, v3 );
- }
- }
- };
-} )();
-
-functorDrawElements[ PrimitiveSet.TRIANGLE_FAN ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
- return function ( offset, count, indexes, cb, vertices ) {
-
- var first = indexes[ offset ];
- for ( var i = 2, pos = offset + 1; i < count; ++i, ++pos ) {
- v1[ 0 ] = vertices[ first ];
- v1[ 1 ] = vertices[ first + 1 ];
- v1[ 2 ] = vertices[ first + 2 ];
- var j = indexes[ pos ] * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- j = indexes[ pos + 1 ] * 3;
- v3[ 0 ] = vertices[ j ];
- v3[ 1 ] = vertices[ j + 1 ];
- v3[ 2 ] = vertices[ j + 2 ];
- cb.operatorTriangle( v1, v2, v3 );
- }
- };
-} )();
-
-functorDrawArrays[ PrimitiveSet.POINTS ] = ( function () {
- var v = vec3.create();
- return function ( first, count, cb, vertices ) {
-
- for ( var i = first; i < first + count; ++i ) {
- var j = i * 3;
- v[ 0 ] = vertices[ j ];
- v[ 1 ] = vertices[ j + 1 ];
- v[ 2 ] = vertices[ j + 2 ];
- cb.operatorPoint( v );
- }
- };
-} )();
-
-functorDrawArrays[ PrimitiveSet.LINES ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- return function ( first, count, cb, vertices ) {
-
- for ( var i = first; i < first + count - 1; i += 2 ) {
- var j = i * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = ( i + 1 ) * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- cb.operatorLine( v1, v2 );
- }
- };
-} )();
-
-functorDrawArrays[ PrimitiveSet.LINE_STRIP ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- return function ( first, count, cb, vertices ) {
-
- for ( var i = first; i < first + count - 1; ++i ) {
- var j = i * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = ( i + 1 ) * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- cb.operatorLine( v1, v2 );
- }
- };
-} )();
-
-functorDrawArrays[ PrimitiveSet.LINE_LOOP ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- return function ( first, count, cb, vertices ) {
-
- var last = first + count - 1;
- for ( var i = first; i < last; ++i ) {
- var j = i * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = ( i + 1 ) * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- cb.operatorLine( v1, v2 );
- }
- last = last * 3;
- v1[ 0 ] = vertices[ last ];
- v1[ 1 ] = vertices[ last + 1 ];
- v1[ 2 ] = vertices[ last + 2 ];
- first = first * 3;
- v2[ 0 ] = vertices[ first ];
- v2[ 1 ] = vertices[ first + 1 ];
- v2[ 2 ] = vertices[ first + 2 ];
- cb.operatorLine( v1, v2 );
- };
-} )();
-
-functorDrawArrays[ PrimitiveSet.TRIANGLES ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
- return function ( first, count, cb, vertices ) {
-
- for ( var i = first; i < first + count; i += 3 ) {
- var j = i * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = ( i + 1 ) * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- j = ( i + 2 ) * 3;
- v3[ 0 ] = vertices[ j ];
- v3[ 1 ] = vertices[ j + 1 ];
- v3[ 2 ] = vertices[ j + 2 ];
- cb.operatorTriangle( v1, v2, v3 );
- }
- };
-} )();
-
-functorDrawArrays[ PrimitiveSet.TRIANGLE_STRIP ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
- return function ( first, count, cb, vertices ) {
-
- for ( var i = 2, pos = first; i < count; ++i, ++pos ) {
- var j = pos * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
- j = ( pos + 1 ) * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- j = ( pos + 2 ) * 3;
- v3[ 0 ] = vertices[ j ];
- v3[ 1 ] = vertices[ j + 1 ];
- v3[ 2 ] = vertices[ j + 2 ];
- if ( i % 2 ) {
- cb.operatorTriangle( v1, v3, v2 );
- } else {
- cb.operatorTriangle( v1, v2, v3 );
- }
- }
- };
-} )();
-
-functorDrawArrays[ PrimitiveSet.TRIANGLE_FAN ] = ( function () {
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
- return function ( first, count, cb, vertices ) {
-
- for ( var i = 2, pos = first + 1; i < count; ++i, ++pos ) {
- v1[ 0 ] = vertices[ first ];
- v1[ 1 ] = vertices[ first + 1 ];
- v1[ 2 ] = vertices[ first + 2 ];
- var j = pos * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
- j = ( pos + 1 ) * 3;
- v3[ 0 ] = vertices[ j ];
- v3[ 1 ] = vertices[ j + 1 ];
- v3[ 2 ] = vertices[ j + 2 ];
- cb.operatorTriangle( v1, v2, v3 );
- }
- };
-} )();
-
-PrimitiveFunctor.prototype = {
- apply: function () {
- var geom = this._geom;
- var primitives = geom.primitives;
- if ( !primitives )
- return;
-
- var cb = this._cb();
- var cbFunctor;
- var vertices = this._vertices;
-
- var nbPrimitives = primitives.length;
- for ( var i = 0; i < nbPrimitives; i++ ) {
-
- var primitive = primitives[ i ];
- if ( primitive instanceof DrawElements ) {
-
- cbFunctor = functorDrawElements[ primitive.getMode() ];
- if ( cbFunctor ) {
- var indexes = primitive.indices.getElements();
- cbFunctor( primitive.getFirst() / indexes.BYTES_PER_ELEMENT, primitive.getCount(), indexes, cb, vertices );
- }
-
- } else if ( primitive instanceof DrawArrays ) {
-
- cbFunctor = functorDrawArrays[ primitive.getMode() ];
- if ( cbFunctor ) {
- cbFunctor( primitive.getFirst(), primitive.getCount(), cb, vertices );
- }
-
- }
- }
- }
-};
-
-module.exports = PrimitiveFunctor;
diff --git a/app/static/app/js/vendor/osgjs/osg/Program.js b/app/static/app/js/vendor/osgjs/osg/Program.js
deleted file mode 100644
index 9711bdc5..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Program.js
+++ /dev/null
@@ -1,323 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Notify = require( 'osg/notify' );
-var GLObject = require( 'osg/GLObject' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var CustomMap = require( 'osg/Map' );
-var Timer = require( 'osg/Timer' );
-
-/**
- * Program encapsulate an vertex and fragment shader
- * @class Program
- */
-var Program = function ( vShader, fShader ) {
- GLObject.call( this );
- StateAttribute.call( this );
- this._program = null;
-
- // used to know if it's a default program
- // a default program does nothing but avoid to do some
- // useless logic
- // if we vertex or fragment shader are set it's not a default
- // program anymore
- this._nullProgram = true;
-
- this._vertex = undefined;
- this._fragment = undefined;
-
- this._uniformsCache = undefined;
- this._attributesCache = undefined;
- this._activeUniforms = undefined;
- this._foreignUniforms = undefined;
- this._trackAttributes = undefined;
-
- if ( vShader )
- this.setVertexShader( vShader );
-
- if ( fShader )
- this.setFragmentShader( fShader );
-
- this._dirty = true;
-};
-
-
-var getAttributeList = function ( vertexShader ) {
- var attributeMap = {};
-
- var r = vertexShader.match( /attribute\s+\w+\s+\w+/g );
- if ( r !== null ) {
- for ( var i = 0, l = r.length; i < l; i++ ) {
- var attr = r[ i ].match( /attribute\s+\w+\s+(\w+)/ )[ 1 ];
- attributeMap[ attr ] = true;
- }
- }
-
- return attributeMap;
-};
-
-
-// static cache of glPrograms flagged for deletion, which will actually
-// be deleted in the correct GL context.
-Program._sDeletedGLProgramCache = new window.Map();
-
-// static method to delete Program
-Program.deleteGLProgram = function ( gl, program ) {
-
- if ( !Program._sDeletedGLProgramCache.has( gl ) )
- Program._sDeletedGLProgramCache.set( gl, [] );
-
- Program._sDeletedGLProgramCache.get( gl ).push( program );
-};
-
-// static method to flush all the cached glPrograms which need to be deleted in the GL context specified
-Program.flushDeletedGLPrograms = function ( gl, availableTime ) {
-
- // if no time available don't try to flush objects.
- if ( availableTime <= 0.0 ) return availableTime;
-
- if ( !Program._sDeletedGLProgramCache.has( gl ) ) return availableTime;
-
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- var deleteList = Program._sDeletedGLProgramCache.get( gl );
- var numPrograms = deleteList.length;
-
- for ( var i = numPrograms - 1; i >= 0 && elapsedTime < availableTime; i-- ) {
- gl.deleteProgram( deleteList[ i ] );
- deleteList.splice( i, 1 );
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- }
-
- return availableTime - elapsedTime;
-};
-
-Program.flushAllDeletedGLPrograms = function ( gl ) {
-
- if ( !Program._sDeletedGLProgramCache.has( gl ) ) return;
-
- var deleteList = Program._sDeletedGLProgramCache.get( gl );
- var numPrograms = deleteList.length;
-
- for ( var i = numPrograms - 1; i >= 0; i-- ) {
- gl.deleteProgram( deleteList[ i ] );
- deleteList.splice( i, 1 );
- }
-};
-
-/** @lends Program.prototype */
-Program.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( GLObject.prototype, MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Program',
-
- cloneType: function () {
- return new Program();
- },
-
- setVertexShader: function ( vs ) {
- this._vertex = vs;
- this._nullProgram = false;
- },
-
- setFragmentShader: function ( fs ) {
- this._fragment = fs;
- this._nullProgram = false;
- },
-
- getVertexShader: function () {
- return this._vertex;
- },
- getFragmentShader: function () {
- return this._fragment;
- },
-
- getProgram: function () {
- return this._program;
- },
-
- setActiveUniforms: function ( activeUniforms ) {
- this._activeUniforms = activeUniforms;
- },
-
- getActiveUniforms: function () {
- return this._activeUniforms;
- },
-
- setForeignUniforms: function ( foreignUniforms ) {
- this._foreignUniforms = foreignUniforms;
- },
-
- getForeignUniforms: function () {
- return this._foreignUniforms;
- },
-
- setUniformsCache: function ( uniformsCache ) {
- this._uniformsCache = uniformsCache;
- },
-
- getUniformsCache: function () {
- return this._uniformsCache;
- },
-
- setAttributesCache: function ( attributesCache ) {
- this._attributesCache = attributesCache;
- },
-
- getAttributesCache: function () {
- return this._attributesCache;
- },
-
- setTrackAttributes: function ( trackAttributes ) {
- this._trackAttributes = trackAttributes;
- },
-
- getTrackAttributes: function () {
- return this._trackAttributes;
- },
-
- releaseGLObjects: function () {
- // Call to releaseGLOBjects on shaders
- if ( this._vertex !== undefined ) this._vertex.releaseGLObjects();
- if ( this._fragment !== undefined ) this._fragment.releaseGLObjects();
- if ( this._program === null ) return;
- if ( this._gl !== undefined ) {
- Program.deleteGLProgram( this._gl, this._program );
- }
- this._program = undefined;
- },
-
- apply: function ( state ) {
-
- if ( this._nullProgram ) return;
-
- if ( !this._gl ) {
- this.setGraphicContext( state.getGraphicContext() );
- }
- var gl = this._gl;
- if ( !this._program || this._dirty ) {
-
- var compileClean;
-
- if ( !this._vertex.shader ) {
- compileClean = this._vertex.compile( gl );
- }
-
- if ( !this._fragment.shader ) {
- compileClean = this._fragment.compile( gl );
- }
-
- var attributeMap = getAttributeList( this._vertex.getText() );
-
- if ( compileClean ) {
-
- this._program = gl.createProgram();
-
- if ( attributeMap.Vertex ) {
- // force Vertex to be on 0
- gl.bindAttribLocation( this._program, 0, 'Vertex' );
- }
-
- gl.attachShader( this._program, this._vertex.shader );
- gl.attachShader( this._program, this._fragment.shader );
- MACROUTILS.timeStamp( 'osgjs.metrics:linkShader' );
- gl.linkProgram( this._program );
-
- if ( !gl.getProgramParameter( this._program, gl.LINK_STATUS ) && !gl.isContextLost() ) {
- var errLink = gl.getProgramInfoLog( this._program );
-
- Notify.errorFold( errLink, 'can\'t link program\nvertex shader:\n' + this._vertex.text + '\n fragment shader:\n' + this._fragment.text );
-
- // rawgl trick is for webgl inspector
- var debugShader = ( gl.rawgl !== undefined ? gl.rawgl : gl );
- if ( debugShader !== undefined && debugShader.getExtension !== undefined ) debugShader = debugShader.getExtension( 'WEBGL_debug_shaders' );
- if ( debugShader && errLink === 'Failed to create D3D shaders.\n' ) {
-
- Notify.error( debugShader.getTranslatedShaderSource( this._vertex.shader ) );
- Notify.error( debugShader.getTranslatedShaderSource( this._fragment.shader ) );
- }
-
- compileClean = false;
- }
- // TODO: better usage of validate.
- // as it's intended at shader program usage
- // validating against current gl state
- // Not for compilation stage
- // gl.validateProgram( this._program );
-
- }
-
- if ( !compileClean ) {
- // Any error, Any
- // Pink must die.
- if ( !Program.prototype._failSafeCache ) {
-
- var program = gl.createProgram();
- this._vertex.failSafe( gl );
- this._fragment.failSafe( gl );
-
- gl.attachShader( program, this._vertex.shader );
- gl.attachShader( program, this._fragment.shader );
- gl.linkProgram( program );
- gl.validateProgram( program );
-
- // cache to compile and allocate only once
- // not polluting the inspector
- Program.prototype._failSafeCache = program;
- }
- Notify.warn( 'FailSafe shader Activated ' );
- this._program = this._failSafeCache;
- }
-
- this._uniformsCache = new CustomMap();
- this._attributesCache = new CustomMap();
-
- this.cacheUniformList( gl, this._vertex.text );
- this.cacheUniformList( gl, this._fragment.text );
-
- this.cacheAttributeList( gl, window.Object.keys( attributeMap ) );
-
- this._dirty = false;
- }
-
- state.applyProgram( this._program );
- },
-
- cacheUniformList: function ( gl, str ) {
-
- var r = str.match( /uniform\s+\w+\s+\w+((\s)?\[(.*?)\])?/g );
- var map = this._uniformsCache;
- if ( r !== null ) {
- for ( var i = 0, l = r.length; i < l; i++ ) {
- var uniform = r[ i ].match( /uniform\s+\w+\s+(\w+)/ )[ 1 ];
- var uniformName = r[ i ].match( /uniform\s+\w+\s+(\w+)(\s?\[.*?\])?/ )[ 1 ];
- var location = gl.getUniformLocation( this._program, uniform );
- if ( location !== undefined && location !== null ) {
- if ( map[ uniformName ] === undefined ) {
- map[ uniformName ] = location;
- this._uniformsCache.dirty();
- }
- }
- }
- }
-
- },
-
- cacheAttributeList: function ( gl, attributeList ) {
-
- var map = this._attributesCache;
- for ( var i = 0, l = attributeList.length; i < l; i++ ) {
-
- var attr = attributeList[ i ];
- var location = gl.getAttribLocation( this._program, attr );
-
- if ( location !== -1 && location !== undefined ) {
- if ( map[ attr ] === undefined ) {
- map[ attr ] = location;
- this._attributesCache.dirty();
- }
- }
- }
-
- }
-} ) ), 'osg', 'Program' );
-
-module.exports = Program;
diff --git a/app/static/app/js/vendor/osgjs/osg/Projection.js b/app/static/app/js/vendor/osgjs/osg/Projection.js
deleted file mode 100644
index 2edb2d96..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Projection.js
+++ /dev/null
@@ -1,21 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Node = require( 'osg/Node' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-
-var Projection = function () {
- Node.call( this );
- this.projection = mat4.create();
-};
-Projection.prototype = MACROUTILS.objectInherit( Node.prototype, {
- getProjectionMatrix: function () {
- return this.projection;
- },
- setProjectionMatrix: function ( m ) {
- this.projection = m;
- }
-} );
-
-MACROUTILS.setTypeID( Projection );
-
-module.exports = Projection;
diff --git a/app/static/app/js/vendor/osgjs/osg/Quat.js b/app/static/app/js/vendor/osgjs/osg/Quat.js
deleted file mode 100644
index 36f8a9f3..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Quat.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require( 'osg/deprecated-MatrixVector/Quat' );
diff --git a/app/static/app/js/vendor/osgjs/osg/RenderBin.js b/app/static/app/js/vendor/osgjs/osg/RenderBin.js
deleted file mode 100644
index bbe3d42e..00000000
--- a/app/static/app/js/vendor/osgjs/osg/RenderBin.js
+++ /dev/null
@@ -1,321 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Notify = require( 'osg/notify' );
-var Object = require( 'osg/Object' );
-var osgMath = require( 'osg/math' );
-
-
-/**
- * RenderBin base class. Renderbin contains geometries to be rendered as a group,
- * renderbins are rendered once each. They can improve efficiency or
- * use different rendering algorithms.
- * A renderBin can contain further renderBins producing a tree hierarchy of renderBins.
- *
- * https://github.com/openscenegraph/osg/blob/master/include/osgUtil/RenderBin#L27-L32
- */
-var RenderBin = function ( sortMode ) {
- Object.call( this );
-
- this._leafs = [];
- this.positionedAttribute = [];
- this.stateGraphList = [];
-
- RenderBin.prototype.init.call( this, sortMode );
-};
-
-RenderBin.SORT_BY_STATE = 0;
-RenderBin.SORT_BACK_TO_FRONT = 1;
-RenderBin.SORT_FRONT_TO_BACK = 2;
-
-
-// change it at runtime for default RenderBin if needed
-RenderBin.defaultSortMode = RenderBin.SORT_BY_STATE;
-
-RenderBin.BinPrototypes = {
- RenderBin: function () {
- return RenderBin.getOrCreate().init();
- },
- DepthSortedBin: function () {
- return RenderBin.getOrCreate().init( RenderBin.SORT_BACK_TO_FRONT );
- }
-};
-
-
-var sortBackToFrontFunction = function ( a, b ) {
- return b._depth - a._depth;
-};
-
-
-var sortFrontToBackFunction = function ( a, b ) {
- return a._depth - b._depth;
-};
-
-var sortBinNumberFunction = function ( a, b ) {
- return a._binNum - b._binNum;
-};
-
-
-RenderBin.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- init: function ( sortMode ) {
-
- this._leafs.length = 0;
- this.positionedAttribute.length = 0;
- this._renderStage = undefined;
- this._bins = {};
- this.stateGraphList.length = 0;
- this._parent = undefined;
- this._binNum = 0;
-
- this._sorted = false;
- this._sortMode = sortMode !== undefined ? sortMode : RenderBin.defaultSortMode;
-
- this._drawCallback = undefined;
-
- return this;
- },
-
- _createRenderBin: function ( binName ) {
-
- // default render bin constructor
- var renderBinConstructor = RenderBin.BinPrototypes.RenderBin;
-
- if ( binName && RenderBin.BinPrototypes[ binName ] )
- renderBinConstructor = RenderBin.BinPrototypes[ binName ];
-
- return renderBinConstructor();
- },
-
- getStateGraphList: function () {
- return this.stateGraphList;
- },
-
- copyLeavesFromStateGraphListToRenderLeafList: function () {
-
- this._leafs.splice( 0, this._leafs.length );
- var detectedNaN = false;
-
- for ( var i = 0, l = this.stateGraphList.length; i < l; i++ ) {
- var leafs = this.stateGraphList[ i ].leafs;
- for ( var j = 0, k = leafs.length; j < k; j++ ) {
- var leaf = leafs[ j ];
- if ( osgMath.isNaN( leaf._depth ) ) {
- detectedNaN = true;
- } else {
- this._leafs.push( leaf );
- }
- }
- }
-
- if ( detectedNaN ) {
- Notify.debug( 'warning: RenderBin::copyLeavesFromStateGraphListToRenderLeafList() detected NaN depth values, database may be corrupted.' );
- }
- // empty the render graph list to prevent it being drawn along side the render leaf list (see drawImplementation.)
- this.stateGraphList.splice( 0, this.stateGraphList.length );
- },
-
- getSortMode: function () {
- return this._sortMode;
- },
-
- sortBackToFront: function () {
- this.copyLeavesFromStateGraphListToRenderLeafList();
- this._leafs.sort( sortBackToFrontFunction );
- },
-
- sortFrontToBack: function () {
- this.copyLeavesFromStateGraphListToRenderLeafList();
- this._leafs.sort( sortFrontToBackFunction );
- },
-
- sortImplementation: function () {
- var SortMode = RenderBin;
- switch ( this._sortMode ) {
- case SortMode.SORT_BACK_TO_FRONT:
- this.sortBackToFront();
- break;
- case SortMode.SORT_FRONT_TO_BACK:
- this.sortFrontToBack();
- break;
- case SortMode.SORT_BY_STATE:
- // do nothing
- break;
- }
- },
-
- sort: function () {
- if ( this._sorted ) {
- return;
- }
-
- var bins = this._bins;
- var keys = window.Object.keys( bins );
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- bins[ keys[ i ] ].sort();
- }
- this.sortImplementation();
-
- this._sorted = true;
- },
-
- setParent: function ( parent ) {
- this._parent = parent;
- },
-
- getParent: function () {
- return this._parent;
- },
-
- getBinNumber: function () {
- return this._binNum;
- },
-
- findOrInsert: function ( binNum, binName ) {
- var bin = this._bins[ binNum ];
-
- if ( !bin ) {
- bin = this._createRenderBin( binName );
- bin._parent = this;
- bin._binNum = binNum;
- bin._renderStage = this._renderStage;
- this._bins[ binNum ] = bin;
- }
-
- return bin;
- },
-
- getStage: function () {
- return this._renderStage;
- },
-
- addStateGraph: function ( sg ) {
- this.stateGraphList.push( sg );
- },
-
- reset: function () {
- this.stateGraphList.length = 0;
- this._bins = {};
- this.positionedAttribute.length = 0;
- this._leafs.length = 0;
- this._sorted = false;
- },
-
- draw: function ( state, previousRenderLeaf ) {
-
- var previousLeaf = previousRenderLeaf;
- // use callback drawImplementation if exist
- if ( this._drawCallback && this._drawCallback.drawImplementation ) {
- previousLeaf = this._drawCallback.drawImplementation( this, state, previousLeaf );
- } else {
- previousLeaf = this.drawImplementation( state, previousLeaf );
- }
-
- return previousLeaf;
- },
-
- applyPositionedAttribute: function ( state, positionedAttributes ) {
- // the idea is to set uniform 'globally' in uniform map.
- for ( var index = 0, l = positionedAttributes.length; index < l; index++ ) {
- var element = positionedAttributes[ index ];
- // add or set uniforms in state
- var stateAttribute = element[ 1 ];
- var matrix = element[ 0 ];
- state.setGlobalDefaultAttribute( stateAttribute );
- stateAttribute.apply( state );
- stateAttribute.applyPositionedUniform( matrix, state );
- state.haveAppliedAttribute( stateAttribute );
- }
- },
-
- drawImplementation: function ( state, previousRenderLeaf ) {
-
- var previousLeaf = previousRenderLeaf;
- var binsKeys = window.Object.keys( this._bins );
- var bins = this._bins;
-
- var binsArray = [];
-
- for ( var i = 0, l = binsKeys.length; i < l; i++ ) {
- var k = binsKeys[ i ];
- binsArray.push( bins[ k ] );
- }
-
- binsArray.sort( sortBinNumberFunction );
-
- var current = 0;
- var end = binsArray.length;
-
- var bin;
- // draw pre bins
- for ( ; current < end; current++ ) {
- bin = binsArray[ current ];
- if ( bin.getBinNumber() > 0 ) {
- break;
- }
- previousLeaf = bin.draw( state, previousLeaf );
- }
-
- // draw leafs
- previousLeaf = this.drawLeafs( state, previousLeaf );
-
- // draw post bins
- for ( ; current < end; current++ ) {
- bin = binsArray[ current ];
- previousLeaf = bin.draw( state, previousLeaf );
- }
- return previousLeaf;
- },
-
-
- drawLeafs: function ( state, previousRenderLeaf ) {
-
- var stateList = this.stateGraphList;
- var leafs = this._leafs;
- var previousLeaf = previousRenderLeaf;
- var leaf;
-
-
- // draw fine grained ordering.
- for ( var d = 0, dl = leafs.length; d < dl; d++ ) {
- leaf = leafs[ d ];
- leaf.render( state, previousLeaf );
- previousLeaf = leaf;
- }
-
-
- // draw coarse grained ordering.
- for ( var i = 0, l = stateList.length; i < l; i++ ) {
-
- var sg = stateList[ i ];
-
- for ( var j = 0, ll = sg.leafs.length; j < ll; j++ ) {
-
- leaf = sg.leafs[ j ];
- leaf.render( state, previousLeaf );
- previousLeaf = leaf;
-
- }
- }
- return previousLeaf;
- }
-} ), 'osg', 'RenderBin' );
-
-
-RenderBin.getOrCreate = function () {
-
- var l = RenderBin._reservedStack[ RenderBin._reservedStackCurrent++ ];
- if ( RenderBin._reservedStackCurrent === RenderBin._reservedStack.length ) {
- RenderBin._reservedStack.push( new RenderBin() );
- }
- return l;
-
-};
-
-RenderBin.resetStack = function () {
- RenderBin._reservedStackCurrent = 0;
-};
-
-RenderBin._reservedStack = [ new RenderBin() ];
-RenderBin._reservedStackCurrent = 0;
-
-module.exports = RenderBin;
diff --git a/app/static/app/js/vendor/osgjs/osg/RenderLeaf.js b/app/static/app/js/vendor/osgjs/osg/RenderLeaf.js
deleted file mode 100644
index 3f71273b..00000000
--- a/app/static/app/js/vendor/osgjs/osg/RenderLeaf.js
+++ /dev/null
@@ -1,213 +0,0 @@
-'use strict';
-var StateGraph = require( 'osg/StateGraph' );
-
-var CacheUniformApply = function ( state, program ) {
- this.modelUniform = program._uniformsCache[ state.modelMatrix.getName() ];
- this.viewUniform = program._uniformsCache[ state.viewMatrix.getName() ];
-
- this.apply = undefined;
- this.generateUniformsApplyMethods();
-};
-
-CacheUniformApply.prototype = {
-
-
- generateUniformsApplyMethods: function () {
-
- var functionStr = [ '//generated by RenderLeaf\n' ];
- functionStr.push( 'var gl = state.getGraphicContext();' );
- functionStr.push( 'var matrixModelViewChanged = state.applyModelViewMatrix( modelview );' );
- functionStr.push( 'state.applyProjectionMatrix( projection );' );
-
- if ( this.modelUniform !== undefined ) {
- functionStr.push( 'if ( matrixModelViewChanged ) {' );
- functionStr.push( ' var modelMatrix = state.modelMatrix;' );
- functionStr.push( ' modelMatrix.setMatrix4( model );' );
- functionStr.push( ' modelMatrix.apply( gl, this.modelUniform);' );
- functionStr.push( '};' );
- }
-
- if ( this.viewUniform !== undefined ) {
- functionStr.push( 'if ( matrixModelViewChanged ) {' );
- functionStr.push( ' var viewMatrix = state.viewMatrix;' );
- functionStr.push( ' viewMatrix.setMatrix4( view );' );
- functionStr.push( ' viewMatrix.apply( gl, this.viewUniform);' );
- functionStr.push( '};' );
- }
-
- // I am the evil, so please bother someone else
- /*jshint evil: true */
- // name the function
- // http://stackoverflow.com/questions/5905492/dynamic-function-name-in-javascript
- var func = ( new Function( 'state', 'modelview', 'model', 'view', 'projection', 'return function RenderLeafApplyMatrixUniformCache( state, modelview, model, view, projection ) { ' + functionStr.join( '\n' ) + '}' ) )();
- /*jshint evil: false */
-
- this.apply = func;
- }
-};
-
-
-var RenderLeaf = function () {
-
- this._parent = undefined;
- this._geometry = undefined;
- this._depth = 0.0;
-
- this._projection = undefined;
- this._view = undefined;
- this._model = undefined;
- this._modelView = undefined;
-};
-
-RenderLeaf.prototype = {
-
- reset: function () {
- this._parent = undefined;
- this._geometry = undefined;
- this._depth = 0.0;
-
- this._projection = undefined;
- this._view = undefined;
- this._model = undefined;
- this._modelView = undefined;
- },
-
- init: function ( parent, geom, projection, view, modelView, model, depth ) {
-
- this._parent = parent;
- this._geometry = geom;
- this._depth = depth;
-
- this._projection = projection;
- this._view = view;
- this._model = model;
- this._modelView = modelView;
-
- },
-
- drawGeometry: ( function () {
-
- return function ( state ) {
-
-
- var program = state.getLastProgramApplied();
- var programInstanceID = program.getInstanceID();
- var cache = state.getCacheUniformsApplyRenderLeaf();
- var obj = cache[ programInstanceID ];
-
- if ( !obj ) {
- obj = new CacheUniformApply( state, program );
- cache[ programInstanceID ] = obj;
- }
-
- obj.apply( state, this._modelView, this._model, this._view, this._projection, this._normal );
-
- this._geometry.drawImplementation( state );
-
- };
- } )(),
-
- render: ( function () {
- var idLastDraw = 0;
- var lastStateSetStackSize = -1;
-
- return function ( state, previousLeaf ) {
-
- var prevRenderGraph;
- var prevRenderGraphParent;
- var curRenderGraph = this._parent;
- var curRenderGraphParent = curRenderGraph.parent;
- var curRenderGraphStateSet = curRenderGraph.stateset;
-
- // When rendering a RenderLeaf we try to limit the state change
- // to do that Graph of State is created during the culling pass.
- // this graph contains nodes of StateGraph type see the class StateGraph
- //
- // So to limit switching of StateSet we check where are the common parent
- // between previous RenderLeaf and this current.
- //
- // There are 3 cases when there is a prev / current render leaf
- //
- //
- // pRG: previousRenderGraph
- // cRG: currentRenderGraph
- // pRL: previousRenderLeaf
- // cRL: currentRenderLeaf
- // each RG contains a StateSet
- //
- // A B C
- // +-----+ +-----+ +-----+ +-----+
- // | pRG | | cRG | +--+ RG +--+ | RG |
- // +--+--+ +--+--+ | +-----+ | +--+--+
- // | | | | |
- // +--v--+ +--v--+ +--v--+ +--v--+ +--v--+
- // | pRG | | cRG | | pRG | | cRG | +--+ RG +--+
- // +--+--+ +--+--+ +--+--+ +--+--+ | +-----+ |
- // | | | | | |
- // +--v--+ +--v--+ +--v--+ +--v--+ +--v--+ +--v--+
- // | pRL | | cRL | | pRL | | cRL | | pRL | | cRL |
- // +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
- //
- //
- // Case A
- // no common parent StateGraphNode we need to
- // popStateSet until we find the common parent and then
- // pushStateSet from the common parent to the current
- // RenderLeaf
- //
- // Case B
- // common parent StateGraphNode so we apply the current stateSet
- //
- // Case C
- // the StateGraphNode is common to the previous RenderLeaf so we dont need
- // to do anything except if we used an insertStateSet
- //
-
- if ( previousLeaf !== undefined ) {
-
- // apply state if required.
- prevRenderGraph = previousLeaf._parent;
- prevRenderGraphParent = prevRenderGraph.parent;
-
- if ( prevRenderGraphParent !== curRenderGraphParent ) {
-
- // Case A
- StateGraph.moveStateGraph( state, prevRenderGraphParent, curRenderGraphParent );
-
- state.applyStateSet( curRenderGraphStateSet );
-
- } else if ( curRenderGraph !== prevRenderGraph ) {
-
- // Case B
- state.applyStateSet( curRenderGraphStateSet );
-
- } else {
-
- // Case C
-
- // in osg we call apply but actually we dont need
- // except if the stateSetStack changed.
- // for example if insert/remove StateSet has been used
- if ( state._stateSetStackChanged( idLastDraw, lastStateSetStackSize ) ) {
- state.applyStateSet( curRenderGraphStateSet );
- }
- }
-
- } else {
-
- StateGraph.moveStateGraph( state, undefined, curRenderGraphParent );
- state.applyStateSet( curRenderGraphStateSet );
-
- }
-
- state._setStateSetsDrawID( ++idLastDraw );
- lastStateSetStackSize = state.getStateSetStackSize();
-
- this.drawGeometry( state );
-
- };
- } )()
-
-};
-
-module.exports = RenderLeaf;
diff --git a/app/static/app/js/vendor/osgjs/osg/RenderStage.js b/app/static/app/js/vendor/osgjs/osg/RenderStage.js
deleted file mode 100644
index fb435497..00000000
--- a/app/static/app/js/vendor/osgjs/osg/RenderStage.js
+++ /dev/null
@@ -1,313 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Camera = require( 'osg/Camera' );
-var FrameBufferObject = require( 'osg/FrameBufferObject' );
-var Notify = require( 'osg/notify' );
-var RenderBin = require( 'osg/RenderBin' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-
-
-/**
- * From OpenSceneGraph http://www.openscenegraph.org
- * RenderStage base class. Used for encapsulate a complete stage in
- * rendering - setting up of viewport, the projection and model
- * matrices and rendering the RenderBin's enclosed with this RenderStage.
- * RenderStage also has a dependency list of other RenderStages, each
- * of which must be called before the rendering of this stage. These
- * 'pre' rendering stages are used for advanced rendering techniques
- * like multistage pixel shading or impostors.
- */
-var RenderStage = function () {
-
- RenderBin.call( this );
- this.clearColor = vec4.create();
- this.preRenderList = [];
- this.postRenderList = [];
- // calling prototype to make sure
- // we call renderstage and not renderbin init
- RenderStage.prototype.init.call( this );
-
-};
-
-RenderStage.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( RenderBin.prototype, {
-
- // temporary, Utils.createPrototypeClass will solve this
- constructor: RenderStage,
-
-
- init: function () {
-
- RenderBin.prototype.init.call( this );
- this.positionedAttribute.length = 0;
- this.clearDepth = 1.0;
- vec4.set( this.clearColor, 0.0, 0.0, 0.0, 1.0 );
- /*jshint bitwise: false */
- this.clearMask = Camera.COLOR_BUFFER_BIT | Camera.DEPTH_BUFFER_BIT;
- /*jshint bitwise: true */
- this.camera = undefined;
- this.viewport = undefined;
- this.preRenderList.length = 0;
- this.postRenderList.length = 0;
- this._renderStage = this;
-
- return this;
- },
-
- reset: function () {
- RenderBin.prototype.reset.call( this );
- this.preRenderList.length = 0;
- this.postRenderList.length = 0;
- },
-
- setClearDepth: function ( depth ) {
- this.clearDepth = depth;
- },
-
- getClearDepth: function () {
- return this.clearDepth;
- },
-
- setClearColor: function ( color ) {
- vec4.copy( this.clearColor, color );
- },
-
- getClearColor: function () {
- return this.clearColor;
- },
-
- setClearMask: function ( mask ) {
- this.clearMask = mask;
- },
-
- getClearMask: function () {
- return this.clearMask;
- },
-
- setViewport: function ( vp ) {
- this.viewport = vp;
- },
-
- getViewport: function () {
- return this.viewport;
- },
-
- setCamera: function ( camera ) {
- this.camera = camera;
- },
-
- getCamera: function () {
- return this.camera;
- },
-
- getPositionedAttribute: function () {
- return this.positionedAttribute;
- },
-
- getPreRenderStageList: function () {
- return this.preRenderList;
- },
-
- getPostRenderStageList: function () {
- return this.postRenderList;
- },
-
- addPreRenderStage: function ( rs, order ) {
- for ( var i = 0, l = this.preRenderList.length; i < l; i++ ) {
- var render = this.preRenderList[ i ];
- if ( order < render.order ) {
- break;
- }
- }
- if ( i < this.preRenderList.length ) {
- this.preRenderList = this.preRenderList.splice( i, 0, {
- 'order': order,
- 'renderStage': rs
- } );
- } else {
- this.preRenderList.push( {
- 'order': order,
- 'renderStage': rs
- } );
- }
- },
-
- addPostRenderStage: function ( rs, order ) {
- for ( var i = 0, l = this.postRenderList.length; i < l; i++ ) {
- var render = this.postRenderList[ i ];
- if ( order < render.order ) {
- break;
- }
- }
- if ( i < this.postRenderList.length ) {
- this.postRenderList = this.postRenderList.splice( i, 0, {
- 'order': order,
- 'renderStage': rs
- } );
- } else {
- this.postRenderList.push( {
- 'order': order,
- 'renderStage': rs
- } );
- }
- },
-
- drawPreRenderStages: function ( state, previousRenderLeaf ) {
- var previousLeaf = previousRenderLeaf;
- for ( var i = 0, l = this.preRenderList.length; i < l; ++i ) {
- var sg = this.preRenderList[ i ].renderStage;
- previousLeaf = sg.draw( state, previousLeaf );
- }
- return previousLeaf;
- },
-
- draw: function ( state, previousRenderLeaf ) {
-
- if ( this.camera && this.camera.getInitialDrawCallback() ) {
- // if we have a camera with a final callback invoke it.
- this.camera.getInitialDrawCallback()( state );
- }
-
- var previousLeaf = this.drawPreRenderStages( state, previousRenderLeaf );
-
- previousLeaf = this.drawImplementation( state, previousLeaf );
-
- previousLeaf = this.drawPostRenderStages( state, previousLeaf );
-
- if ( this.camera && this.camera.getFinalDrawCallback() ) {
- // if we have a camera with a final callback invoke it.
- this.camera.getFinalDrawCallback()( state );
- }
-
- return previousLeaf;
-
- },
-
- sort: function () {
- for ( var i = 0, l = this.preRenderList.length; i < l; ++i ) {
- this.preRenderList[ i ].renderStage.sort();
- }
-
- RenderBin.prototype.sort.call( this );
-
- for ( var j = 0, k = this.postRenderList.length; j < k; ++j ) {
- this.postRenderList[ j ].renderStage.sort();
- }
- },
-
- drawPostRenderStages: function ( state, previousRenderLeaf ) {
- var previousLeaf = previousRenderLeaf;
- for ( var i = 0, l = this.postRenderList.length; i < l; ++i ) {
- var sg = this.postRenderList[ i ].renderStage;
- previousLeaf = sg.draw( state, previousLeaf );
- }
- return previousLeaf;
- },
-
- applyCamera: function ( state ) {
- var gl = state.getGraphicContext();
- if ( this.camera === undefined ) {
- gl.bindFramebuffer( gl.FRAMEBUFFER, null );
- return;
- }
- var viewport = this.camera.getViewport();
- var fbo = this.camera.frameBufferObject;
-
- if ( !fbo ) {
- fbo = new FrameBufferObject();
- this.camera.frameBufferObject = fbo;
- }
-
- if ( fbo.isDirty() ) {
-
- var attachments = this.camera.getAttachments();
-
- // framebuffer texture and renderbuffer must be same dimension
- // otherwise framebuffer is incomplete
- var framebufferWidth, framebufferHeight;
- var colorAttachment = attachments[ FrameBufferObject.COLOR_ATTACHMENT0 ];
- if ( colorAttachment && colorAttachment.texture ) {
- framebufferWidth = colorAttachment.texture.getWidth();
- framebufferHeight = colorAttachment.texture.getHeight();
- }
-
- // we should use a map in camera to avoid to regenerate the keys
- // each time. But because we dont have a lot of camera I guess
- // it does not change a lot
- var keys = window.Object.keys( attachments );
-
- if ( keys.length ) {
-
- // texture and renderbuffer must be same size.
-
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- var key = keys[ i ];
- var a = attachments[ key ];
-
- var attach = {};
- attach.attachment = a.attachment;
-
- if ( a.texture === undefined ) { //renderbuffer
-
- attach.format = a.format;
- attach.width = framebufferWidth !== undefined ? framebufferWidth : viewport.width();
- attach.height = framebufferHeight !== undefined ? framebufferHeight : viewport.height();
-
- } else if ( a.texture !== undefined ) {
-
- attach.texture = a.texture;
- attach.textureTarget = a.textureTarget;
-
- if ( a.format ) {
- attach.format = a.format;
- }
- }
-
- fbo.setAttachment( attach );
- }
- }
- }
- fbo.apply( state );
- },
-
- drawImplementation: function ( state, previousRenderLeaf ) {
- var gl = state.getGraphicContext();
-
- this.applyCamera( state );
-
- // projection clipping
- if ( this.viewport === undefined ) {
- Notify.log( 'RenderStage does not have a valid viewport' );
- }
- state.applyAttribute( this.viewport );
-
- // fragment clipping
- if ( this.camera ) {
- var scissor = this.camera.getStateSet() && this.camera.getStateSet().getAttribute( 'Scissor' );
- if ( scissor ) state.applyAttribute( scissor );
- }
-
- /*jshint bitwise: false */
- if ( this.clearMask !== 0x0 ) {
- if ( this.clearMask & gl.COLOR_BUFFER_BIT ) {
- gl.clearColor( this.clearColor[ 0 ], this.clearColor[ 1 ], this.clearColor[ 2 ], this.clearColor[ 3 ] );
- }
- if ( this.clearMask & gl.DEPTH_BUFFER_BIT ) {
- gl.depthMask( true );
- gl.clearDepth( this.clearDepth );
- }
- /*jshint bitwise: true */
- gl.clear( this.clearMask );
- }
-
- if ( this.positionedAttribute.length !== 0 ) {
- this.applyPositionedAttribute( state, this.positionedAttribute );
- }
-
- var previousLeaf = RenderBin.prototype.drawImplementation.call( this, state, previousRenderLeaf );
-
- return previousLeaf;
- }
-} ), 'osg', 'RenderStage' );
-
-
-module.exports = RenderStage;
diff --git a/app/static/app/js/vendor/osgjs/osg/Scissor.js b/app/static/app/js/vendor/osgjs/osg/Scissor.js
deleted file mode 100644
index d500aa9b..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Scissor.js
+++ /dev/null
@@ -1,67 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-
-var Scissor = function ( x, y, w, h ) {
-
- StateAttribute.call( this );
-
- this._x = x !== undefined ? x : -1;
- this._y = y !== undefined ? y : -1;
- this._width = w !== undefined ? w : -1;
-
- this._height = h !== undefined ? h : -1;
-};
-
-Scissor.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Scissor',
-
- cloneType: function () {
- return new Scissor();
- },
-
- apply: function ( state ) {
-
- var gl = state.getGraphicContext();
- if ( this._x !== -1 ) {
-
- gl.enable( gl.SCISSOR_TEST );
- gl.scissor( this._x, this._y, this._width, this._height );
-
- } else {
-
- gl.disable( gl.SCISSOR_TEST );
-
- }
- },
-
- setScissor: function ( x, y, width, height ) {
-
- this._x = x;
- this._y = y;
- this._width = width;
- this._height = height;
-
- },
-
- x: function () {
- return this._x;
- },
-
- y: function () {
- return this._y;
- },
-
- width: function () {
- return this._width;
- },
-
- height: function () {
- return this._height;
- }
-
-
-} ), 'osg', 'Scissor' );
-
-module.exports = Scissor;
diff --git a/app/static/app/js/vendor/osgjs/osg/Shader.js b/app/static/app/js/vendor/osgjs/osg/Shader.js
deleted file mode 100644
index 44e67f0b..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Shader.js
+++ /dev/null
@@ -1,196 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var Timer = require( 'osg/Timer' );
-var GLObject = require( 'osg/GLObject' );
-
-
-/**
- * Shader manage shader for vertex and fragment, you need both to create a glsl program.
- * @class Shader
- */
-var Shader = function ( type, text ) {
- GLObject.call( this );
- var t = type;
- if ( typeof ( type ) === 'string' ) {
- t = Shader[ type ];
- }
- this.type = t;
- this.setText( text );
-};
-
-Shader.VERTEX_SHADER = 0x8B31;
-Shader.FRAGMENT_SHADER = 0x8B30;
-
-// Debug Pink shader for when shader fails
-Shader.VS_DBG = 'attribute vec3 Vertex;uniform mat4 uModelViewMatrix;uniform mat4 uProjectionMatrix;void main(void) { gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);}';
-Shader.FS_DBG = 'precision lowp float; void main(void) { gl_FragColor = vec4(1.0, 0.6, 0.6, 1.0);}';
-
-var debugName = '\n#define SHADER_NAME FailSafe\n';
-Shader.VS_DBG += debugName;
-Shader.FS_DBG += debugName;
-
-
-// static cache of glShaders flagged for deletion, which will actually
-// be deleted in the correct GL context.
-Shader._sDeletedGLShaderCache = new window.Map();
-
-// static method to delete Program
-Shader.deleteGLShader = function ( gl, shader ) {
- if ( !Shader._sDeletedGLShaderCache.has( gl ) )
- Shader._sDeletedGLShaderCache.set( gl, [] );
- Shader._sDeletedGLShaderCache.get( gl ).push( shader );
-};
-
-// static method to flush all the cached glShaders which need to be deleted in the GL context specified
-Shader.flushDeletedGLShaders = function ( gl, availableTime ) {
- // if no time available don't try to flush objects.
- if ( availableTime <= 0.0 ) return availableTime;
- if ( !Shader._sDeletedGLShaderCache.has( gl ) ) return availableTime;
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- var deleteList = Shader._sDeletedGLShaderCache.get( gl );
- var numShaders = deleteList.length;
- for ( var i = numShaders - 1; i >= 0 && elapsedTime < availableTime; i-- ) {
- gl.deleteShader( deleteList[ i ] );
- deleteList.splice( i, 1 );
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- }
- return availableTime -= elapsedTime;
-};
-
-Shader.flushAllDeletedGLShaders = function ( gl ) {
- if ( !Shader._sDeletedGLShaderCache.has( gl ) ) return;
- var deleteList = Shader._sDeletedGLShaderCache.get( gl );
- var numShaders = deleteList.length;
- for ( var i = numShaders - 1; i >= 0; i-- ) {
- gl.deleteShader( deleteList[ i ] );
- deleteList.splice( i, 1 );
- }
- return;
-};
-
-/** @lends Shader.prototype */
-Shader.prototype = MACROUTILS.objectInherit( GLObject.prototype, {
- setText: function ( text ) {
- this.text = text;
- },
- getText: function () {
- return this.text;
- },
- // this is where it creates a fail safe shader that should work everywhere
- failSafe: function ( gl ) {
- this.shader = gl.createShader( this.type );
- gl.shaderSource( this.shader, this.type === Shader.VERTEX_SHADER ? Shader.VS_DBG : Shader.FS_DBG );
- gl.compileShader( this.shader );
- },
- // webgl shader compiler error to source contextualization
- // for better console log messages
- processErrors: function ( errors, source ) {
- // regex to extract error message and line from webgl compiler reporting
- var r = /ERROR: [\d]+:([\d]+): (.+)/gmi;
- // split sources in indexable per line array
- var lines = source.split( '\n' );
- var linesLength = lines.length;
- if ( linesLength === 0 ) return;
-
- var i, m;
-
- // IE reporting is not the same
- if ( r.exec( errors ) === null ) {
- r = /Shader compilation errors\n\((\d+)\, \d+\): (.+)/gmi;
- }
-
- // reset index to start.
- r.lastIndex = 0;
-
- while ( ( m = r.exec( errors ) ) != null ) {
- if ( m.index === r.lastIndex ) {
- r.lastIndex++; // moving between errors
- }
- // get error line
- var line = parseInt( m[ 1 ] );
-
- if ( line > linesLength ) continue;
- // webgl error report.
- Notify.error( 'ERROR ' + m[ 2 ] + ' in line ' + line );
-
- var minLine = Math.max( 0, line - 7 );
- var maxLine = Math.max( 0, line - 2 );
- // for context
- // log surrounding line priori to error with bof check
- for ( i = minLine; i <= maxLine; i++ ) {
- Notify.warn( lines[ i ].replace( /^[ \t]+/g, '' ) );
- }
-
- // Warn adds a lovely /!\ icon in front of the culprit line
- maxLine = Math.max( 0, line - 1 );
- Notify.error( lines[ maxLine ].replace( /^[ \t]+/g, '' ) );
-
- minLine = Math.min( linesLength, line );
- maxLine = Math.min( linesLength, line + 5 );
- // for context
- // surrounding line posterior to error (with eof check)
- for ( i = minLine; i < maxLine; i++ ) {
- Notify.warn( lines[ i ].replace( /^[ \t]+/g, '' ) );
- }
- }
- },
-
- compile: function ( gl ) {
- if ( !this._gl ) this.setGraphicContext( gl );
- this.shader = gl.createShader( this.type );
-
- var shaderText = this.text;
- if ( Shader.enableGLSLOptimizer && Shader.glslOptimizer ) {
- var shaderTypeString = this.type === Shader.VERTEX_SHADER ? 'vertex' : 'fragment';
- Notify.infoFold( shaderTypeString + ' shader before optimization', shaderText );
- // 1: opengl
- // 2: opengl es 2.0
- // 3: opengl es 3.0
- var optimized = Shader.glslOptimizer( shaderText, '2', this.type === Shader.VERTEX_SHADER );
- if ( optimized.indexOf( 'Error:' ) !== -1 ) {
- Notify.error( optimized );
- } else if ( optimized.length <= 1 ) {
- Notify.warnFold( 'glsl optimizer returned an empty shader, the original will be used', shaderText );
- } else {
- Notify.infoFold( shaderTypeString + ' shader after optimization', optimized );
- shaderText = optimized;
- }
- }
-
- gl.shaderSource( this.shader, shaderText );
- MACROUTILS.timeStamp( 'osgjs.metrics:compileShader' );
- gl.compileShader( this.shader );
- if ( !gl.getShaderParameter( this.shader, gl.COMPILE_STATUS ) && !gl.isContextLost() ) {
-
- var err = gl.getShaderInfoLog( this.shader );
- this.processErrors( err, shaderText );
-
- var tmpText = '\n' + shaderText;
- var splittedText = tmpText.split( '\n' );
- var newText = '\n';
- for ( var i = 0, l = splittedText.length; i < l; ++i ) {
- newText += i + ' ' + splittedText[ i ] + '\n';
- }
- // still logging whole source but folded
- Notify.debugFold( 'can\'t compile shader', newText );
-
- return false;
- }
- return true;
- },
- releaseGLObjects: function () {
- if ( this._gl !== undefined ) {
- Shader.deleteGLShader( this._gl, this.shader );
- }
- this.shader = undefined;
- }
-} );
-
-Shader.create = function ( type, text ) {
- Notify.log( 'Shader.create is deprecated, use new Shader with the same arguments instead' );
- return new Shader( type, text );
-};
-
-module.exports = Shader;
diff --git a/app/static/app/js/vendor/osgjs/osg/Stack.js b/app/static/app/js/vendor/osgjs/osg/Stack.js
deleted file mode 100644
index 64d20b63..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Stack.js
+++ /dev/null
@@ -1,32 +0,0 @@
-'use strict';
-var Stack = function () {
- this.globalDefault = undefined;
- this.lastApplied = undefined;
- this.asChanged = false;
-
- this._values = [];
- this._back = undefined;
-};
-
-Stack.prototype = {
- empty: function () {
- return this._values.length === 0;
- },
- values: function () {
- return this._values;
- },
- back: function () {
- return this._back;
- },
- push: function ( value ) {
- this._values.push( value );
- this._back = value;
- },
- pop: function () {
- var value = this._values.pop();
- this._back = this._values[ this._values.length - 1 ];
- return value;
- }
-};
-
-module.exports = Stack;
diff --git a/app/static/app/js/vendor/osgjs/osg/State.js b/app/static/app/js/vendor/osgjs/osg/State.js
deleted file mode 100644
index 79f0b17c..00000000
--- a/app/static/app/js/vendor/osgjs/osg/State.js
+++ /dev/null
@@ -1,1343 +0,0 @@
-'use strict';
-var Map = require( 'osg/Map' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Notify = require( 'osg/notify' );
-var Object = require( 'osg/Object' );
-var Program = require( 'osg/Program' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var Stack = require( 'osg/Stack' );
-var Uniform = require( 'osg/Uniform' );
-var MACROUTILS = require( 'osg/Utils' );
-var WebGLCaps = require( 'osg/WebGLCaps' );
-
-
-var checkUniformCache = [
- undefined,
- function uniformCheck1( uniformArray, cacheArray ) {
- if ( uniformArray[ 0 ] === cacheArray[ 0 ] ) return true;
- cacheArray[ 0 ] = uniformArray[ 0 ];
- return false;
- },
-
- function uniformCheck2( uniformArray, cacheArray ) {
- if ( uniformArray[ 0 ] === cacheArray[ 0 ] && uniformArray[ 1 ] === cacheArray[ 1 ] ) return true;
- cacheArray[ 0 ] = uniformArray[ 0 ];
- cacheArray[ 1 ] = uniformArray[ 1 ];
- return false;
- },
-
- function uniformCheck3( uniformArray, cacheArray ) {
- if ( uniformArray[ 0 ] === cacheArray[ 0 ] && uniformArray[ 1 ] === cacheArray[ 1 ] && uniformArray[ 2 ] === cacheArray[ 2 ] ) return true;
- cacheArray[ 0 ] = uniformArray[ 0 ];
- cacheArray[ 1 ] = uniformArray[ 1 ];
- cacheArray[ 2 ] = uniformArray[ 2 ];
- return false;
- },
-
- function uniformCheck4( uniformArray, cacheArray ) {
- if ( uniformArray[ 0 ] === cacheArray[ 0 ] && uniformArray[ 1 ] === cacheArray[ 1 ] && uniformArray[ 2 ] === cacheArray[ 2 ] && uniformArray[ 3 ] === cacheArray[ 3 ] ) return true;
- cacheArray[ 0 ] = uniformArray[ 0 ];
- cacheArray[ 1 ] = uniformArray[ 1 ];
- cacheArray[ 2 ] = uniformArray[ 2 ];
- cacheArray[ 3 ] = uniformArray[ 3 ];
- return false;
- }
-];
-
-
-var State = function ( shaderGeneratorProxy ) {
- Object.call( this );
-
- this._graphicContext = undefined;
- this._shaderGeneratorProxy = shaderGeneratorProxy;
-
- if ( shaderGeneratorProxy === undefined )
- console.break();
-
- this._currentVAO = null;
- this._currentIndexVBO = null;
-
- this.vertexAttribList = [];
- this.stateSets = new Stack();
- this._shaderGeneratorNames = new Stack();
- this.uniforms = new Map();
-
- this.textureAttributeMapList = [];
-
- this.attributeMap = new Map();
-
- this.modelMatrix = Uniform.createMatrix4( mat4.create(), 'uModelMatrix' );
- this.viewMatrix = Uniform.createMatrix4( mat4.create(), 'uViewMatrix' );
- this.modelViewMatrix = Uniform.createMatrix4( mat4.create(), 'uModelViewMatrix' );
- this.projectionMatrix = Uniform.createMatrix4( mat4.create(), 'uProjectionMatrix' );
- this.modelViewNormalMatrix = Uniform.createMatrix4( mat4.create(), 'uModelViewNormalMatrix' );
-
- // track uniform for color array enabled
- var arrayColorEnable = new Stack();
- arrayColorEnable.globalDefault = Uniform.createFloat1( 0.0, 'uArrayColorEnabled' );
-
- this.uniforms.setMap( {
- ArrayColorEnabled: arrayColorEnable
- } );
-
-
- this._previousColorAttribPair = {};
- this.vertexAttribMap = {};
- this.vertexAttribMap._disable = [];
- this.vertexAttribMap._keys = [];
-
- this._frameStamp = undefined;
-
- // we dont use Map because in this use case with a few entries
- // {} is faster
- this._programCommonUniformsCache = {};
-
- // keep pointer on the last applied modelview matrix
- this._modelViewMatrix = undefined;
- // keep pointer on the last applied projection matrix
- this._projectionMatrix = undefined;
-
-
- // keep track of last applied program
- this._program = undefined;
- // inject a default program to initialize the stack Program
- this.applyAttribute( new Program() );
-
- this._numPushStateSet = 0;
- this._numApply = 0;
-
- this._programUniformCache = [];
- this._cacheUniformId = 0;
-};
-
-State.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- getCacheUniformsApplyRenderLeaf: function () {
- return this._programCommonUniformsCache;
- },
-
- setGraphicContext: function ( graphicContext ) {
- this._graphicContext = graphicContext;
- this._extVAO = WebGLCaps.instance( graphicContext ).getWebGLExtension( 'OES_vertex_array_object' );
- },
-
- getGraphicContext: function () {
- return this._graphicContext;
- },
-
- getShaderGeneratorProxy: function () {
- return this._shaderGeneratorProxy;
- },
-
- pushCheckOverride: function ( stack, object, maskValue ) {
- // object can be a Uniform, an Attribute, or a shader generator name
- if ( stack.values().length === 0 ) {
- stack.push( this.getObjectPair( object, maskValue ) );
- } else if ( ( stack.back().value & StateAttribute.OVERRIDE ) && !( maskValue & StateAttribute.PROTECTED ) ) {
- stack.push( stack.back() );
- } else {
- stack.push( this.getObjectPair( object, maskValue ) );
- }
- },
-
- pushStateSet: function ( stateset ) {
- this._numPushStateSet++;
- this.stateSets.push( stateset );
-
- if ( stateset.attributeMap ) {
- this.pushAttributeMap( this.attributeMap, stateset.attributeMap );
- }
-
- if ( stateset.textureAttributeMapList ) {
- var list = stateset.textureAttributeMapList;
- for ( var textureUnit = 0, l = list.length; textureUnit < l; textureUnit++ ) {
- if ( !list[ textureUnit ] ) {
- continue;
- }
-
- var textureUnitAttributeMap = this.getOrCreateTextureAttributeMap( textureUnit );
- this.pushAttributeMap( textureUnitAttributeMap, list[ textureUnit ] );
- }
- }
-
- if ( stateset.uniforms ) {
- this.pushUniformsList( this.uniforms, stateset.uniforms );
- }
- var generatorPair = stateset.getShaderGeneratorPair();
- if ( generatorPair )
- this.pushCheckOverride( this._shaderGeneratorNames, generatorPair.getShaderGeneratorName(), generatorPair.getValue() );
- },
-
- getStateSetStackSize: function () {
- return this.stateSets.values().length;
- },
-
- insertStateSet: ( function () {
- var tmpStack = [];
-
- return function ( pos, stateSet ) {
-
- tmpStack.length = 0;
- var length = this.getStateSetStackSize();
- while ( length > pos ) {
- tmpStack.push( this.stateSets.back() );
- this.popStateSet();
- length--;
- }
-
- this.pushStateSet( stateSet );
-
- for ( var i = tmpStack.length - 1; i >= 0; i-- ) {
- this.pushStateSet( tmpStack[ i ] );
- }
-
- };
- } )(),
-
- removeStateSet: ( function () {
- var tmpStack = [];
-
- return function ( pos ) {
-
- var length = this.getStateSetStackSize();
- if ( pos >= length ) {
- Notify.warn( 'Warning State:removeStateSet ' + pos + ' out of range' );
- return;
- }
-
- tmpStack.length = 0;
-
- // record the StateSet above the one we intend to remove
- while ( length - 1 > pos ) {
- tmpStack.push( this.stateSets.back() );
- this.popStateSet();
- length--;
- }
-
- // remove the intended StateSet as well
- this.popStateSet();
-
- // push back the original ones that were above the remove StateSet
- for ( var i = tmpStack.length - 1; i >= 0; i-- ) {
- this.pushStateSet( tmpStack[ i ] );
- }
-
- };
- } )(),
-
-
- // needed because we use a cache during the frame to avoid
- // applying uniform or operation. At each frame we need to
- // invalidate those informations
- resetCacheFrame: function () {
- this._modelViewMatrix = this._projectionMatrix = undefined;
- },
-
- resetStats: function () {
- this._numApply = 0;
- this._numPushStateSet = 0;
- },
-
- // apply program if needed
- applyProgram: function ( program ) {
- if ( this._program === program ) return;
- this._program = program;
- this.getGraphicContext().useProgram( program );
- },
-
- applyModelViewMatrix: ( function () {
-
- var normal = mat4.create();
-
- return function StateApplyModelViewMatrix( matrix ) {
-
- if ( this._modelViewMatrix === matrix ) return false;
-
- var program = this.getLastProgramApplied();
- var uniformCache = program.getUniformsCache();
- var mu = this.modelViewMatrix;
- var mul = uniformCache.uModelViewMatrix;
- var gc = this.getGraphicContext();
- if ( mul ) {
-
- mu.setMatrix4( matrix );
- mu.apply( gc, mul );
- }
-
- var sendNormal;
- if ( this._modelViewMatrix ) {
-
- // check if we need to push normal
- // test rotation component, if not diff
- // we dont need to send normal
- var m2 = this._modelViewMatrix;
- for ( var i = 0; i < 11; i++ ) {
- if ( matrix[ i ] !== m2[ i ] ) {
- sendNormal = true;
- break;
- }
- }
- } else {
- sendNormal = true;
- }
-
- if ( sendNormal ) {
- mu = this.modelViewNormalMatrix;
- mul = uniformCache.uModelViewNormalMatrix;
- if ( mul ) {
-
- normal[ 0 ] = matrix[ 0 ];
- normal[ 1 ] = matrix[ 1 ];
- normal[ 2 ] = matrix[ 2 ];
- normal[ 4 ] = matrix[ 4 ];
- normal[ 5 ] = matrix[ 5 ];
- normal[ 6 ] = matrix[ 6 ];
- normal[ 8 ] = matrix[ 8 ];
- normal[ 9 ] = matrix[ 9 ];
- normal[ 10 ] = matrix[ 10 ];
-
- mat4.invert( normal, normal );
- mat4.transpose( normal, normal );
-
- mu.setMatrix4( normal );
- mu.apply( gc, mul );
- }
- }
-
- this._modelViewMatrix = matrix;
- return true;
- };
- } )(),
-
-
- applyModelViewMatrixEperiment: ( function () {
-
- var normal = mat4.create();
-
- var checkMatrix = function ( m0, m1 ) {
- if ( m0[ 0 ] !== m1[ 0 ] ) return true;
- if ( m0[ 1 ] !== m1[ 1 ] ) return true;
- if ( m0[ 2 ] !== m1[ 2 ] ) return true;
- if ( m0[ 4 ] !== m1[ 4 ] ) return true;
- if ( m0[ 5 ] !== m1[ 5 ] ) return true;
- if ( m0[ 6 ] !== m1[ 6 ] ) return true;
- if ( m0[ 8 ] !== m1[ 8 ] ) return true;
- if ( m0[ 9 ] !== m1[ 9 ] ) return true;
- if ( m0[ 10 ] !== m1[ 10 ] ) return true;
- return false;
- };
-
- var epsilon = 1e-6;
- var scaleEpsilonMax = 1.0 + epsilon;
- var scaleEpsilonMin = 1.0 - epsilon;
-
- return function StateApplyModelViewMatrix( matrix ) {
- if ( this._modelViewMatrix === matrix ) return false;
-
- var program = this.getLastProgramApplied();
-
- var mu = this.modelViewMatrix;
- var mul = program.getUniformsCache().uModelViewMatrix;
- if ( mul ) {
-
- mu.setMatrix4( matrix );
- mu.apply( this.getGraphicContext(), mul );
- }
-
- var sendNormal = true;
- if ( this._modelViewMatrix ) {
- sendNormal = checkMatrix( matrix, this._modelViewMatrix );
- // check if we need to push normal
- // test rotation component, if not diff
- // we dont need to send normal
- // for ( var i = 0; i < 11; i++ ) {
- // if ( matrix[ i ] !== this._modelViewMatrix[ i ] ) {
- // sendNormal = true;
- // break;
- // }
- // }
- }
-
- if ( sendNormal ) {
- mu = this.modelViewNormalMatrix;
- mul = program.getUniformsCache().uModelViewNormalMatrix;
- if ( mul ) {
-
- // mat4.copy( normal , matrix );
- normal[ 0 ] = matrix[ 0 ];
- normal[ 1 ] = matrix[ 1 ];
- normal[ 2 ] = matrix[ 2 ];
- normal[ 4 ] = matrix[ 4 ];
- normal[ 5 ] = matrix[ 5 ];
- normal[ 6 ] = matrix[ 6 ];
- normal[ 8 ] = matrix[ 8 ];
- normal[ 9 ] = matrix[ 9 ];
- normal[ 10 ] = matrix[ 10 ];
-
- // check for scaling
- var xlen = normal[ 0 ] * normal[ 0 ] + normal[ 4 ] * normal[ 4 ] + normal[ 8 ] * normal[ 8 ];
- var ylen = normal[ 1 ] * normal[ 1 ] + normal[ 5 ] * normal[ 5 ] + normal[ 9 ] * normal[ 9 ];
- var zlen = normal[ 2 ] * normal[ 2 ] + normal[ 6 ] * normal[ 6 ] + normal[ 10 ] * normal[ 10 ];
-
- // http://www.gamedev.net/topic/637192-detect-non-uniform-scaling-in-matrix/
- if ( xlen > scaleEpsilonMax || xlen < scaleEpsilonMin ||
- ylen > scaleEpsilonMax || ylen < scaleEpsilonMin ||
- zlen > scaleEpsilonMax || zlen < scaleEpsilonMin ) {
-
- mat4.invert( normal, normal );
- mat4.transpose( normal, normal );
- }
-
- mu.setMatrix4( normal );
- mu.apply( this.getGraphicContext(), mul );
- }
- }
-
- this._modelViewMatrix = matrix;
- return true;
- };
- } )(),
-
- applyProjectionMatrix: function ( matrix ) {
-
- if ( this._projectionMatrix === matrix ) return;
-
- this._projectionMatrix = matrix;
- var program = this.getLastProgramApplied();
- var mu = this.projectionMatrix;
-
- var mul = program.getUniformsCache()[ mu.getName() ];
- if ( mul ) {
-
- mu.setMatrix4( matrix );
- mu.apply( this.getGraphicContext(), mul );
-
- }
- },
-
- applyStateSet: function ( stateset ) {
- this.pushStateSet( stateset );
- this.apply();
- this.popStateSet();
- },
-
- popAllStateSets: function () {
- while ( this.stateSets.values().length ) {
- this.popStateSet();
- }
- },
-
- popStateSet: function () {
-
- if ( this.stateSets.empty() ) return;
-
- var stateset = this.stateSets.pop();
-
- if ( stateset.attributeMap ) {
- this.popAttributeMap( this.attributeMap, stateset.attributeMap );
- }
-
- if ( stateset.textureAttributeMapList ) {
- var list = stateset.textureAttributeMapList;
- for ( var textureUnit = 0, l = list.length; textureUnit < l; textureUnit++ ) {
- if ( !list[ textureUnit ] ) {
- continue;
- }
- this.popAttributeMap( this.textureAttributeMapList[ textureUnit ], list[ textureUnit ] );
- }
- }
-
- if ( stateset.uniforms ) {
- this.popUniformsList( this.uniforms, stateset.uniforms );
- }
-
- if ( stateset.getShaderGeneratorPair() ) {
- this._shaderGeneratorNames.pop();
- }
- },
-
- _createAttributeStack: function ( attributeMap, key, globalDefault ) {
-
- var attributeStack = new Stack();
-
- attributeMap[ key ] = attributeStack;
- attributeMap[ key ].globalDefault = globalDefault;
- attributeMap.dirty();
-
- return attributeStack;
-
- },
-
- haveAppliedAttribute: function ( attribute ) {
-
- var key = attribute.getTypeMember();
- var attributeStack = this.attributeMap[ key ];
- if ( !attributeStack ) {
- attributeStack = this._createAttributeStack( this.attributeMap, key, attribute.cloneType() );
- }
- attributeStack.lastApplied = attribute;
- attributeStack.asChanged = true;
-
- },
-
- applyAttribute: function ( attribute ) {
-
- var key = attribute.getTypeMember();
-
- var attributeMap = this.attributeMap;
- var attributeStack = attributeMap[ key ];
- if ( !attributeStack ) {
- attributeStack = this._createAttributeStack( this.attributeMap, key, attribute.cloneType() );
- }
-
- if ( attributeStack.lastApplied !== attribute ) {
-
- if ( attribute.apply ) {
- attribute.apply( this );
- }
- attributeStack.lastApplied = attribute;
- attributeStack.asChanged = true;
- }
- },
-
- applyTextureAttribute: function ( unit, attribute ) {
-
-
- var gl = this.getGraphicContext();
- gl.activeTexture( gl.TEXTURE0 + unit );
- var key = attribute.getTypeMember();
-
- if ( !this.textureAttributeMapList[ unit ] ) {
- this.textureAttributeMapList[ unit ] = new Map();
- }
-
- var textureUnitAttributeMap = this.getOrCreateTextureAttributeMap( unit );
- var attributeStack = textureUnitAttributeMap[ key ];
- if ( !attributeStack ) {
- attributeStack = this._createAttributeStack( textureUnitAttributeMap, key, attribute.cloneType() );
- }
-
-
- if ( attributeStack.lastApplied !== attribute ) {
-
- if ( attribute.apply ) {
-
- // there is a texture we bind it.
- attribute.apply( this, unit );
-
- // TODO: optimization:
- // if attribute.isTextureNull()
- // only bind if last Framebuffer Texture Binded
- // are the same as those we try to write from
- // need rewrite of the fbo attachments system to keep history
- // and state to keep last fbo textures binded.
- // (applyTextureAttributeStack concerned too)
- }
- attributeStack.lastApplied = attribute;
- attributeStack.asChanged = true;
- }
- },
-
- getLastProgramApplied: function () {
- return this.attributeMap.Program.lastApplied;
- },
-
- applyDefault: function () {
- // reset GL State To Default
- // we skip the textures/uniforms/shaders call since they are not necessary
-
- // noticed that we accumulate lot of stack, maybe because of the stateGraph
- // CP: ^^ really ? check it / report an issue
- this.popAllStateSets();
-
- this.applyAttributeMap( this.attributeMap );
- this.applyTextureAttributeMapList( this.textureAttributeMapList );
- },
-
- apply: function () {
-
- var lastProgram = this.getLastProgramApplied();
-
- this.applyAttributeMap( this.attributeMap );
- this.applyTextureAttributeMapList( this.textureAttributeMapList );
-
- var generatedProgram = this._generateAndApplyProgram();
-
- if ( generatedProgram ) {
- // will cache uniform and apply them with the program
-
- this._applyGeneratedProgramUniforms( this.attributeMap.Program.lastApplied );
-
- } else {
-
- // custom program so we will iterate on uniform from the program and apply them
- // but in order to be able to use Attribute in the state graph we will check if
- // our program want them. It must be defined by the user
- this._applyCustomProgramUniforms( this.attributeMap.Program.lastApplied );
-
- }
-
- // reset reference of last applied matrix
- if ( lastProgram !== this.getLastProgramApplied() ) {
- this._modelViewMatrix = undefined;
- this._projectionMatrix = undefined;
- }
- },
-
-
- applyAttributeMap: function ( attributeMap ) {
-
- var attributeStack;
- var attributeMapKeys = attributeMap.getKeys();
-
- for ( var i = 0, l = attributeMapKeys.length; i < l; i++ ) {
- var key = attributeMapKeys[ i ];
-
- attributeStack = attributeMap[ key ];
- if ( !attributeStack || !attributeStack.asChanged ) {
- continue;
- }
-
- var attribute;
- if ( attributeStack.values().length === 0 ) {
- attribute = attributeStack.globalDefault;
- } else {
- attribute = attributeStack.back().object;
- }
-
- /*develblock:start*/
- Notify.assert( key === attribute.getTypeMember(), 'State:applyAttributeMap attribute key ' + key + ' !== ' + attribute.getTypeMember() );
- /*develblock:end*/
-
-
- if ( attributeStack.lastApplied !== attribute ) {
-
- if ( attribute.apply )
- attribute.apply( this );
-
- attributeStack.lastApplied = attribute;
-
- }
- attributeStack.asChanged = false;
-
- }
- },
-
- getObjectPair: function ( object, value ) {
- return {
- object: object,
- value: value
- };
- },
-
- pushUniformsList: function ( uniformMap, stateSetUniformMap ) {
- /*jshint bitwise: false */
- var name;
- var uniform;
-
- var stateSetUniformMapKeys = stateSetUniformMap.getKeys();
-
- for ( var i = 0, l = stateSetUniformMapKeys.length; i < l; i++ ) {
- var key = stateSetUniformMapKeys[ i ];
- var uniformPair = stateSetUniformMap[ key ];
- uniform = uniformPair.getUniform();
- name = uniform.getName();
- if ( !uniformMap[ name ] ) {
- this._createAttributeStack( uniformMap, name, uniform );
- }
-
- this.pushCheckOverride( uniformMap[ name ], uniform, uniformPair.getValue() );
- }
- /*jshint bitwise: true */
- },
-
- popUniformsList: function ( uniformMap, stateSetUniformMap ) {
-
- var stateSetUniformMapKeys = stateSetUniformMap.getKeys();
-
- for ( var i = 0, l = stateSetUniformMapKeys.length; i < l; i++ ) {
- var key = stateSetUniformMapKeys[ i ];
- uniformMap[ key ].pop();
- }
- },
-
-
- // this funtion must called only if stack has changed
- // check applyTextureAttributeMapList
- _applyTextureAttributeStack: function ( gl, textureUnit, attributeStack ) {
-
- var attribute;
- if ( attributeStack.values().length === 0 ) {
- attribute = attributeStack.globalDefault;
- } else {
- attribute = attributeStack.back().object;
- }
-
- // if the the stack has changed but the last applied attribute is the same
- // then we dont need to apply it again
- if ( attributeStack.lastApplied !== attribute ) {
-
- gl.activeTexture( gl.TEXTURE0 + textureUnit );
- attribute.apply( this, textureUnit );
-
- attributeStack.lastApplied = attribute;
- }
-
- attributeStack.asChanged = false;
- },
-
- applyTextureAttributeMapList: function ( textureAttributesMapList ) {
- var gl = this._graphicContext;
- var textureAttributeMap;
-
- for ( var textureUnit = 0, l = textureAttributesMapList.length; textureUnit < l; textureUnit++ ) {
- textureAttributeMap = textureAttributesMapList[ textureUnit ];
- if ( !textureAttributeMap ) {
- continue;
- }
-
-
- var textureAttributeMapKeys = textureAttributeMap.getKeys();
-
- for ( var i = 0, lt = textureAttributeMapKeys.length; i < lt; i++ ) {
- var key = textureAttributeMapKeys[ i ];
-
- var attributeStack = textureAttributeMap[ key ];
-
- // skip if not stack or not changed in stack
- if ( !attributeStack || !attributeStack.asChanged ) continue;
-
- this._applyTextureAttributeStack( gl, textureUnit, attributeStack );
- // var attribute;
- // if ( attributeStack.values().length === 0 ) {
- // attribute = attributeStack.globalDefault;
- // } else {
- // attribute = attributeStack.back().object;
- // }
- // if ( attributeStack.asChanged ) {
-
- // gl.activeTexture( gl.TEXTURE0 + textureUnit );
- // attribute.apply( this, textureUnit );
- // attributeStack.lastApplied = attribute;
- // attributeStack.asChanged = false;
-
- // }
- }
- }
- },
-
- setGlobalDefaultValue: function ( attribute ) {
- Notify.log( 'setGlobalDefaultValue is deprecated, use instead setGlobalDefaultAttribute' );
- this.setGlobalDefaultAttribute( attribute );
- },
-
- setGlobalDefaultAttribute: function ( attribute ) {
- var typeMember = attribute.getTypeMember();
- var attributeMap = this.attributeMap;
-
- if ( attributeMap[ typeMember ] === undefined ) {
- this._createAttributeStack( attributeMap, typeMember, attribute );
- } else {
- attributeMap[ typeMember ].globalDefault = attribute;
- }
- },
-
- getGlobalDefaultAttribute: function ( typeMember ) {
- var attributeMap = this.attributeMap;
- if ( attributeMap[ typeMember ] === undefined ) return undefined;
-
- return attributeMap[ typeMember ].globalDefault;
- },
-
- setGlobalDefaultTextureAttribute: function ( unit, attribute ) {
- var attributeMap = this.getOrCreateTextureAttributeMap( unit );
-
- var typeMember = attribute.getTypeMember();
-
- if ( attributeMap[ typeMember ] === undefined ) {
- this._createAttributeStack( attributeMap, typeMember, attribute );
- } else {
- attributeMap[ typeMember ].globalDefault = attribute;
- }
-
- },
-
- getGlobalDefaultTextureAttribute: function ( unit, typeMember ) {
- var attributeMap = this.getOrCreateTextureAttributeMap( unit );
- var as = attributeMap[ typeMember ];
- return as.globalDefault;
- },
-
- getOrCreateTextureAttributeMap: function ( unit ) {
- if ( !this.textureAttributeMapList[ unit ] ) this.textureAttributeMapList[ unit ] = new Map();
- return this.textureAttributeMapList[ unit ];
- },
-
- pushAttributeMap: function ( attributeMap, stateSetAttributeMap ) {
- /*jshint bitwise: false */
- var attributeStack;
- var stateSetAttributeMapKeys = stateSetAttributeMap.getKeys();
-
- for ( var i = 0, l = stateSetAttributeMapKeys.length; i < l; i++ ) {
-
- var type = stateSetAttributeMapKeys[ i ];
- var attributePair = stateSetAttributeMap[ type ];
- var attribute = attributePair.getAttribute();
-
- if ( attributeMap[ type ] === undefined ) {
- this._createAttributeStack( attributeMap, type, attribute.cloneType() );
- }
-
- attributeStack = attributeMap[ type ];
- this.pushCheckOverride( attributeStack, attribute, attributePair.getValue() );
- attributeStack.asChanged = true;
- }
- /*jshint bitwise: true */
- },
-
- popAttributeMap: function ( attributeMap, stateSetAttributeMap ) {
-
- var attributeStack;
- var stateSetAttributeMapKeys = stateSetAttributeMap.getKeys();
-
- for ( var i = 0, l = stateSetAttributeMapKeys.length; i < l; i++ ) {
-
- var type = stateSetAttributeMapKeys[ i ];
- attributeStack = attributeMap[ type ];
- attributeStack.pop();
- attributeStack.asChanged = true;
-
- }
- },
-
- setIndexArray: function ( array ) {
-
- var gl = this._graphicContext;
-
- if ( this._currentIndexVBO !== array ) {
- array.bind( gl );
- this._currentIndexVBO = array;
- }
-
- if ( array.isDirty() ) {
- array.compile( gl );
- }
-
- },
-
- lazyDisablingOfVertexAttributes: function () {
- var keys = this.vertexAttribMap._keys;
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- var attr = keys[ i ];
- if ( this.vertexAttribMap[ attr ] ) {
- this.vertexAttribMap._disable[ attr ] = true;
- }
- }
- },
-
- enableVertexColor: function () {
-
- var program = this.attributeMap.Program.lastApplied;
-
- if ( !program.getUniformsCache().uArrayColorEnabled ||
- !program.getAttributesCache().Color ) return; // no color uniform or attribute used, exit
-
- // update uniform
- var uniform = this.uniforms.ArrayColorEnabled.globalDefault;
-
- var previousColorEnabled = this._previousColorAttribPair[ program.getInstanceID() ];
-
- if ( !previousColorEnabled ) {
- uniform.setFloat( 1.0 );
- uniform.apply( this.getGraphicContext(), program.getUniformsCache().uArrayColorEnabled );
- this._previousColorAttribPair[ program.getInstanceID() ] = true;
- }
-
- },
-
-
- disableVertexColor: function () {
-
- var program = this.attributeMap.Program.lastApplied;
-
- if ( !program.getUniformsCache().uArrayColorEnabled ||
- !program.getAttributesCache().Color ) return; // no color uniform or attribute used, exit
-
- // update uniform
- var uniform = this.uniforms.ArrayColorEnabled.globalDefault;
-
- var previousColorEnabled = this._previousColorAttribPair[ program.getInstanceID() ];
-
- if ( previousColorEnabled ) {
- uniform.setFloat( 0.0 );
- uniform.apply( this.getGraphicContext(), program.getUniformsCache().uArrayColorEnabled );
- this._previousColorAttribPair[ program.getInstanceID() ] = false;
- }
-
- },
-
-
- applyDisablingOfVertexAttributes: function () {
-
- var keys = this.vertexAttribMap._keys;
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- if ( this.vertexAttribMap._disable[ keys[ i ] ] === true ) {
- var attr = keys[ i ];
- this._graphicContext.disableVertexAttribArray( attr );
- this.vertexAttribMap._disable[ attr ] = false;
- this.vertexAttribMap[ attr ] = false;
- }
- }
- },
-
- clearVertexAttribCache: function () {
-
- var vertexAttribMap = this.vertexAttribMap;
- var keys = vertexAttribMap._keys;
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- var attr = keys[ i ];
- vertexAttribMap[ attr ] = undefined;
- vertexAttribMap._disable[ attr ] = false;
- }
-
- this.vertexAttribMap._disable.length = 0;
- this.vertexAttribMap._keys.length = 0;
-
- },
-
- /**
- * set a vertex array object.
- * return true if binded the vao and false
- * if was already binded
- */
- setVertexArrayObject: function ( vao ) {
-
- if ( this._currentVAO !== vao ) {
-
- this._extVAO.bindVertexArrayOES( vao );
- this._currentVAO = vao;
-
- // disable cache to force a re enable of array
- if ( !vao ) this.clearVertexAttribCache();
-
- // disable currentIndexVBO to force to bind indexArray from Geometry
- // if there is a change of vao
- this._currentIndexVBO = undefined;
-
- return true;
- }
- return false;
- },
-
- setVertexAttribArray: function ( attrib, array, normalize ) {
-
- var vertexAttribMap = this.vertexAttribMap;
- vertexAttribMap._disable[ attrib ] = false;
- var gl = this._graphicContext;
- var binded = false;
-
- if ( array.isDirty() ) {
- array.bind( gl );
- array.compile( gl );
- binded = true;
- }
-
- var currentArray = vertexAttribMap[ attrib ];
- if ( currentArray !== array ) {
-
- if ( !binded ) {
- array.bind( gl );
- }
-
- if ( !currentArray ) {
- gl.enableVertexAttribArray( attrib );
-
- // can be === false (so undefined check is important)
- if ( currentArray === undefined )
- vertexAttribMap._keys.push( attrib );
-
- }
-
- vertexAttribMap[ attrib ] = array;
- gl.vertexAttribPointer( attrib, array.getItemSize(), array.getType(), normalize, 0, 0 );
- }
- },
-
-
- _getActiveUniformsFromProgramAttributes: function ( program, activeUniformsList ) {
-
- var attributeMapStack = this.attributeMap;
-
- var attributeKeys = program.getTrackAttributes().attributeKeys;
-
- if ( attributeKeys.length > 0 ) {
-
- for ( var i = 0, l = attributeKeys.length; i < l; i++ ) {
-
- var key = attributeKeys[ i ];
- var attributeStack = attributeMapStack[ key ];
- if ( attributeStack === undefined ) {
- continue;
- }
-
- // we just need the uniform list and not the attribute itself
- var attribute = attributeStack.globalDefault;
- if ( attribute.getOrCreateUniforms === undefined ) {
- continue;
- }
-
- var uniformMap = attribute.getOrCreateUniforms();
- var uniformKeys = uniformMap.getKeys();
-
- for ( var a = 0, b = uniformKeys.length; a < b; a++ ) {
- activeUniformsList.push( uniformMap[ uniformKeys[ a ] ] );
- }
- }
-
- }
- },
-
- _getActiveUniformsFromProgramTextureAttributes: function ( program, activeUniformsList ) {
-
- var textureAttributeKeysList = program.getTrackAttributes().textureAttributeKeys;
- if ( textureAttributeKeysList === undefined ) return;
-
- for ( var unit = 0, nbUnit = textureAttributeKeysList.length; unit < nbUnit; unit++ ) {
-
- var textureAttributeKeys = textureAttributeKeysList[ unit ];
- if ( textureAttributeKeys === undefined ) continue;
-
- var unitTextureAttributeList = this.textureAttributeMapList[ unit ];
- if ( unitTextureAttributeList === undefined ) continue;
-
- for ( var i = 0, l = textureAttributeKeys.length; i < l; i++ ) {
- var key = textureAttributeKeys[ i ];
-
- var attributeStack = unitTextureAttributeList[ key ];
- if ( attributeStack === undefined ) {
- continue;
- }
- // we just need the uniform list and not the attribute itself
- var attribute = attributeStack.globalDefault;
- if ( attribute.getOrCreateUniforms === undefined ) {
- continue;
- }
- var uniformMap = attribute.getOrCreateUniforms();
- var uniformMapKeys = uniformMap.getKeys();
-
- for ( var a = 0, b = uniformMapKeys.length; a < b; a++ ) {
- activeUniformsList.push( uniformMap[ uniformMapKeys[ a ] ] );
- }
- }
- }
- },
-
- _cacheUniformsForCustomProgram: function ( program, activeUniformsList ) {
-
- this._getActiveUniformsFromProgramAttributes( program, activeUniformsList );
-
- this._getActiveUniformsFromProgramTextureAttributes( program, activeUniformsList );
-
- var gl = this._graphicContext;
-
- // now we have a list on uniforms we want to track but we will filter them to use only what is needed by our program
- // not that if you create a uniforms whith the same name of a tracked attribute, and it will override it
- var uniformsFinal = new Map();
-
- for ( var i = 0, l = activeUniformsList.length; i < l; i++ ) {
- var u = activeUniformsList[ i ];
- var uniformName = u.getName();
- var loc = gl.getUniformLocation( program._program, uniformName );
- if ( loc !== undefined && loc !== null ) {
- uniformsFinal[ uniformName ] = u;
- }
- }
- uniformsFinal.dirty();
- program.trackUniforms = uniformsFinal;
-
- },
-
- _applyCustomProgramUniforms: ( function () {
-
- var activeUniformsList = [];
-
- return function ( program ) {
-
- // custom program so we will iterate on uniform from the program and apply them
- // but in order to be able to use Attribute in the state graph we will check if
- // our program want them. It must be defined by the user
-
- // first time we see attributes key, so we will keep a list of uniforms from attributes
- activeUniformsList.length = 0;
-
- // fill the program with cached active uniforms map from attributes and texture attributes
- if ( program.getTrackAttributes() !== undefined && program.trackUniforms === undefined ) {
- this._cacheUniformsForCustomProgram( program, activeUniformsList );
- }
-
- var programUniformMap = program.getUniformsCache();
- var programUniformKeys = programUniformMap.getKeys();
- var uniformMapStackContent = this.uniforms;
-
- var programTrackUniformMap;
- if ( program.trackUniforms )
- programTrackUniformMap = program.trackUniforms;
-
- var uniform;
- for ( var i = 0, l = programUniformKeys.length; i < l; i++ ) {
- var uniformKey = programUniformKeys[ i ];
- var location = programUniformMap[ uniformKey ];
- var uniformStack = uniformMapStackContent[ uniformKey ];
-
- if ( uniformStack === undefined ) {
-
- if ( programTrackUniformMap !== undefined ) {
- uniform = programTrackUniformMap[ uniformKey ];
- if ( uniform !== undefined ) {
- uniform.apply( this._graphicContext, location );
- }
- }
-
- } else {
-
- if ( uniformStack.values().length === 0 ) {
- uniform = uniformStack.globalDefault;
- } else {
- uniform = uniformStack.back().object;
- }
- uniform.apply( this._graphicContext, location );
-
- }
- }
- };
- } )(),
-
-
- // apply a generated program if necessary
- // It build a Shader from the shader generator
- // it apply for the following condition
- // the user has not put a Pogram in the stack or if he has he added one with OFF
- _generateAndApplyProgram: function () {
-
- var attributeMap = this.attributeMap;
- if ( attributeMap.Program !== undefined && attributeMap.Program.values().length !== 0 && attributeMap.Program.back().value !== StateAttribute.OFF )
- return undefined;
-
- // no custom program look into the stack of ShaderGenerator name
- // what we should use to generate a program
-
- var last = this._shaderGeneratorNames.back();
- var shaderGenerator = this._shaderGeneratorProxy.getShaderGenerator( last ? last.object : undefined );
-
- var program = shaderGenerator.getOrCreateProgram( this );
- this.applyAttribute( program );
- return program;
- },
-
- _computeForeignUniforms: function ( programUniformMap, activeUniformMap ) {
-
- var uniformMapKeys = programUniformMap.getKeys();
- var uniformMap = programUniformMap;
-
- var foreignUniforms = [];
- for ( var i = 0, l = uniformMapKeys.length; i < l; i++ ) {
-
- var name = uniformMapKeys[ i ];
- var location = uniformMap[ name ];
-
- if ( location !== undefined && activeUniformMap[ name ] === undefined ) {
-
- // filter 'standard' uniform matrix that will be applied for all shader
- if ( name !== this.modelViewMatrix.getName() &&
- name !== this.modelMatrix.getName() &&
- name !== this.viewMatrix.getName() &&
- name !== this.projectionMatrix.getName() &&
- name !== this.modelViewNormalMatrix.getName() &&
- name !== 'uArrayColorEnabled' ) {
- foreignUniforms.push( name );
- }
- }
-
- }
-
- return foreignUniforms;
- },
-
- _removeUniformsNotRequiredByProgram: function ( activeUniformMap, programUniformMap ) {
-
- var activeUniformMapKeys = activeUniformMap.getKeys();
-
- for ( var i = 0, l = activeUniformMapKeys.length; i < l; i++ ) {
- var name = activeUniformMapKeys[ i ];
- var location = programUniformMap[ name ];
- if ( location === undefined || location === null ) {
- delete activeUniformMap[ name ];
- activeUniformMap.dirty();
- }
- }
- },
-
-
- _cacheUniformsForGeneratedProgram: function ( program ) {
-
- var foreignUniforms = this._computeForeignUniforms( program.getUniformsCache(), program.getActiveUniforms() );
- program.setForeignUniforms( foreignUniforms );
-
-
- // remove uniforms listed by attributes (getActiveUniforms) but not required by the program
- this._removeUniformsNotRequiredByProgram( program.getActiveUniforms(), program.getUniformsCache() );
-
- },
-
- _copyUniformEntry: function ( uniform ) {
-
- var internalArray = uniform.getInternalArray();
- var cacheData;
- if ( internalArray.length < 16 )
- cacheData = new internalArray.constructor( internalArray.length );
-
- return cacheData;
- },
-
- _initUniformCache: function ( program ) {
-
- var activeUniformMap = program.getActiveUniforms();
- var activeUniformKeys = activeUniformMap.getKeys();
-
- var foreignUniformKeys = program.getForeignUniforms();
- var uniformMapStack = this.uniforms;
-
- var cacheForeignUniforms = [];
- var cacheActiveUniforms = [];
-
- var i, l, cache, name, cacheData, uniform;
-
- program._cacheUniformId = this._cacheUniformId++;
- this._programUniformCache[ program._cacheUniformId ] = {};
-
- if ( foreignUniformKeys.length ) {
- cache = cacheForeignUniforms;
- for ( i = 0, l = foreignUniformKeys.length; i < l; i++ ) {
- name = foreignUniformKeys[ i ];
- var uniStack = uniformMapStack[ name ];
- if ( uniStack ) {
- uniform = uniStack.globalDefault;
- cacheData = this._copyUniformEntry( uniform );
- cache.push( cacheData );
- }
-
- }
- }
-
- if ( activeUniformKeys.length ) {
- cache = cacheActiveUniforms;
- for ( i = 0, l = activeUniformKeys.length; i < l; i++ ) {
- name = activeUniformKeys[ i ];
- uniform = activeUniformMap[ name ];
- cacheData = this._copyUniformEntry( uniform );
- cache.push( cacheData );
- }
- }
-
- this._programUniformCache[ program._cacheUniformId ].foreign = cacheForeignUniforms;
- this._programUniformCache[ program._cacheUniformId ].active = cacheActiveUniforms;
-
- },
-
- _checkCacheAndApplyUniform: function ( uniform, cacheArray, i, programUniformMap, name ) {
- var isCached;
- var internalArray = uniform.getInternalArray();
- var uniformArrayLength = internalArray.length;
- if ( uniformArrayLength <= 4 ) {
- var uniformCache = cacheArray[ i ];
- isCached = checkUniformCache[ uniformArrayLength ]( internalArray, uniformCache );
- } else {
- isCached = false;
- }
-
- if ( !isCached ) {
- var location = programUniformMap[ name ];
- uniform.apply( this._graphicContext, location );
- }
- },
-
- // note that about TextureAttribute that need uniform on unit we would need to improve
- // the current uniformList ...
-
- // when we apply the shader for the first time, we want to compute the active uniforms for this shader and the list of uniforms not extracted from attributes called foreignUniforms
- _applyGeneratedProgramUniforms: function ( program ) {
-
- var foreignUniformKeys = program.getForeignUniforms();
- if ( !foreignUniformKeys ) {
- this._cacheUniformsForGeneratedProgram( program );
- foreignUniformKeys = program.getForeignUniforms();
-
- this._initUniformCache( program );
- }
-
- var programUniformMap = program.getUniformsCache();
- var activeUniformMap = program.getActiveUniforms();
-
- var cacheUniformsActive = this._programUniformCache[ program._cacheUniformId ].active;
- var cacheUniformsForeign = this._programUniformCache[ program._cacheUniformId ].foreign;
-
- // apply active uniforms
- // caching uniforms from attribtues make it impossible to overwrite uniform with a custom uniform instance not used in the attributes
- var i, l, name, uniform;
- var activeUniformKeys = activeUniformMap.getKeys();
-
- this.nbApplyUniform += activeUniformKeys.length;
- for ( i = 0, l = activeUniformKeys.length; i < l; i++ ) {
-
- name = activeUniformKeys[ i ];
- uniform = activeUniformMap[ name ];
-
- this._checkCacheAndApplyUniform( uniform, cacheUniformsActive, i, programUniformMap, name );
- }
-
- var uniformMapStack = this.uniforms;
-
- // apply now foreign uniforms, it's uniforms needed by the program but not contains in attributes used to generate this program
- for ( i = 0, l = foreignUniformKeys.length; i < l; i++ ) {
- name = foreignUniformKeys[ i ];
- var uniformStack = uniformMapStack[ name ];
- if ( uniformStack !== undefined ) {
- if ( uniformStack.values().length === 0 ) {
- uniform = uniformStack.globalDefault;
- Notify.warn( 'Uniform Default Not attached to a StateSet in Scene Hierarchy: ' + uniformStack.globalDefault.getName() );
- } else {
- uniform = uniformStack.back().object;
- }
- }
-
- this._checkCacheAndApplyUniform( uniform, cacheUniformsForeign, i, programUniformMap, name );
-
- }
- },
-
- // Use to detect changes in RenderLeaf between call to avoid to applyStateSet
- _setStateSetsDrawID: function ( id ) {
- var values = this.stateSets.values();
- for ( var i = 0, nbStateSets = values.length; i < nbStateSets; i++ ) {
- values[ i ].setDrawID( id );
- }
- },
-
- _stateSetStackChanged: function ( id, nbLast ) {
- var values = this.stateSets.values();
- var nbStateSets = values.length;
- if ( nbLast !== nbStateSets )
- return true;
-
- for ( var i = 0; i < nbStateSets; i++ ) {
- if ( id !== values[ i ].getDrawID() )
- return true;
- }
-
- return false;
- }
-
-
-} ), 'osg', 'State' );
-
-module.exports = State;
diff --git a/app/static/app/js/vendor/osgjs/osg/StateAttribute.js b/app/static/app/js/vendor/osgjs/osg/StateAttribute.js
deleted file mode 100644
index cb89e88c..00000000
--- a/app/static/app/js/vendor/osgjs/osg/StateAttribute.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-
-
-var StateAttribute = function () {
- Object.call( this );
-};
-
-StateAttribute.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- getType: function () {
- return this.attributeType;
- },
-
- // basically, if you want two StateAttribute with the same attributeType in a stateSet/State
- // their typeMember should be different
- getTypeMember: function () {
- return this.attributeType;
- },
-
- apply: function () {},
-
- // getHash is used by the compiler to know if a change in a StateAttribute
- // must trigger a shader build
- // If you create your own attribute you will have to customize this function
- // a good rule is to that if you change uniform it should not rebuild a shader
- // but if you change a type or representation of your StateAttribute, then it should
- // if it impact the rendering.
- // check other attributes for examples
- getHash: function () {
- return this.getTypeMember();
- }
-
-} ), 'osg', 'StateAttribute' );
-
-StateAttribute.OFF = 0;
-StateAttribute.ON = 1;
-StateAttribute.OVERRIDE = 2;
-StateAttribute.PROTECTED = 4;
-StateAttribute.INHERIT = 8;
-
-module.exports = StateAttribute;
diff --git a/app/static/app/js/vendor/osgjs/osg/StateGraph.js b/app/static/app/js/vendor/osgjs/osg/StateGraph.js
deleted file mode 100644
index b74001ee..00000000
--- a/app/static/app/js/vendor/osgjs/osg/StateGraph.js
+++ /dev/null
@@ -1,150 +0,0 @@
-'use strict';
-var osgPool = require( 'osgUtil/osgPool' );
-
-
-var StateGraph = function () {
- this.depth = 0;
- this.children = {};
- this.children.keys = [];
- this.leafs = [];
- this.stateset = undefined;
- this.parent = undefined;
-};
-
-StateGraph.prototype = {
-
- clean: function () {
-
- this.leafs.length = 0;
- this.stateset = undefined;
- this.parent = undefined;
- this.depth = 0;
- var children = this.children;
- var child;
- var key, keys = children.keys;
-
- for ( var i = 0, l = keys.length; i < l; i++ ) {
-
- key = keys[ i ];
- child = children[ key ];
- child.clean();
- osgPool.memoryPools.stateGraph.put( child );
-
- }
-
- this.children = {};
- keys.length = 0;
- this.children.keys = keys;
- },
-
- getStateSet: function () {
- return this.stateset;
- },
-
- findOrInsert: function ( stateset ) {
-
- var sg;
- var stateSetID = stateset.getInstanceID();
- var children = this.children;
-
- if ( !children[ stateSetID ] ) {
-
- //sg = new StateGraph();
- sg = osgPool.memoryPools.stateGraph.get();
-
- sg.parent = this;
- sg.depth = this.depth + 1;
- sg.stateset = stateset;
- children[ stateSetID ] = sg;
- children.keys.push( stateSetID );
-
- } else {
-
- sg = children[ stateSetID ];
-
- }
- return sg;
- }
-
-};
-
-StateGraph.moveStateGraph = function ( state, sgCurrentArg, sgNewArg ) {
-
- var stack = [];
- var sgNew = sgNewArg;
- var sgCurrent = sgCurrentArg;
- var i, l;
- if ( sgNew === sgCurrent || sgNew === undefined ) return;
-
- if ( sgCurrent === undefined ) {
- // push stateset from sgNew to root, and apply
- // stateset from root to sgNew
- do {
- if ( sgNew.stateset !== undefined ) {
- stack.push( sgNew.stateset );
- }
- sgNew = sgNew.parent;
- } while ( sgNew );
-
- for ( i = stack.length - 1, l = 0; i >= l; --i ) {
- state.pushStateSet( stack[ i ] );
- }
- return;
-
- } else if ( sgCurrent.parent === sgNew.parent ) {
- // first handle the typical case which is two state groups
- // are neighbours.
-
- // state has changed so need to pop old state.
- if ( sgCurrent.stateset !== undefined ) {
- state.popStateSet();
- }
- // and push new state.
- if ( sgNew.stateset !== undefined ) {
- state.pushStateSet( sgNew.stateset );
- }
- return;
- }
-
- // need to pop back up to the same depth as the new state group.
- while ( sgCurrent.depth > sgNew.depth ) {
- if ( sgCurrent.stateset !== undefined ) {
- state.popStateSet();
- }
- sgCurrent = sgCurrent.parent;
- }
-
- // use return path to trace back steps to sgNew.
- stack = [];
-
- // need to pop back up to the same depth as the curr state group.
- while ( sgNew.depth > sgCurrent.depth ) {
- if ( sgNew.stateset !== undefined ) {
- stack.push( sgNew.stateset );
- }
- sgNew = sgNew.parent;
- }
-
- // now pop back up both parent paths until they agree.
-
- // DRT - 10/22/02
- // should be this to conform with above case where two StateGraph
- // nodes have the same parent
- while ( sgCurrent !== sgNew ) {
- if ( sgCurrent.stateset !== undefined ) {
- state.popStateSet();
- }
- sgCurrent = sgCurrent.parent;
-
- if ( sgNew.stateset !== undefined ) {
- stack.push( sgNew.stateset );
- }
- sgNew = sgNew.parent;
- }
-
- for ( i = stack.length - 1, l = 0; i >= l; --i ) {
- state.pushStateSet( stack[ i ] );
- }
-};
-
-module.exports = StateGraph;
diff --git a/app/static/app/js/vendor/osgjs/osg/StateSet.js b/app/static/app/js/vendor/osgjs/osg/StateSet.js
deleted file mode 100644
index 4417e081..00000000
--- a/app/static/app/js/vendor/osgjs/osg/StateSet.js
+++ /dev/null
@@ -1,307 +0,0 @@
-'use strict';
-var Map = require( 'osg/Map' );
-var Notify = require( 'osg/notify' );
-var Object = require( 'osg/Object' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var MACROUTILS = require( 'osg/Utils' );
-
-
-/** Stores a set of modes and attributes which represent a set of OpenGL state.
- * Notice that a \c StateSet contains just a subset of the whole OpenGL state.
- *
In OSG, each \c Drawable and each \c Node has a reference to a
- * \c StateSet. These StateSets can be shared between
- * different Drawables and Nodes (that is, several
- * Drawables and Nodes can reference the same \c StateSet).
- * Indeed, this practice is recommended whenever possible,
- * as this minimizes expensive state changes in the graphics pipeline.
- */
-var StateSet = function () {
- Object.call( this );
-
- this._parents = [];
- this.attributeMap = new Map();
-
- this.textureAttributeMapList = [];
-
- this._binName = undefined;
- this._binNumber = 0;
-
- // put the shader generator name in an AttributePair
- // so that we can use the mask value
- this._shaderGeneratorPair = null;
-
- this._updateCallbackList = [];
-
- this.uniforms = new Map();
-
- this._drawID = -1; // used by the RenderLeaf to decide if it should apply the stateSet
-};
-
-StateSet.AttributePair = function ( attr, value ) {
- this._object = attr;
- this._value = value;
-};
-
-StateSet.AttributePair.prototype = {
- getShaderGeneratorName: function () {
- return this._object;
- },
- getAttribute: function () {
- return this._object;
- },
- getUniform: function () {
- return this._object;
- },
- getValue: function () {
- return this._value;
- }
-};
-
-
-StateSet.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- setDrawID: function ( id ) {
- this._drawID = id;
- },
-
- getDrawID: function () {
- return this._drawID;
- },
-
- getAttributePair: function ( attribute, value ) {
- return new StateSet.AttributePair( attribute, value );
- },
-
- addUniform: function ( uniform, originalMode ) {
- var mode = originalMode !== undefined ? originalMode : StateAttribute.ON;
- var name = uniform.getName();
- this.uniforms[ name ] = this.getAttributePair( uniform, mode );
- this.uniforms.dirty();
- },
-
- addParent: function ( node ) {
- this._parents.push( node );
- },
-
- removeParent: function ( node ) {
- var idx = this._parents.indexOf( node );
- if ( idx === -1 ) return;
- this._parents.splice( idx, 1 );
- },
-
- removeUniform: function ( uniform ) {
- this.uniforms.remove( uniform.getName() );
- },
-
- removeUniformByName: function ( uniformName ) {
- this.uniforms.remove( uniformName );
- },
-
- getUniform: function ( uniform ) {
- var uniformMap = this.uniforms;
- if ( uniformMap[ uniform ] ) return uniformMap[ uniform ].getAttribute();
- return undefined;
- },
-
- getUniformList: function () {
- return this.uniforms;
- },
-
- setTextureAttributeAndModes: function ( unit, attribute, originalMode ) {
- var mode = originalMode !== undefined ? originalMode : StateAttribute.ON;
- this._setTextureAttribute( unit, this.getAttributePair( attribute, mode ) );
- },
-
- setTextureAttributeAndMode: function ( unit, attribute, mode ) {
- Notify.log( 'StateSet.setTextureAttributeAndMode is deprecated, insteady use setTextureAttributeAndModes' );
- this.setTextureAttributeAndModes( unit, attribute, mode );
- },
-
- getNumTextureAttributeLists: function () {
- return this.textureAttributeMapList.length;
- },
-
- getTextureAttribute: function ( unit, attribute ) {
- if ( this.textureAttributeMapList[ unit ] === undefined ) return undefined;
-
- var textureMap = this.textureAttributeMapList[ unit ];
- if ( textureMap[ attribute ] === undefined ) return undefined;
-
- return textureMap[ attribute ].getAttribute();
- },
-
- removeTextureAttribute: function ( unit, attributeName ) {
- if ( this.textureAttributeMapList[ unit ] === undefined ) return;
-
- var textureAttributeMap = this.textureAttributeMapList[ unit ];
- if ( textureAttributeMap[ attributeName ] === undefined ) return;
-
-
- textureAttributeMap.remove( attributeName );
- this.textureAttributeMapList[ unit ].dirty();
- },
-
- getAttribute: function ( attributeType ) {
- if ( this.attributeMap[ attributeType ] === undefined ) {
- return undefined;
- }
- return this.attributeMap[ attributeType ].getAttribute();
- },
-
- setAttributeAndModes: function ( attribute, originalMode ) {
- var mode = originalMode !== undefined ? originalMode : StateAttribute.ON;
- this._setAttribute( this.getAttributePair( attribute, mode ) );
- },
-
- setAttributeAndMode: function ( attribute, mode ) {
- Notify.log( 'StateSet.setAttributeAndMode is deprecated, insteady use setAttributeAndModes' );
- this.setAttributeAndModes( attribute, mode );
- },
-
- setAttribute: function ( attribute, originalMode ) {
- var mode = originalMode !== undefined ? originalMode : StateAttribute.ON;
- this._setAttribute( this.getAttributePair( attribute, mode ) );
- },
-
- // TODO: check if it's an attribute type or a attribute to remove it
- removeAttribute: function ( attributeName ) {
-
- if ( this.attributeMap[ attributeName ] !== undefined ) {
- delete this.attributeMap[ attributeName ];
- this.attributeMap.dirty();
- }
- },
-
- setRenderingHint: function ( hint ) {
- if ( hint === 'OPAQUE_BIN' ) {
- this.setRenderBinDetails( 0, 'RenderBin' );
- } else if ( hint === 'TRANSPARENT_BIN' ) {
- this.setRenderBinDetails( 10, 'DepthSortedBin' );
- } else {
- this.setRenderBinDetails( 0, '' );
- }
- },
-
- getUpdateCallbackList: function () {
- return this._updateCallbackList;
- },
-
- removeUpdateCallback: function ( cb ) {
- var idx = this._updateCallbackList.indexOf( cb );
- if ( idx === -1 ) return;
- this._updateCallbackList.splice( idx, 1 );
-
- if ( this._updateCallbackList.length === 0 ) {
- var parents = this._parents;
- for ( var i = 0, l = parents.length; i < l; i++ ) {
- var parent = parents[ i ];
- parent.setNumChildrenRequiringUpdateTraversal( parent.getNumChildrenRequiringUpdateTraversal() - 1 );
- }
- }
- },
-
- requiresUpdateTraversal: function () {
- return !!this._updateCallbackList.length;
- },
-
- addUpdateCallback: function ( cb ) {
-
- var dontNoticeParents = Boolean( this._updateCallbackList.length );
- this._updateCallbackList.push( cb );
-
- // parent alreay know we have update callback
- if ( dontNoticeParents ) return;
-
- var parents = this._parents;
- for ( var i = 0, l = parents.length; i < l; i++ ) {
- var parent = parents[ i ];
- parent.setNumChildrenRequiringUpdateTraversal( parent.getNumChildrenRequiringUpdateTraversal() + 1 );
- }
- },
-
- hasUpdateCallback: function ( cb ) {
- return this._updateCallbackList.indexOf( cb ) !== -1;
- },
-
- setRenderBinDetails: function ( num, binName ) {
- this._binNumber = num;
- this._binName = binName;
- },
- getAttributeMap: function () {
- return this.attributeMap;
- },
- getBinNumber: function () {
- return this._binNumber;
- },
- getBinName: function () {
- return this._binName;
- },
- setBinNumber: function ( binNum ) {
- this._binNumber = binNum;
- },
- setBinName: function ( binName ) {
- this._binName = binName;
- },
- getAttributeList: function () {
- var attributeMap = this.attributeMap;
- var attributeMapKeys = attributeMap.getKeys();
-
- var l = attributeMapKeys.length;
- var list = [];
- for ( var i = 0; i < l; i++ ) {
- list.push( attributeMap[ attributeMapKeys[ i ] ] );
- }
- return list;
- },
- setShaderGeneratorName: function ( generatorName, mask ) {
- this._shaderGeneratorPair = this.getAttributePair( generatorName, mask );
- },
- getShaderGeneratorPair: function () {
- return this._shaderGeneratorPair;
- },
- getShaderGeneratorName: function () {
- return this._shaderGeneratorPair ? this._shaderGeneratorPair.getShaderGeneratorName() : undefined;
- },
- releaseGLObjects: function () {
- for ( var i = 0, j = this.textureAttributeMapList.length; i < j; i++ ) {
- this.getTextureAttribute( i, 'Texture' ).releaseGLObjects();
- }
- var list = this.getAttributeList();
- for ( i = 0, j = list.length; i < j; i++ ) {
- // Remove only if we have releaseGLObject method.
- if ( list[ i ]._object.releaseGLObjects ) {
- list[ i ]._object.releaseGLObjects();
- }
- }
- },
- _getUniformMap: function () {
- return this.uniforms;
- },
-
- // for internal use, you should not call it directly
- _setTextureAttribute: function ( unit, attributePair ) {
-
- if ( this.textureAttributeMapList[ unit ] === undefined ) {
- this.textureAttributeMapList[ unit ] = new Map();
- }
-
- var name = attributePair.getAttribute().getTypeMember();
- var textureUnitAttributeMap = this.textureAttributeMapList[ unit ];
-
- textureUnitAttributeMap[ name ] = attributePair;
- textureUnitAttributeMap.dirty();
-
- },
-
- // for internal use, you should not call it directly
- _setAttribute: function ( attributePair ) {
-
- var name = attributePair.getAttribute().getTypeMember();
- this.attributeMap[ name ] = attributePair;
- this.attributeMap.dirty();
-
- }
-
-} ), 'osg', 'StateSet' );
-
-module.exports = StateSet;
diff --git a/app/static/app/js/vendor/osgjs/osg/Texture.js b/app/static/app/js/vendor/osgjs/osg/Texture.js
deleted file mode 100644
index cdb5d8fc..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Texture.js
+++ /dev/null
@@ -1,761 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var Uniform = require( 'osg/Uniform' );
-var Image = require( 'osg/Image' );
-var GLObject = require( 'osg/GLObject' );
-var ReaderParser = require( 'osgDB/readerParser' );
-var CustomMap = require( 'osg/Map' );
-var TextureManager = require( 'osg/TextureManager' );
-var WebglCaps = require( 'osg/WebGLCaps' );
-
-var ImageBitmap = window.ImageBitmap || function () {};
-
-// helper
-var isPowerOf2 = function ( x ) {
- /*jshint bitwise: false */
- return ( ( x !== 0 ) && ( ( x & ( ~x + 1 ) ) === x ) );
- /*jshint bitwise: true */
-};
-
-/**
- * Texture encapsulate webgl texture object
- * @class Texture
- * Not that dirty here is mainly for texture binding
- * any dirty will cause re-bind
- * hint: don't dirty a texture attached to a camera/framebuffer
- * it will end blank
- * @inherits StateAttribute
- */
-var Texture = function () {
-
- StateAttribute.call( this );
- GLObject.call( this );
- this.setDefaultParameters();
- this._dirty = true;
- this._dirtyMipmap = true;
- this._applyTexImage2DCallbacks = [];
- this._textureObject = undefined;
-
- this._textureNull = true;
-};
-
-var checkAndFixEnum = function ( mode, fallback ) {
-
- var value = Texture[ mode ];
-
- if ( value === undefined ) {
- Notify.warn( 'bad Texture enum argument ' + mode + '\n' + 'fallback to ' + fallback );
- return fallback;
- }
-
- return value;
-};
-
-Texture.UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
-Texture.UNPACK_FLIP_Y_WEBGL = 0x9240;
-Texture.BROWSER_DEFAULT_WEBGL = 0x9244;
-Texture.NONE = 0x0;
-
-Texture.DEPTH_COMPONENT = 0x1902;
-Texture.ALPHA = 0x1906;
-Texture.RGB = 0x1907;
-Texture.RGBA = 0x1908;
-Texture.LUMINANCE = 0x1909;
-Texture.LUMINANCE_ALPHA = 0x190A;
-
-// DXT formats, from:
-// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/
-Texture.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
-Texture.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
-Texture.COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
-Texture.COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
-
-// ATC formats, from:
-// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_atc/
-Texture.COMPRESSED_RGB_ATC_WEBGL = 0x8C92;
-Texture.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93;
-Texture.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE;
-
-// PVR formats, from:
-// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_pvrtc/
-Texture.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
-Texture.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
-Texture.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
-Texture.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
-
-// ETC1 format, from:
-// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/
-Texture.COMPRESSED_RGB_ETC1_WEBGL = 0x8D64;
-
-// filter mode
-Texture.LINEAR = 0x2601;
-Texture.NEAREST = 0x2600;
-Texture.NEAREST_MIPMAP_NEAREST = 0x2700;
-Texture.LINEAR_MIPMAP_NEAREST = 0x2701;
-Texture.NEAREST_MIPMAP_LINEAR = 0x2702;
-Texture.LINEAR_MIPMAP_LINEAR = 0x2703;
-// filter anisotropy
-Texture.TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
-Texture.MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
-
-// wrap mode
-Texture.CLAMP_TO_EDGE = 0x812F;
-Texture.REPEAT = 0x2901;
-Texture.MIRRORED_REPEAT = 0x8370;
-
-// target
-Texture.TEXTURE_2D = 0x0DE1;
-Texture.TEXTURE_CUBE_MAP = 0x8513;
-Texture.TEXTURE_BINDING_CUBE_MAP = 0x8514;
-Texture.TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
-Texture.TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
-Texture.TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
-Texture.TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
-Texture.TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
-Texture.TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
-Texture.MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
-
-Texture.UNSIGNED_BYTE = 0x1401;
-Texture.UNSIGNED_SHORT = 0x1403;
-Texture.UNSIGNED_SHORT_4_4_4_4 = 0x8033;
-Texture.UNSIGNED_SHORT_5_5_5_1 = 0x8034;
-Texture.UNSIGNED_SHORT_5_6_5 = 0x8363;
-Texture.FLOAT = 0x1406;
-Texture.HALF_FLOAT_OES = Texture.HALF_FLOAT = 0x8D61;
-
-Texture._sTextureManager = new window.Map();
-
-// Getter for textureManager
-Texture.getTextureManager = function ( gl ) {
-
- if ( !Texture._sTextureManager.has( gl ) )
- Texture._sTextureManager.set( gl, new TextureManager() );
-
- return Texture._sTextureManager.get( gl );
-};
-
-Texture.getEnumFromString = function ( v ) {
-
- var value = v;
-
- if ( typeof ( value ) === 'string' )
- value = checkAndFixEnum( value, v );
-
- return value;
-};
-
-Texture.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( GLObject.prototype, MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Texture',
-
- cloneType: function () {
- return new Texture();
- },
-
- dirty: function () {
- this._dirty = true;
- },
-
- isDirty: function () {
- return this._dirty;
- },
-
- isTextureNull: function () {
- return this._textureNull;
- },
-
- getOrCreateUniforms: function ( unit ) {
-
- if ( Texture.uniforms === undefined ) {
- Texture.uniforms = [];
- }
- if ( Texture.uniforms[ unit ] === undefined ) {
- var name = this.getType() + unit;
- var uniformMap = new CustomMap();
- var uniform = Uniform.createInt1( unit, name );
- uniformMap.setMap( {
- texture: uniform
- } );
-
- Texture.uniforms[ unit ] = uniformMap;
- }
-
- // uniform for an texture attribute should directly in Texture.uniforms[unit]
- // and not in Texture.uniforms[unit][Texture0]
-
- // Why it's in Texture.uniforms[unit]['texture'] :
- // a 'texture' is a texture attribute but you also have old texenv
- // that are texture attribute because they are applied on a texture unit.
- // I admit that currently we dont have this or we used to but we dont have it anymore.
- // It's the same design than osg.
- // We could imagine for example a TextureGreyScale texture attributes,
- // that would transform the input texture
- // on unit X into greyscale used in the shader.
-
- return Texture.uniforms[ unit ];
- },
-
- setDefaultParameters: function () {
- this._image = undefined;
- this._magFilter = Texture.LINEAR;
- this._minFilter = Texture.LINEAR;
- this._maxAnisotropy = 1.0;
- this._wrapS = Texture.CLAMP_TO_EDGE;
- this._wrapT = Texture.CLAMP_TO_EDGE;
- this._textureWidth = 0;
- this._textureHeight = 0;
- this._unrefImageDataAfterApply = false;
- this._internalFormat = undefined;
- this._dirtyMipmap = true;
- this._textureTarget = Texture.TEXTURE_2D;
- this._type = Texture.UNSIGNED_BYTE;
- this._isCompressed = false;
-
- this._flipY = true;
- this._colorSpaceConversion = Texture.NONE; //Texture.BROWSER_DEFAULT_WEBGL;
- },
-
- // check https://www.khronos.org/registry/webgl/specs/latest/1.0/#PIXEL_STORAGE_PARAMETERS
- setColorSpaceConversion: function ( enumValue ) {
- this._colorSpaceConversion = enumValue;
- },
-
- setFlipY: function ( bool ) {
- this._flipY = bool;
- },
-
-
- getTextureTarget: function () {
- return this._textureTarget;
- },
-
- getTextureObject: function () {
- return this._textureObject;
- },
-
- setTextureSize: function ( w, h ) {
-
- var maxSize = WebglCaps.instance().getWebGLParameter( 'MAX_TEXTURE_SIZE' );
-
- if ( w !== this._textureWidth || h !== this._textureHeight )
- this.dirty();
-
- if ( w !== undefined ) {
- if ( w > maxSize ) {
- Notify.error( 'width (' + w + ') too big for GPU. Max Texture Size is "' + maxSize + '"' );
- this._textureWidth = maxSize;
- } else {
- this._textureWidth = w;
- }
- }
-
- if ( h !== undefined ) {
- if ( h > maxSize ) {
- Notify.error( 'height (' + h + ') too big for GPU. Max Texture Size is "' + maxSize + '"' );
- this._textureHeight = maxSize;
- } else {
- this._textureHeight = h;
- }
- }
-
- this._textureNull = false;
- },
-
- init: function ( state ) {
-
- if ( !this._gl ) this.setGraphicContext( state.getGraphicContext() );
-
- if ( !this._textureObject ) {
- this._textureObject = Texture.getTextureManager( this._gl ).generateTextureObject( this._gl,
- this,
- this._textureTarget,
- this._internalFormat,
- this._textureWidth,
- this._textureHeight );
-
- this.dirty();
- this._dirtyTextureObject = false;
- this._textureNull = false;
- }
- },
-
- addApplyTexImage2DCallback: function ( callback ) {
-
- var index = this._applyTexImage2DCallbacks.indexOf( callback );
- if ( index < 0 ) {
- this._applyTexImage2DCallbacks.push( callback );
- }
- },
-
- removeApplyTexImage2DCallback: function ( callback ) {
-
- var index = this._applyTexImage2DCallbacks.indexOf( callback );
- if ( index >= 0 ) {
- this._applyTexImage2DCallbacks.splice( index, 1 );
- }
- },
-
- getWidth: function () {
- return this._textureWidth;
- },
-
- getHeight: function () {
- return this._textureHeight;
- },
-
- releaseGLObjects: function () {
-
- if ( this._textureObject !== undefined && this._textureObject !== null && this._gl !== undefined ) {
- Texture.getTextureManager( this._gl ).releaseTextureObject( this._textureObject );
- }
- this._textureObject = undefined;
- },
-
- getWrapT: function () {
- return this._wrapT;
- },
-
- getWrapS: function () {
- return this._wrapS;
- },
-
- setWrapS: function ( value ) {
-
- if ( typeof value === 'string' ) {
- this._wrapS = checkAndFixEnum( value, Texture.CLAMP_TO_EDGE );
- } else {
- this._wrapS = value;
- }
-
- this.dirtyTextureParameters();
-
- },
-
- setWrapT: function ( value ) {
-
- if ( typeof value === 'string' ) {
- this._wrapT = checkAndFixEnum( value, Texture.CLAMP_TO_EDGE );
- } else {
- this._wrapT = value;
- }
-
- this.dirtyTextureParameters();
- },
-
- // TODO CP:
- // we should split dirty texture object of parameters
- // dirty parameters only regenarate parameter
- // dirty texture object needs to release a texture and
- // re allocate one
- dirtyTextureParameters: function () {
- this.dirty(); // make everything dirty for now
- this.dirtyMipmap();
- this.dirtyTextureObject();
- },
-
- dirtyTextureObject: function () {
- this._dirtyTextureObject = true;
- this.dirtyMipmap();
- this.dirty(); // make everything dirty for now
- },
-
-
- getMinFilter: function () {
- return this._minFilter;
- },
-
- getMagFilter: function () {
- return this._magFilter;
- },
-
- // https://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt
- setMaxAnisotropy: function ( multiplier ) {
- this._maxAnisotropy = multiplier;
- this.dirtyTextureParameters();
- },
-
- getMaxAnisotropy: function () {
- return this._maxAnisotropy;
- },
-
- // some value enable mipmapping
- setMinFilter: function ( value ) {
-
- if ( typeof ( value ) === 'string' ) {
- this._minFilter = checkAndFixEnum( value, Texture.LINEAR );
- } else {
- this._minFilter = value;
- }
-
- this.dirtyTextureParameters();
- },
-
- // Either Linear or nearest.
- setMagFilter: function ( value ) {
-
- if ( typeof ( value ) === 'string' ) {
- this._magFilter = checkAndFixEnum( value, Texture.LINEAR );
- } else {
- this._magFilter = value;
- }
-
- this.dirtyTextureParameters();
- },
-
- setImage: function ( img, imageFormat ) {
-
- var image = img;
- if ( img instanceof window.Image ||
- img instanceof HTMLCanvasElement ||
- img instanceof ImageBitmap ||
- img instanceof Uint8Array ) {
- image = new Image( img );
- }
-
- this._image = image;
- this.setImageFormat( imageFormat );
- if ( image ) {
- if ( image.getWidth && image.getHeight ) {
- this.setTextureSize( image.getWidth(), image.getHeight() );
- } else if ( image.width && image.height ) {
- this.setTextureSize( image.width, image.height );
- }
- }
- this._textureNull = false;
- this.dirty();
- },
-
- getImage: function () {
- return this._image;
- },
-
- setImageFormat: function ( format ) {
-
- var imageFormat = format;
- if ( imageFormat ) {
-
- if ( typeof imageFormat === 'string' )
- imageFormat = Texture[ imageFormat ];
-
- this._imageFormat = imageFormat;
- } else {
- this._imageFormat = Texture.RGBA;
- }
- },
-
- setType: function ( value ) {
- Notify.log( 'Texture.setType is deprecated, use instead Texture.setInternalFormatType' );
- this.setInternalFormatType( value );
- },
-
- setInternalFormatType: function ( value ) {
-
- if ( typeof value === 'string' ) {
- this._type = Texture[ value ];
- } else {
- this._type = value;
- }
- },
-
- getInternalFormatType: function () {
- return this._type;
- },
-
- setUnrefImageDataAfterApply: function ( bool ) {
- this._unrefImageDataAfterApply = bool;
- },
-
- checkIsCompressed: function ( format ) {
-
- var fo = format || this._internalFormat;
- switch ( fo ) {
- case Texture.COMPRESSED_RGB_S3TC_DXT1_EXT:
- case Texture.COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case Texture.COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case Texture.COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case Texture.COMPRESSED_RGB_ATC_WEBGL:
- case Texture.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:
- case Texture.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:
- case Texture.COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
- case Texture.COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
- case Texture.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
- case Texture.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
- case Texture.COMPRESSED_RGB_ETC1_WEBGL:
- return true;
- default:
- return false;
- }
- },
-
- setInternalFormat: function ( formatSource ) {
-
- var format = formatSource;
- if ( format ) {
-
- if ( typeof format === 'string' )
- format = Texture[ format ];
-
- this._isCompressed = this.checkIsCompressed( format );
-
- } else {
- this._isCompressed = false;
- format = Texture.RGBA;
- }
-
- this._internalFormat = format;
- },
-
- getInternalFormat: function () {
- return this._internalFormat;
- },
-
- isDirtyMipmap: function () {
- return this._dirtyMipmap;
- },
-
- // Will cause the mipmaps to be regenerated on the next bind of the texture
- // Nothing will be done if the minFilter is not of the form XXX_MIPMAP_XXX
- // TODO : not to be used if the texture is compressed !
- dirtyMipmap: function () {
- this._dirtyMipmap = true;
- },
-
- applyFilterParameter: function ( gl, target ) {
-
- var powerOfTwo = isPowerOf2( this._textureWidth ) && isPowerOf2( this._textureHeight );
- if ( !powerOfTwo ) {
- // NPOT non support in webGL explained here
- // https://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support
- // so disabling mipmap...
- this._wrapT = Texture.CLAMP_TO_EDGE;
- this._wrapS = Texture.CLAMP_TO_EDGE;
-
- if ( this._minFilter === Texture.LINEAR_MIPMAP_LINEAR ||
- this._minFilter === Texture.LINEAR_MIPMAP_NEAREST ) {
- this._minFilter = Texture.LINEAR;
- }
- }
- gl.texParameteri( target, gl.TEXTURE_MAG_FILTER, this._magFilter );
- gl.texParameteri( target, gl.TEXTURE_MIN_FILTER, this._minFilter );
-
-
- // handle extension EXT_texture_filter_anisotropic
- if ( this._maxAnisotropy > 1.0 && Texture.ANISOTROPIC_SUPPORT_EXT ) {
- var multiplier = this._maxAnisotropy < Texture.ANISOTROPIC_SUPPORT_MAX ? this._maxAnisotropy : Texture.ANISOTROPIC_SUPPORT_MAX;
- gl.texParameterf( target, Texture.TEXTURE_MAX_ANISOTROPY_EXT, multiplier );
- }
-
- gl.texParameteri( target, gl.TEXTURE_WRAP_S, this._wrapS );
- gl.texParameteri( target, gl.TEXTURE_WRAP_T, this._wrapT );
-
- },
-
- generateMipmap: function ( gl, target ) {
-
- this._dirtyMipmap = false;
- if ( !this.hasMipmapFilter() ) return;
-
- // manual mipmap provided
- var img = this._image;
- if ( img && img.hasMipmap() ) {
-
- var internalFormat = this._internalFormat;
- var mips = img.getMipmap();
- for ( var level = 1, nbLevel = mips.length; level < nbLevel; level++ ) {
- var imi = mips[ level ];
- if ( this._isCompressed )
- this.applyTexImage2D( gl, this._textureTarget, level, this._internalFormat, imi.getWidth(), imi.getHeight(), 0, imi.getImage() );
- else
- this.applyTexImage2D( gl, this._textureTarget, level, internalFormat, imi.getWidth(), imi.getHeight(), 0, internalFormat, this._type, imi.getImage() );
- }
-
- } else {
- // automatic mipmap
- gl.generateMipmap( target );
- }
- },
-
- // return true if contains a mipmap filter
- hasMipmapFilter: function () {
-
- return this._minFilter === Texture.NEAREST_MIPMAP_NEAREST ||
- this._minFilter === Texture.LINEAR_MIPMAP_NEAREST ||
- this._minFilter === Texture.NEAREST_MIPMAP_LINEAR ||
- this._minFilter === Texture.LINEAR_MIPMAP_LINEAR;
- },
-
- applyTexImage2D: function ( gl ) {
-
- var args = Array.prototype.slice.call( arguments, 1 );
- MACROUTILS.timeStamp( 'osgjs.metrics:Texture.texImage2d' );
-
- // use parameters of pixel store
- gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, this._flipY );
- gl.pixelStorei( gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._colorSpaceConversion );
-
- if ( this._isCompressed ) gl.compressedTexImage2D.apply( gl, args );
- else gl.texImage2D.apply( gl, args );
-
- // call a callback when upload is done if there is one
- var numCallback = this._applyTexImage2DCallbacks.length;
- if ( numCallback > 0 ) {
- for ( var i = 0, l = numCallback; i < l; i++ ) {
- this._applyTexImage2DCallbacks[ i ].call( this );
- }
- }
- },
-
- computeTextureFormat: function () {
-
- if ( !this._internalFormat ) {
- this._internalFormat = this._imageFormat || Texture.RGBA;
- this._imageFormat = this._internalFormat;
- } else {
- this._imageFormat = this._internalFormat;
- }
-
- },
-
- applyImage: function ( gl, image ) {
-
- if ( this._isCompressed ) {
- this.applyTexImage2D( gl, this._textureTarget, 0, this._internalFormat, this._textureWidth, this._textureHeight, 0, image.getImage() );
- } else if ( image.isTypedArray() ) {
- this.applyTexImage2D( gl,
- this._textureTarget,
- 0,
- this._internalFormat,
- this._textureWidth,
- this._textureHeight,
- 0,
- this._internalFormat,
- this._type,
- this._image.getImage() );
- } else {
- this.applyTexImage2D( gl,
- this._textureTarget,
- 0,
- this._internalFormat,
- this._internalFormat,
- this._type,
- image.getImage() );
- }
- image.setDirty( false );
-
- },
-
- apply: function ( state ) {
-
- var gl = state.getGraphicContext();
- // if need to release the texture
- if ( this._dirtyTextureObject ) {
- this.releaseGLObjects();
- this._dirtyTextureObject = false;
- }
-
- if ( this._textureObject !== undefined && !this.isDirty() ) {
- this._textureObject.bind( gl );
- // If we have modified the texture via Rtt or texSubImage2D and _need_ updated mipmaps,
- // then we must regenerate the mipmaps explicitely.
- // In all other cases, don't set this flag because it can be costly
- if ( this.isDirtyMipmap() ) {
- this.generateMipmap( gl, this._textureTarget );
- }
-
- // image update like video
- if ( this._image !== undefined && this._image.isDirty() ) {
- this.applyImage( gl, this._image );
- }
-
- } else if ( this._textureNull ) {
-
- gl.bindTexture( this._textureTarget, null );
-
- } else {
-
- var image = this._image;
- if ( image !== undefined ) {
-
- // when data is ready we will upload it to the gpu
- if ( image.isReady() ) {
-
- // must be called before init
- this.computeTextureFormat();
-
- var imgWidth = image.getWidth() || this._textureWidth;
- var imgHeight = image.getHeight() || this._textureHeight;
-
- this.setTextureSize( imgWidth, imgHeight );
-
- if ( !this._textureObject ) {
- this.init( state );
- }
-
- this._textureObject.bind( gl );
-
- this.applyImage( gl, this._image );
- this.applyFilterParameter( gl, this._textureTarget );
- this.generateMipmap( gl, this._textureTarget );
-
- if ( this._unrefImageDataAfterApply ) {
- this._image = undefined;
- }
-
- this._dirty = false;
-
- } else {
- gl.bindTexture( this._textureTarget, null );
- }
-
- } else if ( this._textureHeight !== 0 && this._textureWidth !== 0 ) {
-
- // must be called before init
- this.computeTextureFormat();
-
- if ( !this._textureObject ) {
- this.init( state );
- }
- this._textureObject.bind( gl );
- this.applyTexImage2D( gl, this._textureTarget, 0, this._internalFormat, this._textureWidth, this._textureHeight, 0, this._internalFormat, this._type, null );
-
- this.applyFilterParameter( gl, this._textureTarget );
- this.generateMipmap( gl, this._textureTarget );
- this._dirty = false;
- }
- }
- }
-
-} ) ), 'osg', 'Texture' );
-
-MACROUTILS.setTypeID( Texture );
-
-Texture.textureNull = new Texture();
-
-Texture.createFromImage = function ( image, format ) {
- var a = new Texture();
- a.setImage( image, format );
- return a;
-};
-
-Texture.createFromCanvas = function ( canvas, format ) {
- return Texture.createFromImage( canvas, format );
-};
-
-Texture.create = function ( url ) {
- Notify.log( 'Texture.create is deprecated, use Texture.createFromURL instead' );
- return Texture.createFromURL( url );
-};
-
-Texture.createFromURL = function ( imageSource, format ) {
- Notify.log( 'Texture.createFromURL is deprecated, use instead osgDB.readImageURL' );
- var texture = new Texture();
- ReaderParser.readImage( imageSource ).then( function ( img ) {
- texture.setImage( img, format );
- } );
- return texture;
-};
-
-
-module.exports = Texture;
diff --git a/app/static/app/js/vendor/osgjs/osg/TextureCubeMap.js b/app/static/app/js/vendor/osgjs/osg/TextureCubeMap.js
deleted file mode 100644
index a1ec608a..00000000
--- a/app/static/app/js/vendor/osgjs/osg/TextureCubeMap.js
+++ /dev/null
@@ -1,230 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Image = require( 'osg/Image' );
-var Notify = require( 'osg/notify' );
-var Texture = require( 'osg/Texture' );
-
-
-/**
- * TextureCubeMap
- * @class TextureCubeMap
- * @inherits Texture
- */
-var TextureCubeMap = function () {
-
- Texture.call( this );
- this._images = {};
-
- // pre allocated all textures faces slots
- for ( var i = 0; i < 6; i++ ) {
- this._images[ Texture.TEXTURE_CUBE_MAP_POSITIVE_X + i ] = new Image();
- }
-
-};
-
-/** @lends TextureCubeMap.prototype */
-TextureCubeMap.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Texture.prototype, {
-
- setDefaultParameters: function () {
- Texture.prototype.setDefaultParameters.call( this );
- this._textureTarget = Texture.TEXTURE_CUBE_MAP;
-
- this._flipY = false;
- },
-
- cloneType: function () {
- return new TextureCubeMap();
- },
-
- setImage: function ( imageFace, img, imageFormat ) {
-
- var face = imageFace;
-
- if ( typeof face === 'string' )
- face = Texture[ face ];
-
- this._images[ face ].setImage( img, imageFormat );
-
- this.setImageFormat( imageFormat );
- this.setTextureSize( this._images[ face ].getWidth(), this._images[ face ].getHeight() );
-
- this._textureNull = false;
- this.dirty();
- },
-
- getImage: function ( face ) {
- return this._images[ face ].getImage();
- },
-
- initCubemapContent: function ( gl ) {
-
- var internalFormat = this._internalFormat;
-
- this.applyTexImage2D( gl, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalFormat, this._textureWidth, this._textureHeight, 0, internalFormat, this._type, null );
-
- this.applyTexImage2D( gl, gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalFormat, this._textureWidth, this._textureHeight, 0, internalFormat, this._type, null );
-
- this.applyTexImage2D( gl, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalFormat, this._textureWidth, this._textureHeight, 0, internalFormat, this._type, null );
-
- this.applyTexImage2D( gl, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalFormat, this._textureWidth, this._textureHeight, 0, internalFormat, this._type, null );
-
- this.applyTexImage2D( gl, gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalFormat, this._textureWidth, this._textureHeight, 0, internalFormat, this._type, null );
-
- this.applyTexImage2D( gl, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalFormat, this._textureWidth, this._textureHeight, 0, internalFormat, this._type, null );
-
- return true;
- },
-
- // handle mipmap logic, if images for mipmap are provided or not
- generateMipmap: function ( gl, target ) {
-
- if ( !this.hasMipmapFilter() ) return;
-
- // manual mipmap provided
- if ( this._images[ Texture.TEXTURE_CUBE_MAP_POSITIVE_X ].hasMipmap() ) {
-
- for ( var face = 0; face < 6; face++ ) {
- var faceImage = this._images[ Texture.TEXTURE_CUBE_MAP_POSITIVE_X + face ];
- if ( !faceImage.hasMipmap() ) {
- Notify.error( 'mipmap not set correctly for TextureCubemap' );
- }
-
- var internalFormat = this._internalFormat;
- for ( var level = 1; level < faceImage.getMipmap().length; level++ ) {
- var size = faceImage.getMipmap()[ level ].getWidth();
-
- this.applyTexImage2D( gl, gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, level, internalFormat, size, size, 0, internalFormat, this._type, faceImage.getMipmap()[ level ].getImage() );
- }
- }
-
- } else {
-
- // automatic mipmap
- gl.generateMipmap( target );
- }
-
- this._dirtyMipmap = false;
- },
-
- applyImageTarget: function ( gl, internalFormat, target ) {
-
- var faceImage = this._images[ target ];
-
- if ( !faceImage.getImage() ) return 0;
-
- if ( !faceImage.isReady() ) return 0;
-
- if ( !faceImage.isDirty() ) return 1;
-
- this.setTextureSize( faceImage.getWidth(), faceImage.getHeight() );
-
- faceImage.setDirty( false );
-
- if ( faceImage.isTypedArray() ) {
- this.applyTexImage2D( gl,
- target,
- 0,
- internalFormat,
- this._textureWidth,
- this._textureHeight,
- 0,
- internalFormat,
- this._type,
- faceImage.getImage() );
- } else {
- this.applyTexImage2D( gl,
- target,
- 0,
- internalFormat,
- internalFormat,
- this._type,
- faceImage.getImage() );
- }
-
- // release here only if no mipmap
- if ( this._unrefImageDataAfterApply &&
- !( this.hasMipmap() && faceImage.hasMipmap() ) ) {
-
- faceImage.release();
- }
-
- return 1;
- },
-
- initCubemapContentImage: function ( gl ) {
-
- var internalFormat = this._internalFormat;
- var valid = 0;
- valid += this.applyImageTarget( gl, internalFormat, gl.TEXTURE_CUBE_MAP_POSITIVE_X );
- valid += this.applyImageTarget( gl, internalFormat, gl.TEXTURE_CUBE_MAP_NEGATIVE_X );
-
- valid += this.applyImageTarget( gl, internalFormat, gl.TEXTURE_CUBE_MAP_POSITIVE_Y );
- valid += this.applyImageTarget( gl, internalFormat, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y );
-
- valid += this.applyImageTarget( gl, internalFormat, gl.TEXTURE_CUBE_MAP_POSITIVE_Z );
- valid += this.applyImageTarget( gl, internalFormat, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z );
-
- if ( valid === 6 )
- return true;
-
- return false;
- },
-
- apply: function ( state ) {
-
- var gl = state.getGraphicContext();
- // if need to release the texture
- if ( this._dirtyTextureObject )
- this.releaseGLObjects();
-
- if ( this._textureObject !== undefined && !this.isDirty() ) {
- this._textureObject.bind( gl );
-
- // If we have modified the texture via Rtt or texSubImage2D and _need_ updated mipmaps,
- // then we must regenerate the mipmaps explicitely.
- // In all other cases, don't set this flag because it can be costly
- if ( this.isDirtyMipmap() ) {
- this.generateMipmap( gl, this._textureTarget );
- }
-
- } else if ( this._textureNull ) {
-
- gl.bindTexture( this._textureTarget, null );
-
- } else {
-
- if ( !this._textureObject ) {
-
- // must be called before init
- this.computeTextureFormat();
-
- this.init( state );
- }
- this._textureObject.bind( gl );
-
- var valid;
-
- // no images it's must be a cubemap filled from rtt
- if ( !this._images[ Texture.TEXTURE_CUBE_MAP_POSITIVE_X ].getImage() ) {
-
- valid = this.initCubemapContent( gl );
-
- } else {
-
- valid = this.initCubemapContentImage( gl );
-
- }
-
- if ( valid ) {
- this._dirty = false;
- this.applyFilterParameter( gl, this._textureTarget );
- this.generateMipmap( gl, this._textureTarget );
- }
- } // render to cubemap not yet implemented
- }
-
-} ), 'osg', 'TextureCubeMap' );
-
-MACROUTILS.setTypeID( TextureCubeMap );
-
-module.exports = TextureCubeMap;
diff --git a/app/static/app/js/vendor/osgjs/osg/TextureManager.js b/app/static/app/js/vendor/osgjs/osg/TextureManager.js
deleted file mode 100644
index 933a502d..00000000
--- a/app/static/app/js/vendor/osgjs/osg/TextureManager.js
+++ /dev/null
@@ -1,272 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var Timer = require( 'osg/Timer' );
-
-
-var TextureProfile = function ( target, internalFormat, width, height ) {
- this._target = target;
- this._internalFormat = internalFormat;
- this._width = width;
- this._height = height;
- this._size = 0;
- this.computeSize();
-};
-
-TextureProfile.prototype = {
- match: function ( textureProfile ) {
- return textureProfile._target === this._target &&
- textureProfile._internalFormat === this._internalFormat &&
- textureProfile._width === this._width &&
- textureProfile._height === this._height;
- },
- computeSize: function () {
- var Texture = require( 'osg/Texture' );
-
- var numBitsPerTexel = 0;
- switch ( this._internalFormat ) {
- case ( 1 ):
- numBitsPerTexel = 8;
- break;
- case ( Texture.ALPHA ):
- numBitsPerTexel = 8;
- break;
- case ( Texture.LUMINANCE ):
- numBitsPerTexel = 8;
- break;
-
- case ( Texture.LUMINANCE_ALPHA ):
- numBitsPerTexel = 16;
- break;
- case ( 2 ):
- numBitsPerTexel = 16;
- break;
-
- case ( Texture.RGB ):
- numBitsPerTexel = 24;
- break;
- case ( 3 ):
- numBitsPerTexel = 24;
- break;
-
- case ( Texture.RGBA ):
- numBitsPerTexel = 32;
- break;
- case ( 4 ):
- numBitsPerTexel = 32;
- break;
-
- }
- var size = ( Math.ceil( this._width * this._height * numBitsPerTexel ) / 8.0 );
-
- if ( this._target === Texture.TEXTURE_CUBE_MAP )
- size *= 6.0;
-
- // add the mipmap overhead size even if not used
- size += size / 3.0;
-
- this._size = size;
- },
-
- getSize: function () {
- return this._size;
- }
-
-};
-TextureProfile.getHash = function () {
- var array = Array.prototype.slice.call( arguments );
- var hash = '';
- array.forEach( function ( element ) {
- hash += element;
- } );
- return hash;
-};
-
-
-var TextureObject = function ( texture, id, textureSet ) {
- this._texture = texture;
- this._id = id;
- this._textureSet = textureSet;
-};
-
-TextureObject.prototype = {
- target: function () {
- return this._textureSet._profile._target;
- },
- id: function () {
- return this._id;
- },
- getTextureSet: function () {
- return this._textureSet;
- },
- reset: function () {
- this._textureObject = null;
- this._texture = undefined;
- },
- bind: function ( gl ) {
- gl.bindTexture( this.target(), this._id );
- }
-};
-
-var TextureObjectSet = function ( profile ) {
- this._profile = profile;
- this._usedTextureObjects = [];
- this._orphanedTextureObjects = [];
-};
-
-TextureObjectSet.prototype = {
- getProfile: function () {
- return this._profile;
- },
- getUsedTextureObjects: function () {
- return this._usedTextureObjects;
- },
- getOrphanedTextureObjects: function () {
- return this._orphanedTextureObjects;
- },
-
- takeOrGenerate: function ( gl, texture ) {
-
- var textureObject;
- if ( this._orphanedTextureObjects.length > 0 ) {
- textureObject = this.takeFromOrphans();
- textureObject._texture = texture;
- this._usedTextureObjects.push( textureObject );
- return textureObject;
- }
-
- var textureID = gl.createTexture();
- textureObject = new TextureObject( texture, textureID, this );
- this._usedTextureObjects.push( textureObject );
-
- return textureObject;
- },
-
- // get texture object from pool
- takeFromOrphans: function () {
-
- if ( this._orphanedTextureObjects.length )
- return this._orphanedTextureObjects.pop();
-
- return undefined;
- },
-
- // release texture object
- orphan: function ( textureObject ) {
- var index = this._usedTextureObjects.indexOf( textureObject );
- if ( index !== -1 ) {
- this._orphanedTextureObjects.push( this._usedTextureObjects[ index ] );
- this._usedTextureObjects.splice( index, 1 );
- }
- },
-
- flushDeletedTextureObjects: function ( gl, availableTime ) {
- // if no time available don't try to flush objects.
- if ( availableTime <= 0.0 ) return availableTime;
- var nbTextures = this._orphanedTextureObjects.length;
- // Should we use a maxSizeTexturePool value?
- //var size = this.getProfile().getSize();
- // We need to test if we have time to flush
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- var i;
- for ( i = 0; i < nbTextures && elapsedTime < availableTime; i++ ) {
- gl.deleteTexture( this._orphanedTextureObjects[ i ].id() );
- this._orphanedTextureObjects[ i ].reset();
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- }
- this._orphanedTextureObjects.splice( 0, i );
- return availableTime - elapsedTime;
- },
-
- flushAllDeletedTextureObjects: function ( gl ) {
- var nbTextures = this._orphanedTextureObjects.length;
- var size = this.getProfile().getSize();
- for ( var i = 0, j = nbTextures; i < j; ++i ) {
- gl.deleteTexture( this._orphanedTextureObjects[ i ].id() );
- this._orphanedTextureObjects[ i ].reset();
- }
- this._orphanedTextureObjects.length = 0;
- Notify.info( 'TextureManager: released ' + nbTextures + ' with ' + ( nbTextures * size / ( 1024 * 1024 ) ) + ' MB' );
- }
-};
-
-
-var TextureManager = function () {
- this._textureSetMap = {};
-};
-
-TextureManager.prototype = {
-
- generateTextureObject: function ( gl,
- texture,
- target,
- internalFormat,
- width,
- height ) {
- var hash = TextureProfile.getHash( target, internalFormat, width, height );
-
- if ( this._textureSetMap[ hash ] === undefined ) {
- this._textureSetMap[ hash ] = new TextureObjectSet( new TextureProfile( target, internalFormat, width, height ) );
- }
-
- var textureSet = this._textureSetMap[ hash ];
- var textureObject = textureSet.takeOrGenerate( gl, texture );
- return textureObject;
- },
-
- updateStats: function ( frameNumber, rStats ) {
- var totalUsed = 0;
- var totalUnused = 0;
- window.Object.keys( this._textureSetMap ).forEach( function ( key ) {
- var profile = this._textureSetMap[ key ].getProfile();
- var size = profile.getSize();
- var nbUsed = this._textureSetMap[ key ].getUsedTextureObjects().length;
- var nbUnused = this._textureSetMap[ key ].getOrphanedTextureObjects().length;
- totalUsed += nbUsed * size;
- totalUnused += nbUnused * size;
- }, this );
-
- var MB = 1024 * 1024;
- rStats( 'textureused' ).set( totalUsed / MB );
- rStats( 'texturereserved' ).set( totalUnused / MB );
- rStats( 'texturetotal' ).set( ( totalUsed + totalUnused ) / MB );
- },
-
- reportStats: function () {
- var total = 0;
- window.Object.keys( this._textureSetMap ).forEach( function ( key ) {
- var profile = this._textureSetMap[ key ].getProfile();
- var size = profile.getSize() / ( 1024 * 1024 );
- var nb = this._textureSetMap[ key ].getUsedTextureObjects().length;
- size *= nb;
- total += size;
- Notify.notice( String( size ) + ' MB with ' + nb + ' texture of ' + profile._width + 'x' + profile._height + ' ' + profile._internalFormat );
- }, this );
- Notify.notice( String( total ) + ' MB in total' );
- },
-
- flushAllDeletedTextureObjects: function ( gl ) {
- window.Object.keys( this._textureSetMap ).forEach( function ( key ) {
- this._textureSetMap[ key ].flushAllDeletedTextureObjects( gl );
- }, this );
- },
-
- flushDeletedTextureObjects: function ( gl, availableTimeArg ) {
- var availableTime = availableTimeArg;
- var keys = window.Object.keys( this._textureSetMap );
- for ( var i = 0, j = keys.length; i < j && availableTime > 0.0; i++ ) {
- availableTime = this._textureSetMap[ keys[ i ] ].flushDeletedTextureObjects( gl, availableTime );
- }
- return availableTime;
- },
-
- releaseTextureObject: function ( textureObject ) {
- if ( textureObject ) {
- var ts = textureObject.getTextureSet();
- ts.orphan( textureObject );
- }
- }
-
-};
-
-module.exports = TextureManager;
diff --git a/app/static/app/js/vendor/osgjs/osg/Timer.js b/app/static/app/js/vendor/osgjs/osg/Timer.js
deleted file mode 100644
index e30cacf7..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Timer.js
+++ /dev/null
@@ -1,55 +0,0 @@
-// user performance if available or fallback
-
-'use strict';
-var now = ( function () {
-
- var w = window || global;
-
- // if no window.performance
- if ( w.performance === undefined ) {
- return function () {
- return Date.now();
- };
- }
-
- var fn = w.performance.now || w.performance.mozNow || w.performance.msNow || w.performance.oNow || w.performance.webkitNow ||
- function () {
- return Date.now();
- };
- return function () {
- return fn.apply( w.performance, arguments );
- };
-} )();
-
-
-var Timer = function () {};
-
-Timer.instance = function () {
-
- if ( !Timer._instance )
- Timer._instance = new Timer();
-
- return Timer._instance;
-};
-
-Timer.prototype = {
-
- // delta in seconds
- deltaS: function ( t0, t1 ) {
- return ( t1 - t0 ) / 1000.0;
- },
-
- // delta in milliseconds
- deltaM: function ( t0, t1 ) {
- return t1 - t0;
- },
-
- tick: function () {
- return now();
- }
-
-
-};
-
-
-module.exports = Timer;
diff --git a/app/static/app/js/vendor/osgjs/osg/TimerGPU.js b/app/static/app/js/vendor/osgjs/osg/TimerGPU.js
deleted file mode 100644
index 3ab15119..00000000
--- a/app/static/app/js/vendor/osgjs/osg/TimerGPU.js
+++ /dev/null
@@ -1,382 +0,0 @@
-'use strict';
-
-var Notify = require( 'osg/notify' );
-
-/*
-use EXT_disjoint_timer_queryto time webgl calls GPU side average over multiple frames
-
-If timestamp feature is not supported, we virtualize the query by splitting and adding
-dummy queries, that way it should handle both nested and interleaved queries.
-
-Also, if you time the same queryID multiple time in the same frame, it will sum the different
-queries, that way you can track a particular of gl command for examples
-
-*/
-
-var TimerGPU = function ( gl ) {
-
- this._enabled = false;
-
- if ( gl ) {
-
- var ext = gl.getExtension( 'EXT_disjoint_timer_query' );
- if ( !ext ) return this;
-
- // https://github.com/KhronosGroup/WebGL/blob/master/sdk/tests/conformance/extensions/ext-disjoint-timer-query.html#L102
- // run the page if strange results
- // to validate you gpu/browser has correct gpu queries support
- this._hasTimeElapsed = ext.getQueryEXT( ext.TIME_ELAPSED_EXT, ext.QUERY_COUNTER_BITS_EXT ) >= 30;
- this._hasTimeStamp = ext.getQueryEXT( ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT ) >= 30;
-
- if ( !this._hasTimeElapsed && !this._hasTimeStamp ) {
- return this;
- }
-
- // no timestamp means not start/end absolute time
- // which means each start must be followed by a end
- // BEFORE any other start (of other queryID)
- if ( !this._hasTimeStamp ) Notify.debug( 'Warning: do not use interleaved GPU query' );
-
- this._gl = gl;
- this._glTimer = ext;
- this._enabled = true;
-
- }
-
- this._frameAverageCount = 10;
-
- this._glQueries = [];
- this._queriesByID = {};
- this._userQueries = []; // for timestamp, it's the same as _glQueries
-
- // stuffs used to virtualize query (no timestamp)
- this._queryCount = 0;
- this._nbOpened = 0;
-};
-
-TimerGPU.FRAME_COUNT = 0;
-
-TimerGPU.instance = function ( gl ) {
-
- if ( !TimerGPU._instance ) {
- TimerGPU._instance = new TimerGPU( gl );
- } else if ( gl && TimerGPU._instance.getContext() !== gl ) {
- TimerGPU._instance.setContext( gl );
- }
- return TimerGPU._instance;
-
-};
-
-TimerGPU.prototype = {
-
- getContext: function () {
- return this._gl;
- },
- setContext: function ( gl ) {
- this._gl = gl;
- },
- setFrameAverageCount: function ( val ) {
- this._frameAverageCount = val;
- },
-
- clearQueries: function () {
- var glQueries = this._glQueries;
- for ( var i = 0, nbQueries = glQueries.length; i < nbQueries; ++i ) {
- var query = glQueries[ i ];
- this._glTimer.deleteQueryEXT( query._pollingStartQuery );
- if ( query._pollingEndQuery ) this._glTimer.deleteQueryEXT( query );
- }
-
- this._userQueries.length = 0;
- this._glQueries.length = 0;
- this._queriesByID = {};
- },
-
- supportTimeStamp: function () {
- return this._hasTimeStamp;
- },
-
- // many browser doesn't yet have
- // the marvellous gpu timers
- enable: function () {
- // enable only if we have the extension
- this._enabled = this._glTimer;
- },
-
- disable: function () {
- this._enabled = false;
- },
- isEnabled: function () {
- return this._enabled;
- },
-
- setCallback: function ( cb ) {
- this._callback = cb;
- },
-
- createUserQuery: function ( queryID ) {
- var query;
- if ( this._hasTimeStamp ) {
- query = this.createGLQuery();
- } else {
- query = {
- _startIndex: 0,
- _endIndex: 0
- };
- }
-
- query._id = queryID;
- query._frame = TimerGPU.FRAME_COUNT;
- query._isOpened = true;
- query._siblings = []; // if the query is called multiple time in the same frame
-
- return query;
- },
-
- createGLQuery: function () {
- var query = {};
- query._isWaiting = false; // wait typically 1 or 2 frames
- query._pollingStartQuery = undefined; // gl query object
- query._pollingEndQuery = undefined; // gl query object (timestamp only)
- query._averageTimer = 0.0; // cumulative average time
- query._resultCount = 0; // cumulative average count
-
- if ( this._hasTimeStamp ) query._pollingEndQuery = this._glTimer.createQueryEXT();
- query._pollingStartQuery = this._glTimer.createQueryEXT();
-
- this._glQueries.push( query );
-
- return query;
- },
-
- getOrCreateLastGLQuery: function () {
- var query = this._glQueries[ this._queryCount - 1 ];
- if ( query ) return query;
-
- query = this._glQueries[ this._queryCount - 1 ] = this.createGLQuery();
-
- return query;
- },
-
- beginCurrentQuery: function () {
- if ( this._nbOpened === 0 ) return;
-
- this._queryCount++;
-
- var query = this.getOrCreateLastGLQuery();
- if ( !query._isWaiting ) {
- this._glTimer.beginQueryEXT( this._glTimer.TIME_ELAPSED_EXT, query._pollingStartQuery );
- }
- },
-
- endCurrentQuery: function () {
- if ( this._nbOpened === 0 ) return;
-
- if ( !this.getOrCreateLastGLQuery()._isWaiting ) {
- this._glTimer.endQueryEXT( this._glTimer.TIME_ELAPSED_EXT );
- }
- },
-
- getAvailableQueryByID: function ( queryID ) {
- var query = this._queriesByID[ queryID ];
- if ( !query ) {
- query = this._queriesByID[ queryID ] = this.createUserQuery( queryID );
- this._userQueries.push( query );
- return query;
- }
-
- if ( query._frame === TimerGPU.FRAME_COUNT ) {
-
- if ( query._isOpened ) return query;
-
- var siblings = query._siblings;
- for ( var i = 0, nbSiblings = siblings.length; i < nbSiblings; ++i ) {
- var qsib = siblings[ i ];
- if ( qsib._frame !== TimerGPU.FRAME_COUNT || qsib._isOpened ) {
- qsib._frame = TimerGPU.FRAME_COUNT;
- return qsib;
- }
- }
-
- var newQuery = this.createUserQuery();
- siblings.push( newQuery );
- return newQuery;
- }
-
- query._frame = TimerGPU.FRAME_COUNT;
-
- return query;
- },
-
- // start recording time if query already exist, don't recreate
- start: function ( queryID ) {
-
- // If timing currently disabled or glTimer does not exist, exit early.
- if ( !this._enabled ) {
- return undefined;
- }
-
- var query = this.getAvailableQueryByID( queryID );
- query._isOpened = true;
-
- if ( this._hasTimeStamp ) {
-
- if ( !query._isWaiting ) this._glTimer.queryCounterEXT( query._pollingStartQuery, this._glTimer.TIMESTAMP_EXT );
-
- } else {
-
- this.endCurrentQuery();
-
- this._nbOpened++;
- query._startIndex = this._queryCount;
-
- this.beginCurrentQuery();
-
- }
-
- },
-
- // stop query recording (if running) polls for results
- end: function ( queryID ) {
-
- if ( !this._enabled ) {
- return;
- }
-
- var query = this.getAvailableQueryByID( queryID );
- query._isOpened = false;
-
- if ( this._hasTimeStamp ) {
-
- if ( !query._isWaiting ) this._glTimer.queryCounterEXT( query._pollingEndQuery, this._glTimer.TIMESTAMP_EXT );
-
- } else {
-
- this.endCurrentQuery();
-
- query._endIndex = this._queryCount;
- this._nbOpened--;
-
- this.beginCurrentQuery();
-
- }
-
- },
-
- computeQueryAverageTime: function ( query ) {
- var average = 0;
- var glQueries = this._glQueries;
-
- for ( var i = query._startIndex; i < query._endIndex; ++i ) {
- var glAvg = glQueries[ i ]._averageTimer;
- if ( glAvg < 0 ) return -1;
- average += glAvg;
- }
-
- return average;
- },
-
- computeFullAverageTime: function ( query ) {
- var average = this.computeQueryAverageTime( query );
-
- if ( average < 0 ) return -1;
-
- var siblings = query._siblings;
- for ( var i = 0, nbSiblings = siblings.length; i < nbSiblings; ++i ) {
- var qsib = siblings[ i ];
- if ( qsib._frame !== TimerGPU.FRAME_COUNT - 1 )
- continue;
-
- var sibAvg = this.computeQueryAverageTime( qsib );
- if ( sibAvg < 0 ) return -1;
- average += sibAvg;
- }
-
- return average;
- },
-
- pollQueries: function () {
-
- TimerGPU.FRAME_COUNT++;
- this._queryCount = 0;
- this._nbOpened = 0;
-
- if ( !this._enabled || !this._callback ) {
- return;
- }
-
- var glQueries = this._glQueries;
- var nbGlQueries = glQueries.length;
- var i;
-
- // all timer are corrupted, clear the queries
- var disjoint = this._gl.getParameter( this._glTimer.GPU_DISJOINT_EXT );
- if ( disjoint ) {
- for ( i = 0; i < nbGlQueries; ++i ) {
- glQueries[ i ]._isWaiting = false;
- }
- return;
- }
-
-
- // update average time for each queries
- for ( i = 0; i < nbGlQueries; ++i ) {
- this.pollQuery( glQueries[ i ] );
- }
-
- var userQueries = this._userQueries;
- var nbUserQueries = userQueries.length;
-
- for ( i = 0; i < nbUserQueries; ++i ) {
- var query = userQueries[ i ];
- var average = this.computeFullAverageTime( query );
- if ( average > 0 ) {
- this._callback( average, query._id );
- }
- }
- },
-
- pollQuery: function ( query ) {
- query._isWaiting = false;
-
- // last to be queried
- var lastQuery = this._hasTimeStamp ? query._pollingEndQuery : query._pollingStartQuery;
-
- // wait till results are ready
- var available = this._glTimer.getQueryObjectEXT( lastQuery, this._glTimer.QUERY_RESULT_AVAILABLE_EXT );
- if ( !available ) {
- query._isWaiting = true;
- return 0;
- }
-
- var timeElapsed;
-
- if ( this._hasTimeStamp ) {
-
- var startTime = this._glTimer.getQueryObjectEXT( query._pollingStartQuery, this._glTimer.QUERY_RESULT_EXT );
- var endTime = this._glTimer.getQueryObjectEXT( lastQuery, this._glTimer.QUERY_RESULT_EXT );
- timeElapsed = endTime - startTime;
-
- } else {
-
- timeElapsed = this._glTimer.getQueryObjectEXT( lastQuery, this._glTimer.QUERY_RESULT_EXT );
-
- }
-
- query._resultCount++;
-
- // restart cumulative average every frameAveragecount frames
- if ( query._resultCount > this._frameAverageCount ) {
- query._averageTimer = 0.0;
- query._resultCount = 1;
- }
-
- // https://en.wikipedia.org/wiki/Moving_average#Cumulative_moving_average
- query._averageTimer = query._averageTimer + ( ( timeElapsed - query._averageTimer ) / ( query._resultCount ) );
-
- return query._averageTimer;
- }
-
-};
-
-module.exports = TimerGPU;
diff --git a/app/static/app/js/vendor/osgjs/osg/Transform.js b/app/static/app/js/vendor/osgjs/osg/Transform.js
deleted file mode 100644
index 0dc7612e..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Transform.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Node = require( 'osg/Node' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var TransformEnums = require( 'osg/transformEnums' );
-
-/**
- * Transform - base class for Transform type node ( Camera, MatrixTransform )
- * @class Transform
- * @inherits Node
- */
-var Transform = function () {
- Node.call( this );
- this.referenceFrame = TransformEnums.RELATIVE_RF;
-};
-
-/** @lends Transform.prototype */
-Transform.prototype = MACROUTILS.objectInherit( Node.prototype, {
- setReferenceFrame: function ( value ) {
- this.referenceFrame = value;
- },
- getReferenceFrame: function () {
- return this.referenceFrame;
- },
-
- computeBoundingSphere: ( function () {
- var matrix = mat4.create();
- return function ( bSphere ) {
- Node.prototype.computeBoundingSphere.call( this, bSphere );
- if ( !bSphere.valid() ) {
- return bSphere;
- }
-
- mat4.identity( matrix );
- // local to local world (not Global World)
- this.computeLocalToWorldMatrix( matrix );
- bSphere.transformMat4( bSphere, matrix );
- return bSphere;
- };
- } )()
-} );
-
-module.exports = Transform;
diff --git a/app/static/app/js/vendor/osgjs/osg/TriangleIndexFunctor.js b/app/static/app/js/vendor/osgjs/osg/TriangleIndexFunctor.js
deleted file mode 100644
index 3ce291b0..00000000
--- a/app/static/app/js/vendor/osgjs/osg/TriangleIndexFunctor.js
+++ /dev/null
@@ -1,96 +0,0 @@
-'use strict';
-
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var DrawElements = require( 'osg/DrawElements' );
-var DrawArrays = require( 'osg/DrawArrays' );
-
-// This class can be used to visit all the triangles of a geometry
-var TriangleIndexFunctor = function () {};
-
-var functorDrawElements = TriangleIndexFunctor.functorDrawElements = [];
-var functorDrawArrays = TriangleIndexFunctor.functorDrawArrays = [];
-
-functorDrawElements[ PrimitiveSet.TRIANGLES ] = function ( offset, count, indexes, cb ) {
- var end = offset + count;
- for ( var i = offset; i < end; i += 3 ) {
- cb( indexes[ i ], indexes[ i + 1 ], indexes[ i + 2 ] );
- }
-};
-
-functorDrawElements[ PrimitiveSet.TRIANGLE_STRIP ] = function ( offset, count, indexes, cb ) {
- for ( var i = 2, j = offset; i < count; ++i, ++j ) {
- if ( i % 2 ) cb( indexes[ j ], indexes[ j + 2 ], indexes[ j + 1 ] );
- else cb( indexes[ j ], indexes[ j + 1 ], indexes[ j + 2 ] );
- }
-};
-
-functorDrawElements[ PrimitiveSet.TRIANGLE_FAN ] = function ( offset, count, indexes, cb ) {
- var first = indexes[ offset ];
- for ( var i = 2, j = offset + 1; i < count; ++i, ++j ) {
- cb( first, indexes[ j ], indexes[ j + 1 ] );
- }
-};
-
-functorDrawArrays[ PrimitiveSet.TRIANGLES ] = function ( first, count, cb ) {
- for ( var i = 2, pos = first; i < count; i += 3, pos += 3 ) {
- cb( pos, pos + 1, pos + 2 );
- }
-};
-
-functorDrawArrays[ PrimitiveSet.TRIANGLE_STRIP ] = function ( first, count, cb ) {
- for ( var i = 2, pos = first; i < count; ++i, ++pos ) {
- if ( i % 2 ) cb( pos, pos + 2, pos + 1 );
- else cb( pos, pos + 1, pos + 2 );
- }
-};
-
-functorDrawArrays[ PrimitiveSet.TRIANGLE_FAN ] = function ( first, count, cb ) {
- for ( var i = 2, pos = first + 1; i < count; ++i, ++pos ) {
- cb( first, pos, pos + 1 );
- }
-};
-
-
-TriangleIndexFunctor.prototype = {
-
- // You feed it with a callback that will be called for each triangle
- // (with the 3 indexes of vertices as arguments)
- init: function ( geom, cb ) {
- this._geom = geom;
- this._cb = cb;
- },
-
- apply: function () {
- var geom = this._geom;
- var primitives = geom.primitives;
- if ( !primitives )
- return;
-
- var cb = this._cb;
- var cbFunctor;
-
- var nbPrimitives = primitives.length;
- for ( var i = 0; i < nbPrimitives; i++ ) {
-
- var primitive = primitives[ i ];
- if ( primitive instanceof DrawElements ) {
-
- cbFunctor = functorDrawElements[ primitive.getMode() ];
- if ( cbFunctor ) {
- var indexes = primitive.indices.getElements();
- cbFunctor( primitive.getFirst() / indexes.BYTES_PER_ELEMENT, primitive.getCount(), indexes, cb );
- }
-
- } else if ( primitive instanceof DrawArrays ) {
-
- cbFunctor = functorDrawArrays[ primitive.getMode() ];
- if ( cbFunctor ) {
- cbFunctor( primitive.getFirst(), primitive.getCount(), cb );
- }
-
- }
- }
- }
-};
-
-module.exports = TriangleIndexFunctor;
diff --git a/app/static/app/js/vendor/osgjs/osg/Uniform.js b/app/static/app/js/vendor/osgjs/osg/Uniform.js
deleted file mode 100644
index 356acb59..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Uniform.js
+++ /dev/null
@@ -1,277 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-
-
-/**
- * Uniform manage variable used in glsl shader.
- * @class Uniform
- */
-var Uniform = function ( name ) {
- this._data = undefined;
- this._transpose = false;
- this._glCall = '';
- this._cache = undefined;
- this._name = name;
- this._type = undefined;
- this._isMatrix = false;
-};
-
-Uniform.isUniform = function ( obj ) {
- if ( typeof obj === 'object' && window.Object.getPrototypeOf( obj ) === Uniform.prototype ) {
- return true;
- }
- return false;
-};
-
-/** @lends Uniform.prototype */
-Uniform.prototype = {
-
- getName: function () {
- return this._name;
- },
-
- dirty: function () {
- Notify.log( 'deprecated dont use Uniform.dirty anymore' );
- },
-
- getType: function () {
- return this._type;
- },
-
- get: function () {
- Notify.log( 'deprecated use getInternalArray instead' );
- return this._data;
- },
-
- set: function ( array ) {
- Notify.log( 'deprecated use setFloat/setInt instead' );
- var value = array;
- if ( !Array.isArray( value ) && value.byteLength === undefined )
- this._data[ 0 ] = value;
- else
- this._data = array;
- },
-
- apply: function UniformApply( gl, location ) {
-
- if ( !this._cache )
- this._cache = gl[ this._glCall ];
-
- if ( this._isMatrix )
- this._cache.call( gl, location, this._transpose, this._data );
- else
- this._cache.call( gl, location, this._data );
- },
-
- // no type checking, so array should be valid
- setInternalArray: function ( array ) {
- this._data = array;
- },
-
- getInternalArray: function () {
- return this._data;
- },
-
- setFloat: function ( f ) {
- this._data[ 0 ] = f;
- },
-
- setFloat1: function ( f ) {
- this._data[ 0 ] = f[ 0 ];
- },
-
- setFloat2: function ( f ) {
- this._data[ 0 ] = f[ 0 ];
- this._data[ 1 ] = f[ 1 ];
- },
-
- setFloat3: function ( f ) {
- this._data[ 0 ] = f[ 0 ];
- this._data[ 1 ] = f[ 1 ];
- this._data[ 2 ] = f[ 2 ];
- },
-
- setFloat4: function ( f ) {
- this._data[ 0 ] = f[ 0 ];
- this._data[ 1 ] = f[ 1 ];
- this._data[ 2 ] = f[ 2 ];
- this._data[ 3 ] = f[ 3 ];
- },
-
- setFloat9: function ( f ) {
- this._data[ 0 ] = f[ 0 ];
- this._data[ 1 ] = f[ 1 ];
- this._data[ 2 ] = f[ 2 ];
- this._data[ 3 ] = f[ 3 ];
- this._data[ 4 ] = f[ 4 ];
- this._data[ 5 ] = f[ 5 ];
- this._data[ 6 ] = f[ 6 ];
- this._data[ 7 ] = f[ 7 ];
- this._data[ 8 ] = f[ 8 ];
- },
-
- setFloat16: function ( f ) {
- this._data[ 0 ] = f[ 0 ];
- this._data[ 1 ] = f[ 1 ];
- this._data[ 2 ] = f[ 2 ];
- this._data[ 3 ] = f[ 3 ];
- this._data[ 4 ] = f[ 4 ];
- this._data[ 5 ] = f[ 5 ];
- this._data[ 6 ] = f[ 6 ];
- this._data[ 7 ] = f[ 7 ];
- this._data[ 8 ] = f[ 8 ];
- this._data[ 9 ] = f[ 9 ];
- this._data[ 10 ] = f[ 10 ];
- this._data[ 11 ] = f[ 11 ];
- this._data[ 12 ] = f[ 12 ];
- this._data[ 13 ] = f[ 13 ];
- this._data[ 14 ] = f[ 14 ];
- this._data[ 15 ] = f[ 15 ];
- }
-};
-Uniform.prototype.setVec2 = Uniform.prototype.setFloat2;
-Uniform.prototype.setVec3 = Uniform.prototype.setFloat3;
-Uniform.prototype.setVec4 = Uniform.prototype.setFloat4;
-Uniform.prototype.setMatrix4 = Uniform.prototype.setFloat16;
-Uniform.prototype.setMatrix3 = Uniform.prototype.setFloat9;
-Uniform.prototype.setInt = Uniform.prototype.setFloat;
-Uniform.prototype.setInt1 = Uniform.prototype.setFloat1;
-Uniform.prototype.setInt2 = Uniform.prototype.setFloat2;
-Uniform.prototype.setInt3 = Uniform.prototype.setFloat3;
-Uniform.prototype.setInt4 = Uniform.prototype.setFloat4;
-
-
-var createUniformX = function ( dataOrName, uniformName, defaultConstructor, glSignature, type, isMatrix ) {
- var data = uniformName === undefined ? undefined : dataOrName;
- var uniform = new Uniform( uniformName === undefined ? dataOrName : uniformName );
-
- uniform._data = defaultConstructor();
-
- if ( data !== undefined ) {
- if ( data.length ) {
- for ( var i = 0, nbElts = data.length; i < nbElts; ++i )
- uniform._data[ i ] = data[ i ];
- } else {
- uniform._data[ 0 ] = data;
- }
- }
-
- uniform._glCall = glSignature;
- uniform._type = type;
- uniform._isMatrix = !!isMatrix;
- return uniform;
-};
-
-var constructorFloat = function () {
- return new Float32Array( 1 );
-};
-
-var constructorFloat2 = function () {
- return new Float32Array( 2 );
-};
-
-var constructorFloat3 = function () {
- return new Float32Array( 3 );
-};
-
-var constructorFloat4 = function () {
- return new Float32Array( 4 );
-};
-
-var constructorInt = function () {
- return new Int32Array( 1 );
-};
-
-var constructorInt2 = function () {
- return new Int32Array( 2 );
-};
-
-var constructorInt3 = function () {
- return new Int32Array( 3 );
-};
-
-var constructorInt4 = function () {
- return new Int32Array( 4 );
-};
-
-var constructorMat2 = function () {
- var out = new Float32Array( 4 );
- out[ 0 ] = out[ 3 ] = 1.0;
- return out;
-};
-
-var constructorMat3 = function () {
- var out = new Float32Array( 9 );
- out[ 0 ] = out[ 4 ] = out[ 8 ] = 1.0;
- return out;
-};
-
-var constructorMat4 = function () {
- var out = new Float32Array( 16 );
- out[ 0 ] = out[ 5 ] = out[ 10 ] = out[ 15 ] = 1.0;
- return out;
-};
-
-// works also for float array but data must be given
-Uniform.createFloat1 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorFloat, 'uniform1fv', 'float' );
-};
-
-Uniform.createInt1 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorInt, 'uniform1iv', 'int' );
-};
-
-Uniform.createFloat2 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorFloat2, 'uniform2fv', 'vec2' );
-};
-
-Uniform.createInt2 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorInt2, 'uniform2iv', 'vec2i' );
-};
-
-Uniform.createFloat3 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorFloat3, 'uniform3fv', 'vec3' );
-};
-
-Uniform.createInt3 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorInt3, 'uniform3iv', 'vec3i' );
-};
-
-Uniform.createFloat4 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorFloat4, 'uniform4fv', 'vec4' );
-};
-
-Uniform.createInt4 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorInt4, 'uniform4iv', 'vec4i' );
-};
-
-Uniform.createMatrix2 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorMat2, 'uniformMatrix2fv', 'mat2', true );
-};
-
-Uniform.createMatrix3 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorMat3, 'uniformMatrix3fv', 'mat3', true );
-};
-
-Uniform.createMatrix4 = function ( data, uniformName ) {
- return createUniformX( data, uniformName, constructorMat4, 'uniformMatrix4fv', 'mat4', true );
-};
-
-// alias
-Uniform.float = Uniform.createFloatArray = Uniform.createFloat = Uniform.createFloat1;
-Uniform.int = Uniform.createIntArray = Uniform.createInt = Uniform.createInt1;
-
-Uniform.vec2 = Uniform.createFloat2Array = Uniform.createFloat2;
-Uniform.vec2i = Uniform.createInt2Array = Uniform.createInt2;
-
-Uniform.vec3 = Uniform.createFloat3Array = Uniform.createFloat3;
-Uniform.vec3i = Uniform.createInt3Array = Uniform.createInt3;
-
-Uniform.vec4 = Uniform.createFloat4Array = Uniform.createFloat4;
-Uniform.vec4i = Uniform.createInt4Array = Uniform.createInt4;
-
-Uniform.mat2 = Uniform.createMat2 = Uniform.createMatrix2;
-Uniform.mat3 = Uniform.createMat3 = Uniform.createMatrix3;
-Uniform.mat4 = Uniform.createMat4 = Uniform.createMatrix4;
-
-module.exports = Uniform;
diff --git a/app/static/app/js/vendor/osgjs/osg/UpdateVisitor.js b/app/static/app/js/vendor/osgjs/osg/UpdateVisitor.js
deleted file mode 100644
index 3767ca26..00000000
--- a/app/static/app/js/vendor/osgjs/osg/UpdateVisitor.js
+++ /dev/null
@@ -1,52 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-
-
-var UpdateVisitor = function () {
- NodeVisitor.call( this );
- this.visitorType = NodeVisitor.UPDATE_VISITOR;
- this._numUpdateCallback = 0;
-};
-
-UpdateVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
-
- resetStats: function () {
- this._numUpdateCallback = 0;
- },
-
- apply: function ( node ) {
-
- // a way to avoid extra call is to implement getNumChildrenRequiringUpdateTraversal
- // and stateset.requiresUpdateTraversal()
-
-
- // handle callback in stateset
- var stateSet = node.getStateSet();
- if ( stateSet && stateSet.requiresUpdateTraversal() ) {
- var updateCallbackList = stateSet.getUpdateCallbackList();
-
- var numStateSetUpdateCallback = updateCallbackList.length;
- if ( numStateSetUpdateCallback ) {
- this._numUpdateCallback += numStateSetUpdateCallback;
- for ( var i = 0, l = numStateSetUpdateCallback; i < l; i++ )
- updateCallbackList[ i ].update( stateSet, this );
- }
- }
-
- // handle callback in nodes
- var ncs = node.getUpdateCallbackList();
- var numUpdateCallback = ncs.length;
- for ( var j = 0; j < numUpdateCallback; j++ ) {
- this._numUpdateCallback++;
- if ( !ncs[ j ].update( node, this ) ) {
- return;
- }
- }
-
- if ( node.getNumChildrenRequiringUpdateTraversal() > 0 )
- this.traverse( node );
- }
-} );
-
-module.exports = UpdateVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osg/Utils.js b/app/static/app/js/vendor/osgjs/osg/Utils.js
deleted file mode 100644
index 09d0eb6f..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Utils.js
+++ /dev/null
@@ -1,210 +0,0 @@
-'use strict';
-var osgPool = require( 'osgUtil/osgPool' );
-var StateGraph = require( 'osg/StateGraph' );
-var Timer = require( 'osg/Timer' );
-var Notify = require( 'osg/notify' );
-
-// make the warning about StateGraph desappear
-window.Object.keys( StateGraph );
-
-var Utils = {};
-
-Utils.init = function () {
- var StateGraphClass = require( 'osg/StateGraph' );
- osgPool.memoryPools.stateGraph = new osgPool.OsgObjectMemoryPool( StateGraphClass ).grow( 50 );
-};
-
-Utils.isArray = function ( obj ) {
- Notify.log( 'isArray is deprecated, use instead Array.isArray' );
- return Array.isArray( obj );
-};
-
-Utils.extend = function () {
- // Save a reference to some core methods
- var toString = window.Object.prototype.toString;
- var hasOwnPropertyFunc = window.Object.prototype.hasOwnProperty;
-
- var isFunction = function ( obj ) {
- return toString.call( obj ) === '[object Function]';
- };
- var isArray = Utils.isArray;
- var isPlainObject = function ( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || toString.call( obj ) !== '[object Object]' || obj.nodeType || obj.setInterval ) {
- return false;
- }
-
- // Not own constructor property must be Object
- if ( obj.constructor && !hasOwnPropertyFunc.call( obj, 'constructor' ) && !hasOwnPropertyFunc.call( obj.constructor.prototype, 'isPrototypeOf' ) ) {
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
-
- var key;
- for ( key in obj ) {}
-
- return key === undefined || hasOwnPropertyFunc.call( obj, key );
- };
-
- // copy reference to target object
- var target = arguments[ 0 ] || {},
- i = 1,
- length = arguments.length,
- deep = false,
- options, name, src, copy;
-
- // Handle a deep copy situation
- if ( typeof target === 'boolean' ) {
- deep = target;
- target = arguments[ 1 ] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== 'object' && !isFunction( target ) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( ( options = arguments[ i ] ) !== null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging object literal values or arrays
- if ( deep && copy && ( isPlainObject( copy ) || isArray( copy ) ) ) {
- var clone = src && ( isPlainObject( src ) || isArray( src ) ) ? src : isArray( copy ) ? [] : {};
-
- // Never move original objects, clone them
- target[ name ] = Utils.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-Utils.objectInherit = function ( base /*, extras*/ ) {
- function F() {}
- F.prototype = base;
- var obj = new F();
-
- // let augment object with multiple arguement
- for ( var i = 1; i < arguments.length; i++ ) {
- Utils.objectMix( obj, arguments[ i ], false );
- }
- return obj;
-};
-
-Utils.objectInehrit = function () {
- console.warn( 'please use objectInherit instead of objectInehrit' );
-};
-
-Utils.objectMix = function ( obj, properties, test ) {
- for ( var key in properties ) {
- if ( !( test && obj[ key ] ) ) {
- obj[ key ] = properties[ key ];
- }
- }
- return obj;
-};
-
-Utils.objectType = {};
-Utils.objectType.type = 0;
-Utils.objectType.generate = function ( arg ) {
- var t = Utils.objectType.type;
- Utils.objectType[ t ] = arg;
- Utils.objectType[ arg ] = t;
- Utils.objectType.type += 1;
- return t;
-};
-
-Utils.objectLibraryClass = function ( object, libName, className ) {
- object.className = function () {
- return className;
- };
- object.libraryName = function () {
- return libName;
- };
- var libraryClassName = libName + '::' + className;
- object.libraryClassName = function () {
- return libraryClassName;
- };
-
- return object;
-};
-
-Utils.setTypeID = function ( classObject ) {
- var className = classObject.prototype.libraryClassName();
- var typeID = Utils.objectType.generate( className );
- var getTypeID = function () {
- return typeID;
- };
- classObject.typeID = classObject.prototype.typeID = typeID;
- classObject.getTypeID = classObject.prototype.getTypeID = getTypeID;
-};
-
-Utils.createPrototypeClass = function ( Constructor, prototype, libraryName, className ) {
-
- Constructor.prototype = prototype;
- prototype.constructor = Constructor;
-
- Utils.objectLibraryClass( prototype, libraryName, className );
- Utils.setTypeID( Constructor );
-};
-
-Utils.Float32Array = typeof Float32Array !== 'undefined' ? Float32Array : null;
-Utils.Int32Array = typeof Int32Array !== 'undefined' ? Int32Array : null;
-Utils.Uint8Array = typeof Uint8Array !== 'undefined' ? Uint8Array : null;
-Utils.Uint16Array = typeof Uint16Array !== 'undefined' ? Uint16Array : null;
-Utils.Uint32Array = typeof Uint32Array !== 'undefined' ? Uint32Array : null;
-
-var times = {};
-
-// we bind the function to Notify.console once and for all to avoid costly apply function
-
-Utils.time = ( Notify.console.time || function ( name ) {
- times[ name ] = Timer.instance().tick();
-} ).bind( Notify.console );
-
-Utils.timeEnd = ( Notify.console.timeEnd || function ( name ) {
-
- if ( times[ name ] === undefined )
- return;
-
- var duration = Timer.instance().deltaM( times[ name ], Timer.instance().tick() );
-
- Notify.debug( name + ': ' + duration + 'ms' );
- times[ name ] = undefined;
-
-} ).bind( Notify.console );
-
-Utils.timeStamp = ( Notify.console.timeStamp || Notify.console.markTimeline || function () {} ).bind( Notify.console );
-Utils.profile = ( Notify.console.profile || function () {} ).bind( Notify.console );
-Utils.profileEnd = ( Notify.console.profileEnd || function () {} ).bind( Notify.console );
-
-module.exports = Utils;
diff --git a/app/static/app/js/vendor/osgjs/osg/Vec2.js b/app/static/app/js/vendor/osgjs/osg/Vec2.js
deleted file mode 100644
index 1d4435af..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Vec2.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require( 'osg/deprecated-MatrixVector/Vec2' );
diff --git a/app/static/app/js/vendor/osgjs/osg/Vec3.js b/app/static/app/js/vendor/osgjs/osg/Vec3.js
deleted file mode 100644
index b8a11ed8..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Vec3.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require( 'osg/deprecated-MatrixVector/Vec3' );
diff --git a/app/static/app/js/vendor/osgjs/osg/Vec4.js b/app/static/app/js/vendor/osgjs/osg/Vec4.js
deleted file mode 100644
index c9015cfc..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Vec4.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require( 'osg/deprecated-MatrixVector/Vec4' );
diff --git a/app/static/app/js/vendor/osgjs/osg/Viewport.js b/app/static/app/js/vendor/osgjs/osg/Viewport.js
deleted file mode 100644
index dcaa14bb..00000000
--- a/app/static/app/js/vendor/osgjs/osg/Viewport.js
+++ /dev/null
@@ -1,69 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-var Viewport = function ( x, y, w, h ) {
- StateAttribute.call( this );
-
- this._x = x !== undefined ? x : 0;
- this._y = y !== undefined ? y : 0;
- this._width = w !== undefined ? w : 800;
- this._height = h !== undefined ? h : 600;
-};
-
-Viewport.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Viewport',
-
- cloneType: function () {
- return new Viewport();
- },
-
- apply: function ( state ) {
- var gl = state.getGraphicContext();
- gl.viewport( this._x, this._y, this._width, this._height );
- },
-
- setViewport: function ( x, y, width, height ) {
- this._x = x;
- this._y = y;
- this._width = width;
- this._height = height;
- },
-
- x: function () {
- return this._x;
- },
-
- y: function () {
- return this._y;
- },
-
- width: function () {
- return this._width;
- },
-
- height: function () {
- return this._height;
- },
-
- computeWindowMatrix: ( function () {
- var translate = mat4.create();
- var scale = mat4.create();
- var unitVec = vec3.fromValues( 1.0, 1.0, 1.0 );
- return function ( destination ) {
- // res = Matrix offset * Matrix scale * Matrix translate
- mat4.fromTranslation( translate, unitVec );
- mat4.fromScaling( scale, [ 0.5 * this._width, 0.5 * this._height, 0.5 ] );
- var offset = mat4.fromTranslation( destination, vec3.fromValues( this._x, this._y, 0.0 ) );
-
- return mat4.mul( offset, offset, mat4.mul( scale, scale, translate ) );
-
- };
- } )()
-
-} ), 'osg', 'Viewport' );
-
-module.exports = Viewport;
diff --git a/app/static/app/js/vendor/osgjs/osg/WebGLCaps.js b/app/static/app/js/vendor/osgjs/osg/WebGLCaps.js
deleted file mode 100644
index 8253c96d..00000000
--- a/app/static/app/js/vendor/osgjs/osg/WebGLCaps.js
+++ /dev/null
@@ -1,376 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var WebGLUtils = require( 'osgViewer/webgl-utils' );
-var Texture;
-
-var WebGLCaps = function () {
-
- // circular deps with texture
- if ( !Texture ) Texture = require( 'osg/Texture' );
-
- this._checkRTT = {};
- this._webGLExtensions = {};
- this._webGLParameters = {};
- this._webGLShaderMaxInt = 'NONE';
- this._webGLShaderMaxFloat = 'NONE';
-
- this._bugsDB = {};
- this._webGLPlatforms = {};
-
- // webgl minimum requirements as per webgl specs
- // useful for nodejs env
- this._webGLParameters[ 'MAX_COMBINED_TEXTURE_IMAGE_UNITS' ] = 8;
- this._webGLParameters[ 'MAX_CUBE_MAP_TEXTURE_SIZE' ] = 16;
- this._webGLParameters[ 'MAX_FRAGMENT_UNIFORM_VECTORS' ] = 16;
- this._webGLParameters[ 'MAX_RENDERBUFFER_SIZE' ] = 1;
- this._webGLParameters[ 'MAX_TEXTURE_IMAGE_UNITS' ] = 8;
- this._webGLParameters[ 'MAX_TEXTURE_SIZE' ] = 64;
- this._webGLParameters[ 'MAX_VARYING_VECTORS' ] = 8;
- this._webGLParameters[ 'MAX_VERTEX_ATTRIBS' ] = 8;
- this._webGLParameters[ 'MAX_VERTEX_TEXTURE_IMAGE_UNITS' ] = 0;
- this._webGLParameters[ 'MAX_VERTEX_UNIFORM_VECTORS' ] = 128;
- this._webGLParameters[ 'MAX_VIEWPORT_DIMS' ] = [ 1, 1 ];
- this._webGLParameters[ 'NUM_COMPRESSED_TEXTURE_FORMATS' ] = 0;
- this._webGLParameters[ 'MAX_SHADER_PRECISION_FLOAT' ] = 'none';
- this._webGLParameters[ 'MAX_SHADER_PRECISION_INT' ] = 'none';
-
- // for multiple context
- // allow checking we're on the good one
- this._gl = undefined;
-
-};
-
-WebGLCaps.instance = function ( glParam ) {
-
-
- if ( !WebGLCaps._instance ) {
-
- var oldWebGLInspector;
- var gl = glParam;
-
- if ( !gl ) {
-
- // make sure we don't break webglinspector
- // with our webglcaps canvas
- var webglInspector = typeof window !== 'undefined' && window.gli;
-
- if ( webglInspector ) {
-
- oldWebGLInspector = window.gli.host.inspectContext;
- window.gli.host.inspectContext = false;
-
- }
-
- var c = document.createElement( 'canvas' );
- c.width = 32;
- c.height = 32;
- // not necessary, but for some reasons it crashed on chromium vr build
- var opt = {
- antialias: false
- };
-
- gl = WebGLUtils.setupWebGL( c, opt, function () {} );
-
- }
-
- WebGLCaps._instance = new WebGLCaps();
- if ( gl ) {
-
- WebGLCaps._instance.init( gl );
-
- } else {
-
- // gracefully handle non webgl
- // like nodejs, phantomjs
- // warns but no error so that nodejs/phantomjs
- // can still has some webglcaps object
- Notify.warn( 'no support for webgl context detected.' );
-
- }
-
- if ( oldWebGLInspector ) {
-
- window.gli.host.inspectContext = oldWebGLInspector;
-
- }
-
- //delete c;
- }
-
- if ( glParam && glParam !== WebGLCaps._instance.getContext() ) {
-
- // webgl caps called with a different context
- // than the one we draw in, will result on hard crash
- // when using extension from another context
- WebGLCaps._instance.initContextDependant( glParam );
-
- }
-
- return WebGLCaps._instance;
-};
-
-WebGLCaps.prototype = {
-
- getContext: function () {
- return this._gl;
- },
-
- initContextDependant: function ( gl ) {
-
- // store context in case of multiple context
- this._gl = gl;
-
- // Takes care of circular dependencies on Texture
- // Texture should be resolved at this point
- // Texture = require( 'osg/Texture' );
-
- // get extensions
- this.initWebGLExtensions( gl );
-
- // get float support
- this.hasLinearHalfFloatRTT( gl );
- this.hasLinearFloatRTT( gl );
- this.hasHalfFloatRTT( gl );
- this.hasFloatRTT( gl );
-
- },
-
- init: function ( gl ) {
-
- // get capabilites
- this.initWebGLParameters( gl );
-
- // order is important
- // to allow webgl extensions filtering
- this.initPlatformSupport();
- this.initBugDB();
-
- this.initContextDependant( gl );
-
- this._isGL2 = typeof window.WebGL2RenderingContext !== 'undefined' && gl instanceof window.WebGL2RenderingContext;
-
- if ( this._isGL2 ) {
-
-
- // osgjs code is webgl1, so we fake webgl2 capabilities
- // and calls for retrocompatibility with webgl1
- this._checkRTT[ Texture.FLOAT + ',' + Texture.NEAREST ] = true;
- this._checkRTT[ Texture.HALF_FLOAT + ',' + Texture.NEAREST ] = true;
- this._checkRTT[ Texture.FLOAT + ',' + Texture.LINEAR ] = true;
- this._checkRTT[ Texture.HALF_FLOAT + ',' + Texture.LINEAR ] = true;
-
- var nativeExtension = [
- 'OES_element_index_uint',
- 'EXT_sRGB',
- 'EXT_blend_minmax',
- 'EXT_frag_depth',
- 'WEBGL_depth_texture',
- 'EXT_shader_texture_lod',
- 'OES_standard_derivatives',
- 'OES_texture_float',
- 'OES_texture_half_float',
- 'OES_vertex_array_object',
- 'WEBGL_draw_buffers',
- 'OES_fbo_render_mipmap',
- 'ANGLE_instanced_arrays'
- ];
-
- var ext = WebGLCaps._instance.getWebGLExtensions();
- var dummyFunc = function () {};
- for ( var i = 0, l = nativeExtension.length; i < l; i++ ) {
- ext[ nativeExtension[ i ] ] = dummyFunc;
- }
- }
-
- },
-
- isWebGL2: function () {
- return this._isGL2;
- },
- // inevitable bugs per platform (browser/OS/GPU)
- initBugDB: function () {
-
- },
- initPlatformSupport: function () {
-
- var p = this._webGLPlatforms;
-
- p.Apple = navigator.vendor.indexOf( 'Apple' ) !== -1 || navigator.vendor.indexOf( 'OS X' ) !== -1;
-
- // degrades complexity on handhelds.
- p.Mobile = /Mobi/.test( navigator.userAgent ) || /ablet/.test( navigator.userAgent );
-
- },
- getWebGLPlatform: function ( str ) {
- return this._webGLPlatforms[ str ];
- },
- getWebGLPlatforms: function () {
- return this._webGLPlatforms;
- },
-
- getWebGLParameter: function ( str ) {
- return this._webGLParameters[ str ];
- },
- getWebGLParameters: function () {
- return this._webGLParameters;
- },
- getShaderMaxPrecisionFloat: function () {
- return this._webGLParameters.MAX_SHADER_PRECISION_FLOAT;
- },
- getShaderMaxPrecisionInt: function () {
- return this._webGLParameters.MAX_SHADER_PRECISION_INT;
- },
- checkSupportRTT: function ( gl, typeFloat, typeTexture ) {
-
- var key = typeFloat + ',' + typeTexture;
-
- // check once only
- if ( this._checkRTT[ key ] !== undefined )
- return this._checkRTT[ key ];
-
- // no cached results, need gl context
- if ( !gl ) return false;
-
- // from http://codeflow.org/entries/2013/feb/22/how-to-write-portable-webgl/#how-can-i-detect-if-i-can-render-to-floating-point-textures
-
- // setup the texture
- var texture = gl.createTexture();
- gl.bindTexture( gl.TEXTURE_2D, texture );
- gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, typeFloat, null );
- gl.texParameteri( gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, typeTexture );
- gl.texParameteri( gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, typeTexture );
-
- // setup the framebuffer
- var framebuffer = gl.createFramebuffer();
- gl.bindFramebuffer( gl.FRAMEBUFFER, framebuffer );
- gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0 );
-
- // check the framebuffer
- var status = this._checkRTT[ key ] = gl.checkFramebufferStatus( gl.FRAMEBUFFER ) === gl.FRAMEBUFFER_COMPLETE;
-
- // cleanup
- gl.deleteTexture( texture );
- gl.deleteFramebuffer( framebuffer );
- gl.bindTexture( gl.TEXTURE_2D, null );
- gl.bindFramebuffer( gl.FRAMEBUFFER, null );
-
- return status;
- },
- hasLinearHalfFloatRTT: function ( gl ) {
- return this._webGLExtensions[ 'OES_texture_half_float_linear' ] && this.checkSupportRTT( gl, Texture.HALF_FLOAT, Texture.LINEAR );
- },
- hasLinearFloatRTT: function ( gl ) {
- return this._webGLExtensions[ 'OES_texture_float_linear' ] && this.checkSupportRTT( gl, Texture.FLOAT, Texture.LINEAR );
- },
- hasHalfFloatRTT: function ( gl ) {
- return this._webGLExtensions[ 'OES_texture_half_float' ] && this.checkSupportRTT( gl, Texture.HALF_FLOAT, Texture.NEAREST );
- },
- hasFloatRTT: function ( gl ) {
- return this._webGLExtensions[ 'OES_texture_float' ] && this.checkSupportRTT( gl, Texture.FLOAT, Texture.NEAREST );
- },
- queryPrecision: function ( gl, shaderType, precision ) {
- var answer = gl.getShaderPrecisionFormat( shaderType, precision );
- if ( !answer ) return false;
- return answer.precision !== 0;
- },
- initWebGLParameters: function ( gl ) {
- if ( !gl ) return;
- var limits = [
- 'MAX_COMBINED_TEXTURE_IMAGE_UNITS',
- 'MAX_CUBE_MAP_TEXTURE_SIZE',
- 'MAX_FRAGMENT_UNIFORM_VECTORS',
- 'MAX_RENDERBUFFER_SIZE',
- 'MAX_TEXTURE_IMAGE_UNITS',
- 'MAX_TEXTURE_SIZE',
- 'MAX_VARYING_VECTORS',
- 'MAX_VERTEX_ATTRIBS',
- 'MAX_VERTEX_TEXTURE_IMAGE_UNITS',
- 'MAX_VERTEX_UNIFORM_VECTORS',
- 'MAX_VIEWPORT_DIMS',
- 'SHADING_LANGUAGE_VERSION',
- 'VERSION',
- 'VENDOR',
- 'RENDERER',
- 'ALIASED_LINE_WIDTH_RANGE',
- 'ALIASED_POINT_SIZE_RANGE',
- 'RED_BITS',
- 'GREEN_BITS',
- 'BLUE_BITS',
- 'ALPHA_BITS',
- 'DEPTH_BITS',
- 'STENCIL_BITS'
- ];
- var params = this._webGLParameters;
- for ( var i = 0, len = limits.length; i < len; ++i ) {
- var par = limits[ i ];
- params[ par ] = gl.getParameter( gl[ par ] );
- }
-
- //shader precisions for float
- if ( this.queryPrecision( gl, gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ) ) {
- params.MAX_SHADER_PRECISION_FLOAT = 'high';
- } else if ( this.queryPrecision( gl, gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ) ) {
- params.MAX_SHADER_PRECISION_FLOAT = 'medium';
- } else if ( this.queryPrecision( gl, gl.FRAGMENT_SHADER, gl.LOW_FLOAT ) ) {
- params.MAX_SHADER_PRECISION_FLOAT = 'low';
- }
-
- //shader precisions for float
- if ( this.queryPrecision( gl, gl.FRAGMENT_SHADER, gl.HIGH_INT ) ) {
- params.MAX_SHADER_PRECISION_INT = 'high';
- } else if ( this.queryPrecision( gl, gl.FRAGMENT_SHADER, gl.MEDIUM_INT ) ) {
- params.MAX_SHADER_PRECISION_INT = 'medium';
- } else if ( this.queryPrecision( gl, gl.FRAGMENT_SHADER, gl.LOW_INT ) ) {
- params.MAX_SHADER_PRECISION_INT = 'low';
- }
-
- // get GPU, Angle or not, Opengl/directx, etc.
- // ffx && chrome only
- var debugInfo = gl.getExtension( 'WEBGL_debug_renderer_info' );
- if ( debugInfo ) {
- params.UNMASKED_RENDERER_WEBGL = gl.getParameter( debugInfo.UNMASKED_VENDOR_WEBGL );
- params.UNMASKED_VENDOR_WEBGL = gl.getParameter( debugInfo.UNMASKED_RENDERER_WEBGL );
-
- }
- // TODO ?
- // try to compile a small shader to test the spec is respected
- },
- getWebGLExtension: function ( str ) {
- return this._webGLExtensions[ str ];
- },
- getWebGLExtensions: function () {
- return this._webGLExtensions;
- },
- initWebGLExtensions: function ( gl, filterBugs ) {
-
- // nodejs, phantomjs
- if ( !gl ) return;
-
- var doFilter = filterBugs;
- if ( doFilter === undefined )
- doFilter = true;
-
- var supported = gl.getSupportedExtensions();
- var ext = this._webGLExtensions;
- // we load all the extensions
- for ( var i = 0, len = supported.length; i < len; ++i ) {
- var sup = supported[ i ];
-
- if ( doFilter && this._bugsDB[ sup ] ) {
- // bugs on that configuration, do not enable
- continue;
- }
-
- ext[ sup ] = gl.getExtension( sup );
- }
-
- var anisoExt = this.getWebGLExtension( 'EXT_texture_filter_anisotropic' );
- if ( anisoExt ) {
- Texture.ANISOTROPIC_SUPPORT_EXT = true;
- Texture.ANISOTROPIC_SUPPORT_MAX = gl.getParameter( anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT );
- }
-
- }
-};
-
-module.exports = WebGLCaps;
diff --git a/app/static/app/js/vendor/osgjs/osg/computeMatrixFromNodePath.js b/app/static/app/js/vendor/osgjs/osg/computeMatrixFromNodePath.js
deleted file mode 100644
index 45020fbf..00000000
--- a/app/static/app/js/vendor/osgjs/osg/computeMatrixFromNodePath.js
+++ /dev/null
@@ -1,52 +0,0 @@
-'use strict';
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var TransformEnums = require( 'osg/transformEnums' );
-
-
-var computeLocalToWorld = function ( nodePath, ignoreCameras, userMatrix ) {
-
- var ignoreCamera = ignoreCameras;
-
- if ( ignoreCamera === undefined ) ignoreCamera = true;
-
- var matrix = userMatrix || mat4.create();
-
- var j = 0;
-
- if ( ignoreCamera ) {
-
- for ( j = nodePath.length - 1; j >= 0; j-- ) {
-
- var camera = nodePath[ j ];
-
- if ( camera.className() === 'Camera' &&
- ( camera.getReferenceFrame() !== TransformEnums.RELATIVE_RF || camera.getParents().length === 0 ) ) {
- break;
- }
-
- }
-
- // because when we break it's to an index - 1
- // it works because if nothing camera found j == -1 at the end of the loop
- // and if we found a camera we want to start at the camera index + 1
- j += 1;
-
- }
-
- for ( var i = j, l = nodePath.length; i < l; i++ ) {
-
- var node = nodePath[ i ];
-
- if ( node.computeLocalToWorldMatrix ) {
- node.computeLocalToWorldMatrix( matrix );
- }
-
- }
-
- return matrix;
-
-};
-
-module.exports = {
- computeLocalToWorld: computeLocalToWorld
-};
diff --git a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Matrix.js b/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Matrix.js
deleted file mode 100644
index c8fc485c..00000000
--- a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Matrix.js
+++ /dev/null
@@ -1,701 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var osgMath = require( 'osg/math' );
-var BoundingBox = require( 'osg/BoundingBox' );
-var Plane = require( 'osg/Plane' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-var glm = require( 'osg/glMatrix' );
-
-var Mabs = Math.abs;
-var NMIN_VALUE = Number.MIN_VALUE;
-
-// call by closur'd variables because Matrix object is not
-// resolved yet, a workaround would be to define Matrix such as:
-// var Matrix = {};
-// Matrix.create = function... ;
-// Matrix.func2 = function... ;
-var matrixCreate = glm.mat4.create;
-
-/** @class Matrix Operations */
-var Matrix = {
-
- create: glm.mat4.create,
- createAndSet: glm.mat4.fromValues,
-
- isIdentity: function ( matrix ) {
- return glm.mat4.equals( Matrix.identity, matrix );
- },
-
- valid: function ( matrix ) {
- for ( var i = 0; i < 16; i++ )
- if ( osgMath.isNaN( matrix[ i ] ) )
- return false;
- return true;
- },
-
- setRow: function ( matrix, row, v0, v1, v2, v3 ) {
- var rowIndex = row * 4;
- matrix[ rowIndex + 0 ] = v0;
- matrix[ rowIndex + 1 ] = v1;
- matrix[ rowIndex + 2 ] = v2;
- matrix[ rowIndex + 3 ] = v3;
- },
-
- innerProduct: function ( a, b, r, c ) {
- var rIndex = r * 4;
- return ( ( a[ rIndex + 0 ] * b[ 0 + c ] ) + ( a[ rIndex + 1 ] * b[ 4 + c ] ) + ( a[ rIndex + 2 ] * b[ 8 + c ] ) + ( a[ rIndex + 3 ] * b[ 12 + c ] ) );
- },
-
- set: function ( matrix, row, col, value ) {
- matrix[ row * 4 + col ] = value;
- return value;
- },
-
- get: function ( matrix, row, col ) {
- return matrix[ row * 4 + col ];
- },
-
- makeIdentity: glm.mat4.identity,
-
- equal: glm.mat4.exactEquals,
-
- /**
- * @param {Number} x position
- * @param {Number} y position
- * @param {Number} z position
- * @param {Array} matrix to write result
- */
- makeTranslate: function ( x, y, z, matrix ) {
- return glm.mat4.fromTranslation( matrix, vec3.fromValues( x, y, z ) );
- },
-
- setTrans: function ( matrix, x, y, z ) {
- matrix[ 12 ] = x;
- matrix[ 13 ] = y;
- matrix[ 14 ] = z;
- return matrix;
- },
-
- getTrans: function ( matrix, result ) {
- return glm.mat4.getTranslation( result, matrix );
- },
-
- // do a * b and result in a
- preMult: function ( a, b ) {
- return glm.mat4.multiply( a, a, b );
- },
-
- // do a * b and store the result in b
- // Be aware of the change w.r.t OSG as b holds the result!
- postMult: function ( a, b ) {
- return glm.mat4.multiply( b, a, b );
- },
-
- /* r = a * b */
- mult: function ( a, b, r ) {
- return glm.mat4.multiply( r, a, b );
- },
-
- makeLookFromDirection: ( function () {
- var s = vec3.create();
- var u = vec3.create();
- var neg = vec3.create();
-
- return function ( eye, eyeDir, up, result ) {
- var f = eyeDir;
- vec3.cross( s, f, up );
- vec3.normalize( s, s );
-
- vec3.cross( u, s, f );
- vec3.normalize( u, u );
-
- // s[0], u[0], -f[0], 0.0,
- // s[1], u[1], -f[1], 0.0,
- // s[2], u[2], -f[2], 0.0,
- // 0, 0, 0, 1.0
-
- result[ 0 ] = s[ 0 ];
- result[ 1 ] = u[ 0 ];
- result[ 2 ] = -f[ 0 ];
- result[ 3 ] = 0.0;
- result[ 4 ] = s[ 1 ];
- result[ 5 ] = u[ 1 ];
- result[ 6 ] = -f[ 1 ];
- result[ 7 ] = 0.0;
- result[ 8 ] = s[ 2 ];
- result[ 9 ] = u[ 2 ];
- result[ 10 ] = -f[ 2 ];
- result[ 11 ] = 0.0;
- result[ 12 ] = 0;
- result[ 13 ] = 0;
- result[ 14 ] = 0;
- result[ 15 ] = 1.0;
-
- Matrix.multTranslate( result, vec3.neg( neg, eye ), result );
- return result;
- };
- } )(),
-
- makeLookAt: function ( eye, center, up, result ) {
- return glm.mat4.lookAt( result, eye, center, up );
- },
-
- makeOrtho: function ( left, right, bottom, top, zNear, zFar, result ) {
- return glm.mat4.ortho( result, left, right, bottom, top, zNear, zFar );
- },
-
- getLookAt: ( function () {
- var inv = matrixCreate();
- var v1 = vec3.create();
- var v2 = vec3.fromValues( 0.0, 1.0, 0.0 );
- var v3 = vec3.fromValues( 0.0, 0.0, -1.0 );
-
- return function ( matrix, eye, center, up, distance ) {
- if ( distance === undefined ) {
- distance = 1.0;
- }
- var result = Matrix.inverse( matrix, inv );
- if ( !result ) {
- glm.mat4.identity( inv );
- }
- Matrix.transformVec3( inv, v1, eye );
- Matrix.transform3x3( matrix, v2, up );
- Matrix.transform3x3( matrix, v3, center );
- vec3.normalize( center, center );
- vec3.add( center, vec3.scale( v1, center, distance ), eye );
- };
- } )(),
-
- //getRotate_David_Spillings_Mk1
- getRotate: function ( mat, quatResult ) {
- return glm.mat4.getRotation( quatResult, mat );
- },
-
- // Matrix M = Matrix M * Matrix Translate
- preMultTranslate: function ( mat, translate ) {
- return glm.mat4.translate( mat, mat, translate );
- },
-
- postMultTranslate: function ( mat, translate ) {
- return glm.mat4.multiply( mat, glm.mat4.fromTranslation( glm.mat4.create(), translate ), mat );
- },
-
- // result = Matrix M * Matrix Translate
- multTranslate: function ( mat, translate, result ) {
- return glm.mat4.translate( result, mat, translate );
- },
-
- makeRotate: function ( angle, x, y, z, result ) {
- var v = vec3.fromValues( x, y, z );
- if ( x === 0.0 && y === 0.0 && z === 0.0 )
- v[ 2 ] = 1.0;
- return glm.mat4.fromRotation( result, angle, v );
- },
-
- preMultRotate: ( function () {
- var r = matrixCreate();
- return function ( matrix, q ) {
- return glm.mat4.multiply( matrix, matrix, glm.mat4.fromQuat( r, q ) );
- };
- } )(),
-
- postMultRotate: ( function () {
- var r = matrixCreate();
- return function ( m, q ) {
- return glm.mat4.multiply( m, glm.mat4.fromQuat( r, q ), m );
- };
- } )(),
-
- transform3x3: function ( m, v, result ) {
- result[ 0 ] = m[ 0 ] * v[ 0 ] + m[ 1 ] * v[ 1 ] + m[ 2 ] * v[ 2 ];
- result[ 1 ] = m[ 4 ] * v[ 0 ] + m[ 5 ] * v[ 1 ] + m[ 6 ] * v[ 2 ];
- result[ 2 ] = m[ 8 ] * v[ 0 ] + m[ 9 ] * v[ 1 ] + m[ 10 ] * v[ 2 ];
- return result;
- },
-
- transformVec3: function ( matrix, vector, result ) {
- return glm.vec3.transformMat4( result, vector, matrix );
- },
-
- transformVec4: function ( matrix, vector, result ) {
- return glm.vec4.transformMat4( result, vector, matrix );
- },
-
- // http://dev.theomader.com/transform-bounding-boxes/
- // https://github.com/erich666/GraphicsGems/blob/master/gems/TransBox.c
- transformBoundingBox: ( function () {
- var tempBbox = new BoundingBox();
- return function ( m, bbIn, bbOut ) {
- if ( bbOut === bbIn ) {
- bbOut = tempBbox;
- }
- var inMin = bbIn.getMin();
- var inMax = bbIn.getMax();
-
- /* Take care of translation by beginning at T. */
- var outMin = glm.mat4.getTranslation( bbOut.getMin(), m );
- var outMax = vec3.copy( bbOut.getMax(), outMin );
-
- /* Now find the extreme points by considering the product of the */
- /* min and max with each component of M. */
- for ( var i = 0; i < 3; ++i ) {
- var i4 = i * 4;
- var mini = inMin[ i ];
- var maxi = inMax[ i ];
- for ( var j = 0; j < 3; ++j ) {
- var cm = m[ i4 + j ];
- var a = cm * maxi;
- var b = cm * mini;
- if ( a < b ) {
- outMin[ j ] += a;
- outMax[ j ] += b;
- } else {
- outMin[ j ] += b;
- outMax[ j ] += a;
- }
- }
- }
-
- if ( bbOut === tempBbox ) {
- bbIn.copy( tempBbox );
- }
- };
- } )(),
-
- transformBoundingSphere: ( function () {
- var scaleVec = vec3.create();
- return function ( matrix, bSphere, bsOut ) {
- if ( !bSphere.valid() ) {
- return bsOut;
- }
- vec3.copy( bsOut._center, bSphere._center );
- bsOut._radius = bSphere._radius;
- var sphCenter = bsOut._center;
- var sphRadius = bsOut._radius;
-
- Matrix.getScale2( matrix, scaleVec );
- var scale = Math.sqrt( Math.max( Math.max( scaleVec[ 0 ], scaleVec[ 1 ] ), scaleVec[ 2 ] ) );
- sphRadius = sphRadius * scale;
- bsOut._radius = sphRadius;
- Matrix.transformVec3( matrix, sphCenter, sphCenter );
-
- return bsOut;
- };
- } )(),
-
- transformVec4PostMult: function ( matrix, vector, result ) {
-
- var x = vector[ 0 ];
- var y = vector[ 1 ];
- var z = vector[ 2 ];
- var w = vector[ 3 ];
-
- result[ 0 ] = matrix[ 0 ] * x + matrix[ 1 ] * y + matrix[ 2 ] * z + matrix[ 3 ] * w;
- result[ 1 ] = matrix[ 4 ] * x + matrix[ 5 ] * y + matrix[ 6 ] * z + matrix[ 7 ] * w;
- result[ 2 ] = matrix[ 8 ] * x + matrix[ 9 ] * y + matrix[ 10 ] * z + matrix[ 11 ] * w;
- result[ 3 ] = matrix[ 12 ] * x + matrix[ 13 ] * y + matrix[ 14 ] * z + matrix[ 15 ] * w;
-
- return result;
- },
-
- copy: function ( matrix, result ) {
- return glm.mat4.copy( result, matrix );
- },
-
- inverse: function ( matrix, result ) {
- var r = glm.mat4.invert( result, matrix );
- if ( r === null ) return false;
- return true;
- },
-
- transpose: function ( mat, dest ) {
- return glm.mat4.transpose( dest, mat );
- },
-
- getFrustumPlanes: ( function () {
-
- var mvp = matrixCreate();
-
- return function ( projection, view, result, withNearFar ) {
- glm.mat4.multiply( mvp, projection, view );
-
- if ( withNearFar === undefined )
- withNearFar = false;
- // Right clipping plane.
- var right = result[ 0 ];
- right[ 0 ] = mvp[ 3 ] - mvp[ 0 ];
- right[ 1 ] = mvp[ 7 ] - mvp[ 4 ];
- right[ 2 ] = mvp[ 11 ] - mvp[ 8 ];
- right[ 3 ] = mvp[ 15 ] - mvp[ 12 ];
-
- // Left clipping plane.
- var left = result[ 1 ];
- left[ 0 ] = mvp[ 3 ] + mvp[ 0 ];
- left[ 1 ] = mvp[ 7 ] + mvp[ 4 ];
- left[ 2 ] = mvp[ 11 ] + mvp[ 8 ];
- left[ 3 ] = mvp[ 15 ] + mvp[ 12 ];
-
- // Bottom clipping plane.
- var bottom = result[ 2 ];
- bottom[ 0 ] = mvp[ 3 ] + mvp[ 1 ];
- bottom[ 1 ] = mvp[ 7 ] + mvp[ 5 ];
- bottom[ 2 ] = mvp[ 11 ] + mvp[ 9 ];
- bottom[ 3 ] = mvp[ 15 ] + mvp[ 13 ];
-
- // Top clipping plane.
- var top = result[ 3 ];
- top[ 0 ] = mvp[ 3 ] - mvp[ 1 ];
- top[ 1 ] = mvp[ 7 ] - mvp[ 5 ];
- top[ 2 ] = mvp[ 11 ] - mvp[ 9 ];
- top[ 3 ] = mvp[ 15 ] - mvp[ 13 ];
-
- if ( withNearFar ) {
- // Far clipping plane.
- var far = result[ 4 ];
- far[ 0 ] = mvp[ 3 ] - mvp[ 2 ];
- far[ 1 ] = mvp[ 7 ] - mvp[ 6 ];
- far[ 2 ] = mvp[ 11 ] - mvp[ 10 ];
- far[ 3 ] = mvp[ 15 ] - mvp[ 14 ];
-
- // Near clipping plane.
- var near = result[ 5 ];
- near[ 0 ] = mvp[ 3 ] + mvp[ 2 ];
- near[ 1 ] = mvp[ 7 ] + mvp[ 6 ];
- near[ 2 ] = mvp[ 11 ] + mvp[ 10 ];
- near[ 3 ] = mvp[ 15 ] + mvp[ 14 ];
- }
-
- //Normalize the planes
- var j = withNearFar ? 6 : 4;
- for ( var i = 0; i < j; i++ ) {
- Plane.normalizeEquation( result[ i ] );
- }
-
- };
- } )(),
-
- makePerspective: function ( fovy, aspect, znear, zfar, result ) {
- return glm.mat4.perspective( result, fovy * Math.PI / 180.0, aspect, znear, zfar );
- },
-
- getFrustum: function ( matrix, result ) {
- var right = 0.0;
- var left = 0.0;
- var top = 0.0;
- var bottom = 0.0;
- var zNear, zFar;
-
- if ( matrix[ 0 * 4 + 3 ] !== 0.0 || matrix[ 1 * 4 + 3 ] !== 0.0 || matrix[ 2 * 4 + 3 ] !== -1.0 || matrix[ 3 * 4 + 3 ] !== 0.0 ) {
- return false;
- }
-
- // note: near and far must be used inside this method instead of zNear and zFar
- // because zNear and zFar are references and they may point to the same variable.
- var tempNear = matrix[ 3 * 4 + 2 ] / ( matrix[ 2 * 4 + 2 ] - 1.0 );
- var tempFar = matrix[ 3 * 4 + 2 ] / ( 1.0 + matrix[ 2 * 4 + 2 ] );
-
- left = tempNear * ( matrix[ 2 * 4 ] - 1.0 ) / matrix[ 0 ];
- right = tempNear * ( 1.0 + matrix[ 2 * 4 ] ) / matrix[ 0 ];
-
- top = tempNear * ( 1.0 + matrix[ 2 * 4 + 1 ] ) / matrix[ 1 * 4 + 1 ];
- bottom = tempNear * ( matrix[ 2 * 4 + 1 ] - 1.0 ) / matrix[ 1 * 4 + 1 ];
-
- zNear = tempNear;
- zFar = tempFar;
-
- result.left = left;
- result.right = right;
- result.top = top;
- result.bottom = bottom;
- result.zNear = zNear;
- result.zFar = zFar;
-
- return true;
- },
-
- getPerspective: ( function () {
- var c = {
- 'right': 0,
- 'left': 0,
- 'top': 0,
- 'bottom': 0,
- 'zNear': 0,
- 'zFar': 0
- };
- return function ( matrix, result ) {
- // get frustum and compute results
- var r = Matrix.getFrustum( matrix, c );
- if ( r ) {
- result.fovy = 180 / Math.PI * ( Math.atan( c.top / c.zNear ) - Math.atan( c.bottom / c.zNear ) );
- result.aspectRatio = ( c.right - c.left ) / ( c.top - c.bottom );
- }
- result.zNear = c.zNear;
- result.zFar = c.zFar;
- return result;
- };
- } )(),
-
- preMultScale: function ( m, scale ) {
- return glm.mat4.scale( m, m, scale );
- },
-
- postMultScale: function ( m, scale ) {
- return glm.mat4.multiply( m, glm.mat4.fromScaling( glm.mat4.create(), scale ), m );
- },
-
- makeScale: function ( x, y, z, result ) {
- return glm.mat4.fromScaling( result, [ x, y, z ] );
- },
-
- getScale: ( function () {
- var sx = vec3.create();
- var sy = vec3.create();
- var sz = vec3.create();
- return function ( matrix, result ) {
- sx[ 0 ] = matrix[ 0 ];
- sx[ 1 ] = matrix[ 4 ];
- sx[ 2 ] = matrix[ 8 ];
- sy[ 0 ] = matrix[ 1 ];
- sy[ 1 ] = matrix[ 5 ];
- sy[ 2 ] = matrix[ 9 ];
- sz[ 0 ] = matrix[ 2 ];
- sz[ 1 ] = matrix[ 6 ];
- sz[ 2 ] = matrix[ 10 ];
-
- result[ 0 ] = vec3.length( sx );
- result[ 1 ] = vec3.length( sy );
- result[ 2 ] = vec3.length( sz );
- return result;
- };
- } )(),
-
- getScale2: ( function () {
- var sx = vec3.create();
- var sy = vec3.create();
- var sz = vec3.create();
- return function ( matrix, result ) {
- sx[ 0 ] = matrix[ 0 ];
- sx[ 1 ] = matrix[ 4 ];
- sx[ 2 ] = matrix[ 8 ];
- sy[ 0 ] = matrix[ 1 ];
- sy[ 1 ] = matrix[ 5 ];
- sy[ 2 ] = matrix[ 9 ];
- sz[ 0 ] = matrix[ 2 ];
- sz[ 1 ] = matrix[ 6 ];
- sz[ 2 ] = matrix[ 10 ];
-
- result[ 0 ] = vec3.sqrLen( sx );
- result[ 1 ] = vec3.sqrLen( sy );
- result[ 2 ] = vec3.sqrLen( sz );
- return result;
- };
- } )(),
-
- clampProjectionMatrix: function ( projection, znear, zfar, nearFarRatio, resultNearFar ) {
- var epsilon = 1e-6;
- if ( zfar < znear - epsilon ) {
- Notify.log( 'clampProjectionMatrix not applied, invalid depth range, znear = ' + znear + ' zfar = ' + zfar, false, true );
- return false;
- }
-
- var desiredZnear, desiredZfar;
- if ( zfar < znear + epsilon ) {
- // znear and zfar are too close together and could cause divide by zero problems
- // late on in the clamping code, so move the znear and zfar apart.
- var average = ( znear + zfar ) * 0.5;
- znear = average - epsilon;
- zfar = average + epsilon;
- // OSG_INFO << '_clampProjectionMatrix widening znear and zfar to '< 1.0 - epsilon ) {
- // negligible rotation: optimize by just a lerp
- // a line rather than a rotation.
- ta = 1.0 - t;
- tb = t;
-
- } else {
-
- var sin = Math.sqrt( 1.0 - cos * cos );
-
- // which one is better ?
-
- // Atan2:
- // sin != 0 && cos !f= 0
- // Atan2 returns the angle between -π and π radians (equivalent to -180 and 180 degrees)
- var angle = Math.atan2( sin, cos );
- // Acos:
- // need clamp(-1,1) on input Cos to avoid NaN but we make it lerp anyway
- // acos returns the angle between 0 and π radians (equivalent to 0 and 180 degrees)
- //var angle = Math.acos( cos ); / / 0 <= omega <= Pi( see man acos )
-
- var oneOverSin = 1.0 / sin;
- ta = Math.sin( ( 1.0 - t ) * angle ) * oneOverSin;
- tb = Math.sin( t * angle ) * oneOverSin;
- }
-
- tb *= invTB;
-
- r[ 0 ] = a[ 0 ] * ta + b[ 0 ] * tb;
- r[ 1 ] = a[ 1 ] * ta + b[ 1 ] * tb;
- r[ 2 ] = a[ 2 ] * ta + b[ 2 ] * tb;
- r[ 3 ] = a[ 3 ] * ta + b[ 3 ] * tb;
- return r;
- };
-
- } )(),
-
- transformVec3: function ( q, a, result ) {
- var x = a[ 0 ];
- var y = a[ 1 ];
- var z = a[ 2 ];
- var qx = q[ 0 ];
- var qy = q[ 1 ];
- var qz = q[ 2 ];
- var qw = q[ 3 ];
- // calculate quat * vec
- 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
- result[ 0 ] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
- result[ 1 ] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
- result[ 2 ] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
- return result;
- },
-
- normalize: function ( q, qr ) {
- var div = 1.0 / this.length( q );
- qr[ 0 ] = q[ 0 ] * div;
- qr[ 1 ] = q[ 1 ] * div;
- qr[ 2 ] = q[ 2 ] * div;
- qr[ 3 ] = q[ 3 ] * div;
- return qr;
- },
-
- // conjugate
- // we suppose to have unit quaternion
- conj: function ( a, result ) {
- result[ 0 ] = -a[ 0 ];
- result[ 1 ] = -a[ 1 ];
- result[ 2 ] = -a[ 2 ];
- result[ 3 ] = a[ 3 ];
- return result;
- },
-
- // only if you don't have unit quaternion
- // otherwise use conjugate
- inverse: function ( a, result ) {
- var div = 1.0 / this.length2( a );
- this.conj( a, result );
- result[ 0 ] *= div;
- result[ 1 ] *= div;
- result[ 2 ] *= div;
- result[ 3 ] *= div;
- return result;
- },
-
- // we suppose to have unit quaternion
- // multiply 2 quaternions
- mult: function ( a, b, result ) {
- var ax = a[ 0 ];
- var ay = a[ 1 ];
- var az = a[ 2 ];
- var aw = a[ 3 ];
-
- var bx = b[ 0 ];
- var by = b[ 1 ];
- var bz = b[ 2 ];
- var bw = b[ 3 ];
-
- result[ 0 ] = ax * bw + ay * bz - az * by + aw * bx;
- result[ 1 ] = -ax * bz + ay * bw + az * bx + aw * by;
- result[ 2 ] = ax * by - ay * bx + az * bw + aw * bz;
- result[ 3 ] = -ax * bx - ay * by - az * bz + aw * bw;
- return result;
- },
-
- div: function ( a, b, result ) {
- var d = 1.0 / b;
- result[ 0 ] = a[ 0 ] * d;
- result[ 1 ] = a[ 1 ] * d;
- result[ 2 ] = a[ 2 ] * d;
- result[ 3 ] = a[ 3 ] * d;
- return result;
- },
-
- exp: function ( a, res ) {
- var r = Math.sqrt( a[ 0 ] * a[ 0 ] + a[ 1 ] * a[ 1 ] + a[ 2 ] * a[ 2 ] );
- var et = Math.exp( a[ 3 ] );
- var s = 0;
- if ( r > 0.00001 ) {
- s = et * Math.sin( r ) / r;
- }
-
- res[ 0 ] = s * a[ 0 ];
- res[ 1 ] = s * a[ 1 ];
- res[ 2 ] = s * a[ 2 ];
- res[ 3 ] = et * Math.cos( r );
- return res;
- },
-
- ln: function ( a, res ) {
- var n = a[ 0 ] * a[ 0 ] + a[ 1 ] * a[ 1 ] + a[ 2 ] * a[ 2 ];
- var r = Math.sqrt( n );
- var t = 0;
- if ( r > 0.00001 ) {
- t = Math.atan2( r, a[ 3 ] ) / r;
- }
-
- n += a[ 3 ] * a[ 3 ];
- res[ 0 ] = t * a[ 0 ];
- res[ 1 ] = t * a[ 1 ];
- res[ 2 ] = t * a[ 2 ];
- res[ 3 ] = 0.5 * Math.log( n );
- return res;
- },
-
-
- //http://theory.org/software/qfa/writeup/node12.html
- //http://www.ece.uwaterloo.ca/~dwharder/C++/CQOST/src/
- //http://willperone.net/Code/quaternion.php
-
- // a is computeTangent(q1-1,q1,q2)
- // b is computeTangent(q2-1,q2,q2+1)
- squad: function ( t, q1, a, b, q2, r ) {
- var r1 = this.slerp( t, q1, q2 );
- var r2 = this.slerp( t, a, b );
- return this.slerp( 2.0 * t * ( 1.0 - t ), r1, r2, r );
- },
-
- // qcur is current
- // q0 is qcur-1
- // q2 is qcur+1
- // compute tangent in of q1
- computeTangent: function ( q0, qcur, q2, r ) {
-
- // first step
- var invq = this.inv( qcur );
- var qa = this.create();
- var qb = this.create();
-
- this.mult( q2, invq, qa );
- this.ln( qa, qa );
-
- this.mult( q0, invq, qb );
- this.ln( qb, qb );
-
- this.add( qa, qb, qa );
- this.div( qa, -4.0, qa );
- this.exp( qa, qb );
- return this.mult( qb, qcur, r );
- },
-
- makeRotateFromTo: function ( from, to, out ) {
- // Now let's get into the real stuff
- // Use "dot product plus one" as test as it can be re-used later on
- var dotProdPlus1 = 1.0 + vec3.dot( from, to );
-
- // Check for degenerate case of full u-turn. Use epsilon for detection
- if ( dotProdPlus1 < 1e-7 ) {
-
- // Get an orthogonal vector of the given vector
- // in a plane with maximum vector coordinates.
- // Then use it as quaternion axis with pi angle
- // Trick is to realize one value at least is >0.6 for a normalized vector.
- var x = from[ 0 ];
- var y = from[ 1 ];
- var z = from[ 2 ];
- var norm;
- if ( Math.abs( x ) < 0.6 ) {
- norm = Math.sqrt( 1.0 - x * x );
- out[ 1 ] = z / norm;
- out[ 2 ] = -y / norm;
- out[ 0 ] = out[ 3 ] = 0.0;
- } else if ( Math.abs( y ) < 0.6 ) {
- norm = Math.sqrt( 1.0 - y * y );
- out[ 0 ] = -z / norm;
- out[ 2 ] = x / norm;
- out[ 1 ] = out[ 3 ] = 0.0;
- } else {
- norm = Math.sqrt( 1.0 - z * z );
- out[ 0 ] = y / norm;
- out[ 1 ] = -x / norm;
- out[ 2 ] = out[ 3 ] = 0.0;
- }
- } else {
- // Find the shortest angle quaternion that transforms normalized vectors
- // into one other. Formula is still valid when vectors are colinear
-
- var s = Math.sqrt( 0.5 * dotProdPlus1 );
- vec3.cross( out, from, to );
- var f = 0.5 / s;
- out[ 0 ] *= f;
- out[ 1 ] *= f;
- out[ 2 ] *= f;
- out[ 3 ] = s;
- }
- return out;
- }
-
-};
-
-Quat.identity = Quat.create();
-
-module.exports = Quat;
diff --git a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec2.js b/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec2.js
deleted file mode 100644
index 9846d32c..00000000
--- a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec2.js
+++ /dev/null
@@ -1,67 +0,0 @@
-'use strict';
-var osgMath = require( 'osg/math' );
-var glm = require( 'osg/glMatrix' );
-var vec2 = glm.vec2;
-
-/** @class Vec2 Operations */
-var Vec2 = {
-
- create: vec2.create,
- createAndSet: vec2.fromValues,
-
- copy: function ( a, r ) {
- return vec2.copy( r, a );
- },
-
- set: function ( a, b, r ) {
- return vec2.set( r, a, b );
- },
-
- valid: function ( a ) {
- if ( osgMath.isNaN( a[ 0 ] ) ) return false;
- if ( osgMath.isNaN( a[ 1 ] ) ) return false;
- return true;
- },
-
- mult: function ( a, b, r ) {
- r[ 0 ] = a[ 0 ] * b;
- r[ 1 ] = a[ 1 ] * b;
- return r;
- },
-
- length2: vec2.sqrLen,
- length: vec2.len,
-
- distance2: function ( a, b ) {
- return vec2.sqrDist( b, a );
- },
-
- distance: function ( a, b ) {
- return vec2.dist( b, a );
- },
-
- normalize: function ( a, r ) {
- return vec2.normalize( r, a );
- },
-
- dot: vec2.dot,
-
- sub: function ( a, b, r ) {
- return vec2.sub( r, a, b );
- },
-
- add: function ( a, b, r ) {
- return vec2.add( r, a, b );
- },
-
- neg: function ( a, r ) {
- return vec2.negate( r, a );
- },
-
- lerp: function ( t, a, b, r ) {
- return vec2.lerp( r, a, b, t );
- }
-
-};
-
-module.exports = Vec2;
diff --git a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec3.js b/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec3.js
deleted file mode 100644
index da32e65d..00000000
--- a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec3.js
+++ /dev/null
@@ -1,85 +0,0 @@
-'use strict';
-var osgMath = require( 'osg/math' );
-var glm = require( 'osg/glMatrix' );
-var vec3 = glm.vec3;
-
-/** @class Vec3 Operations */
-var Vec3 = {
-
- create: vec3.create,
- createAndSet: vec3.fromValues,
-
- init: function ( a ) {
- return vec3.set( a, 0.0, 0.0, 0.0 );
- },
-
- set: function ( a, b, c, r ) {
- return vec3.set( r, a, b, c );
- },
-
- copy: function ( a, r ) {
- return vec3.copy( r, a );
- },
-
- cross: function ( a, b, r ) {
- return vec3.cross( r, a, b );
- },
-
- valid: function ( a ) {
- if ( osgMath.isNaN( a[ 0 ] ) ) return false;
- if ( osgMath.isNaN( a[ 1 ] ) ) return false;
- if ( osgMath.isNaN( a[ 2 ] ) ) return false;
- return true;
- },
-
- mult: function ( a, b, r ) {
- r[ 0 ] = a[ 0 ] * b;
- r[ 1 ] = a[ 1 ] * b;
- r[ 2 ] = a[ 2 ] * b;
- return r;
- },
-
- length2: vec3.sqrLen,
- length: vec3.len,
-
- distance2: function ( a, b ) {
- return vec3.sqrDist( b, a );
- },
-
- distance: function ( a, b ) {
- return vec3.dist( b, a );
- },
-
- normalize: function ( a, r ) {
- return vec3.normalize( r, a );
- },
-
- dot: vec3.dot,
-
- sub: function ( a, b, r ) {
- return vec3.sub( r, a, b );
- },
-
- add: function ( a, b, r ) {
- return vec3.add( r, a, b );
- },
-
- neg: function ( a, r ) {
- return vec3.negate( r, a );
- },
-
- lerp: function ( t, a, b, r ) {
- return vec3.lerp( r, a, b, t );
- },
-
- equal: function ( a, b ) {
- return vec3.exactEquals( a, b );
- }
-};
-
-Vec3.zero = Vec3.create();
-Vec3.one = Vec3.createAndSet( 1.0, 1.0, 1.0 );
-Vec3.infinity = Vec3.createAndSet( Infinity, Infinity, Infinity );
-Vec3.negativeInfinity = Vec3.createAndSet( -Infinity, -Infinity, -Infinity );
-
-module.exports = Vec3;
diff --git a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec4.js b/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec4.js
deleted file mode 100644
index a8810dc4..00000000
--- a/app/static/app/js/vendor/osgjs/osg/deprecated-MatrixVector/Vec4.js
+++ /dev/null
@@ -1,50 +0,0 @@
-'use strict';
-var glm = require( 'osg/glMatrix' );
-var vec4 = glm.vec4;
-
-/** @class Vec4 Operations */
-var Vec4 = {
-
- create: vec4.create,
- createAndSet: vec4.fromValues,
-
- init: function ( a ) {
- return vec4.set( a, 0.0, 0.0, 0.0, 0.0 );
- },
-
- set: function ( a, b, c, d, r ) {
- return vec4.set( r, a, b, c, d );
- },
-
- dot: vec4.dot,
-
- copy: function ( a, r ) {
- return vec4.copy( r, a );
- },
-
- sub: function ( a, b, r ) {
- return vec4.sub( r, a, b );
- },
-
- mult: function ( a, b, r ) {
- r[ 0 ] = a[ 0 ] * b;
- r[ 1 ] = a[ 1 ] * b;
- r[ 2 ] = a[ 2 ] * b;
- r[ 3 ] = a[ 3 ] * b;
- return r;
- },
-
- add: function ( a, b, r ) {
- return vec4.add( r, a, b );
- },
-
- neg: function ( a, r ) {
- return vec4.negate( r, a );
- },
-
- lerp: function ( t, a, b, r ) {
- return vec4.lerp( r, a, b, t );
- }
-};
-
-module.exports = Vec4;
diff --git a/app/static/app/js/vendor/osgjs/osg/glMatrix.js b/app/static/app/js/vendor/osgjs/osg/glMatrix.js
deleted file mode 100644
index 37abfff4..00000000
--- a/app/static/app/js/vendor/osgjs/osg/glMatrix.js
+++ /dev/null
@@ -1,537 +0,0 @@
-'use strict';
-
-var mth = require( 'osg/math' );
-var glm = require( 'gl-matrix' );
-var config = require( '../config.js' );
-glm.glMatrix.setMatrixArrayType( config.ArrayType );
-glm.glMatrix.EPSILON = 1e-9;
-
-
-var vec2 = glm.vec2;
-var vec3 = glm.vec3;
-var vec4 = glm.vec4;
-var mat4 = glm.mat4;
-var quat = glm.quat;
-
-// osg vec3 additions
-
-vec3.create32 = function () {
- return new Float32Array( 3 );
-};
-
-vec3.create64 = function () {
- return new Float64Array( 3 );
-};
-
-vec3.fromValues32 = function ( a, b, c ) {
- var out = new Float32Array( 3 );
- out[ 0 ] = a;
- out[ 1 ] = b;
- out[ 2 ] = c;
- return out;
-};
-
-vec3.fromValues64 = function ( a, b, c ) {
- var out = new Float64Array( 3 );
- out[ 0 ] = a;
- out[ 1 ] = b;
- out[ 2 ] = c;
- return out;
-};
-
-vec3.init = function ( out ) {
- return vec3.set( out, 0.0, 0.0, 0.0 );
-};
-
-vec3.transformMat4R = function ( out, v, m ) {
- out[ 0 ] = m[ 0 ] * v[ 0 ] + m[ 1 ] * v[ 1 ] + m[ 2 ] * v[ 2 ];
- out[ 1 ] = m[ 4 ] * v[ 0 ] + m[ 5 ] * v[ 1 ] + m[ 6 ] * v[ 2 ];
- out[ 2 ] = m[ 8 ] * v[ 0 ] + m[ 9 ] * v[ 1 ] + m[ 10 ] * v[ 2 ];
-};
-
-vec3.valid = function ( a ) {
- if ( mth.isNaN( a[ 0 ] ) ) return false;
- if ( mth.isNaN( a[ 1 ] ) ) return false;
- if ( mth.isNaN( a[ 2 ] ) ) return false;
- return true;
-};
-vec3.neg = vec3.negate;
-vec3.ZERO = vec3.create();
-vec3.ONE = vec3.fromValues( 1.0, 1.0, 1.0 );
-vec3.INFINITY = vec3.fromValues( Infinity, Infinity, Infinity );
-vec3.NEGATIVE_INFINITY = vec3.fromValues( -Infinity, -Infinity, -Infinity );
-
-// osg vec2 additions
-
-vec2.create32 = function () {
- return new Float32Array( 2 );
-};
-
-vec2.create64 = function () {
- return new Float64Array( 2 );
-};
-
-vec2.fromValues32 = function ( a, b ) {
- var out = new Float32Array( 2 );
- out[ 0 ] = a;
- out[ 1 ] = b;
- return out;
-};
-
-vec2.fromValues64 = function ( a, b ) {
- var out = new Float64Array( 2 );
- out[ 0 ] = a;
- out[ 1 ] = b;
- return out;
-};
-
-vec2.init = function ( out ) {
- return vec2.set( out, 0.0, 0.0 );
-};
-
-vec2.valid = function ( a ) {
- if ( mth.isNaN( a[ 0 ] ) ) return false;
- if ( mth.isNaN( a[ 1 ] ) ) return false;
- return true;
-};
-
-vec2.ZERO = vec2.create();
-vec2.ONE = vec2.fromValues( 1.0, 1.0 );
-vec2.INFINITY = vec2.fromValues( Infinity, Infinity );
-vec2.NEGATIVE_INFINITY = vec2.fromValues( -Infinity, -Infinity );
-
-// osg vec4 additions
-
-vec4.create32 = function () {
- return new Float32Array( 4 );
-};
-
-vec4.create64 = function () {
- return new Float64Array( 4 );
-};
-
-vec4.fromValues32 = function ( a, b, c, d ) {
- var out = new Float32Array( 4 );
- out[ 0 ] = a;
- out[ 1 ] = b;
- out[ 2 ] = c;
- out[ 3 ] = d;
- return out;
-};
-
-vec4.fromValues64 = function ( a, b, c, d ) {
- var out = new Float64Array( 4 );
- out[ 0 ] = a;
- out[ 1 ] = b;
- out[ 2 ] = c;
- out[ 3 ] = d;
- return out;
-};
-
-vec4.init = function ( out ) {
- return vec4.set( out, 0.0, 0.0, 0.0, 0.0 );
-};
-
-vec4.valid = function ( a ) {
- if ( mth.isNaN( a[ 0 ] ) ) return false;
- if ( mth.isNaN( a[ 1 ] ) ) return false;
- if ( mth.isNaN( a[ 2 ] ) ) return false;
- if ( mth.isNaN( a[ 3 ] ) ) return false;
- return true;
-};
-vec4.neg = vec4.negate;
-vec4.ZERO = vec4.create();
-vec4.ONE = vec4.fromValues( 1.0, 1.0, 1.0, 1.0 );
-vec4.INFINITY = vec4.fromValues( Infinity, Infinity, Infinity, Infinity );
-vec4.NEGATIVE_INFINITY = vec4.fromValues( -Infinity, -Infinity, -Infinity, -Infinity );
-
-
-// quat
-
-quat.IDENTITY = quat.create();
-
-quat.zeroRotation = function ( q ) {
- return q[ 0 ] === 0.0 && q[ 1 ] === 0.0 && q[ 2 ] === 0.0 && q[ 3 ] === 1.0;
-};
-
-quat.create32 = function () {
- var out = new Float32Array( 4 );
- out[ 3 ] = 1.0;
- return out;
-};
-
-quat.create64 = function () {
- var out = new Float64Array( 4 );
- out[ 3 ] = 1.0;
- return out;
-};
-
-quat.fromValues32 = vec4.fromValues32;
-quat.fromValues64 = vec4.fromValues64;
-quat.init = quat.identity;
-
-// http://physicsforgames.blogspot.fr/2010/02/quaternions.html
-// called quatBlend
-//
-// NLERP is supposed to be
-// - Commutative,
-// - NOT Constant velocity
-// - Torque minimal
-//
-// a and be must be normalized
-// (otherwise they're not rotation...)
-// t must be between 0 and 1
-quat.nlerp = function ( out, a, b, t ) {
- var ax = a[ 0 ],
- ay = a[ 1 ],
- az = a[ 2 ],
- aw = a[ 3 ],
- bx = b[ 0 ],
- by = b[ 1 ],
- bz = b[ 2 ],
- bw = b[ 3 ];
- var dot = ax * bx + ay * by + az * bz + aw * bw;
- var at = 1.0 - t;
- var outx, outy, outz, outw;
- // shortest path
- if ( dot < 0.0 ) {
-
- // negates directly b in the 4 equation
- // this.neg( b, r );
- outx = ax * at - bx * t;
- outy = ay * at - by * t;
- outz = az * at - bz * t;
- outw = aw * at - bw * t;
-
- } else {
- outx = ax * at + bx * t;
- outy = ay * at + by * t;
- outz = az * at + bz * t;
- outw = aw * at + bw * t;
- }
-
- var invLen = 1.0 / Math.sqrt( outx * outx + outy * outy + outz * outz + outw * outw );
- out[ 0 ] = outx * invLen;
- out[ 1 ] = outy * invLen;
- out[ 2 ] = outz * invLen;
- out[ 3 ] = outw * invLen;
- return out;
-};
-
-// MUST READ on SLERP, NLERP, LOG-LERP
-// http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
-// with a slerp implementation (robust)
-//
-// MUST READ Howto enhance lerp, slerp and q normalize
-// http://number-none.com/product/Hacking%20Quaternions/
-//
-// MUST READ The book:
-// Essential Mathematics for Games and Interactive Applications page
-// ( from 10.6.1 Linear Interpolation to 10.6.3 Performance Improvements )
-//
-// SLERP is:
-// - NOT commutative
-// - constant velocity
-// - torque minimal
-//
-// so not to be used when blending multiple non ordered rotations
-// (as in multiple animation)
-//
-// slerp see glMatrix implementation
-
-
-// mat4 additions
-mat4.IDENTITY = mat4.create();
-
-mat4.create32 = function () {
- var out = new Float32Array( 16 );
- out[ 0 ] = out[ 5 ] = out[ 10 ] = out[ 15 ] = 1.0;
- return out;
-};
-
-mat4.create64 = function () {
- var out = new Float64Array( 16 );
- out[ 0 ] = out[ 5 ] = out[ 10 ] = out[ 15 ] = 1.0;
- return out;
-};
-
-mat4.setTranslation = function ( out, a ) {
- out[ 12 ] = a[ 0 ];
- out[ 13 ] = a[ 1 ];
- out[ 14 ] = a[ 2 ];
- return out;
-};
-
-mat4.getFrustum = function ( out, matrix ) {
- var right = 0.0;
- var left = 0.0;
- var top = 0.0;
- var bottom = 0.0;
- var zNear, zFar;
-
- if ( matrix[ 0 * 4 + 3 ] !== 0.0 || matrix[ 1 * 4 + 3 ] !== 0.0 || matrix[ 2 * 4 + 3 ] !== -1.0 || matrix[ 3 * 4 + 3 ] !== 0.0 ) {
- return false;
- }
-
- // note: near and far must be used inside this method instead of zNear and zFar
- // because zNear and zFar are references and they may point to the same variable.
- var tempNear = matrix[ 3 * 4 + 2 ] / ( matrix[ 2 * 4 + 2 ] - 1.0 );
- var tempFar = matrix[ 3 * 4 + 2 ] / ( 1.0 + matrix[ 2 * 4 + 2 ] );
-
- left = tempNear * ( matrix[ 2 * 4 ] - 1.0 ) / matrix[ 0 ];
- right = tempNear * ( 1.0 + matrix[ 2 * 4 ] ) / matrix[ 0 ];
-
- top = tempNear * ( 1.0 + matrix[ 2 * 4 + 1 ] ) / matrix[ 1 * 4 + 1 ];
- bottom = tempNear * ( matrix[ 2 * 4 + 1 ] - 1.0 ) / matrix[ 1 * 4 + 1 ];
-
- zNear = tempNear;
- zFar = tempFar;
-
- out.left = left;
- out.right = right;
- out.top = top;
- out.bottom = bottom;
- out.zNear = zNear;
- out.zFar = zFar;
-
- return true;
-};
-
-mat4.getPerspective = ( function () {
- var c = {
- right: 0,
- left: 0,
- top: 0,
- bottom: 0,
- zNear: 0,
- zFar: 0
- };
- return function ( out, matrix ) {
- // get frustum and compute results
- var r = mat4.getFrustum( c, matrix );
- if ( r ) {
- out.fovy = 180 / Math.PI * ( Math.atan( c.top / c.zNear ) - Math.atan( c.bottom / c.zNear ) );
- out.aspectRatio = ( c.right - c.left ) / ( c.top - c.bottom );
- }
- out.zNear = c.zNear;
- out.zFar = c.zFar;
- return out;
- };
-} )();
-
-mat4.getLookAt = ( function () {
- var inv = mat4.create();
- var v1 = vec3.create();
- var v2 = vec3.fromValues( 0.0, 1.0, 0.0 );
- var v3 = vec3.fromValues( 0.0, 0.0, -1.0 );
-
- return function ( eye, center, up, matrix, distance ) {
-
- var d = distance !== undefined ? distance : 1.0;
- mat4.invert( inv, matrix );
- vec3.transformMat4( eye, v1, inv );
- vec3.transformMat4R( up, v2, matrix );
- vec3.transformMat4R( center, v3, matrix );
- vec3.normalize( center, center );
- vec3.add( center, vec3.scale( v1, center, d ), eye );
- };
-} )();
-
-mat4.getFrustumPlanes = ( function () {
-
- var mvp = mat4.create();
-
- return function ( out, projection, view, withNearFar ) {
- mat4.mul( mvp, projection, view );
-
- var computeNearFar = !!withNearFar;
-
- // Right clipping plane.
- var right = out[ 0 ];
- right[ 0 ] = mvp[ 3 ] - mvp[ 0 ];
- right[ 1 ] = mvp[ 7 ] - mvp[ 4 ];
- right[ 2 ] = mvp[ 11 ] - mvp[ 8 ];
- right[ 3 ] = mvp[ 15 ] - mvp[ 12 ];
-
- // Left clipping plane.
- var left = out[ 1 ];
- left[ 0 ] = mvp[ 3 ] + mvp[ 0 ];
- left[ 1 ] = mvp[ 7 ] + mvp[ 4 ];
- left[ 2 ] = mvp[ 11 ] + mvp[ 8 ];
- left[ 3 ] = mvp[ 15 ] + mvp[ 12 ];
-
- // Bottom clipping plane.
- var bottom = out[ 2 ];
- bottom[ 0 ] = mvp[ 3 ] + mvp[ 1 ];
- bottom[ 1 ] = mvp[ 7 ] + mvp[ 5 ];
- bottom[ 2 ] = mvp[ 11 ] + mvp[ 9 ];
- bottom[ 3 ] = mvp[ 15 ] + mvp[ 13 ];
-
- // Top clipping plane.
- var top = out[ 3 ];
- top[ 0 ] = mvp[ 3 ] - mvp[ 1 ];
- top[ 1 ] = mvp[ 7 ] - mvp[ 5 ];
- top[ 2 ] = mvp[ 11 ] - mvp[ 9 ];
- top[ 3 ] = mvp[ 15 ] - mvp[ 13 ];
-
- var nbPlanes = 4;
- if ( computeNearFar ) {
- nbPlanes = 6;
- // Far clipping plane.
- var far = out[ 4 ];
- far[ 0 ] = mvp[ 3 ] - mvp[ 2 ];
- far[ 1 ] = mvp[ 7 ] - mvp[ 6 ];
- far[ 2 ] = mvp[ 11 ] - mvp[ 10 ];
- far[ 3 ] = mvp[ 15 ] - mvp[ 14 ];
-
- // Near clipping plane.
- var near = out[ 5 ];
- near[ 0 ] = mvp[ 3 ] + mvp[ 2 ];
- near[ 1 ] = mvp[ 7 ] + mvp[ 6 ];
- near[ 2 ] = mvp[ 11 ] + mvp[ 10 ];
- near[ 3 ] = mvp[ 15 ] + mvp[ 14 ];
- }
-
- //Normalize the planes, from osg code
- for ( var i = 0; i < nbPlanes; i++ ) {
- var p = out[ i ];
- // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.
- var inv = 1.0 / Math.sqrt( p[ 0 ] * p[ 0 ] + p[ 1 ] * p[ 1 ] + p[ 2 ] * p[ 2 ] );
- p[ 0 ] *= inv;
- p[ 1 ] *= inv;
- p[ 2 ] *= inv;
- p[ 3 ] *= inv;
- }
-
- };
-} )();
-
-// better precison
-// no far clipping artifacts.
-// no reason not to use.
-// Tightening the Precision of Perspective Rendering
-//http://www.geometry.caltech.edu/pubs/UD12.pdf
-// drop-in, just remove the one below, and rename this one
-mat4.infiniteFrustum = function ( out, left, right, bottom, top, znear ) {
- var X = 2.0 * znear / ( right - left );
- var Y = 2.0 * znear / ( top - bottom );
- var A = ( right + left ) / ( right - left );
- var B = ( top + bottom ) / ( top - bottom );
- var C = -1.0;
- out[ 0 ] = X;
- out[ 1 ] = 0.0;
- out[ 2 ] = 0.0;
- out[ 3 ] = 0.0;
-
- out[ 4 ] = 0.0;
- out[ 5 ] = Y;
- out[ 6 ] = 0.0;
- out[ 7 ] = 0.0;
-
- out[ 8 ] = A;
- out[ 9 ] = B;
- out[ 10 ] = C;
- out[ 11 ] = -1.0;
-
- out[ 12 ] = 0.0;
- out[ 13 ] = 0.0;
- out[ 14 ] = -2.0 * znear;
- out[ 15 ] = 0.0;
-
- return out;
-};
-
-mat4.lookAtDirection = ( function () {
- var s = vec3.create();
- var u = vec3.create();
- var neg = vec3.create();
-
- return function ( out, eye, eyeDir, up ) {
- var f = eyeDir;
- vec3.cross( s, f, up );
- vec3.normalize( s, s );
-
- vec3.cross( u, s, f );
- vec3.normalize( u, u );
-
- // s[0], u[0], -f[0], 0.0,
- // s[1], u[1], -f[1], 0.0,
- // s[2], u[2], -f[2], 0.0,
- // 0, 0, 0, 1.0
-
- out[ 0 ] = s[ 0 ];
- out[ 1 ] = u[ 0 ];
- out[ 2 ] = -f[ 0 ];
- out[ 3 ] = 0.0;
- out[ 4 ] = s[ 1 ];
- out[ 5 ] = u[ 1 ];
- out[ 6 ] = -f[ 1 ];
- out[ 7 ] = 0.0;
- out[ 8 ] = s[ 2 ];
- out[ 9 ] = u[ 2 ];
- out[ 10 ] = -f[ 2 ];
- out[ 11 ] = 0.0;
- out[ 12 ] = 0;
- out[ 13 ] = 0;
- out[ 14 ] = 0;
- out[ 15 ] = 1.0;
-
- return mat4.translate( out, out, vec3.neg( neg, eye ) );
- };
-} )();
-
-mat4.getScale = ( function () {
- var sx = vec3.create();
- var sy = vec3.create();
- var sz = vec3.create();
- return function ( out, matrix ) {
- sx[ 0 ] = matrix[ 0 ];
- sx[ 1 ] = matrix[ 4 ];
- sx[ 2 ] = matrix[ 8 ];
- sy[ 0 ] = matrix[ 1 ];
- sy[ 1 ] = matrix[ 5 ];
- sy[ 2 ] = matrix[ 9 ];
- sz[ 0 ] = matrix[ 2 ];
- sz[ 1 ] = matrix[ 6 ];
- sz[ 2 ] = matrix[ 10 ];
-
- out[ 0 ] = vec3.length( sx );
- out[ 1 ] = vec3.length( sy );
- out[ 2 ] = vec3.length( sz );
- return out;
- };
-} )();
-
-mat4.getSqrScale = ( function () {
- var sx = vec3.create();
- var sy = vec3.create();
- var sz = vec3.create();
- return function ( out, matrix ) {
- sx[ 0 ] = matrix[ 0 ];
- sx[ 1 ] = matrix[ 4 ];
- sx[ 2 ] = matrix[ 8 ];
- sy[ 0 ] = matrix[ 1 ];
- sy[ 1 ] = matrix[ 5 ];
- sy[ 2 ] = matrix[ 9 ];
- sz[ 0 ] = matrix[ 2 ];
- sz[ 1 ] = matrix[ 6 ];
- sz[ 2 ] = matrix[ 10 ];
-
- out[ 0 ] = vec3.sqrLen( sx );
- out[ 1 ] = vec3.sqrLen( sy );
- out[ 2 ] = vec3.sqrLen( sz );
- return out;
- };
-} )();
-
-var glmRotate = mat4.rotate;
-mat4.rotate = function ( out, a, rad, axis ) {
- return glmRotate( out, a, rad, axis ) || mat4.identity( out );
-};
-
-var glmFromRotate = mat4.fromRotation;
-mat4.fromRotation = function ( out, rad, axis ) {
- return glmFromRotate( out, rad, axis ) || mat4.identity( out );
-};
-
-module.exports = glm;
diff --git a/app/static/app/js/vendor/osgjs/osg/math.js b/app/static/app/js/vendor/osgjs/osg/math.js
deleted file mode 100644
index 9887fbff..00000000
--- a/app/static/app/js/vendor/osgjs/osg/math.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-
-var clamp = function ( x, min, max ) {
- // http://jsperf.com/math-clamp
- // http://jsperf.com/clamping-methods/2
- return Math.min( max, Math.max( min, x ) );
-};
-
-var smoothStep = function ( edge0, edge1, x ) {
- var t = clamp( ( x - edge0 ) / ( edge1 - edge0 ), 0.0, 1.0 );
- return t * t * ( 3.0 - 2.0 * t );
-};
-
-// native isNaN is slow (e.g: https://jsperf.com/isnan-performance/2)
-// note : native isNaN will return true for undefined but
-// this function assume that x is a number
-var fastIsNaN = function ( x ) {
- return x !== x;
-};
-
-module.exports = {
- clamp: clamp,
- smoothStep: smoothStep,
- isNaN: fastIsNaN
-};
diff --git a/app/static/app/js/vendor/osgjs/osg/notify.js b/app/static/app/js/vendor/osgjs/osg/notify.js
deleted file mode 100644
index 3eba011a..00000000
--- a/app/static/app/js/vendor/osgjs/osg/notify.js
+++ /dev/null
@@ -1,108 +0,0 @@
-'use strict';
-
-var Notify = {};
-
-// must be uppercase and match loggers
-Notify.DEBUG = 0;
-Notify.INFO = 1;
-Notify.NOTICE = Notify.LOG = 2;
-Notify.WARN = 3;
-Notify.ERROR = 4;
-
-Notify.console = window.console;
-
-/** logging with readability in mind.
- * @param { level } what severity is that log (gives text color too )
- * @param { str } actual log text
- * @param { fold } sometimes you want to hide looooong text
- */
-function logSub( level, str ) {
-
- if ( !Notify.console ) return;
-
- Notify.console[ level ]( str );
- if ( Notify.traceLogCall && level !== 'error' ) console.trace();
-
-}
-
-function logSubFold( level, title, str ) {
-
- if ( !Notify.console ) return;
-
- if ( Notify.console.groupCollapsed ) Notify.console.groupCollapsed( title );
- Notify.console[ level ]( str );
- if ( Notify.traceLogCall && level !== 'error' ) console.trace();
-
- if ( Notify.console.groupEnd ) Notify.console.groupEnd();
-
-}
-
-function unFlattenMatrix( m, rowMajor ) {
- if ( rowMajor ) {
- return [ m.slice( 0, 4 ), m.slice( 4, 8 ), m.slice( 8, 12 ), m.slice( 12, 16 ) ];
- }
-
- return [
- [ m[ 0 ], m[ 4 ], m[ 8 ], m[ 12 ] ],
- [ m[ 1 ], m[ 5 ], m[ 9 ], m[ 13 ] ],
- [ m[ 2 ], m[ 6 ], m[ 10 ], m[ 14 ] ],
- [ m[ 3 ], m[ 7 ], m[ 11 ], m[ 15 ] ]
- ];
-}
-
-function logMatrix( m, rowMajor ) {
- if ( Notify.console.table )
- logSub( 'table', unFlattenMatrix( m, rowMajor ) );
-}
-
-function logMatrixFold( title, m, rowMajor ) {
- if ( Notify.console.table )
- logSubFold( 'table', title, unFlattenMatrix( m, rowMajor ) );
-}
-
-var levelEntries = [ 'log', 'info', 'warn', 'error', 'debug' ];
-var loggers = {};
-for ( var i = 0; i < levelEntries.length; ++i ) {
- var level = levelEntries[ i ];
- loggers[ level ] = logSub.bind( Notify, level );
- loggers[ level + 'Fold' ] = logSubFold.bind( Notify, level );
- loggers[ level + 'Matrix' ] = logMatrix.bind( Notify );
- loggers[ level + 'MatrixFold' ] = logMatrixFold.bind( Notify );
-}
-
-var assert = function ( test, str ) {
- if ( this.console !== undefined && !test ) {
- this.console.assert( test, str );
- }
-};
-Notify.assert = assert;
-
-Notify.setNotifyLevel = function ( logLevel ) {
-
- var dummy = function () {};
-
- for ( var i = 0; i < levelEntries.length; ++i ) {
- var level = levelEntries[ i ];
- var doDummy = logLevel > Notify[ level.toUpperCase() ];
- Notify[ level ] = doDummy ? dummy : loggers[ level ];
- Notify[ level + 'Fold' ] = doDummy ? dummy : loggers[ level + 'Fold' ];
- Notify[ level + 'Matrix' ] = doDummy ? dummy : loggers[ level + 'Matrix' ];
- Notify[ level + 'MatrixFold' ] = doDummy ? dummy : loggers[ level + 'MatrixFold' ];
- }
-
- // alias
- Notify.notice = Notify.log;
- Notify.noticeFold = Notify.logFold;
- Notify.noticeMatrix = Notify.logMatrix;
- Notify.noticeMatrixFold = Notify.logMatrixFold;
-};
-
-Notify.setNotifyLevel( Notify.NOTICE );
-
-Notify.reportWebGLError = false;
-
-Notify.setConsole = function ( replacement ) {
- Notify.console = replacement;
-};
-
-module.exports = Notify;
diff --git a/app/static/app/js/vendor/osgjs/osg/osg.js b/app/static/app/js/vendor/osgjs/osg/osg.js
deleted file mode 100644
index 5919ae43..00000000
--- a/app/static/app/js/vendor/osgjs/osg/osg.js
+++ /dev/null
@@ -1,176 +0,0 @@
-'use strict';
-var AutoTransform = require( 'osg/AutoTransform' );
-var BillboardAttribute = require( 'osg/BillboardAttribute' );
-var BlendColor = require( 'osg/BlendColor' );
-var BlendFunc = require( 'osg/BlendFunc' );
-var BoundingBox = require( 'osg/BoundingBox' );
-var BoundingSphere = require( 'osg/BoundingSphere' );
-var BufferArray = require( 'osg/BufferArray' );
-var Camera = require( 'osg/Camera' );
-var ColorMask = require( 'osg/ColorMask' );
-var ComputeBoundsVisitor = require( 'osg/ComputeBoundsVisitor' );
-var ComputeMatrixFromNodePath = require( 'osg/computeMatrixFromNodePath' );
-var CullFace = require( 'osg/CullFace' );
-var CullingSet = require( 'osg/CullingSet' );
-var CullSettings = require( 'osg/CullSettings' );
-var CullStack = require( 'osg/CullStack' );
-var CullVisitor = require( 'osg/CullVisitor' );
-var Depth = require( 'osg/Depth' );
-var DrawArrayLengths = require( 'osg/DrawArrayLengths' );
-var DrawArrays = require( 'osg/DrawArrays' );
-var DrawElements = require( 'osg/DrawElements' );
-var EllipsoidModel = require( 'osg/EllipsoidModel' );
-var FrameBufferObject = require( 'osg/FrameBufferObject' );
-var FrameStamp = require( 'osg/FrameStamp' );
-var Geometry = require( 'osg/Geometry' );
-var GLObject = require( 'osg/GLObject' );
-var Image = require( 'osg/Image' );
-var ImageStream = require( 'osg/ImageStream' );
-var KdTree = require( 'osg/KdTree' );
-var KdTreeBuilder = require( 'osg/KdTreeBuilder' );
-var Light = require( 'osg/Light' );
-var LightSource = require( 'osg/LightSource' );
-var LineWidth = require( 'osg/LineWidth' );
-var Lod = require( 'osg/Lod' );
-var Map = require( 'osg/Map' );
-var Material = require( 'osg/Material' );
-var osgjsMath = require( 'osg/math' );
-var Matrix = require( 'osg/Matrix' );
-var MatrixMemoryPool = require( 'osg/MatrixMemoryPool' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var Node = require( 'osg/Node' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Notify = require( 'osg/notify' );
-var Object = require( 'osg/Object' );
-var PagedLOD = require( 'osg/PagedLOD' );
-var Polytope = require( 'osg/Polytope' );
-var Plane = require( 'osg/Plane' );
-var PrimitiveFunctor = require( 'osg/PrimitiveFunctor' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var Program = require( 'osg/Program' );
-var Projection = require( 'osg/Projection' );
-var Quat = require( 'osg/Quat' );
-var RenderBin = require( 'osg/RenderBin' );
-var RenderLeaf = require( 'osg/RenderLeaf' );
-var RenderStage = require( 'osg/RenderStage' );
-var Shader = require( 'osg/Shader' );
-var Shape = require( 'osg/shape' );
-var Stack = require( 'osg/Stack' );
-var State = require( 'osg/State' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var StateGraph = require( 'osg/StateGraph' );
-var StateSet = require( 'osg/StateSet' );
-var Texture = require( 'osg/Texture' );
-var TextureCubeMap = require( 'osg/TextureCubeMap' );
-var Transform = require( 'osg/Transform' );
-var TriangleIndexFunctor = require( 'osg/TriangleIndexFunctor' );
-var Uniform = require( 'osg/Uniform' );
-var UpdateVisitor = require( 'osg/UpdateVisitor' );
-var MACROUTILS = require( 'osg/Utils' );
-var Vec2 = require( 'osg/Vec2' );
-var Vec3 = require( 'osg/Vec3' );
-var Vec4 = require( 'osg/Vec4' );
-var Viewport = require( 'osg/Viewport' );
-var osgPool = require( 'osgUtil/osgPool' );
-var Scissor = require( 'osg/Scissor' );
-var TransformEnums = require( 'osg/transformEnums' );
-var Timer = require( 'osg/Timer' );
-var TimerGPU = require( 'osg/TimerGPU' );
-var WebGLCaps = require( 'osg/WebGLCaps' );
-
-
-var osg = {};
-osg.AutoTransform = AutoTransform;
-osg.BillboardAttribute = BillboardAttribute;
-osg.BlendColor = BlendColor;
-osg.BlendFunc = BlendFunc;
-osg.BoundingBox = BoundingBox;
-osg.BoundingSphere = BoundingSphere;
-osg.BufferArray = BufferArray;
-osg.ColorMask = ColorMask;
-osg.Camera = Camera;
-osg.ColorMask = ColorMask;
-osg.ComputeBoundsVisitor = ComputeBoundsVisitor;
-MACROUTILS.objectMix( osg, ComputeMatrixFromNodePath );
-osg.CullFace = CullFace;
-osg.CullingSet = CullingSet;
-osg.CullSettings = CullSettings;
-osg.CullStack = CullStack;
-osg.CullVisitor = CullVisitor;
-osg.Depth = Depth;
-osg.DrawArrayLengths = DrawArrayLengths;
-osg.DrawArrays = DrawArrays;
-osg.DrawElements = DrawElements;
-osg.EllipsoidModel = EllipsoidModel;
-osg.WGS_84_RADIUS_EQUATOR = EllipsoidModel.WGS_84_RADIUS_EQUATOR;
-osg.WGS_84_RADIUS_POLAR = EllipsoidModel.WGS_84_RADIUS_POLAR;
-osg.FrameBufferObject = FrameBufferObject;
-osg.FrameStamp = FrameStamp;
-osg.Geometry = Geometry;
-osg.GLObject = GLObject;
-osg.Image = Image;
-osg.ImageStream = ImageStream;
-osg.KdTree = KdTree;
-osg.KdTreeBuilder = KdTreeBuilder;
-osg.Light = Light;
-osg.LightSource = LightSource;
-osg.LineWidth = LineWidth;
-osg.Lod = Lod;
-osg.Map = Map;
-osg.Material = Material;
-MACROUTILS.objectMix( osg, osgjsMath );
-osg.Matrix = Matrix;
-osg.MatrixTransform = MatrixTransform;
-osg.MatrixMemoryPool = MatrixMemoryPool;
-osg.Node = Node;
-osg.NodeVisitor = NodeVisitor;
-MACROUTILS.objectMix( osg, Notify );
-osg.Object = Object;
-osg.PagedLOD = PagedLOD;
-osg.Plane = Plane;
-osg.Polytope = Polytope;
-osg.PrimitiveSet = PrimitiveSet;
-osg.PrimitiveFunctor = PrimitiveFunctor;
-osg.Program = Program;
-osg.Projection = Projection;
-osg.Quat = Quat;
-osg.RenderBin = RenderBin;
-osg.RenderLeaf = RenderLeaf;
-osg.RenderStage = RenderStage;
-osg.Shader = Shader;
-MACROUTILS.objectMix( osg, Shape );
-osg.Stack = Stack;
-osg.State = State;
-osg.StateAttribute = StateAttribute;
-osg.StateGraph = StateGraph;
-osg.StateSet = StateSet;
-osg.Scissor = Scissor;
-osg.Texture = Texture;
-osg.TextureCubeMap = TextureCubeMap;
-osg.Transform = Transform;
-osg.TriangleIndexFunctor = TriangleIndexFunctor;
-osg.Uniform = Uniform;
-osg.UpdateVisitor = UpdateVisitor;
-MACROUTILS.objectMix( osg, MACROUTILS );
-osg.Vec2 = Vec2;
-osg.Vec3 = Vec3;
-osg.Vec4 = Vec4;
-osg.Viewport = Viewport;
-
-var glm = require( 'osg/glMatrix' );
-osg.vec2 = glm.vec2;
-osg.vec3 = glm.vec3;
-osg.vec4 = glm.vec4;
-osg.quat = glm.quat;
-osg.mat4 = glm.mat4;
-
-osg.memoryPools = osgPool.memoryPools;
-
-osg.Transform.RELATIVE_RF = TransformEnums.RELATIVE_RF;
-osg.Transform.ABSOLUTE_RF = TransformEnums.ABSOLUTE_RF;
-osg.Timer = Timer;
-osg.TimerGPU = TimerGPU;
-osg.WebGLCaps = WebGLCaps;
-
-
-module.exports = osg;
diff --git a/app/static/app/js/vendor/osgjs/osg/primitiveSet.js b/app/static/app/js/vendor/osgjs/osg/primitiveSet.js
deleted file mode 100644
index 161706e1..00000000
--- a/app/static/app/js/vendor/osgjs/osg/primitiveSet.js
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict';
-var PrimitiveSet = {};
-PrimitiveSet.POINTS = 0x0000;
-PrimitiveSet.LINES = 0x0001;
-PrimitiveSet.LINE_LOOP = 0x0002;
-PrimitiveSet.LINE_STRIP = 0x0003;
-PrimitiveSet.TRIANGLES = 0x0004;
-PrimitiveSet.TRIANGLE_STRIP = 0x0005;
-PrimitiveSet.TRIANGLE_FAN = 0x0006;
-
-module.exports = PrimitiveSet;
diff --git a/app/static/app/js/vendor/osgjs/osg/shape.js b/app/static/app/js/vendor/osgjs/osg/shape.js
deleted file mode 100644
index 8120adc3..00000000
--- a/app/static/app/js/vendor/osgjs/osg/shape.js
+++ /dev/null
@@ -1,797 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var BufferArray = require( 'osg/BufferArray' );
-var Geometry = require( 'osg/Geometry' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var DrawArrays = require( 'osg/DrawArrays' );
-var DrawElements = require( 'osg/DrawElements' );
-var Program = require( 'osg/Program' );
-var Shader = require( 'osg/Shader' );
-var MACROUTILS = require( 'osg/Utils' );
-
-
-/**
- * Create a Textured Box on the given center with given size
- * @name createTexturedBox
- */
-var createTexturedBoxGeometry = function ( cx, cy, cz,
- sx, sy, sz ) {
-
- var centerx = cx !== undefined ? cx : 0.0;
- var centery = cy !== undefined ? cy : 0.0;
- var centerz = cz !== undefined ? cz : 0.0;
-
- var sizex = sx !== undefined ? sx : 1.0;
- var sizey = sy !== undefined ? sy : 1.0;
- var sizez = sz !== undefined ? sz : 1.0;
-
- var g = new Geometry();
- var dx, dy, dz;
- dx = sizex / 2.0;
- dy = sizey / 2.0;
- dz = sizez / 2.0;
-
- var vertexes = new MACROUTILS.Float32Array( 72 );
- var uv = new MACROUTILS.Float32Array( 48 );
- var normal = new MACROUTILS.Float32Array( 72 );
-
- // -ve y plane
- vertexes[ 0 ] = centerx - dx;
- vertexes[ 1 ] = centery - dy;
- vertexes[ 2 ] = centerz + dz;
- normal[ 0 ] = 0.0;
- normal[ 1 ] = -1.0;
- normal[ 2 ] = 0.0;
- uv[ 0 ] = 0.0;
- uv[ 1 ] = 1.0;
-
- vertexes[ 3 ] = centerx - dx;
- vertexes[ 4 ] = centery - dy;
- vertexes[ 5 ] = centerz - dz;
- normal[ 3 ] = 0.0;
- normal[ 4 ] = -1.0;
- normal[ 5 ] = 0.0;
- uv[ 2 ] = 0.0;
- uv[ 3 ] = 0.0;
-
- vertexes[ 6 ] = centerx + dx;
- vertexes[ 7 ] = centery - dy;
- vertexes[ 8 ] = centerz - dz;
- normal[ 6 ] = 0.0;
- normal[ 7 ] = -1.0;
- normal[ 8 ] = 0.0;
- uv[ 4 ] = 1.0;
- uv[ 5 ] = 0.0;
-
- vertexes[ 9 ] = centerx + dx;
- vertexes[ 10 ] = centery - dy;
- vertexes[ 11 ] = centerz + dz;
- normal[ 9 ] = 0.0;
- normal[ 10 ] = -1.0;
- normal[ 11 ] = 0.0;
- uv[ 6 ] = 1.0;
- uv[ 7 ] = 1.0;
-
-
- // +ve y plane
- vertexes[ 12 ] = centerx + dx;
- vertexes[ 13 ] = centery + dy;
- vertexes[ 14 ] = centerz + dz;
- normal[ 12 ] = 0.0;
- normal[ 13 ] = 1.0;
- normal[ 14 ] = 0.0;
- uv[ 8 ] = 0.0;
- uv[ 9 ] = 1.0;
-
- vertexes[ 15 ] = centerx + dx;
- vertexes[ 16 ] = centery + dy;
- vertexes[ 17 ] = centerz - dz;
- normal[ 15 ] = 0.0;
- normal[ 16 ] = 1.0;
- normal[ 17 ] = 0.0;
- uv[ 10 ] = 0.0;
- uv[ 11 ] = 0.0;
-
- vertexes[ 18 ] = centerx - dx;
- vertexes[ 19 ] = centery + dy;
- vertexes[ 20 ] = centerz - dz;
- normal[ 18 ] = 0.0;
- normal[ 19 ] = 1.0;
- normal[ 20 ] = 0.0;
- uv[ 12 ] = 1.0;
- uv[ 13 ] = 0.0;
-
- vertexes[ 21 ] = centerx - dx;
- vertexes[ 22 ] = centery + dy;
- vertexes[ 23 ] = centerz + dz;
- normal[ 21 ] = 0.0;
- normal[ 22 ] = 1.0;
- normal[ 23 ] = 0.0;
- uv[ 14 ] = 1.0;
- uv[ 15 ] = 1.0;
-
-
- // +ve x plane
- vertexes[ 24 ] = centerx + dx;
- vertexes[ 25 ] = centery - dy;
- vertexes[ 26 ] = centerz + dz;
- normal[ 24 ] = 1.0;
- normal[ 25 ] = 0.0;
- normal[ 26 ] = 0.0;
- uv[ 16 ] = 0.0;
- uv[ 17 ] = 1.0;
-
- vertexes[ 27 ] = centerx + dx;
- vertexes[ 28 ] = centery - dy;
- vertexes[ 29 ] = centerz - dz;
- normal[ 27 ] = 1.0;
- normal[ 28 ] = 0.0;
- normal[ 29 ] = 0.0;
- uv[ 18 ] = 0.0;
- uv[ 19 ] = 0.0;
-
- vertexes[ 30 ] = centerx + dx;
- vertexes[ 31 ] = centery + dy;
- vertexes[ 32 ] = centerz - dz;
- normal[ 30 ] = 1.0;
- normal[ 31 ] = 0.0;
- normal[ 32 ] = 0.0;
- uv[ 20 ] = 1.0;
- uv[ 21 ] = 0.0;
-
- vertexes[ 33 ] = centerx + dx;
- vertexes[ 34 ] = centery + dy;
- vertexes[ 35 ] = centerz + dz;
- normal[ 33 ] = 1.0;
- normal[ 34 ] = 0.0;
- normal[ 35 ] = 0.0;
- uv[ 22 ] = 1.0;
- uv[ 23 ] = 1.0;
-
- // -ve x plane
- vertexes[ 36 ] = centerx - dx;
- vertexes[ 37 ] = centery + dy;
- vertexes[ 38 ] = centerz + dz;
- normal[ 36 ] = -1.0;
- normal[ 37 ] = 0.0;
- normal[ 38 ] = 0.0;
- uv[ 24 ] = 0.0;
- uv[ 25 ] = 1.0;
-
- vertexes[ 39 ] = centerx - dx;
- vertexes[ 40 ] = centery + dy;
- vertexes[ 41 ] = centerz - dz;
- normal[ 39 ] = -1.0;
- normal[ 40 ] = 0.0;
- normal[ 41 ] = 0.0;
- uv[ 26 ] = 0.0;
- uv[ 27 ] = 0.0;
-
- vertexes[ 42 ] = centerx - dx;
- vertexes[ 43 ] = centery - dy;
- vertexes[ 44 ] = centerz - dz;
- normal[ 42 ] = -1.0;
- normal[ 43 ] = 0.0;
- normal[ 44 ] = 0.0;
- uv[ 28 ] = 1.0;
- uv[ 29 ] = 0.0;
-
- vertexes[ 45 ] = centerx - dx;
- vertexes[ 46 ] = centery - dy;
- vertexes[ 47 ] = centerz + dz;
- normal[ 45 ] = -1.0;
- normal[ 46 ] = 0.0;
- normal[ 47 ] = 0.0;
- uv[ 30 ] = 1.0;
- uv[ 31 ] = 1.0;
-
- // top
- // +ve z plane
- vertexes[ 48 ] = centerx - dx;
- vertexes[ 49 ] = centery + dy;
- vertexes[ 50 ] = centerz + dz;
- normal[ 48 ] = 0.0;
- normal[ 49 ] = 0.0;
- normal[ 50 ] = 1.0;
- uv[ 32 ] = 0.0;
- uv[ 33 ] = 1.0;
-
- vertexes[ 51 ] = centerx - dx;
- vertexes[ 52 ] = centery - dy;
- vertexes[ 53 ] = centerz + dz;
- normal[ 51 ] = 0.0;
- normal[ 52 ] = 0.0;
- normal[ 53 ] = 1.0;
- uv[ 34 ] = 0.0;
- uv[ 35 ] = 0.0;
-
- vertexes[ 54 ] = centerx + dx;
- vertexes[ 55 ] = centery - dy;
- vertexes[ 56 ] = centerz + dz;
- normal[ 54 ] = 0.0;
- normal[ 55 ] = 0.0;
- normal[ 56 ] = 1.0;
- uv[ 36 ] = 1.0;
- uv[ 37 ] = 0.0;
-
- vertexes[ 57 ] = centerx + dx;
- vertexes[ 58 ] = centery + dy;
- vertexes[ 59 ] = centerz + dz;
- normal[ 57 ] = 0.0;
- normal[ 58 ] = 0.0;
- normal[ 59 ] = 1.0;
- uv[ 38 ] = 1.0;
- uv[ 39 ] = 1.0;
-
- // bottom
- // -ve z plane
- vertexes[ 60 ] = centerx + dx;
- vertexes[ 61 ] = centery + dy;
- vertexes[ 62 ] = centerz - dz;
- normal[ 60 ] = 0.0;
- normal[ 61 ] = 0.0;
- normal[ 62 ] = -1.0;
- uv[ 40 ] = 0.0;
- uv[ 41 ] = 1.0;
-
- vertexes[ 63 ] = centerx + dx;
- vertexes[ 64 ] = centery - dy;
- vertexes[ 65 ] = centerz - dz;
- normal[ 63 ] = 0.0;
- normal[ 64 ] = 0.0;
- normal[ 65 ] = -1.0;
- uv[ 42 ] = 0.0;
- uv[ 43 ] = 0.0;
-
- vertexes[ 66 ] = centerx - dx;
- vertexes[ 67 ] = centery - dy;
- vertexes[ 68 ] = centerz - dz;
- normal[ 66 ] = 0.0;
- normal[ 67 ] = 0.0;
- normal[ 68 ] = -1.0;
- uv[ 44 ] = 1.0;
- uv[ 45 ] = 0.0;
-
- vertexes[ 69 ] = centerx - dx;
- vertexes[ 70 ] = centery + dy;
- vertexes[ 71 ] = centerz - dz;
- normal[ 69 ] = 0.0;
- normal[ 70 ] = 0.0;
- normal[ 71 ] = -1.0;
- uv[ 46 ] = 1.0;
- uv[ 47 ] = 1.0;
-
- var indexes = new MACROUTILS.Uint16Array( 36 );
- indexes[ 0 ] = 0;
- indexes[ 1 ] = 1;
- indexes[ 2 ] = 2;
- indexes[ 3 ] = 0;
- indexes[ 4 ] = 2;
- indexes[ 5 ] = 3;
-
- indexes[ 6 ] = 4;
- indexes[ 7 ] = 5;
- indexes[ 8 ] = 6;
- indexes[ 9 ] = 4;
- indexes[ 10 ] = 6;
- indexes[ 11 ] = 7;
-
- indexes[ 12 ] = 8;
- indexes[ 13 ] = 9;
- indexes[ 14 ] = 10;
- indexes[ 15 ] = 8;
- indexes[ 16 ] = 10;
- indexes[ 17 ] = 11;
-
- indexes[ 18 ] = 12;
- indexes[ 19 ] = 13;
- indexes[ 20 ] = 14;
- indexes[ 21 ] = 12;
- indexes[ 22 ] = 14;
- indexes[ 23 ] = 15;
-
- indexes[ 24 ] = 16;
- indexes[ 25 ] = 17;
- indexes[ 26 ] = 18;
- indexes[ 27 ] = 16;
- indexes[ 28 ] = 18;
- indexes[ 29 ] = 19;
-
- indexes[ 30 ] = 20;
- indexes[ 31 ] = 21;
- indexes[ 32 ] = 22;
- indexes[ 33 ] = 20;
- indexes[ 34 ] = 22;
- indexes[ 35 ] = 23;
-
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertexes, 3 );
- g.getAttributes().Normal = new BufferArray( BufferArray.ARRAY_BUFFER, normal, 3 );
- g.getAttributes().TexCoord0 = new BufferArray( BufferArray.ARRAY_BUFFER, uv, 2 );
-
- var primitive = new DrawElements( PrimitiveSet.TRIANGLES, new BufferArray( BufferArray.ELEMENT_ARRAY_BUFFER, indexes, 1 ) );
- g.getPrimitives().push( primitive );
- return g;
-};
-
-// better perf
-// no more pixel shader hurt for nothing
-// http://michaldrobot.com/2014/04/01/gcn-execution-patterns-in-full-screen-passes/
-// It's a Singleton, as it's rendering invariant
-// so same remove uneeded state change when same geom
-var createTexturedFullScreenFakeQuadGeometry = ( function () {
- var g = new Geometry();
-
- var uvs = new MACROUTILS.Float32Array( [ -1.0, -1.0, -1.0, 4.0, 4.0, -1.0 ] );
- var vertexes = new MACROUTILS.Float32Array( [ -1.0, -1.0, -1.0, 4.0, 4.0, -1.0 ] );
-
- var indexes = new MACROUTILS.Uint16Array( 3 );
- indexes[ 0 ] = 2;
- indexes[ 1 ] = 1;
- indexes[ 2 ] = 0;
-
- // Further optim: no index, no uv (uv.xy = position.xy in vertex shader)
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertexes, 2 );
- g.getAttributes().TexCoord0 = new BufferArray( BufferArray.ARRAY_BUFFER, uvs, 2 );
-
- var primitive = new DrawElements( PrimitiveSet.TRIANGLES, new BufferArray( BufferArray.ELEMENT_ARRAY_BUFFER, indexes, 1 ) );
- g.getPrimitives().push( primitive );
-
- return function () {
- return g;
- };
-} )();
-
-
-var createTexturedQuadGeometry = function ( cornerx, cornery, cornerz,
- wx, wy, wz,
- hx, hy, hz,
- l, b, r, t ) {
-
- if ( r === undefined && t === undefined ) {
- r = l;
- t = b;
- l = 0.0;
- b = 0.0;
- }
-
- var g = new Geometry();
-
- var vertexes = new MACROUTILS.Float32Array( 12 );
- vertexes[ 0 ] = cornerx + hx;
- vertexes[ 1 ] = cornery + hy;
- vertexes[ 2 ] = cornerz + hz;
-
- vertexes[ 3 ] = cornerx;
- vertexes[ 4 ] = cornery;
- vertexes[ 5 ] = cornerz;
-
- vertexes[ 6 ] = cornerx + wx;
- vertexes[ 7 ] = cornery + wy;
- vertexes[ 8 ] = cornerz + wz;
-
- vertexes[ 9 ] = cornerx + wx + hx;
- vertexes[ 10 ] = cornery + wy + hy;
- vertexes[ 11 ] = cornerz + wz + hz;
-
- if ( r === undefined ) {
- r = 1.0;
- }
- if ( t === undefined ) {
- t = 1.0;
- }
-
- var uvs = new MACROUTILS.Float32Array( 8 );
- uvs[ 0 ] = l;
- uvs[ 1 ] = t;
-
- uvs[ 2 ] = l;
- uvs[ 3 ] = b;
-
- uvs[ 4 ] = r;
- uvs[ 5 ] = b;
-
- uvs[ 6 ] = r;
- uvs[ 7 ] = t;
-
- var n = vec3.fromValues( wx, wy, wz );
- vec3.cross( n, n, vec3.fromValues( hx, hy, hz ) );
- vec3.normalize( n, n );
-
- var normal = new MACROUTILS.Float32Array( 12 );
- normal[ 0 ] = n[ 0 ];
- normal[ 1 ] = n[ 1 ];
- normal[ 2 ] = n[ 2 ];
-
- normal[ 3 ] = n[ 0 ];
- normal[ 4 ] = n[ 1 ];
- normal[ 5 ] = n[ 2 ];
-
- normal[ 6 ] = n[ 0 ];
- normal[ 7 ] = n[ 1 ];
- normal[ 8 ] = n[ 2 ];
-
- normal[ 9 ] = n[ 0 ];
- normal[ 10 ] = n[ 1 ];
- normal[ 11 ] = n[ 2 ];
-
-
- var indexes = new MACROUTILS.Uint16Array( 6 );
- indexes[ 0 ] = 0;
- indexes[ 1 ] = 1;
- indexes[ 2 ] = 2;
- indexes[ 3 ] = 0;
- indexes[ 4 ] = 2;
- indexes[ 5 ] = 3;
-
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertexes, 3 );
- g.getAttributes().Normal = new BufferArray( BufferArray.ARRAY_BUFFER, normal, 3 );
- g.getAttributes().TexCoord0 = new BufferArray( BufferArray.ARRAY_BUFFER, uvs, 2 );
-
- var primitive = new DrawElements( PrimitiveSet.TRIANGLES, new BufferArray( BufferArray.ELEMENT_ARRAY_BUFFER, indexes, 1 ) );
- g.getPrimitives().push( primitive );
- return g;
-};
-
-var createTexturedBox = function ( centerx, centery, centerz,
- sizex, sizey, sizez ) {
- Notify.log( 'createTexturedBox is deprecated use instead createTexturedBoxGeometry' );
- return createTexturedBoxGeometry( centerx, centery, centerz,
- sizex, sizey, sizez );
-};
-
-var createTexturedQuad = function ( cornerx, cornery, cornerz,
- wx, wy, wz,
- hx, hy, hz,
- l, b, r, t ) {
- Notify.log( 'createTexturedQuad is deprecated use instead createTexturedQuadGeometry' );
- return createTexturedQuadGeometry( cornerx, cornery, cornerz,
- wx, wy, wz,
- hx, hy, hz,
- l, b, r, t );
-};
-
-var createAxisGeometry = function ( size ) {
- if ( size === undefined ) {
- size = 5.0;
- }
- if ( createAxisGeometry.getShader === undefined ) {
- createAxisGeometry.getShader = function () {
- if ( createAxisGeometry.getShader.program === undefined ) {
- var vertexshader = [
- '#ifdef GL_ES',
- 'precision highp float;',
- '#endif',
- 'attribute vec3 Vertex;',
- 'attribute vec4 Color;',
- 'uniform mat4 uModelViewMatrix;',
- 'uniform mat4 uProjectionMatrix;',
- '',
- 'varying vec4 vColor;',
- '',
- 'void main(void) {',
- ' gl_Position = uProjectionMatrix * (uModelViewMatrix * vec4(Vertex, 1.0));',
- ' vColor = Color;',
- '}'
- ].join( '\n' );
-
- var fragmentshader = [
- '#ifdef GL_ES',
- 'precision highp float;',
- '#endif',
- 'varying vec4 vColor;',
-
- 'void main(void) {',
- 'gl_FragColor = vColor;',
- '}'
- ].join( '\n' );
-
- var program = new Program( new Shader( 'VERTEX_SHADER', vertexshader ),
- new Shader( 'FRAGMENT_SHADER', fragmentshader ) );
- createAxisGeometry.getShader.program = program;
- }
- return createAxisGeometry.getShader.program;
- };
- }
-
- var g = new Geometry();
-
- var vertexes = new MACROUTILS.Float32Array( 18 );
- vertexes[ 3 ] = size;
- vertexes[ 10 ] = size;
- vertexes[ 17 ] = size;
-
- var colors = new MACROUTILS.Float32Array( 24 );
- //red color
- colors[ 0 ] = colors[ 3 ] = 1.0;
- colors[ 4 ] = colors[ 4 + 3 ] = 1.0;
- //green color
- colors[ 4 * 2 + 1 ] = colors[ 4 * 2 + 3 ] = 1.0;
- colors[ 4 * 3 + 1 ] = colors[ 4 * 3 + 3 ] = 1.0;
- //blue color
- colors[ 4 * 4 + 2 ] = colors[ 4 * 4 + 3 ] = 1.0;
- colors[ 4 * 5 + 2 ] = colors[ 4 * 5 + 3 ] = 1.0;
-
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertexes, 3 );
- g.getAttributes().Color = new BufferArray( BufferArray.ARRAY_BUFFER, colors, 4 );
-
- var primitive = new DrawArrays( PrimitiveSet.LINES, 0, 6 );
- g.getPrimitives().push( primitive );
- g.getOrCreateStateSet().setAttributeAndModes( createAxisGeometry.getShader() );
-
- return g;
-};
-
-/**
- * Create a Textured Sphere on the given center with given radius
- * @name createTexturedSphere
- * @author Darrell Esau
- */
-var createTexturedSphere = function ( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
- radius = radius || 50.0;
-
- phiStart = phiStart !== undefined ? phiStart : 0.0;
- phiLength = phiLength !== undefined ? phiLength : Math.PI * 2;
-
- thetaStart = thetaStart !== undefined ? thetaStart : 0.0;
- thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
-
- var segmentsX = Math.max( 3, Math.floor( widthSegments ) || 8 );
- var segmentsY = Math.max( 2, Math.floor( heightSegments ) || 6 );
-
- var useDrawArrays = ( ( segmentsX * segmentsY ) / 3 ) >= 65536;
- var nbPrim = useDrawArrays ? segmentsX * segmentsY * 6 : segmentsX * segmentsY * 4;
- var fullVerticesList = new MACROUTILS.Float32Array( nbPrim * 3 );
- var fullNormalsList = new MACROUTILS.Float32Array( nbPrim * 3 );
- var fullUVList = new MACROUTILS.Float32Array( nbPrim * 2 );
- var indexes = !useDrawArrays ? new MACROUTILS.Uint16Array( segmentsX * segmentsY * 6 ) : undefined;
- var vtxCount = 0;
- var triCount = 0;
-
- var v1 = new MACROUTILS.Float32Array( 3 );
- var v2 = new MACROUTILS.Float32Array( 3 );
- var v3 = new MACROUTILS.Float32Array( 3 );
- var v4 = new MACROUTILS.Float32Array( 3 );
- var n1 = new MACROUTILS.Float32Array( 3 );
- var n2 = new MACROUTILS.Float32Array( 3 );
- var n3 = new MACROUTILS.Float32Array( 3 );
- var n4 = new MACROUTILS.Float32Array( 3 );
- var uv1 = new MACROUTILS.Float32Array( 2 );
- var uv2 = new MACROUTILS.Float32Array( 2 );
- var uv3 = new MACROUTILS.Float32Array( 2 );
- var uv4 = new MACROUTILS.Float32Array( 2 );
- var getCoordAndUvSphere = function ( u, v, coord, norm, uv ) {
- coord[ 0 ] = -radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
- coord[ 1 ] = radius * Math.cos( thetaStart + v * thetaLength );
- coord[ 2 ] = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
- vec3.normalize( norm, coord );
- uv[ 0 ] = u;
- uv[ 1 ] = 1 - v;
- };
- for ( var y = 0; y < segmentsY; y++ ) {
- for ( var x = 0; x < segmentsX; x++ ) {
- getCoordAndUvSphere( ( x + 1 ) / segmentsX, y / segmentsY, v1, n1, uv1 );
- getCoordAndUvSphere( x / segmentsX, y / segmentsY, v2, n2, uv2 );
- getCoordAndUvSphere( x / segmentsX, ( y + 1 ) / segmentsY, v3, n3, uv3 );
- getCoordAndUvSphere( ( x + 1 ) / segmentsX, ( y + 1 ) / segmentsY, v4, n4, uv4 );
-
- var idv = vtxCount * 3;
- fullVerticesList[ idv ] = v1[ 0 ];
- fullVerticesList[ idv + 1 ] = v1[ 1 ];
- fullVerticesList[ idv + 2 ] = v1[ 2 ];
- fullVerticesList[ idv + 3 ] = v2[ 0 ];
- fullVerticesList[ idv + 4 ] = v2[ 1 ];
- fullVerticesList[ idv + 5 ] = v2[ 2 ];
- fullVerticesList[ idv + 6 ] = v3[ 0 ];
- fullVerticesList[ idv + 7 ] = v3[ 1 ];
- fullVerticesList[ idv + 8 ] = v3[ 2 ];
-
- fullNormalsList[ idv ] = n1[ 0 ];
- fullNormalsList[ idv + 1 ] = n1[ 1 ];
- fullNormalsList[ idv + 2 ] = n1[ 2 ];
- fullNormalsList[ idv + 3 ] = n2[ 0 ];
- fullNormalsList[ idv + 4 ] = n2[ 1 ];
- fullNormalsList[ idv + 5 ] = n2[ 2 ];
- fullNormalsList[ idv + 6 ] = n3[ 0 ];
- fullNormalsList[ idv + 7 ] = n3[ 1 ];
- fullNormalsList[ idv + 8 ] = n3[ 2 ];
-
- var idu = vtxCount * 2;
- fullUVList[ idu ] = uv1[ 0 ];
- fullUVList[ idu + 1 ] = uv1[ 1 ];
- fullUVList[ idu + 2 ] = uv2[ 0 ];
- fullUVList[ idu + 3 ] = uv2[ 1 ];
- fullUVList[ idu + 4 ] = uv3[ 0 ];
- fullUVList[ idu + 5 ] = uv3[ 1 ];
-
- vtxCount += 3;
- if ( useDrawArrays ) {
- idv = vtxCount * 3;
- fullVerticesList[ idv ] = v1[ 0 ];
- fullVerticesList[ idv + 1 ] = v1[ 1 ];
- fullVerticesList[ idv + 2 ] = v1[ 2 ];
- fullVerticesList[ idv + 3 ] = v3[ 0 ];
- fullVerticesList[ idv + 4 ] = v3[ 1 ];
- fullVerticesList[ idv + 5 ] = v3[ 2 ];
- fullVerticesList[ idv + 6 ] = v4[ 0 ];
- fullVerticesList[ idv + 7 ] = v4[ 1 ];
- fullVerticesList[ idv + 8 ] = v4[ 2 ];
-
- fullNormalsList[ idv ] = n1[ 0 ];
- fullNormalsList[ idv + 1 ] = n1[ 1 ];
- fullNormalsList[ idv + 2 ] = n1[ 2 ];
- fullNormalsList[ idv + 3 ] = n3[ 0 ];
- fullNormalsList[ idv + 4 ] = n3[ 1 ];
- fullNormalsList[ idv + 5 ] = n3[ 2 ];
- fullNormalsList[ idv + 6 ] = n4[ 0 ];
- fullNormalsList[ idv + 7 ] = n4[ 1 ];
- fullNormalsList[ idv + 8 ] = n4[ 2 ];
-
- idu = vtxCount * 2;
- fullUVList[ idu ] = uv1[ 0 ];
- fullUVList[ idu + 1 ] = uv1[ 1 ];
- fullUVList[ idu + 2 ] = uv3[ 0 ];
- fullUVList[ idu + 3 ] = uv3[ 1 ];
- fullUVList[ idu + 4 ] = uv4[ 0 ];
- fullUVList[ idu + 5 ] = uv4[ 1 ];
- vtxCount += 3;
- } else {
- idv = vtxCount * 3;
- fullVerticesList[ idv ] = v4[ 0 ];
- fullVerticesList[ idv + 1 ] = v4[ 1 ];
- fullVerticesList[ idv + 2 ] = v4[ 2 ];
-
- fullNormalsList[ idv ] = n4[ 0 ];
- fullNormalsList[ idv + 1 ] = n4[ 1 ];
- fullNormalsList[ idv + 2 ] = n4[ 2 ];
-
- idu = vtxCount * 2;
- fullUVList[ idu ] = uv4[ 0 ];
- fullUVList[ idu + 1 ] = uv4[ 1 ];
-
- var iStart = triCount * 3;
- var tristart = vtxCount - 3;
- indexes[ iStart ] = tristart;
- indexes[ iStart + 1 ] = tristart + 1;
- indexes[ iStart + 2 ] = tristart + 2;
- indexes[ iStart + 3 ] = tristart;
- indexes[ iStart + 4 ] = tristart + 2;
- indexes[ iStart + 5 ] = tristart + 3;
- triCount += 2;
- vtxCount += 1;
- }
- }
- }
-
- var g = new Geometry();
- g.getAttributes().Vertex = new BufferArray( 'ARRAY_BUFFER', fullVerticesList, 3 );
- g.getAttributes().Normal = new BufferArray( 'ARRAY_BUFFER', fullNormalsList, 3 );
- g.getAttributes().TexCoord0 = new BufferArray( 'ARRAY_BUFFER', fullUVList, 2 );
-
- if ( useDrawArrays )
- g.getPrimitives().push( new DrawArrays( PrimitiveSet.TRIANGLES, 0, fullVerticesList.length / 3 ) );
- else
- g.getPrimitives().push( new DrawElements( PrimitiveSet.TRIANGLES, new BufferArray( 'ELEMENT_ARRAY_BUFFER', indexes, 1 ) ) );
- return g;
-};
-
-var createGridGeometry = function ( cx, cy, cz, wx, wy, wz, hx, hy, hz, res1, res2 ) {
- cx = cx !== undefined ? cx : -0.5;
- cy = cy !== undefined ? cy : -0.5;
- cz = cz !== undefined ? cz : 0.0;
-
- wx = wx !== undefined ? wx : 1.0;
- wy = wy !== undefined ? wy : 0.0;
- wz = wz !== undefined ? wz : 0.0;
-
- hx = hx !== undefined ? hx : 0.0;
- hy = hy !== undefined ? hy : 1.0;
- hz = hz !== undefined ? hz : 0.0;
-
- res1 = res1 !== undefined ? res1 : 5;
- res2 = res2 !== undefined ? res2 : res1;
- res1 += 2;
- res2 += 2;
-
- var g = new Geometry();
- var vertices = new Float32Array( ( res1 + res2 ) * 2 * 3 );
- var i = 0;
- var j = 0;
- var sx = wx / ( res1 - 1 );
- var sy = wy / ( res1 - 1 );
- var sz = wz / ( res1 - 1 );
- var ux = cx + wx + hx;
- var uy = cy + wy + hy;
- var uz = cz + wz + hz;
- for ( i = 0; i < res1; ++i ) {
- j = i * 6;
- vertices[ j ] = cx + sx * i;
- vertices[ j + 1 ] = cy + sy * i;
- vertices[ j + 2 ] = cz + sz * i;
- vertices[ j + 3 ] = ux - sx * ( res1 - i - 1 );
- vertices[ j + 4 ] = uy - sy * ( res1 - i - 1 );
- vertices[ j + 5 ] = uz - sz * ( res1 - i - 1 );
- }
- sx = hx / ( res2 - 1 );
- sy = hy / ( res2 - 1 );
- sz = hz / ( res2 - 1 );
- for ( i = 0; i < res2; ++i ) {
- j = ( res1 + i ) * 6;
- vertices[ j ] = cx + sx * i;
- vertices[ j + 1 ] = cy + sy * i;
- vertices[ j + 2 ] = cz + sz * i;
- vertices[ j + 3 ] = ux - sx * ( res2 - i - 1 );
- vertices[ j + 4 ] = uy - sy * ( res2 - i - 1 );
- vertices[ j + 5 ] = uz - sz * ( res2 - i - 1 );
- }
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertices, 3 );
- var primitive = new DrawArrays( PrimitiveSet.LINES, 0, ( res1 + res2 ) * 2 );
- g.getPrimitives().push( primitive );
- return g;
-};
-
-/*
- * debug lines showing bounding box abstraction
- * @param col bbox color
- */
-var createBoundingBoxGeometry = function ( col ) {
-
- var g = new Geometry();
- //unit cube centered on 0
- var vertices = new Float32Array( [ -0.5, -0.5, -0.5,
- 0.5, -0.5, -0.5,
- 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5,
- 0.5, -0.5, 0.5,
- 0.5, 0.5, 0.5, -0.5, 0.5, 0.5
- ] );
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertices, 3 );
-
- // use color or red
- if ( !col ) col = [ 1.0, 0.0, 0.0, 1.0 ];
- var colors = new MACROUTILS.Float32Array( 8 * 4 );
- for ( var i = 0; i < 8; i++ ) {
- for ( var k = 0; k < 4; k++ ) {
- colors[ i * 3 + k ] = col[ k ];
- }
- }
-
- g.getAttributes().Color = new BufferArray( BufferArray.ARRAY_BUFFER, colors, 4 );
-
- var indexes = new MACROUTILS.Uint16Array(
- [
- //up
- 0, 1,
- 1, 2,
- 2, 3,
- 3, 0,
- //down
- 4, 5,
- 5, 6,
- 6, 7,
- 7, 4,
- // side
- 0, 4,
- 1, 5,
- 2, 6,
- 3, 7
-
- ] );
-
- g.getPrimitives().push( new DrawElements( PrimitiveSet.LINES, new BufferArray( 'ELEMENT_ARRAY_BUFFER', indexes, 1 ) ) );
-
- return g;
-
-};
-
-module.exports = {
- createTexturedBoxGeometry: createTexturedBoxGeometry,
- createTexturedQuadGeometry: createTexturedQuadGeometry,
- createTexturedSphereGeometry: createTexturedSphere,
- createTexturedBox: createTexturedBox,
- createTexturedFullScreenFakeQuadGeometry: createTexturedFullScreenFakeQuadGeometry,
- createTexturedQuad: createTexturedQuad,
- createAxisGeometry: createAxisGeometry,
- createTexturedSphere: createTexturedSphere,
- createGridGeometry: createGridGeometry,
- createBoundingBoxGeometry: createBoundingBoxGeometry
-};
diff --git a/app/static/app/js/vendor/osgjs/osg/transformEnums.js b/app/static/app/js/vendor/osgjs/osg/transformEnums.js
deleted file mode 100644
index 48823760..00000000
--- a/app/static/app/js/vendor/osgjs/osg/transformEnums.js
+++ /dev/null
@@ -1,5 +0,0 @@
-'use strict';
-module.exports = {
- RELATIVE_RF: 0,
- ABSOLUTE_RF: 1
-};
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/AnimationUpdateCallback.js b/app/static/app/js/vendor/osgjs/osgAnimation/AnimationUpdateCallback.js
deleted file mode 100644
index 8af04954..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/AnimationUpdateCallback.js
+++ /dev/null
@@ -1,58 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-
-
-/**
- * AnimationUpdateCallback
- * @class AnimationUpdateCallback
- */
-var AnimationUpdateCallback = function () {
- Object.call( this );
-};
-
-// check if the path is animated, it could be elsewhere though
-AnimationUpdateCallback.checkPathIsAnimated = function ( path ) {
-
- for ( var i = 0, nbNodes = path.length; i < nbNodes; ++i ) {
- var node = path[ i ];
-
- if ( node instanceof MatrixTransform ) {
- var ups = node.getUpdateCallbackList();
- for ( var j = 0, nbUp = ups.length; j < nbUp; ++j ) {
- if ( ups[ j ] instanceof AnimationUpdateCallback )
- return true;
- }
- }
-
- }
-
- return false;
-};
-
-/** @lends AnimationUpdateCallback.prototype */
-AnimationUpdateCallback.prototype = MACROUTILS.objectInherit( Object.prototype, {
-
- linkChannel: function () {},
- linkAnimation: function ( anim ) {
- var name = this.getName();
- if ( name.length === 0 ) {
- Notify.log( 'no name on an update callback, discard' );
- return 0;
- }
- var nbLinks = 0;
- var channels = anim.getChannels();
- for ( var i = 0, l = channels.length; i < l; i++ ) {
- var channel = channels[ i ];
- if ( channel.getTargetName() === name ) {
- this.linkChannel( channel );
- nbLinks++;
- }
- }
- return nbLinks;
- }
-} );
-
-module.exports = AnimationUpdateCallback;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/BasicAnimationManager.js b/app/static/app/js/vendor/osgjs/osgAnimation/BasicAnimationManager.js
deleted file mode 100644
index a1e25039..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/BasicAnimationManager.js
+++ /dev/null
@@ -1,711 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var BaseObject = require( 'osg/Object' );
-var quat = require( 'osg/glMatrix' ).quat;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Channel = require( 'osgAnimation/channel' );
-var Animation = require( 'osgAnimation/animation' );
-var Interpolator = require( 'osgAnimation/interpolator' );
-var CollectAnimationUpdateCallbackVisitor = require( 'osgAnimation/CollectAnimationUpdateCallbackVisitor' );
-var Target = require( 'osgAnimation/target' );
-var UpdateMorph = require( 'osgAnimation/UpdateMorph' );
-
-
-var Float = {
- lerp: function ( a, b, t ) {
- return a + ( b - a ) * t;
- },
- init: function () {
- return 0.0;
- },
- copy: function ( src ) {
- return src;
- },
- create: function () {
- return 0.0;
- }
-};
-
-var TypeToSize = [];
-TypeToSize[ Channel.ChannelType.Float ] = 1;
-TypeToSize[ Channel.ChannelType.FloatCubicBezier ] = 1;
-TypeToSize[ Channel.ChannelType.Vec3 ] = 3;
-TypeToSize[ Channel.ChannelType.Vec3CubicBezier ] = 3;
-TypeToSize[ Channel.ChannelType.Quat ] = 4;
-TypeToSize[ Channel.ChannelType.QuatSlerp ] = 4;
-TypeToSize[ Channel.ChannelType.Matrix ] = 16;
-
-
-var ResultType = [];
-ResultType.length = Channel.ChannelType.Count;
-ResultType[ Channel.ChannelType.Vec3 ] = vec3;
-ResultType[ Channel.ChannelType.Quat ] = quat;
-ResultType[ Channel.ChannelType.QuatSlerp ] = quat;
-ResultType[ Channel.ChannelType.Float ] = Float;
-ResultType[ Channel.ChannelType.FloatCubicBezier ] = Float;
-ResultType[ Channel.ChannelType.Vec3CubicBezier ] = vec3;
-ResultType[ Channel.ChannelType.Matrix ] = mat4;
-
-/**
- * BasicAnimationManager
- * @class BasicAnimationManager
- */
-var BasicAnimationManager = function () {
- BaseObject.call( this );
-
- this._simulationTime = 0.0;
- this._pauseTime = 0.0;
- this._timeFactor = 1.0;
- this._startTime = 0.0;
-
- // contains a map with instance animations
- this._instanceAnimations = {};
-
- // animations to start
- this._startAnimations = {};
-
- // target contains an array of all target for this manager
- // index in the array is used as ID
- // see Animation.createTarget
- // [
- // { id: 0,
- // channels: [],
- // value: 0.0,
- // defaultValue: 0.0,
- // type
- // },
- // ...
- // ];
- this._targets = [];
- this._targetsMap = {};
-
- // target id with active lists
- // [
- // vec3: [ targetID0, targetID1 ]
- // Quat: [ targetID2, targetID3, ... ]
- // Float: [ ... ]
- // ]
- this._targetsByTypes = [];
- this._targetsByTypes.length = Channel.ChannelType.Count;
- for ( var i = 0, ni = this._targetsByTypes.length; i < ni; i++ ) {
- this._targetsByTypes[ i ] = [];
- }
-
- // current playing animations
- this._activeAnimations = {};
- this._activeAnimationList = [];
-
- // current actives channels by types
- // [ chanel0, channel1, ... ] // vec3 type
- // [ chanel2, channel3, ... ] // Quat type
- // [ chanel5, channel6, ... ] // Float type
- this._activeChannelsByTypes = [];
- this._activeChannelsByTypes.length = Channel.ChannelType.Count;
- for ( var j = 0, nj = this._activeChannelsByTypes.length; j < nj; j++ ) {
- this._activeChannelsByTypes[ j ] = [];
- }
-
- // assign all target/channel in animationCallback
- // then they can read it directly
- // animation callback to update
- this._animationsUpdateCallback = {};
- this._animationsUpdateCallbackArray = [];
-
- // queue of animations to register
- this._animationsToRegister = [];
-
- //Pause status (true / false)
- this._pause = false;
-
- this._dirty = false;
-
- this._seekTime = -1;
-};
-
-BasicAnimationManager.prototype = MACROUTILS.objectInherit( BaseObject.prototype, {
-
- init: function ( animations ) {
-
- // reset all
- this._simulationTime = 0.0;
- this._pauseTime = 0.0;
- this._timeFactor = 1.0;
- this._startTime = 0.0;
-
- // contains a map with instance animations
- this._instanceAnimations = {};
-
- // animations to start
- this._startAnimations = {};
-
- this._resetTargets();
-
- this._activeAnimations = {};
- this._activeAnimationList.length = 0;
-
- for ( var i = 0, ni = this._activeChannelsByTypes.length; i < ni; i++ )
- this._activeChannelsByTypes[ i ].length = 0;
-
- this._animationsUpdateCallback = {};
- this._animationsUpdateCallbackArray.length = 0;
-
- this._pause = false;
- this._seekTime = -1;
-
- // add animations
- this.addAnimations( animations );
- },
-
-
- // push all animations into the queue
- addAnimations: function ( animations ) {
-
- var instanceAnimationList = this._addAnimation( animations );
-
- // qeue them to assign target
- Array.prototype.push.apply( this._animationsToRegister, instanceAnimationList );
- this._dirty = true;
- this._registerAnimations();
- },
-
-
- update: function ( node, nv ) {
-
- if ( this._dirty ) {
- this._findAnimationUpdateCallback( node );
- this._registerTargetFoundInAnimationCallback();
- this._registerAnimations();
- }
-
- var t = nv.getFrameStamp().getSimulationTime();
-
- if ( this._seekTime !== -1 )
- this._pauseTime = -this._seekTime + this._startTime + t;
- this._seekTime = -1;
-
- if ( !this._pause ) { // Not in pause
- this._simulationTime = this._startTime + ( t - this._pauseTime );
- } else {
- this._pauseTime = ( t - this._simulationTime + this._startTime );
- }
-
- this.updateManager( this._simulationTime * this._timeFactor );
- return true;
- },
-
- updateManager: function ( t ) {
-
-
- // adds active animations / channels requested
- //
- this._processStartAnimation( t );
-
- var l = Channel.ChannelType.Count;
- // update all actives channels by type
- //
- for ( var i = 0; i < l; i++ ) {
- var activeChannelType = this._activeChannelsByTypes[ i ];
- this._updateChannelsType( t, activeChannelType, Interpolator[ i ] );
- }
-
- // update targets
- //
- for ( var j = 0; j < l; j++ ) {
- var targetType = this._targetsByTypes[ j ];
- this._updateTargetType( targetType, ResultType[ j ] );
- }
-
-
- // update all animation callback
- // expect to have UpdateMatrixTransform
- for ( var k = 0, nk = this._animationsUpdateCallbackArray.length; k < nk; k++ ) {
- var animCallback = this._animationsUpdateCallbackArray[ k ];
- animCallback.computeChannels();
- }
-
- // check animation finished
- this._removeFinishedAnimation( t );
- },
-
- togglePause: function () { //Pause the manager's time
- this._pause = !this._pause;
- // if we resume an animation we don't want to move forward the animation
- if ( !this._pause )
- this._seekTime = this._simulationTime;
- },
-
- getSimulationTime: function () {
- return this._simulationTime;
- },
-
- setSimulationTime: function ( t ) {
- this._simulationTime = t;
- },
-
- setSeekTime: function ( t ) {
- this._simulationTime = t;
- this._seekTime = t;
- },
-
- stopAnimation: function ( name ) {
- var activeAnimationList = this._activeAnimationList;
- for ( var i = 0, nbAnim = activeAnimationList.length; i < nbAnim; ++i ) {
- if ( activeAnimationList[ i ].name === name ) {
- this._removeActiveChannels( this._instanceAnimations[ name ] );
- this._activeAnimations[ name ] = undefined;
- activeAnimationList.splice( i, 1 );
- return;
- }
- }
- },
-
- stopAllAnimation: function () {
- var activeAnimationList = this._activeAnimationList;
- for ( var i = 0, nbAnim = activeAnimationList.length; i < nbAnim; ++i ) {
- var name = activeAnimationList[ i ].name;
- this._removeActiveChannels( this._instanceAnimations[ name ] );
- this._activeAnimations[ name ] = undefined;
- }
- activeAnimationList.length = 0;
- },
-
- setTimeFactor: function ( timeFactor ) {
- var tf = timeFactor / this._timeFactor;
- this._startTime += ( this._simulationTime - this._simulationTime * tf ) / tf;
-
- this._timeFactor = timeFactor;
-
- if ( this._pause )
- this._simulationTime += ( this._simulationTime - this._simulationTime * tf ) / tf;
- },
-
- getTimeFactor: function () {
- return this._timeFactor;
- },
-
- isPlaying: function ( name ) {
- if ( this._activeAnimations[ name ] ) return true;
- return false;
- },
-
- // play animation using object as config
- // {
- // name: string,
- // priority: 0,
- // weight: 1.0,
- // loop: true / false
- // }
- playAnimationObject: function ( obj ) {
-
- var anim = this._instanceAnimations[ obj.name ];
- if ( !anim ) {
- Notify.info( 'no animation ' + obj.name + ' found' );
- return;
- }
-
- if ( this.isPlaying( obj.name ) ) return;
-
- anim.priority = ( obj.priority === undefined ) ? 0 : obj.priority;
- anim.weight = ( obj.weight === undefined ) ? 1.0 : obj.weight;
- anim.loop = ( obj.loop === undefined ) ? true : obj.loop;
-
- this._startAnimations[ anim.name ] = anim;
- },
-
- // if first argument is an object
- // playAnimationObject is called instead
- playAnimation: function ( name, loop, priority, weight ) {
-
- var animationObject;
- if ( typeof name === 'object' )
- animationObject = name;
- else {
- animationObject = {
- name: name,
- priority: priority,
- weight: weight,
- loop: loop
- };
- }
-
- return this.playAnimationObject( animationObject );
- },
-
- getAnimations: function () {
- return this._instanceAnimations;
- },
-
-
- _registerAnimations: function () {
-
- if ( !this._targets.length ) return;
-
- for ( var i = 0, ni = this._animationsToRegister.length; i < ni; i++ ) {
- var instanceAnimation = this._animationsToRegister[ i ];
- this._registerInstanceAnimation( instanceAnimation );
- }
-
- this._animationsToRegister.length = 0;
- this._dirty = false;
- },
-
- // Register animation
- //
- // Register animation list all target from channel in the animations and associate
- // target found in the scenegraph. If no target are registered animation cant be
- // registered. In this case animation will be pending and resolved after a visitor
- // extract target.
- _registerInstanceAnimation: function ( instanceAnimation ) {
-
- var instanceChannels = instanceAnimation.channels;
- for ( var i = 0, ni = instanceChannels.length; i < ni; i++ ) {
- var instanceChannel = instanceChannels[ i ];
- var targetName = instanceChannel.channel.target;
- var name = instanceChannel.channel.name;
- var uniqueTargetName = targetName + '.' + name;
-
- // disply a warning if animation has a channel but not target found in the
- // scene graph. We could probably optimize and removes those channels, but
- // it must be a user decision in case the user plugin different scene
- // graph together and target would appear later in the scenegraph
- if ( !this._targetMap[ uniqueTargetName ] ) {
- Notify.warn( 'registerInstanceAnimation did not find targetName (' + uniqueTargetName + ') in the scene graph' );
- continue;
- }
-
- instanceChannel.targetID = this._targetMap[ uniqueTargetName ].id;
- }
- return true;
- },
-
- _findAnimationUpdateCallback: function ( node ) {
- var collector = new CollectAnimationUpdateCallbackVisitor();
- node.accept( collector );
- this._animationsUpdateCallback = collector.getAnimationUpdateCallbackMap();
- },
-
- // assignTargetToAnimationCallback
- //
- // check all animationUpdateCallback collected and try to
- // assign the channel instance registered in the manager. If a
- // animationUpdateCallback contains channels not known by the
- // manager we skip it. It means that it should be called
- // after the animations has been registered into the animation
- // manager
- _registerTargetFoundInAnimationCallback: function () {
-
- this._resetTargets();
-
- var targetID = 0;
- var targetMap = this._targetMap;
- var targets = this._targets;
-
- var registerTarget = function ( uniqueTargetName, target, name ) {
- if ( !targetMap[ uniqueTargetName ] ) {
- targetMap[ uniqueTargetName ] = target;
- // assign an id that will be an index into a array
- target.id = targetID++;
- targets.push( target );
-
- var type = target.type; // split by type
- this._targetsByTypes[ type ].push( target );
- } else {
- // detect differents target instance with same
- // unique target name. It's a problem
- if ( target !== targetMap[ uniqueTargetName ] )
- Notify.warn( 'detected differents target instance with the same name (' + name + ')' );
- }
- }.bind( this );
-
-
- var target;
- var name;
- var uniqueTargetName;
-
- var animationCallbackMap = this._animationsUpdateCallback;
- var keys = window.Object.keys( animationCallbackMap );
- for ( var i = 0, ni = keys.length; i < ni; i++ ) {
- var key = keys[ i ];
- var animationCallback = animationCallbackMap[ key ];
-
- // handle UpdateBone and UpdateMatrixTransform but not stateSet
- if ( animationCallback.getStackedTransforms && animationCallback.getStackedTransforms().length ) {
- this._animationsUpdateCallbackArray.push( animationCallback );
-
- var stackedTransforms = animationCallback.getStackedTransforms();
- for ( var j = 0, nj = stackedTransforms.length; j < nj; j++ ) {
- var stackedTransform = stackedTransforms[ j ];
- target = stackedTransform.getTarget();
- name = stackedTransform.getName();
- uniqueTargetName = animationCallback.getName() + '.' + name;
-
- registerTarget( uniqueTargetName, target, name );
- }
- } else if ( animationCallback instanceof UpdateMorph ) {
- for ( var t = 0, numTarget = animationCallback.getNumTarget(); t < numTarget; t++ ) {
- name = animationCallback.getTargetName( t );
- uniqueTargetName = name + '.' + t;
- target = animationCallback.getTarget( t );
-
- registerTarget( uniqueTargetName, target, name );
- }
- }
- }
- },
-
- _addAnimation: function ( animations ) {
-
- var instanceAnimationList = [];
- for ( var i = 0, ni = animations.length; i < ni; i++ ) {
-
- var animation = animations[ i ];
- var animationName = animation.name;
-
- if ( this._instanceAnimations[ animationName ] )
- continue;
-
- var instanceAnimation = Animation.createInstanceAnimation( animation );
- this._instanceAnimations[ animationName ] = instanceAnimation;
- instanceAnimationList.push( instanceAnimation );
- }
-
- return instanceAnimationList;
- },
-
- // add channels from instance animation to the active channels list
- _addActiveChannels: function ( t, instanceAnimation ) {
-
- var instanceChannels = instanceAnimation.channels;
- for ( var i = 0, ni = instanceChannels.length; i < ni; i++ ) {
- var instanceChannel = instanceChannels[ i ];
- var type = instanceChannel.channel.type;
- instanceChannel.t = t; // reset time
- instanceChannel.instanceAnimation = instanceAnimation; // link with parent animation
- var targetID = instanceChannel.targetID;
-
- if ( targetID === Target.InvalidTargetID ) continue;
-
- this._activeChannelsByTypes[ type ].push( instanceChannel );
- this._targets[ targetID ].channels.push( instanceChannel );
- }
-
- },
-
- _removeActiveChannels: function ( instanceAnimation ) {
-
- var instanceChannels = instanceAnimation.channels;
- for ( var i = 0, ni = instanceChannels.length; i < ni; i++ ) {
- var instanceChannel = instanceChannels[ i ];
- var type = instanceChannel.channel.type;
- var targetID = instanceChannel.targetID;
-
- if ( targetID === Target.InvalidTargetID ) continue;
-
- // remove channel instance from targetID channel list
- var targetChannelsList = this._targets[ targetID ].channels;
- var index = targetChannelsList.indexOf( instanceChannel );
- targetChannelsList.splice( index, 1 );
-
- // remove channel from active channels
- var channelTypeList = this._activeChannelsByTypes[ type ];
- var channelIndex = channelTypeList.indexOf( instanceChannel );
- channelTypeList.splice( channelIndex, 1 );
- }
-
- },
-
- // blend value from each channels for each target
- // or copy default value if not updated by an active animation
- _updateTargetType: function ( targetList, operatorType ) {
-
- for ( var i = 0, ni = targetList.length; i < ni; i++ ) {
-
- var target = targetList[ i ];
- var affectedChannels = target.channels;
- var nbChannels = affectedChannels.length;
- // note operatorType operations doesn't always operate on arrays (float)
- // so we can't simply assume that target.value is an array so we need
- // to write "target.value = ..."
-
- if ( nbChannels === 0 ) { // no blending ?
- target.value = operatorType.copy( target.defaultValue, target.value );
-
- } else if ( nbChannels === 1 ) {
- target.value = operatorType.copy( affectedChannels[ 0 ].value, target.value );
-
- } else {
-
- // blend between multiple channels
- target.value = operatorType.init( target.value );
- var accumulatedWeight = 0.0;
-
- // it's the same as targetOut = (v0 * w0 + v1 * w1 + ...) / (w0 + w1 + ...)
- for ( var j = 0, nj = affectedChannels.length; j < nj; j++ ) {
-
- var achannel = affectedChannels[ j ];
- var weight = achannel.weight;
- accumulatedWeight += weight;
- // avoid divide by zero and useless lerp
- if ( accumulatedWeight === 0.0 || weight === 0.0 )
- continue;
-
- var ratio = weight / accumulatedWeight;
- target.value = operatorType.lerp( target.value, target.value, achannel.value, ratio );
- }
- }
- }
- },
-
- _updateChannelsType: function ( t, channels, interpolator ) {
-
- for ( var i = 0, ni = channels.length; i < ni; i++ ) {
- var channel = channels[ i ];
- var instanceAnimation = channel.instanceAnimation;
- var loop = instanceAnimation.loop;
-
- var tLocal = t - channel.t;
-
- // handle loop, careful in case animation is one frame
- if ( loop && instanceAnimation.duration > 0.0 ) tLocal = tLocal % instanceAnimation.duration;
-
- interpolator( tLocal + instanceAnimation.firstKeyTime, channel );
- }
- },
-
- _removeFinishedAnimation: function ( t ) {
-
- var activeAnimationList = this._activeAnimationList;
-
- var i = 0;
- while ( i < activeAnimationList.length ) {
- var instanceAnimation = activeAnimationList[ i ];
- var name = instanceAnimation.name;
-
- if ( t > instanceAnimation.end && instanceAnimation.loop === false ) {
- this._removeActiveChannels( instanceAnimation );
- this._activeAnimations[ name ] = undefined;
- activeAnimationList.splice( i, 1 );
- } else {
- i++;
- }
- }
- },
-
- _addActiveAnimation: function ( t, cmd ) {
-
- this._activeAnimations[ cmd.name ] = cmd; // set animation in the list of active one
-
- var instanceAnimation = this._instanceAnimations[ cmd.name ];
- instanceAnimation.start = t;
- instanceAnimation.end = t + instanceAnimation.duration;
- this._addActiveChannels( t, instanceAnimation );
-
- // keep track of instance animation active in a list
- this._activeAnimationList.push( instanceAnimation );
- },
-
- // execute start animations events
- // during the updateManager
- _processStartAnimation: function ( t ) {
-
- // dont really start animation if we dont have yet targets
- if ( !this._targets.length ) return;
-
- var animations = this._startAnimations;
- var keys = window.Object.keys( animations );
- for ( var i = 0, ni = keys.length; i < ni; i++ ) {
- var key = keys[ i ];
- var cmd = animations[ key ];
- var name = cmd.name;
-
- if ( this.isPlaying( name ) )
- continue;
-
- this._addActiveAnimation( t, cmd );
- }
-
- if ( keys.length ) this._startAnimations = {};
- },
-
- _resetTargets: function () {
-
- this._targetMap = {};
- this._targets.length = 0;
-
- for ( var i = 0, ni = this._targetsByTypes.length; i < ni; i++ ) {
- this._targetsByTypes[ i ].length = 0;
- }
-
- },
-
- resetAllStackedTransforms: function () {
- var anims = this._animationsUpdateCallbackArray;
- for ( var i = 0, nbAnims = anims.length; i < nbAnims; i++ ) {
- var stacked = anims[ i ].getStackedTransforms();
- for ( var j = 0, nbStacked = stacked.length; j < nbStacked; j++ ) {
- stacked[ j ].resetToDefaultValue();
- }
-
- // computeChannels is not mandatory here as the following frame will call
- // this function anyway
- anims[ i ].computeChannels();
- }
- },
-
- setAnimationLerpEndStart: function ( anim, lerpDuration ) {
- var channels = anim.channels;
- if ( anim.originalDuration === undefined )
- anim.originalDuration = anim.duration;
-
- anim.duration = anim.originalDuration + lerpDuration;
-
- var firstKey = anim.firstKeyTime;
- var animDuration = anim.originalDuration;
-
- for ( var i = 0, nbChannels = channels.length; i < nbChannels; ++i ) {
- var ch = channels[ i ].channel;
-
- // compare first and last key and detect if we can loop the channel or not
- // it uses an arbitrary epsilon
- if ( Math.abs( ch.start - firstKey ) > 0.01 || Math.abs( ch.duration - animDuration ) > 0.01 )
- continue;
-
- // update channel end time
- if ( ch.originalEnd === undefined )
- ch.originalEnd = ch.end;
-
- ch.end = ch.originalEnd + lerpDuration;
-
- // add or remove additonal key and time
-
- var sizeElt = TypeToSize[ ch.type ];
- var size = ch.times.buffer.byteLength / 4;
-
- // no lerp between end and start
- if ( lerpDuration === 0.0 ) {
-
- ch.keys = new Float32Array( ch.keys.buffer, 0, ( size - 1 ) * sizeElt );
- ch.times = new Float32Array( ch.times.buffer, 0, size - 1 );
-
- } else {
-
- // take full size of buffer (with additional keys)
- ch.keys = new Float32Array( ch.keys.buffer, 0, size * sizeElt );
- // copy first key
- var idLast = ( size - 1 ) * sizeElt;
- for ( var j = 0; j < sizeElt; ++j )
- ch.keys[ idLast + j ] = ch.keys[ j ];
-
- ch.times = new Float32Array( ch.times.buffer, 0, size );
- ch.times[ size - 1 ] = ch.times[ size - 2 ] + lerpDuration;
- }
- }
- }
-
-} );
-
-BasicAnimationManager.TypeToSize = TypeToSize;
-
-module.exports = BasicAnimationManager;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/Bone.js b/app/static/app/js/vendor/osgjs/osgAnimation/Bone.js
deleted file mode 100644
index c0feba17..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/Bone.js
+++ /dev/null
@@ -1,84 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var BoundingBox = require( 'osg/BoundingBox' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var UpdateBone = require( 'osgAnimation/UpdateBone' );
-
-
-/**
- * Bone
- * @class Bone
- */
-var Bone = function ( name ) {
- if ( name !== undefined )
- this.setName( name );
-
- MatrixTransform.call( this );
- this._invBindInSkeletonSpace = mat4.create();
- this._boneInSkeletonSpace = mat4.create();
- this._boneBoundingBox = new BoundingBox();
-};
-
-Bone.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( MatrixTransform.prototype, {
-
- // consistent color depending of id
- // _rand: function ( id ) {
- // var x = Math.sin( id * 45.233 ) * 43758.5453;
- // return x - Math.floor( x );
- // },
- // _generateBoneColor: function ( id ) {
- // return vec3.fromValues( this._rand( id + 2.16 ), this._rand( id * 57.27 ), this._rand( id * 0.874 ) );
- // },
-
- getOrCreateDebugColor: function () {
- // for bone display (debugging, etc)
- if ( this._boneColor ) return this._boneColor;
- // this._boneColor = this._generateBoneColor( this.getInstanceID() );
- this._boneColor = vec3.fromValues( Math.random(), Math.random(), Math.random() );
- return this._boneColor;
- },
-
- getBoneBoundingBox: function () {
- return this._boneBoundingBox;
- },
-
- setBoneBoundingBox: function ( bb ) {
- this._boneBoundingBox = bb;
- },
-
- getMatrixInSkeletonSpace: function () {
- return this._boneInSkeletonSpace;
- },
-
- getInvBindMatrixInSkeletonSpace: function () {
- return this._invBindInSkeletonSpace;
- },
-
- setMatrixInSkeletonSpace: function ( m ) {
- mat4.copy( this._boneInSkeletonSpace, m );
- },
-
- setInvBindMatrixInSkeletonSpace: function ( m ) {
- mat4.copy( this._invBindInSkeletonSpace, m );
- },
-
- getBoneParent: function () {
- var parents = this.getParents();
- for ( var i = 0, l = parents.length; i < l; i++ ) {
- var typeID = parents[ i ].getTypeID();
- if ( typeID === Bone.getTypeID() ) {
- return parents[ i ];
- }
- }
- return undefined;
- },
-
- setDefaultUpdateCallback: function ( name ) {
- this.addUpdateCallback( new UpdateBone( ( name !== undefined ) ? name : this.getName() ) );
- }
-} ), 'osgAnimation', 'Bone' );
-MACROUTILS.setTypeID( Bone );
-
-module.exports = Bone;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/CollectAnimationUpdateCallbackVisitor.js b/app/static/app/js/vendor/osgjs/osgAnimation/CollectAnimationUpdateCallbackVisitor.js
deleted file mode 100644
index 8840a9a6..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/CollectAnimationUpdateCallbackVisitor.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var AnimationUpdateCallback = require( 'osgAnimation/AnimationUpdateCallback' );
-
-
-// search into a subgraph all target
-var CollectAnimationUpdateCallbackVisitor = function () {
- NodeVisitor.call( this );
- this._animationUpdateCallback = {};
-};
-
-
-CollectAnimationUpdateCallbackVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- getAnimationUpdateCallbackMap: function () {
- return this._animationUpdateCallback;
- },
-
- apply: function ( node ) {
- var cbs = node.getUpdateCallbackList();
-
- // collect and remove animation update callback
- for ( var i = 0, cbsLength = cbs.length; i < cbsLength; i++ ) {
- var cb = cbs[ i ];
- if ( cb instanceof AnimationUpdateCallback ) {
- this._animationUpdateCallback[ cb.getInstanceID() ] = cb;
- //node.removeUpdateCallback( cb );
- }
- }
- this.traverse( node );
- }
-
-} );
-
-module.exports = CollectAnimationUpdateCallbackVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/CollectBoneVisitor.js b/app/static/app/js/vendor/osgjs/osgAnimation/CollectBoneVisitor.js
deleted file mode 100644
index 04bb941f..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/CollectBoneVisitor.js
+++ /dev/null
@@ -1,37 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Notify = require( 'osg/notify' );
-var Bone = require( 'osgAnimation/Bone' );
-
-
-var CollectBoneVisitor = function () {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ALL_CHILDREN );
- this._boneMap = {};
-};
-
-CollectBoneVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
-
- apply: function ( node ) {
-
- if ( node.typeID === Bone.typeID ) {
-
- var name = node.getName();
-
- if ( !name ) {
- Notify.warn( 'found Bone without name' );
- } else {
- this._boneMap[ name ] = node;
- }
- }
-
- this.traverse( node );
- },
-
- getBoneMap: function () {
- return this._boneMap;
- }
-
-} );
-
-module.exports = CollectBoneVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/FindNearestParentSkeleton.js b/app/static/app/js/vendor/osgjs/osgAnimation/FindNearestParentSkeleton.js
deleted file mode 100644
index e354ccce..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/FindNearestParentSkeleton.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Skeleton = require( 'osgAnimation/Skeleton' );
-
-
-/**
- * FindNearestParentSkeleton
- */
-
-var FindNearestParentSkeleton = function () {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_PARENTS );
- this._root = undefined;
-
- // node path to skeleton (without skeleton node though)
- this._pathToRoot = undefined;
-};
-
-FindNearestParentSkeleton.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
-
- apply: function ( node ) {
-
- if ( this._root ) return;
-
- if ( node.typeID === Skeleton.typeID ) {
- this._root = node;
- this._pathToRoot = this.nodePath.slice( 1 );
- return;
- }
-
- this.traverse( node );
- }
-} );
-
-module.exports = FindNearestParentSkeleton;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/MorphAttribute.js b/app/static/app/js/vendor/osgjs/osgAnimation/MorphAttribute.js
deleted file mode 100644
index c5f0c111..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/MorphAttribute.js
+++ /dev/null
@@ -1,96 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Map = require( 'osg/Map' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var Uniform = require( 'osg/Uniform' );
-
-
-/**
- * MorphAttribute encapsulate Animation State
- * @class MorphAttribute
- * @inherits StateAttribute
- */
-var MorphAttribute = function ( nbTarget, disable ) {
- StateAttribute.call( this );
- this._nbTarget = nbTarget;
- this._enable = !disable;
-
- this._targetNames = {};
- this._hashNames = ''; // compute only once target hash names
-};
-
-MorphAttribute.uniforms = {};
-
-MorphAttribute.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Morph',
-
- cloneType: function () {
- return new MorphAttribute( undefined, true );
- },
-
- hasTarget: function ( name ) {
- return !!this._targetNames[ name ];
- },
-
- copyTargetNames: function ( names ) {
- var tNames = this._targetNames;
- var hash = '';
- var nbNames = tNames.length = names.length;
-
- for ( var i = 0; i < nbNames; ++i ) {
- var att = names[ i ];
- tNames[ att ] = true;
- hash += att;
- }
-
- this._hashNames = hash;
- },
-
- getOrCreateUniforms: function () {
- var obj = MorphAttribute;
- var unifHash = this.getNumTargets();
-
- if ( obj.uniforms[ unifHash ] ) return obj.uniforms[ unifHash ];
-
- var uniforms = {};
- uniforms.uTargetWeights = Uniform.createFloat4( 'uTargetWeights' );
- obj.uniforms[ unifHash ] = new Map( uniforms );
-
- return obj.uniforms[ unifHash ];
- },
-
- getNumTargets: function () {
- return this._nbTarget;
- },
-
- setTargetWeights: function ( targetWeight ) {
- this._targetWeights = targetWeight;
- },
-
- getTargetWeights: function () {
- return this._targetWeights;
- },
-
- isEnabled: function () {
- return this._enable;
- },
-
- getHash: function () {
- return this.getTypeMember() + this._hashNames + this.getNumTargets() + this.isEnabled();
- },
-
- apply: function () {
-
- if ( !this._enable ) return;
-
- var uniformMap = this.getOrCreateUniforms();
- uniformMap.uTargetWeights.setFloat4( this._targetWeights );
-
- }
-
-} ), 'osgAnimation', 'MorphAttribute' );
-
-MACROUTILS.setTypeID( MorphAttribute );
-
-module.exports = MorphAttribute;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/MorphGeometry.js b/app/static/app/js/vendor/osgjs/osgAnimation/MorphGeometry.js
deleted file mode 100644
index 4260dcb8..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/MorphGeometry.js
+++ /dev/null
@@ -1,205 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var BufferArrayProxy = require( 'osg/BufferArrayProxy' );
-var Notify = require( 'osg/notify' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var Geometry = require( 'osg/Geometry' );
-var StateSet = require( 'osg/StateSet' );
-var MorphAttribute = require( 'osgAnimation/MorphAttribute' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var BoundingBox = require( 'osg/BoundingBox' );
-
-
-/**
- * MorphGeometry manage up to 4 morphTargets
- * @class MorphGeometry
- * @inherits Geometry
- */
-
-var MorphGeometry = function () {
- Geometry.call( this );
-
- this._shape = null; // by default no kdtree/shape for morph
-
- this._targets = []; // Target list (Geometry)
- this._stateSetAnimation = new StateSet(); // StateSet to handle morphAttribute
- this._targetWeights = new Float32Array( 4 ); // Fixed length array feed by UpdateMorph
-
- this._morphTargetNames = undefined;
- this._updateMorph = undefined;
-
- this._isInitialized = false;
-};
-
-// sync with UpdateMorph
-var EFFECTIVE_EPS = MorphGeometry.EFFECTIVE_EPS = 0.05;
-
-MorphGeometry.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Geometry.prototype, {
-
- init: function () {
- var animAttrib = new MorphAttribute( Math.min( 4, this.getMorphTargets().length ) );
- this.getStateSetAnimation().setAttributeAndModes( animAttrib, StateAttribute.ON );
- animAttrib.setTargetWeights( this.getTargetsWeight() );
-
-
- if ( this._targets[ 0 ] ) {
- this._morphTargetNames = window.Object.keys( this._targets[ 0 ].getVertexAttributeList() );
- animAttrib.copyTargetNames( this._morphTargetNames );
- } else {
- this._morphTargetNames = [];
- Notify.error( 'No Targets in the MorphGeometry !' );
- }
-
- this._isInitialized = true;
- return true;
- },
-
- getMorphTargetNames: function () {
- return this._morphTargetNames;
- },
-
- getStateSetAnimation: function () {
- return this._stateSetAnimation;
- },
-
- getMorphTargets: function () {
- return this._targets;
- },
-
- isInitialized: function () {
- return this._isInitialized;
- },
-
- getTargetsWeight: function () {
- return this._targetWeights;
- },
-
- computeBoundingBox: ( function () {
- var tmpBox = new BoundingBox();
-
- return function ( boundingBox ) {
- Geometry.prototype.computeBoundingBox.call( this, boundingBox );
-
- // expand bb with targets
- // Note : if the morphs have many many targets it can be done more smartly in
- // the UpdateMorph on each frame by just taking into account the "active morphs"
- for ( var i = 0, l = this._targets.length; i < l; i++ ) {
- boundingBox.expandByBoundingBox( this._targets[ i ].computeBoundingBox( tmpBox ) );
- }
-
- return boundingBox;
- };
- } )(),
-
- mergeChildrenVertexAttributeList: function () {
-
- for ( var i = 0, l = this._targets.length; i < l; i++ ) {
-
- var target = this._targets[ i ];
-
- // change BufferArray to BufferArrayProxy
- var attributeList = target.getVertexAttributeList();
- var names = window.Object.keys( attributeList );
- for ( var j = 0, jn = names.length; j < jn; j++ ) {
-
- var name = names[ j ];
- var att = attributeList[ name ];
- // check it's a buffer array before swtiching to proxy
- if ( att && !att.getBufferArray ) {
-
- attributeList[ name ] = new BufferArrayProxy( att );
-
- }
-
- }
-
- Geometry.appendVertexAttributeToList( target.getVertexAttributeList(), this.getVertexAttributeList(), i );
-
- }
-
- },
-
- _computeEffectiveSumWeights: function () {
- var sum = 0.0;
- var weights = this._targetWeights;
- for ( var i = 0, nb = weights.length; i < nb; ++i ) {
-
- var weight = weights[ i ];
- if ( Math.abs( weight ) < EFFECTIVE_EPS )
- continue;
-
- sum += weight;
- }
- var eps = 1e-5;
- if ( Math.abs( sum ) > eps ) return sum;
- return sum < 0.0 ? -eps : eps;
- },
-
- computeTransformedVertex: function ( id, out ) {
- out = out || vec3.create();
-
- var id3 = id * 3;
-
- var weights = this._targetWeights;
- var vList = this.getVertexAttributeList();
-
- var baseVerts = vList.Vertex.getElements();
-
- var sumWeights = 1.0 - this._computeEffectiveSumWeights();
- out[ 0 ] = sumWeights * baseVerts[ id3 ];
- out[ 1 ] = sumWeights * baseVerts[ id3 + 1 ];
- out[ 2 ] = sumWeights * baseVerts[ id3 + 2 ];
-
- for ( var j = 0, nb = weights.length; j < nb; ++j ) {
-
- var weight = weights[ j ];
- if ( Math.abs( weight ) < EFFECTIVE_EPS )
- continue;
-
- var morphElts = vList[ 'Vertex_' + j ].getElements();
- out[ 0 ] += weight * morphElts[ id3 ];
- out[ 1 ] += weight * morphElts[ id3 + 1 ];
- out[ 2 ] += weight * morphElts[ id3 + 2 ];
- }
-
- return out;
- },
-
- computeTransformedVertices: function () {
-
- var weights = this._targetWeights;
- var vList = this.getVertexAttributeList();
-
- var baseVerts = vList.Vertex.getElements();
- var vertexLen = baseVerts.length;
-
- var morphedVerts = this._morphedVerts = this._morphedVerts || new Float32Array( vertexLen );
-
- // base vertex influence
- var baseWeight = 1.0 - this._computeEffectiveSumWeights();
- for ( var i = 0; i < vertexLen; ++i ) {
- morphedVerts[ i ] = baseWeight * baseVerts[ i ];
- }
-
- for ( var j = 0, nb = weights.length; j < nb; ++j ) {
-
- var weight = weights[ j ];
- if ( Math.abs( weight ) < EFFECTIVE_EPS )
- continue;
-
- // important : we should not take getInitialBufferArray as we should take the partially computed cpu morph from UpdateMorph
- var morphElts = vList[ 'Vertex_' + j ].getElements();
- for ( var k = 0; k < vertexLen; ++k ) {
- morphedVerts[ k ] += weight * morphElts[ k ];
- }
- }
-
- return morphedVerts;
- }
-
-
-} ), 'osgAnimation', 'MorphGeometry' );
-
-MACROUTILS.setTypeID( MorphGeometry );
-
-module.exports = MorphGeometry;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/RigGeometry.js b/app/static/app/js/vendor/osgjs/osgAnimation/RigGeometry.js
deleted file mode 100644
index f4f01050..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/RigGeometry.js
+++ /dev/null
@@ -1,443 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var Geometry = require( 'osg/Geometry' );
-var Notify = require( 'osg/notify' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var StateSet = require( 'osg/StateSet' );
-var MorphGeometry = require( 'osgAnimation/MorphGeometry' );
-var UpdateRigGeometry = require( 'osgAnimation/UpdateRigGeometry' );
-var RigTransformHardware = require( 'osgAnimation/RigTransformHardware' );
-var AnimationUpdateCallback = require( 'osgAnimation/AnimationUpdateCallback' );
-var ComputeMatrixFromNodePath = require( 'osg/computeMatrixFromNodePath' );
-
-
-// RigGeometry is a Geometry deformed by bones
-// To connect bones to RigGeometry it requires:
-// - a map of bones with index / weight eg also called VertexInfluenceMap
-// {
-// bone0: { index: [], // vertex index
-// weight: [] // weight for this index
-// },
-// bone2: { index: [],
-// weight: []
-// }
-// }
-
-
-var RigGeometry = function () {
-
- Geometry.call( this );
-
- this._shape = null; // by default no kdtree/shape for rig
-
- this.addUpdateCallback( new UpdateRigGeometry() );
-
- // handle matrixFromSkeletonToGeometry and invMatrixFromSkeletonToGeometry computation
- this._root = undefined;
- this._pathToRoot = undefined;
- this._isAnimatedPath = false;
-
- this._boneNameID = {};
-
- this._matrixFromSkeletonToGeometry = mat4.create();
- this._invMatrixFromSkeletonToGeometry = mat4.create();
-
- this._rigTransformImplementation = new RigTransformHardware();
-
- // RigGeometry have a special stateset that will be pushed at the very end of the culling
- // this stateSet only represents animation (and shouldn't contain any rendering attributes)
- // It's a way to make every RigGeometry unique (in term of stateSet stack)
- this._stateSetAnimation = new StateSet();
-
- this._needToComputeMatrix = true;
-
-};
-
-RigGeometry.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Geometry.prototype, {
-
- getStateSetAnimation: function () {
- return this._stateSetAnimation;
- },
-
- getSkeleton: function () {
- return this._root;
- },
-
- setSkeleton: function ( root ) {
- this._root = root;
- },
-
- setPathToSkeleton: function ( path ) {
- this._pathToRoot = path;
- this._isAnimatedPath = AnimationUpdateCallback.checkPathIsAnimated( path );
- },
-
- setNeedToComputeMatrix: function ( needToComputeMatrix ) {
- this._needToComputeMatrix = needToComputeMatrix;
- },
-
- getNeedToComputeMatrix: function () {
- return this._needToComputeMatrix;
- },
-
- computeBoundingBox: function ( boundingBox ) {
-
- boundingBox.init();
-
- var vertexArray = this.getVertexAttributeList().Vertex;
- var weightsArray = this.getVertexAttributeList().Weights;
- // mainly copy paste of geometry computeBoundingBox code, except we only
- // take into account the non-influenced vertices
-
- // we do that only for the non-influenced vertices because the rigged ones
- // can't be statically computed (full moving bbox of rigs should be computed externally
- // through bones or cpu rigged colision mesh, etc)
- // bbox is important for culling (near/far)
-
- if ( vertexArray && weightsArray && vertexArray.getElements() && vertexArray.getItemSize() > 2 ) {
-
- var weights = weightsArray.getElements();
- var vertexes = vertexArray.getElements();
- var itemSize = vertexArray.getItemSize();
-
- var min = boundingBox.getMin();
- var max = boundingBox.getMax();
-
- var minx = min[ 0 ];
- var miny = min[ 1 ];
- var minz = min[ 2 ];
- var maxx = max[ 0 ];
- var maxy = max[ 1 ];
- var maxz = max[ 2 ];
-
- for ( var idx = 0, idb = 0, l = vertexes.length; idx < l; idx += itemSize, idb += 4 ) {
-
- if ( weights[ idx ] !== 0.0 || weights[ idx + 1 ] !== 0.0 || weights[ idx + 2 ] !== 0.0 || weights[ idx + 3 ] !== 0.0 )
- continue;
-
- var v1 = vertexes[ idx ];
- var v2 = vertexes[ idx + 1 ];
- var v3 = vertexes[ idx + 2 ];
- if ( v1 < minx ) minx = v1;
- if ( v1 > maxx ) maxx = v1;
- if ( v2 < miny ) miny = v2;
- if ( v2 > maxy ) maxy = v2;
- if ( v3 < minz ) minz = v3;
- if ( v3 > maxz ) maxz = v3;
- }
-
- min[ 0 ] = minx;
- min[ 1 ] = miny;
- min[ 2 ] = minz;
- max[ 0 ] = maxx;
- max[ 1 ] = maxy;
- max[ 2 ] = maxz;
- }
-
- return boundingBox;
- },
-
- computeMatrixFromRootSkeleton: function () {
-
- if ( !this._root ) {
- Notify.warn( 'Warning ' + this.className() + '.computeMatrixFromRootSkeleton if you have this message it means you miss to call buildTransformer( root ), or your RigGeometry (' + this.getName() + ') is not attached to a Skeleton subgraph' );
- return;
- }
-
- mat4.identity( this._matrixFromSkeletonToGeometry );
- ComputeMatrixFromNodePath.computeLocalToWorld( this._pathToRoot, true, this._matrixFromSkeletonToGeometry );
- mat4.invert( this._invMatrixFromSkeletonToGeometry, this._matrixFromSkeletonToGeometry );
-
- if ( !this._isAnimatedPath )
- this._needToComputeMatrix = false;
- },
-
- getMatrixFromSkeletonToGeometry: function () {
- return this._matrixFromSkeletonToGeometry;
- },
-
- getInvMatrixFromSkeletonToGeometry: function () {
- return this._invMatrixFromSkeletonToGeometry;
- },
-
- getSourceGeometry: function () {
- return this._geometry;
- },
-
- setSourceGeometry: function ( geometry ) {
- this._geometry = geometry;
- },
-
- getBoneNameID: function () {
- return this._boneNameID;
- },
-
- setBoneNameID: function ( boneMap ) {
- this._boneNameID = boneMap;
- },
-
- mergeChildrenVertexAttributeList: function () {
-
- if ( this._geometry instanceof MorphGeometry )
- this._geometry.mergeChildrenVertexAttributeList();
-
- var sourceGeometryVertexAttributeList = this._geometry.getVertexAttributeList();
-
- Geometry.appendVertexAttributeToList( sourceGeometryVertexAttributeList, this.getVertexAttributeList() );
-
- },
-
- mergeChildrenData: function () {
-
- // move to the rig the vertex attributes, the primitives and the stateset
-
- this.mergeChildrenVertexAttributeList();
- var primitiveSetList = this._geometry.getPrimitiveSetList();
-
- this.getPrimitiveSetList().length = 0;
- for ( var i = 0, il = primitiveSetList.length; i < il; i++ )
- this.getPrimitiveSetList()[ i ] = primitiveSetList[ i ];
-
- if ( this.getStateSet() )
- console.error( 'A stateset in the rig is already present : ' + this.getStateSet() );
- this.setStateSet( this._geometry.getStateSet() );
- },
-
- update: function () {
- this._rigTransformImplementation.update( this );
- },
-
- computeTransformedVertex: function ( id, out ) {
- out = out || vec3.create();
-
- var vList = this.getVertexAttributeList();
- var vWeights = vList.Weights.getElements();
- var vBones = vList.Bones.getElements();
-
- var x = 0.0;
- var y = 0.0;
- var z = 0.0;
- if ( this._geometry.computeTransformedVertex ) {
- this._geometry.computeTransformedVertex( id, out );
- x = out[ 0 ];
- y = out[ 1 ];
- z = out[ 2 ];
- } else {
- var verts = vList.Vertex.getElements();
- x = verts[ id * 3 ];
- y = verts[ id * 3 + 1 ];
- z = verts[ id * 3 + 2 ];
- }
-
- var id4 = id * 4;
-
- var palette = this._rigTransformImplementation._skinningAttribute.getMatrixPalette();
- var m0 = 0.0;
- var m1 = 0.0;
- var m2 = 0.0;
- var m4 = 0.0;
- var m5 = 0.0;
- var m6 = 0.0;
- var m8 = 0.0;
- var m9 = 0.0;
- var m10 = 0.0;
- var m12 = 0.0;
- var m13 = 0.0;
- var m14 = 0.0;
- var m15 = 0.0;
-
- var doSkin = false;
- for ( var i = 0; i < 4; ++i ) {
- var w = vWeights[ id4 + i ];
- if ( w === 0.0 )
- continue;
-
- var idBone = vBones[ id4 + i ] * 12;
-
- m0 += palette[ idBone + 0 ] * w;
- m4 += palette[ idBone + 1 ] * w;
- m8 += palette[ idBone + 2 ] * w;
- m12 += palette[ idBone + 3 ] * w;
-
- m1 += palette[ idBone + 4 ] * w;
- m5 += palette[ idBone + 5 ] * w;
- m9 += palette[ idBone + 6 ] * w;
- m13 += palette[ idBone + 7 ] * w;
-
- m2 += palette[ idBone + 8 ] * w;
- m6 += palette[ idBone + 9 ] * w;
- m10 += palette[ idBone + 10 ] * w;
- m14 += palette[ idBone + 11 ] * w;
-
- m15 += w;
- doSkin = true;
- }
-
- if ( !doSkin ) {
- out[ 0 ] = x;
- out[ 1 ] = y;
- out[ 2 ] = z;
- }
-
- var d = 1.0 / m15;
- out[ 0 ] = ( m0 * x + m4 * y + m8 * z + m12 ) * d;
- out[ 1 ] = ( m1 * x + m5 * y + m9 * z + m13 ) * d;
- out[ 2 ] = ( m2 * x + m6 * y + m10 * z + m14 ) * d;
-
- return out;
- },
-
- computeTransformedVertices: function () {
-
- // obviously slow as it can't rely on kdTree AND we transform everything cpu side
-
- var vList = this.getVertexAttributeList();
- var verts = this._geometry.computeTransformedVertices ? this._geometry.computeTransformedVertices() : vList.Vertex.getElements();
- var vWeights = vList.Weights.getElements();
- var vBones = vList.Bones.getElements();
-
- var riggedVerts = this._riggedVerts || new Float32Array( verts.length );
-
- // /!\ if the geometry has several parents inside a skeleton
- // it might not work as it will just take the last compute matrix palette
- var palette = this._rigTransformImplementation._skinningAttribute.getMatrixPalette();
-
- // verbose... but fast
- for ( var idv = 0, idr = 0, len = verts.length; idv < len; idv += 3, idr += 4 ) {
-
- var m0 = 0.0;
- var m1 = 0.0;
- var m2 = 0.0;
-
- var m4 = 0.0;
- var m5 = 0.0;
- var m6 = 0.0;
-
- var m8 = 0.0;
- var m9 = 0.0;
- var m10 = 0.0;
-
- var m12 = 0.0;
- var m13 = 0.0;
- var m14 = 0.0;
- var m15 = 0.0;
-
- var doSkin = false;
-
- var w = vWeights[ idr ];
- var idBone;
- if ( w !== 0.0 ) {
- idBone = vBones[ idr ] * 12;
- m0 += palette[ idBone + 0 ] * w;
- m4 += palette[ idBone + 1 ] * w;
- m8 += palette[ idBone + 2 ] * w;
- m12 += palette[ idBone + 3 ] * w;
-
- m1 += palette[ idBone + 4 ] * w;
- m5 += palette[ idBone + 5 ] * w;
- m9 += palette[ idBone + 6 ] * w;
- m13 += palette[ idBone + 7 ] * w;
-
- m2 += palette[ idBone + 8 ] * w;
- m6 += palette[ idBone + 9 ] * w;
- m10 += palette[ idBone + 10 ] * w;
- m14 += palette[ idBone + 11 ] * w;
-
- m15 += w;
- doSkin = true;
- }
-
- w = vWeights[ idr + 1 ];
- if ( w !== 0.0 ) {
- idBone = vBones[ idr + 1 ] * 12;
- m0 += palette[ idBone + 0 ] * w;
- m4 += palette[ idBone + 1 ] * w;
- m8 += palette[ idBone + 2 ] * w;
- m12 += palette[ idBone + 3 ] * w;
-
- m1 += palette[ idBone + 4 ] * w;
- m5 += palette[ idBone + 5 ] * w;
- m9 += palette[ idBone + 6 ] * w;
- m13 += palette[ idBone + 7 ] * w;
-
- m2 += palette[ idBone + 8 ] * w;
- m6 += palette[ idBone + 9 ] * w;
- m10 += palette[ idBone + 10 ] * w;
- m14 += palette[ idBone + 11 ] * w;
-
- m15 += w;
- doSkin = true;
- }
-
- w = vWeights[ idr + 2 ];
- if ( w !== 0.0 ) {
- idBone = vBones[ idr + 2 ] * 12;
-
- m0 += palette[ idBone + 0 ] * w;
- m4 += palette[ idBone + 1 ] * w;
- m8 += palette[ idBone + 2 ] * w;
- m12 += palette[ idBone + 3 ] * w;
-
- m1 += palette[ idBone + 4 ] * w;
- m5 += palette[ idBone + 5 ] * w;
- m9 += palette[ idBone + 6 ] * w;
- m13 += palette[ idBone + 7 ] * w;
-
- m2 += palette[ idBone + 8 ] * w;
- m6 += palette[ idBone + 9 ] * w;
- m10 += palette[ idBone + 10 ] * w;
- m14 += palette[ idBone + 11 ] * w;
-
- m15 += w;
- doSkin = true;
- }
-
- w = vWeights[ idr + 3 ];
- if ( w !== 0.0 ) {
- idBone = vBones[ idr + 3 ] * 12;
-
- m0 += palette[ idBone + 0 ] * w;
- m4 += palette[ idBone + 1 ] * w;
- m8 += palette[ idBone + 2 ] * w;
- m12 += palette[ idBone + 3 ] * w;
-
- m1 += palette[ idBone + 4 ] * w;
- m5 += palette[ idBone + 5 ] * w;
- m9 += palette[ idBone + 6 ] * w;
- m13 += palette[ idBone + 7 ] * w;
-
- m2 += palette[ idBone + 8 ] * w;
- m6 += palette[ idBone + 9 ] * w;
- m10 += palette[ idBone + 10 ] * w;
- m14 += palette[ idBone + 11 ] * w;
-
- m15 += w;
- doSkin = true;
- }
-
- var x = verts[ idv ];
- var y = verts[ idv + 1 ];
- var z = verts[ idv + 2 ];
-
- if ( !doSkin ) {
- riggedVerts[ idv ] = x;
- riggedVerts[ idv + 1 ] = y;
- riggedVerts[ idv + 2 ] = z;
- continue;
- }
-
- var d = 1.0 / m15;
- riggedVerts[ idv ] = ( m0 * x + m4 * y + m8 * z + m12 ) * d;
- riggedVerts[ idv + 1 ] = ( m1 * x + m5 * y + m9 * z + m13 ) * d;
- riggedVerts[ idv + 2 ] = ( m2 * x + m6 * y + m10 * z + m14 ) * d;
- }
-
- return riggedVerts;
- }
-
-} ), 'osgAnimation', 'RigGeometry' );
-
-MACROUTILS.setTypeID( RigGeometry );
-
-module.exports = RigGeometry;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/RigTransformHardware.js b/app/static/app/js/vendor/osgjs/osgAnimation/RigTransformHardware.js
deleted file mode 100644
index bd8bae81..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/RigTransformHardware.js
+++ /dev/null
@@ -1,136 +0,0 @@
-'use strict';
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var StateAttribute = require( 'osg/StateAttribute' );
-var SkinningAttribute = require( 'osgAnimation/SkinningAttribute' );
-var CollectBoneVisitor = require( 'osgAnimation/CollectBoneVisitor' );
-
-
-/**
- * Hardware implementation for rigGeometry
- *
- */
-var RigTransformHardware = function () {
- this._isInitialized = false;
-
- // bones are sorted to be used directly by
- // computeMatrixPalette
- // means the
- this._bones = [];
-};
-
-
-RigTransformHardware.prototype = {
-
- // boneNameID contains a map: boneName: id
- // {
- // 'bone0' : 1,
- // 'bone4' : 0,
- // }
- //
- // boneMap contains a map: boneName: Bone
- // {
- // 'bone0: : Bone object,
- // 'bone1: : Bone object,
- // }
- //
- // return index / bone object
- // [
- // Bone4 object,
- // Bone0 object
- // ]
- computeBonePalette: function ( boneMap, boneNameID ) {
- var keys = window.Object.keys( boneMap );
- var size = keys.length;
- var bones = this._bones;
-
-
- for ( var i = 0; i < size; i++ ) {
- var bName = keys[ i ];
- var index = boneNameID[ bName ];
- var bone = boneMap[ bName ];
-
- if ( index !== undefined )
- bones[ index ] = bone;
- }
-
- return bones;
- },
-
-
- init: function ( geom ) {
-
- // init the bones map
-
- // stop here
- // compute bonemap / index
- var mapVisitor = new CollectBoneVisitor();
- geom.getSkeleton().accept( mapVisitor );
- var bm = mapVisitor.getBoneMap();
-
- this.computeBonePalette( bm, geom._boneNameID );
-
- // matrix are 4x3
- var nbVec4Uniforms = this._bones.length * 3;
- var animAttrib = this._skinningAttribute = new SkinningAttribute();
- animAttrib.setMatrixPalette( new Float32Array( nbVec4Uniforms * 4 ) );
- geom.getStateSetAnimation().setAttributeAndModes( animAttrib, StateAttribute.ON );
-
- this._isInitialized = true;
- return true;
- },
-
-
- computeMatrixPalette: ( function () {
-
- var mTmp = mat4.create();
-
- return function ( transformFromSkeletonToGeometry, invTransformFromSkeletonToGeometry ) {
-
- var bones = this._bones;
- var matPalette = this._skinningAttribute.getMatrixPalette();
- var uniformIndex = 0;
-
- for ( var i = 0, l = bones.length; i < l; i++ ) {
- var bone = bones[ i ];
-
- var invBindMatrix = bone.getInvBindMatrixInSkeletonSpace();
- var boneMatrix = bone.getMatrixInSkeletonSpace();
-
- mat4.mul( mTmp, boneMatrix, invBindMatrix );
- mat4.mul( mTmp, invTransformFromSkeletonToGeometry, mTmp );
- mat4.mul( mTmp, mTmp, transformFromSkeletonToGeometry );
-
- // TODO: maybe change upload order so that we can use
- // glsl constructor :
- // mat4(uBones[index], uBones[index+1], uBones[index+2], vec4(0.0, 0.0, 0.0, 1.0))
- // for faster glsl
- matPalette[ uniformIndex++ ] = mTmp[ 0 ];
- matPalette[ uniformIndex++ ] = mTmp[ 4 ];
- matPalette[ uniformIndex++ ] = mTmp[ 8 ];
- matPalette[ uniformIndex++ ] = mTmp[ 12 ];
-
- matPalette[ uniformIndex++ ] = mTmp[ 1 ];
- matPalette[ uniformIndex++ ] = mTmp[ 5 ];
- matPalette[ uniformIndex++ ] = mTmp[ 9 ];
- matPalette[ uniformIndex++ ] = mTmp[ 13 ];
-
- matPalette[ uniformIndex++ ] = mTmp[ 2 ];
- matPalette[ uniformIndex++ ] = mTmp[ 6 ];
- matPalette[ uniformIndex++ ] = mTmp[ 10 ];
- matPalette[ uniformIndex++ ] = mTmp[ 14 ];
- }
- };
-
- } )(),
-
- update: function ( geom ) {
-
- if ( !this._isInitialized )
- this.init( geom );
-
- this.computeMatrixPalette( geom.getMatrixFromSkeletonToGeometry(), geom.getInvMatrixFromSkeletonToGeometry() );
- }
-};
-
-
-module.exports = RigTransformHardware;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/Skeleton.js b/app/static/app/js/vendor/osgjs/osgAnimation/Skeleton.js
deleted file mode 100644
index 644e85d6..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/Skeleton.js
+++ /dev/null
@@ -1,49 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var UpdateSkeleton = require( 'osgAnimation/UpdateSkeleton' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var UpdateMatrixTransform = require( 'osgAnimation/UpdateMatrixTransform' );
-var Bone = require( 'osgAnimation/Bone' );
-
-
-var ResetRestPoseVisitor = function () {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ALL_CHILDREN );
-};
-ResetRestPoseVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- apply: function ( node ) {
- if ( node.getTypeID() === Bone.getTypeID() ) {
- var cb = node.getUpdateCallback();
- if ( cb instanceof UpdateMatrixTransform ) {
- var stackedTransforms = cb._stackedTransforms;
- for ( var st = 0, l = stackedTransforms.length; st < l; st++ ) {
- var stackedTransform = stackedTransforms[ st ];
- stackedTransform.resetToDefaultValue();
- }
- cb.computeChannels();
- }
- }
- this.traverse( node );
- }
-} );
-
-var resetter = new ResetRestPoseVisitor();
-
-var Skeleton = function () {
- MatrixTransform.call( this );
-};
-
-Skeleton.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( MatrixTransform.prototype, {
-
- setDefaultUpdateCallback: function () {
- this.addUpdateCallback( new UpdateSkeleton() );
- },
-
- setRestPose: function () {
- this.accept( resetter );
- }
-
-} ), 'osgAnimation', 'Skeleton' );
-MACROUTILS.setTypeID( Skeleton );
-
-module.exports = Skeleton;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/SkinningAttribute.js b/app/static/app/js/vendor/osgjs/osgAnimation/SkinningAttribute.js
deleted file mode 100644
index de46a9ab..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/SkinningAttribute.js
+++ /dev/null
@@ -1,96 +0,0 @@
-'use strict';
-var Map = require( 'osg/Map' );
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var Uniform = require( 'osg/Uniform' );
-
-
-/**
- * SkinningAttribute encapsulate Animation State
- * @class SkinningAttribute
- * @inherits StateAttribute
- */
-var SkinningAttribute = function ( disable, boneUniformSize ) {
- StateAttribute.call( this );
- this._enable = !disable;
- // optional, if it's not provided, it will fall back to the maximum bone uniform size
- // boneUniformSize represents the number of vec4 (uniform) used in the shader for all the bones
- this._boneUniformSize = boneUniformSize;
-};
-
-SkinningAttribute.uniforms = {};
-SkinningAttribute.maxBoneUniformSize = 1;
-SkinningAttribute.maxBoneUniformAllowed = Infinity; // can be overriden by application specific limit on startup (typically gl limit)
-
-SkinningAttribute.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'Skinning',
-
- cloneType: function () {
- return new SkinningAttribute( true );
- },
-
- setBoneUniformSize: function ( boneUniformSize ) {
- this._boneUniformSize = boneUniformSize;
- },
-
- getBoneUniformSize: function () {
- return this._boneUniformSize !== undefined ? this._boneUniformSize : SkinningAttribute.maxBoneUniformSize;
- },
-
- getOrCreateUniforms: function () {
- var obj = SkinningAttribute;
- var unifHash = this.getBoneUniformSize();
-
- if ( obj.uniforms[ unifHash ] ) return obj.uniforms[ unifHash ];
-
- var uniforms = {};
- uniforms.uBones = Uniform.createFloat4Array( 'uBones' );
- obj.uniforms[ unifHash ] = new Map( uniforms );
-
- return obj.uniforms[ unifHash ];
- },
-
- setMatrixPalette: function ( matrixPalette ) {
- this._matrixPalette = matrixPalette;
- // update max bone size
- if ( this._boneUniformSize === undefined ) {
- SkinningAttribute.maxBoneUniformSize = Math.max( SkinningAttribute.maxBoneUniformSize, matrixPalette.length / 4 );
- SkinningAttribute.maxBoneUniformSize = Math.min( SkinningAttribute.maxBoneUniformAllowed, SkinningAttribute.maxBoneUniformSize );
- }
- },
-
- getMatrixPalette: function () {
- return this._matrixPalette;
- },
-
- // need a isEnabled to let the ShaderGenerator to filter
- // StateAttribute from the shader compilation
- isEnabled: function () {
- return this._enable;
- },
-
- getHash: function () {
- // bonesize is important, as the shader itself
- // has a different code and uniform are not shared
- // geoms have each their own bones matrix palette
- // it's up to rigGeometry to use same anim Attrib per
- // same bone matrix palette
- // as uniform array size must be statically declared
- // in shader code
- return this.getTypeMember() + this.getBoneUniformSize() + this.isEnabled();
- },
-
- apply: function () {
-
- if ( !this._enable ) return;
-
- this.getOrCreateUniforms().uBones.setInternalArray( this._matrixPalette );
-
- }
-
-} ), 'osgAnimation', 'SkinningAttribute' );
-
-MACROUTILS.setTypeID( SkinningAttribute );
-
-module.exports = SkinningAttribute;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/StackedMatrix.js b/app/static/app/js/vendor/osgjs/osgAnimation/StackedMatrix.js
deleted file mode 100644
index 75f2fc03..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/StackedMatrix.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Target = require( 'osgAnimation/target' );
-
-
-var StackedMatrix = function ( name, matrix ) {
- Object.call( this );
- this._target = Target.createMatrixTarget( matrix || mat4.IDENTITY );
- if ( name ) this.setName( name );
-};
-
-StackedMatrix.prototype = MACROUTILS.objectInherit( Object.prototype, {
-
- init: function ( matrix ) {
- this.setMatrix( matrix );
- mat4.copy( this._target.defaultValue, matrix );
- },
-
- getTarget: function () {
- return this._target;
- },
-
- getMatrix: function () {
- return this._target.value;
- },
-
- setMatrix: function ( m ) {
- mat4.copy( this._target.value, m );
- },
-
- resetToDefaultValue: function () {
- this.setMatrix( this._target.defaultValue );
- },
-
- applyToMatrix: function ( m ) {
- mat4.mul( m, m, this._target.value );
- }
-
-} );
-
-module.exports = StackedMatrix;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/StackedQuaternion.js b/app/static/app/js/vendor/osgjs/osgAnimation/StackedQuaternion.js
deleted file mode 100644
index c338ffc8..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/StackedQuaternion.js
+++ /dev/null
@@ -1,47 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var quat = require( 'osg/glMatrix' ).quat;
-var Target = require( 'osgAnimation/target' );
-
-var qIdentity = quat.create();
-
-var StackedQuaternion = function ( name, q ) {
- Object.call( this );
- this._target = Target.createQuatTarget( q || qIdentity );
- if ( name ) this.setName( name );
-};
-
-StackedQuaternion.prototype = MACROUTILS.objectInherit( Object.prototype, {
-
- init: function ( q ) {
- this.setQuaternion( q );
- quat.copy( this._target.defaultValue, q );
- },
-
- setQuaternion: function ( q ) {
- quat.copy( this._target.value, q );
- },
-
- getTarget: function () {
- return this._target;
- },
-
- resetToDefaultValue: function () {
- this.setQuaternion( this._target.defaultValue );
- },
-
- applyToMatrix: ( function () {
- var matrixTmp = mat4.create();
-
- return function applyToMatrix( m ) {
- var mtmp = matrixTmp;
- mat4.fromQuat( mtmp, this._target.value );
- mat4.mul( m, m, mtmp );
- };
- } )()
-
-} );
-
-module.exports = StackedQuaternion;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/StackedRotateAxis.js b/app/static/app/js/vendor/osgjs/osgAnimation/StackedRotateAxis.js
deleted file mode 100644
index 839c1f8e..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/StackedRotateAxis.js
+++ /dev/null
@@ -1,60 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var quat = require( 'osg/glMatrix' ).quat;
-var Target = require( 'osgAnimation/target' );
-
-
-var StackedRotateAxis = function ( name, axis, angle ) {
- Object.call( this );
- this._axis = vec3.fromValues( 0, 0, 1 );
- if ( axis ) vec3.copy( this._axis, axis );
- this._target = Target.createFloatTarget( typeof angle === 'number' ? angle : 0.0 );
- if ( name ) this.setName( name );
-};
-
-StackedRotateAxis.prototype = MACROUTILS.objectInherit( Object.prototype, {
-
- init: function ( axis, angle ) {
- this.setAxis( axis );
- this.setAngle( angle );
- this._target.defaultValue = angle;
- },
-
- setAxis: function ( axis ) {
- vec3.copy( this._axis, axis );
- },
-
- setAngle: function ( angle ) {
- this._target.value = angle;
- },
-
- getTarget: function () {
- return this._target;
- },
-
- resetToDefaultValue: function () {
- this.setAngle( this._target.defaultValue );
- },
-
- applyToMatrix: ( function () {
- var matrixTmp = mat4.create();
- var quatTmp = quat.create();
-
- return function ( m ) {
- var axis = this._axis;
- var qtmp = quatTmp;
- var mtmp = matrixTmp;
- var angle = this._target.value;
-
- quat.setAxisAngle( qtmp, axis, angle );
- mat4.fromQuat( mtmp, qtmp );
- mat4.mul( m, m, mtmp );
- };
- } )()
-
-} );
-
-module.exports = StackedRotateAxis;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/StackedScale.js b/app/static/app/js/vendor/osgjs/osgAnimation/StackedScale.js
deleted file mode 100644
index 110f7462..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/StackedScale.js
+++ /dev/null
@@ -1,45 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var Target = require( 'osgAnimation/target' );
-
-
-var StackedScale = function ( name, scale ) {
- Object.call( this );
- this._target = Target.createVec3Target( scale || vec3.ONE );
- if ( name ) this.setName( name );
-};
-
-
-StackedScale.prototype = MACROUTILS.objectInherit( Object.prototype, {
-
- init: function ( scale ) {
- this.setScale( scale );
- vec3.copy( this._target.defaultValue, scale );
- },
-
- setScale: function ( scale ) {
- vec3.copy( this._target.value, scale );
- },
-
- getTarget: function () {
- return this._target;
- },
-
- resetToDefaultValue: function () {
- this.setScale( this._target.defaultValue );
- },
-
- // must be optimized
- applyToMatrix: function ( m ) {
-
- var scale = this._target.value;
- mat4.scale( m, m, scale );
-
- }
-
-} );
-
-module.exports = StackedScale;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/StackedTranslate.js b/app/static/app/js/vendor/osgjs/osgAnimation/StackedTranslate.js
deleted file mode 100644
index 9f761c3a..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/StackedTranslate.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Target = require( 'osgAnimation/target' );
-
-
-/**
- * StackedTranslate
- */
-var StackedTranslate = function ( name, translate ) {
- Object.call( this );
- this._target = Target.createVec3Target( translate || vec3.ZERO );
- if ( name ) this.setName( name );
-};
-
-
-StackedTranslate.prototype = MACROUTILS.objectInherit( Object.prototype, {
-
- init: function ( translate ) {
- this.setTranslate( translate );
- vec3.copy( this._target.defaultValue, translate );
- },
-
- setTranslate: function ( translate ) {
- vec3.copy( this._target.value, translate );
- },
-
- getTarget: function () {
- return this._target;
- },
-
- resetToDefaultValue: function () {
- this.setTranslate( this._target.defaultValue );
- },
-
- applyToMatrix: function ( m ) {
- mat4.translate( m, m, this._target.value );
- }
-} );
-
-module.exports = StackedTranslate;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateBone.js b/app/static/app/js/vendor/osgjs/osgAnimation/UpdateBone.js
deleted file mode 100644
index fa07416a..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateBone.js
+++ /dev/null
@@ -1,47 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Notify = require( 'osg/notify' );
-var UpdateMatrixTransform = require( 'osgAnimation/UpdateMatrixTransform' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var NodeVisitor = require( 'osg/NodeVisitor' );
-
-
-/**
- * UpdateBone
- * @class UpdateBone
- */
-var UpdateBone = function () {
- UpdateMatrixTransform.call( this );
-};
-
-/** @lends UpdateBone.prototype */
-UpdateBone.prototype = MACROUTILS.objectInherit( UpdateMatrixTransform.prototype, {
-
- update: function ( node, nv ) {
-
- if ( nv.getVisitorType() === NodeVisitor.UPDATE_VISITOR ) {
-
- if ( node.className && node.className() !== 'Bone' ) {
- Notify.warn( 'Warning: UpdateBone set on non-Bone object.' );
- return false;
- }
-
- var bone = node;
-
- UpdateMatrixTransform.prototype.update.call( this, node );
- bone.setMatrix( bone.getMatrix() );
- var matrix = bone.getMatrix();
- var parent = bone.getBoneParent();
-
- if ( parent ) {
- mat4.mul( bone.getMatrixInSkeletonSpace(), parent.getMatrixInSkeletonSpace(), matrix );
- } else {
- bone.setMatrixInSkeletonSpace( matrix );
- }
- }
- return true;
- }
-
-} );
-
-module.exports = UpdateBone;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateMatrixTransform.js b/app/static/app/js/vendor/osgjs/osgAnimation/UpdateMatrixTransform.js
deleted file mode 100644
index c2a682f7..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateMatrixTransform.js
+++ /dev/null
@@ -1,51 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var AnimationUpdateCallback = require( 'osgAnimation/AnimationUpdateCallback' );
-
-
-/**
- * UpdateMatrixTransform
- */
-var UpdateMatrixTransform = function () {
- AnimationUpdateCallback.call( this );
-
- // maybe could have a more generic name and used by all AnimationUpdateCallback
- this._stackedTransforms = [];
-
- this._matrix = mat4.create();
-
- this._dirty = false;
-};
-
-
-UpdateMatrixTransform.prototype = MACROUTILS.objectInherit( AnimationUpdateCallback.prototype, {
-
- getStackedTransforms: function () {
- return this._stackedTransforms;
- },
-
- computeChannels: function () {
- this._dirty = true;
- var matrix = this._matrix;
- mat4.identity( matrix );
- var transforms = this._stackedTransforms;
-
- for ( var i = 0, l = transforms.length; i < l; i++ ) {
- var transform = transforms[ i ];
- transform.applyToMatrix( matrix );
- }
- },
-
- update: function ( node /*, nv */ ) {
- mat4.copy( node.getMatrix(), this._matrix );
- if ( this._dirty ) {
- node.dirtyBound();
- this._dirty = false;
- }
- return true;
- }
-
-} );
-
-module.exports = UpdateMatrixTransform;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateMorph.js b/app/static/app/js/vendor/osgjs/osgAnimation/UpdateMorph.js
deleted file mode 100644
index eb3f40b7..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateMorph.js
+++ /dev/null
@@ -1,271 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var BufferArray = require( 'osg/BufferArray' );
-var RigGeometry = require( 'osgAnimation/RigGeometry' );
-var AnimationUpdateCallback = require( 'osgAnimation/AnimationUpdateCallback' );
-var Target = require( 'osgAnimation/target' );
-var MorphGeometry = require( 'osgAnimation/MorphGeometry' );
-
-var UpdateMorph = function () {
- AnimationUpdateCallback.call( this );
-
- this._isInitialized = false;
- this._targets = []; // float target
- this._targetNames = []; // names of targets
- this._morphs = []; // the update morph can update several morphs
-
- this._weights = new Float32Array( 4 );
- // stuffs to handles > 4 targets
- this._indexMap = [ 0, 0, 0, 0 ]; // we map VA to the first 4th VA targets
- this._gpuMorphed = []; // size of this._targets, for each target a bool states if it's gpu morphed or not
-};
-
-var EFFECTIVE_EPS = MorphGeometry.EFFECTIVE_EPS; // in case we have more than 4 morphs, we can skip low effective weights
-
-// for sorting
-var funcWeights = function ( a, b ) {
- return Math.abs( b.value ) - Math.abs( a.value );
-};
-
-UpdateMorph.prototype = MACROUTILS.objectInherit( AnimationUpdateCallback.prototype, {
-
- init: function ( node ) {
- //Find the morph geometry & init it
- var children = node.getChildren();
- for ( var i = 0, l = children.length; i < l; i++ ) {
-
- var geom = children[ i ];
- var morph;
- if ( geom instanceof MorphGeometry ) {
- morph = geom;
- } else if ( geom instanceof RigGeometry && geom.getSourceGeometry() instanceof MorphGeometry ) {
- morph = geom.getSourceGeometry();
- }
-
- if ( !morph ) continue;
-
- if ( morph.getName() === this.getName() ) {
- if ( !morph.isInitialized() )
- morph.init();
-
- this._morphs.push( morph );
- this._isInitialized = true;
- }
- }
- },
-
- isInitialized: function () {
- return this._isInitialized;
- },
-
- getNumTarget: function () {
- return this._targets.length;
- },
-
- getTarget: function ( index ) {
- return this._targets[ index ];
- },
-
- getTargetName: function ( index ) {
- return this._targetNames[ index ];
- },
-
- addTarget: function ( name, index ) {
- this._targets[ index ] = Target.createFloatTarget( 0 );
- this._targetNames[ index ] = name;
- },
-
- _remapBufferArrays: function () {
-
- // basically, this function remaps all the active morphed VA to the 4th first morphTargets VA
- var indexMap = this._indexMap;
- var morphs = this._morphs;
- for ( var i = 0; i < 4; ++i ) {
- var index = indexMap[ i ];
- var strI = '_' + i;
- var strIndex = '_' + index;
-
- for ( var j = 0, nbMorphs = morphs.length; j < nbMorphs; ++j ) {
-
- var morph = morphs[ j ];
- var vAttrs = morph.getVertexAttributeList();
- var morphNames = morph.getMorphTargetNames();
- for ( var k = 0, nbNames = morphNames.length; k < nbNames; ++k ) {
-
- var attName = morphNames[ k ];
- vAttrs[ attName + strI ].setBufferArray( vAttrs[ attName + strIndex ].getInitialBufferArray() );
-
- }
- }
- }
- },
-
- _mergeExtraMorphTarget: function ( attrs, attName, extraWeightSum ) {
-
- var i = 0;
- // ignore the gpu morphed
- var gpuMorphed = this._gpuMorphed;
- var vAttr = attrs[ attName ];
- var vertexLen = vAttr.getElements().length;
- var nbVertex = vertexLen / vAttr.getItemSize();
- var itemSize = vAttr.getItemSize();
-
- vAttr._cpuMorph = vAttr._cpuMorph || new BufferArray( BufferArray.ARRAY_BUFFER, new Float32Array( vertexLen ), itemSize );
- var morphExtraTargets = vAttr._cpuMorph.getElements();
- for ( i = 0; i < vertexLen; ++i ) {
- morphExtraTargets[ i ] = 0.0;
- }
-
- var targets = this._targets;
- for ( var j = 0, nb = targets.length; j < nb; ++j ) {
-
- // ignore gpu morphed targets
- if ( gpuMorphed[ j ] === true )
- continue;
-
- var weight = targets[ j ].value;
- if ( Math.abs( weight ) < EFFECTIVE_EPS )
- continue;
-
- weight /= extraWeightSum;
-
- var morphElts = attrs[ attName + '_' + j ].getInitialBufferArray().getElements();
- for ( i = 0; i < nbVertex; ++i ) {
-
- var k = i * itemSize;
- morphExtraTargets[ k ] += weight * morphElts[ k ];
- morphExtraTargets[ k + 1 ] += weight * morphElts[ k + 1 ];
- morphExtraTargets[ k + 2 ] += weight * morphElts[ k + 2 ];
- // don't morph tangent w component
- }
- }
-
- // map on last index target
- attrs[ attName + '_3' ].setBufferArray( vAttr._cpuMorph );
- vAttr._cpuMorph.dirty();
- },
-
- _computeExtraWeightsSum: function () {
- var gpuMorphed = this._gpuMorphed;
- var sum = 0.0;
- var targets = this._targets;
- for ( var i = 0, nb = targets.length; i < nb; ++i ) {
-
- // ignore gpu morphed targets
- if ( gpuMorphed[ i ] === true )
- continue;
-
- var weight = targets[ i ].value;
- if ( Math.abs( weight ) < EFFECTIVE_EPS )
- continue;
-
- sum += weight;
- }
- // check comment in _morphBufferArrayCPU (avoid near zero value)
- var eps = 1e-5;
- if ( Math.abs( sum ) > eps ) return sum;
- return sum < 0.0 ? -eps : eps;
- },
-
- _morphBufferArrayCPU: function () {
-
- // the idea is... we have :
- // v' = v * (1-w1-w2-w3) + t1*w1 + t2*w2 + t3*w3
- // we want
- // v' = v * (1-w1-w4) + t1*w1 + t4*w4
- // so basically we have to compute
- // w4 = w2+w3 // (check if ~0 !)
- // t4 = (t2*w2+t3*w3)/w4
- // (w4 is extraWeightSum and t4 will be computed in _mergeExtraMorphTarget)
-
- // compute new weights for the 4th target (all the extra target will be merged inside this one)
- var extraWeightSum = this._weights[ 3 ] = this._computeExtraWeightsSum();
-
- var processed = {}; // handles referenced buffer array (avoid useless double morph computation the same buffer)
- var morphs = this._morphs;
- for ( var i = 0, nbMorphs = morphs.length; i < nbMorphs; ++i ) {
-
- var morph = morphs[ i ];
- var vAttrs = morph.getVertexAttributeList();
- var morphNames = morph.getMorphTargetNames();
-
- for ( var j = 0, nbNames = morphNames.length; j < nbNames; ++j ) {
-
- var name = morphNames[ j ];
- var attr = vAttrs[ name ];
- // skip if the bufferArray is shared in another morphGeometry and has already been cpu morphed
- if ( !attr || processed[ attr.getInstanceID() ] ) continue;
- processed[ attr.getInstanceID() ] = true;
-
- this._mergeExtraMorphTarget( vAttrs, name, extraWeightSum );
- }
- }
- },
-
- updateWeights: function () {
-
- var i = 0;
- var targets = this._targets;
- var nbTargets = targets.length;
- // reset weights
- var weights = this._weights;
- weights[ 0 ] = weights[ 1 ] = weights[ 2 ] = weights[ 3 ] = 0.0;
-
- // no need to swap VA or to use CPU morph
- if ( nbTargets <= 4 ) {
- for ( i = 0; i < nbTargets; ++i ) {
- weights[ i ] = targets[ i ].value;
- }
- return;
- }
-
- // reset indexMap
- var indexMap = this._indexMap;
- indexMap[ 0 ] = indexMap[ 1 ] = indexMap[ 2 ] = indexMap[ 3 ] = 0;
-
- // reset gpu morphed array
- var gpuMorphed = this._gpuMorphed;
- gpuMorphed.length = nbTargets;
- for ( i = 0; i < nbTargets; ++i ) gpuMorphed[ i ] = false;
-
- var sortedTargets = targets.slice( 0 ).sort( funcWeights );
-
- for ( i = 0; i < 4; ++i ) {
- var ti = targets.indexOf( sortedTargets[ i ] );
- gpuMorphed[ ti ] = true;
- indexMap[ i ] = ti;
- weights[ i ] = sortedTargets[ i ].value;
- }
-
- // check more than 4 targets, we compute all the extra targets influence and merge in the last 4th morphs targets
- var extraMorphCPU = Math.abs( sortedTargets[ 4 ].value ) >= EFFECTIVE_EPS;
- gpuMorphed[ indexMap[ 3 ] ] = !extraMorphCPU;
-
- this._remapBufferArrays();
- if ( extraMorphCPU ) {
- this._morphBufferArrayCPU();
- }
- },
-
- update: function ( node /*, nv*/ ) {
- if ( !this.isInitialized() )
- this.init( node );
-
- this.updateWeights();
-
- var weights = this._weights;
- var nbTargets = Math.min( 4, this._targets.length );
- var morphs = this._morphs;
- for ( var i = 0, nbMorphs = morphs.length; i < nbMorphs; ++i ) {
-
- var array = morphs[ i ].getTargetsWeight();
- for ( var j = 0; j < nbTargets; j++ ) {
- array[ j ] = weights[ j ];
- }
- }
-
- return true;
- }
-} );
-
-module.exports = UpdateMorph;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateRigGeometry.js b/app/static/app/js/vendor/osgjs/osgAnimation/UpdateRigGeometry.js
deleted file mode 100644
index 384d1ffd..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateRigGeometry.js
+++ /dev/null
@@ -1,53 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Notify = require( 'osg/notify' );
-var ObjectBase = require( 'osg/Object' );
-var FindNearestParentSkeleton = require( 'osgAnimation/FindNearestParentSkeleton' );
-
-
-// converted from C++ probably it could be merged into RigGeometry
-// it could probably inlined into RigGeometry code
-var UpdateRigGeometry = function () {
- ObjectBase.call( this );
-};
-
-UpdateRigGeometry.prototype = MACROUTILS.objectInherit( ObjectBase.prototype, {
-
- init: function ( geom ) {
-
- var finder = new FindNearestParentSkeleton();
- if ( geom.getParents().length > 1 )
- Notify.warn( 'A RigGeometry should not have multi parent ( ' + geom.getName() + ' )' );
-
- geom.getParents()[ 0 ].accept( finder );
-
- if ( !finder._root ) {
- Notify.warn( 'A RigGeometry did not find a parent skeleton for RigGeometry ( ' + geom.getName() + ' )' );
- return;
- }
-
- geom.setSkeleton( finder._root );
- geom.setPathToSkeleton( finder._pathToRoot );
- },
-
- update: function ( node /*, nv*/ ) {
-
- // Circular ref
- if ( node && node.className() !== 'RigGeometry' ) return true;
-
- var geom = node;
-
- // maybe this code could simpler
- if ( !geom.getSkeleton() && geom.getParents().length !== 0 ) this.init( geom );
- if ( !geom.getSkeleton() ) return true;
-
- if ( geom.getNeedToComputeMatrix() ) geom.computeMatrixFromRootSkeleton();
-
- geom.update();
-
- return true;
- }
-
-} );
-
-module.exports = UpdateRigGeometry;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateSkeleton.js b/app/static/app/js/vendor/osgjs/osgAnimation/UpdateSkeleton.js
deleted file mode 100644
index 47d0f238..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/UpdateSkeleton.js
+++ /dev/null
@@ -1,84 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Bone = require( 'osgAnimation/Bone' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Notify = require( 'osg/notify' );
-var Object = require( 'osg/Object' );
-
-
-/**
- * ValidateSkeletonVisitor
- * @class ValidateSkeletonVisitor
- */
-var ValidateSkeletonVisitor = function () {
- NodeVisitor.call( this );
-};
-
-ValidateSkeletonVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- apply: function ( node ) {
- if ( node.getTypeID() !== Bone.getTypeID() ) {
- return;
- }
- var foundNonBone = false;
-
- var children = node.getChildren();
- for ( var i = 0, l = node.getChildren().length; i < l; i++ ) {
- var child = children[ i ];
- if ( child.getTypeID() === Bone.getTypeID() ) {
- if ( foundNonBone ) {
- Notify.warn( 'Warning: a Bone was found after a non-Bone child ' +
- 'within a Skeleton. Children of a Bone must be ordered ' +
- 'with all child Bones first for correct update order.' );
- //this.traversalMode = NodeVisitor.TRAVERSE_NONE;
- return;
- }
- } else {
- foundNonBone = true;
- }
- }
- this.traverse( node );
- }
-
-} );
-
-var compareBone = function ( x, y ) {
- var a = x instanceof Bone ? 0 : 1;
- var b = y instanceof Bone ? 0 : 1;
-
- return a - b;
-};
-
-/**
- * UpdateSkeleton
- * @class UpdateSkeleton
- */
-var UpdateSkeleton = function () {
- this._needValidate = true;
-};
-
-UpdateSkeleton.prototype = MACROUTILS.objectInherit( Object.prototype, {
- needToValidate: function () {
- return this._needValidate;
- },
-
- update: function ( node, nv ) {
- if ( this._needValidate && nv.getVisitorType() === NodeVisitor.UPDATE_VISITOR ) {
- if ( node.className && node.className() === 'Skeleton' ) {
- var validateSkeletonVisitor = new ValidateSkeletonVisitor();
- var children = node.getChildren();
- for ( var i = 0, l = children.length; i < l; i++ ) {
- var child = children[ i ];
- child.accept( validateSkeletonVisitor );
- }
-
- //Re-order skeleton children to force correct bones update, we should put bones first
- children.sort( compareBone );
-
- this._needValidate = false;
- }
- }
- return true;
- }
-} );
-
-module.exports = UpdateSkeleton;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/animation.js b/app/static/app/js/vendor/osgjs/osgAnimation/animation.js
deleted file mode 100644
index 9f6426a4..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/animation.js
+++ /dev/null
@@ -1,67 +0,0 @@
-'use strict';
-var Channel = require( 'osgAnimation/channel' );
-
-
-// create Animation data
-// Animation {
-// channels: [],
-// duration: 0.0;
-// name: string
-// },
-
-var animationCount = 0;
-
-// assume that iniChannel has been called
-// on each channel
-var createAnimation = function ( channels, name ) {
-
- var min = Infinity;
- var max = -Infinity;
- for ( var i = 0; i < channels.length; i++ ) {
- min = Math.min( min, channels[ i ].start );
- max = Math.max( max, channels[ i ].end );
- }
-
- var duration = max - min;
- var animationName = name || ( 'animation' + animationCount.toString() );
- animationCount++;
- return {
- channels: channels,
- duration: duration,
- name: animationName,
- start: min
- };
-};
-
-// create instance Animation data. An instance animation
-// contains instance channels instead of original channels
-// Animation {
-// channels: [],
-// duration: 0.0;
-// start: 0.0, // used to know when an animation has been started
-// name: string
-// },
-var createInstanceAnimation = function ( animation ) {
-
- var channels = [];
- for ( var i = 0; i < animation.channels.length; i++ ) {
- var channel = Channel.createInstanceChannel( animation.channels[ i ] );
- channels.push( channel );
- }
-
- return {
- channels: channels,
- duration: animation.duration,
- start: 0.0,
- name: animation.name,
- firstKeyTime: animation.start
- };
-};
-
-
-var Animation = function () {};
-
-Animation.createAnimation = createAnimation;
-Animation.createInstanceAnimation = createInstanceAnimation;
-
-module.exports = Animation;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/channel.js b/app/static/app/js/vendor/osgjs/osgAnimation/channel.js
deleted file mode 100644
index 62deb209..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/channel.js
+++ /dev/null
@@ -1,253 +0,0 @@
-'use strict';
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var quat = require( 'osg/glMatrix' ).quat;
-
-var Target = require( 'osgAnimation/target' );
-var channelType = require( 'osgAnimation/channelType' );
-
-
-var Channel = {};
-
-// channel {
-// keys: [],
-// times: [],
-// type: enum,
-// target: targetName
-// }
-// init a channel with extra field
-// start, end, duration
-var initChannel = function ( type, keys, times, targetName, channelName, channel ) {
- var start = times[ 0 ];
- var end = times[ times.length - 1 ];
- channel.start = start;
- channel.keys = keys;
- channel.end = end;
- channel.times = times;
- channel.type = type;
- channel.duration = end - start;
- channel.target = targetName;
- channel.name = channelName;
- return channel;
-};
-
-var createVec3Channel = function ( keys, times, targetName, channelName, chan ) {
- return initChannel( channelType.Vec3, keys, times, targetName, channelName, chan || {} );
-};
-
-var createFloatChannel = function ( keys, times, targetName, channelName, chan ) {
- return initChannel( channelType.Float, keys, times, targetName, channelName, chan || {} );
-};
-
-var createQuatChannel = function ( keys, times, targetName, channelName, chan ) {
- return initChannel( channelType.Quat, keys, times, targetName, channelName, chan || {} );
-};
-
-var createQuatSlerpChannel = function ( keys, times, targetName, channelName, chan ) {
- return initChannel( channelType.QuatSlerp, keys, times, targetName, channelName, chan || {} );
-};
-
-var createFloatCubicBezierChannel = function ( keys, times, targetName, channelName, chan ) {
- return initChannel( channelType.FloatCubicBezier, keys, times, targetName, channelName, chan || {} );
-};
-
-var createVec3CubicBezierChannel = function ( keys, times, targetName, channelName, chan ) {
- return initChannel( channelType.Vec3CubicBezier, keys, times, targetName, channelName, chan || {} );
-};
-
-
-// channel contains {
-// keys: [],
-// times: [],
-// start: 0.0,
-// end: 1.0,
-// }
-// return {
-// channel: channel,
-// value: vec3.create(),
-// targetID: int,
-// key: 0,
-// t: 0, //global start time
-// }
-
-var Float = {
- create: function () {
- return 0;
- }
-};
-var Vec3 = {
- create: function () {
- return vec3.create32();
- }
-};
-var Quat = {
- create: function () {
- return quat.create32();
- }
-};
-
-
-var createInstanceChannelType = function ( operator, channel ) {
- return {
- channel: channel,
- value: operator.create(),
- targetID: Target.InvalidTargetID,
- weight: 1.0,
- key: 0,
- start: 0.0,
- end: 0.0
- };
-};
-
-var createInstanceVec3Channel = function ( channel ) {
- return createInstanceChannelType( Vec3, channel );
-};
-
-var createInstanceQuatChannel = function ( channel ) {
- return createInstanceChannelType( Quat, channel );
-};
-
-var createInstanceFloatChannel = function ( channel ) {
- return createInstanceChannelType( Float, channel );
-};
-
-var createInstanceFloatCubicBezierChannel = function ( channel ) {
- return createInstanceChannelType( Float, channel );
-};
-
-var createInstanceVec3CubicBezierChannel = function ( channel ) {
- return createInstanceChannelType( Vec3, channel );
-};
-
-
-// create an instance channel from type
-var createInstanceChannel = function ( channel ) {
- return Channel[ channel.type ]( channel );
-};
-
-// animations instances
-/*
-
- |-----------------| anim0 (channel0_0, channel0_1 )
- |--------------| anim1 (channel1_0, channel1_1, channel1_2 )
-
- // si triage a cause de la priorité
- // iterate on priority
- // and for animations of the same priority
-
-
- // init d'une animation
-
- // init du manager
- // createInstanceAnimation pour chaque animations
- // createInstanceChannels pour chaque animation
-
- // initChannelTargetID pour toute les animations du manager
- // id -> targetName
-
-
- // get target for an animation to push on target list ( to blend )
- var targets = {};
- for ( var i = 0 ; i < channels.length; i++ ) {
- var target = channels[i].target;
- targets[target].push( channels[i] );
- }
-
-
- // pour l'instant on ignore les pb d'organisation de priorité
- //
- // target X : [
- // ChannelAnima0_0
- // ChannelAnima1_0
- // ]
-
- // target Y : [
- // ChannelAnima0_1
- // ChannelAnima1_1
- // ]
-
-
- */
-
-
-// for a target compute each channel contribution
-// channel0, value0, w, priority0
-// channel1, value1, w, priority0
-// channel2, value2, w, priority0
-
-
-// channel0, value0, w, priority1
-// channel1, value1, w, priority1
-// channel2, value2, w, priority1
-
-/*
-
- var value;
- Copy( channels[0].value, value );
- var weight = 0.0;
- var priority = channels[0].priority;
- var priorityWeight = channels[0].weight;
-
- for ( var i = 1; i < channels.length; i++ ) {
-
- if ( priority !== channels[i].priority ) {
- weight += priorityWeight * ( 1.0 - weight );
- priorityWeight = 0.0;
- priority = channels[i].priority;
- }
-
- priorityWeight += weight;
- t = ( 1.0 - weight ) * channels[i].weight / priorityWeight;
- lerp( t, value, channels[i].value );
- }
-
-
- // second version
-
- var value;
- Copy( channels[0].value, value );
- var weight = 0; //channels[0].weight;
- //var priority = channels[0].priority;
- var priorityWeight = 0;
-
- for ( var i = 0; i < channels.length; i++ ) {
-
- if ( priority !== channels[i].priority ) {
- weight += priorityWeight * ( 1.0 - weight );
- priorityWeight = 0.0;
- priority = channels[i].priority;
- }
-
- priorityWeight += weight;
- t = ( 1.0 - weight ) * channels[i].weight / priorityWeight;
- lerp( t, value, channels[i].value );
- }
-
-
- */
-
-Channel.createInstanceChannel = createInstanceChannel;
-Channel.createInstanceVec3Channel = createInstanceVec3Channel;
-Channel.createInstanceQuatChannel = createInstanceQuatChannel;
-Channel.createInstanceQuatSlerpChannel = createInstanceQuatChannel;
-Channel.createInstanceFloatChannel = createInstanceFloatChannel;
-Channel.createInstanceFloatCubicBezierChannel = createInstanceFloatCubicBezierChannel;
-Channel.createInstanceVec3CubicBezierChannel = createInstanceVec3CubicBezierChannel;
-
-Channel.createVec3Channel = createVec3Channel;
-Channel.createQuatChannel = createQuatChannel;
-Channel.createQuatSlerpChannel = createQuatSlerpChannel;
-Channel.createFloatChannel = createFloatChannel;
-Channel.createFloatCubicBezierChannel = createFloatCubicBezierChannel;
-Channel.createVec3CubicBezierChannel = createVec3CubicBezierChannel;
-
-Channel[ channelType.Vec3 ] = createInstanceVec3Channel;
-Channel[ channelType.Quat ] = createInstanceQuatChannel;
-Channel[ channelType.QuatSlerp ] = createInstanceQuatChannel;
-Channel[ channelType.Float ] = createInstanceFloatChannel;
-Channel[ channelType.FloatCubicBezier ] = createInstanceFloatCubicBezierChannel;
-Channel[ channelType.Vec3CubicBezier ] = createInstanceVec3CubicBezierChannel;
-
-Channel.ChannelType = channelType;
-
-
-module.exports = Channel;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/channelType.js b/app/static/app/js/vendor/osgjs/osgAnimation/channelType.js
deleted file mode 100644
index 531ea72e..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/channelType.js
+++ /dev/null
@@ -1,13 +0,0 @@
-'use strict';
-
-// must be sync wiht Interpolator Type
-module.exports = {
- Vec3: 0,
- Quat: 1,
- Float: 2,
- FloatCubicBezier: 3,
- Vec3CubicBezier: 4,
- QuatSlerp: 5,
- Matrix: 6,
- Count: 7
-};
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/easing.js b/app/static/app/js/vendor/osgjs/osgAnimation/easing.js
deleted file mode 100644
index c08c3bad..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/easing.js
+++ /dev/null
@@ -1,56 +0,0 @@
-'use strict';
-
-var easeOutQuad = function ( t ) {
- return -( t * ( t - 2.0 ) );
-};
-var easeInQuad = function ( t ) {
- return ( t * t );
-};
-var easeOutCubic = function ( t ) {
- t = t - 1.0;
- return ( t * t * t + 1 );
-};
-var easeInCubic = function ( t ) {
- return ( t * t * t );
-};
-var easeOutQuart = function ( t ) {
- t = t - 1;
- return -( t * t * t * t - 1 );
-};
-var easeInQuart = function ( t ) {
- return ( t * t * t * t );
-};
-var easeOutElastic = function ( t ) {
- return Math.pow( 2.0, -10.0 * t ) * Math.sin( ( t - 0.3 / 4.0 ) * ( 2.0 * Math.PI ) / 0.3 ) + 1.0;
-};
-//osgAnimation.EaseInElastic = function(t) { return ; };
-var easeOutBounce = function ( t ) {
- if ( t < ( 1 / 2.75 ) ) {
- return ( 7.5625 * t * t );
- } else if ( t < ( 2 / 2.75 ) ) {
- return ( 7.5625 * ( t -= ( 1.5 / 2.75 ) ) * t + 0.75 );
- } else if ( t < ( 2.5 / 2.75 ) ) {
- return ( 7.5625 * ( t -= ( 2.25 / 2.75 ) ) * t + 0.9375 );
- } else {
- return ( 7.5625 * ( t -= ( 2.625 / 2.75 ) ) * t + 0.984375 );
- }
-};
-
-module.exports = {
- easeOutQuad: easeOutQuad,
- easeInQuad: easeInQuad,
- easeOutCubic: easeOutCubic,
- easeInCubic: easeInCubic,
- easeOutQuart: easeOutQuart,
- easeInQuart: easeInQuart,
- easeOutElastic: easeOutElastic,
- easeOutBounce: easeOutBounce,
- EaseOutQuad: easeOutQuad,
- EaseInQuad: easeInQuad,
- EaseOutCubic: easeOutCubic,
- EaseInCubic: easeInCubic,
- EaseOutQuart: easeOutQuart,
- EaseInQuart: easeInQuart,
- EaseOutElastic: easeOutElastic,
- EaseOutBounce: easeOutBounce
-};
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/interpolator.js b/app/static/app/js/vendor/osgjs/osgAnimation/interpolator.js
deleted file mode 100644
index c59acb05..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/interpolator.js
+++ /dev/null
@@ -1,328 +0,0 @@
-'use strict';
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var quat = require( 'osg/glMatrix' ).quat;
-var Channel = require( 'osgAnimation/channel' );
-
-
-var vec3CopyKeyFrame = function ( i, keys, result ) {
- result[ 0 ] = keys[ i++ ];
- result[ 1 ] = keys[ i++ ];
- result[ 2 ] = keys[ i++ ];
-};
-
-var Vec4CopyKeyFrame = function ( i, keys, result ) {
- result[ 0 ] = keys[ i++ ];
- result[ 1 ] = keys[ i++ ];
- result[ 2 ] = keys[ i++ ];
- result[ 3 ] = keys[ i++ ];
-};
-
-var Vec3LerpInterpolator = function ( t, channelInstance ) {
-
- var channel = channelInstance.channel;
- var value = channelInstance.value;
- var start = channel.start;
- var end = channel.end;
- var keys = channel.keys;
- var times = channel.times;
-
- if ( t >= end ) {
- channelInstance.key = 0;
- vec3CopyKeyFrame( keys.length - 3, keys, value );
- return;
-
- } else if ( t <= start ) {
- channelInstance.key = 0;
- vec3CopyKeyFrame( 0, keys, value );
- return;
- }
-
- var i1 = channelInstance.key;
- if ( t > times[ i1 ] )
- while ( times[ i1 + 1 ] < t ) i1++;
- else if ( t < times[ i1 ] )
- while ( times[ i1 ] > t ) i1--;
-
- var t1 = times[ i1 ];
- var t2 = times[ i1 + 1 ];
-
- var index = i1 * 3;
- var x1 = keys[ index++ ];
- var y1 = keys[ index++ ];
- var z1 = keys[ index++ ];
-
- var x2 = keys[ index++ ];
- var y2 = keys[ index++ ];
- var z2 = keys[ index++ ];
-
- var r = ( t - t1 ) / ( t2 - t1 );
-
- value[ 0 ] = x1 + ( x2 - x1 ) * r;
- value[ 1 ] = y1 + ( y2 - y1 ) * r;
- value[ 2 ] = z1 + ( z2 - z1 ) * r;
- channelInstance.key = i1;
-};
-
-
-var QuatLerpInterpolator = ( function () {
-
- var q0 = quat.create32();
- var q1 = quat.create32();
-
- return function ( t, channelInstance ) {
-
- var channel = channelInstance.channel;
- var value = channelInstance.value;
- var start = channel.start;
- var end = channel.end;
- var keys = channel.keys;
- var times = channel.times;
-
- if ( t >= end ) {
- channelInstance.key = 0;
- Vec4CopyKeyFrame( keys.length - 4, keys, value );
- return;
-
- } else if ( t <= start ) {
- channelInstance.key = 0;
- Vec4CopyKeyFrame( 0, keys, value );
- return;
- }
-
- var i1 = channelInstance.key;
- if ( t > times[ i1 ] )
- while ( times[ i1 + 1 ] < t ) i1++;
- else if ( t < times[ i1 ] )
- while ( times[ i1 ] > t ) i1--;
-
- var t1 = times[ i1 ];
- var t2 = times[ i1 + 1 ];
-
- var index = i1 * 4;
- q0[ 0 ] = keys[ index++ ];
- q0[ 1 ] = keys[ index++ ];
- q0[ 2 ] = keys[ index++ ];
- q0[ 3 ] = keys[ index++ ];
-
- q1[ 0 ] = keys[ index++ ];
- q1[ 1 ] = keys[ index++ ];
- q1[ 2 ] = keys[ index++ ];
- q1[ 3 ] = keys[ index++ ];
-
- var r = ( t - t1 ) / ( t2 - t1 );
-
- quat.nlerp( value, q0, q1, r );
- channelInstance.key = i1;
- };
-
-} )();
-
-var QuatSlerpInterpolator = ( function () {
-
- var q0 = quat.create32();
- var q1 = quat.create32();
-
- return function ( t, channelInstance ) {
-
- var channel = channelInstance.channel;
- var value = channelInstance.value;
- var start = channel.start;
- var end = channel.end;
- var keys = channel.keys;
- var times = channel.times;
-
- if ( t >= end ) {
- channelInstance.key = 0;
- Vec4CopyKeyFrame( keys.length - 4, keys, value );
- return;
-
- } else if ( t <= start ) {
- channelInstance.key = 0;
- Vec4CopyKeyFrame( 0, keys, value );
- return;
- }
-
- var i1 = channelInstance.key;
- if ( t > times[ i1 ] )
- while ( times[ i1 + 1 ] < t ) i1++;
- else if ( t < times[ i1 ] )
- while ( times[ i1 ] > t ) i1--;
-
- var t1 = times[ i1 ];
- var t2 = times[ i1 + 1 ];
-
- var index = i1 * 4;
- q0[ 0 ] = keys[ index++ ];
- q0[ 1 ] = keys[ index++ ];
- q0[ 2 ] = keys[ index++ ];
- q0[ 3 ] = keys[ index++ ];
-
- q1[ 0 ] = keys[ index++ ];
- q1[ 1 ] = keys[ index++ ];
- q1[ 2 ] = keys[ index++ ];
- q1[ 3 ] = keys[ index++ ];
-
- var r = ( t - t1 ) / ( t2 - t1 );
-
- quat.slerp( value, q0, q1, r );
-
- channelInstance.key = i1;
- };
-} )();
-
-
-var FloatLerpInterpolator = function ( t, channelInstance ) {
-
- var channel = channelInstance.channel;
- var value = channelInstance.value;
- var start = channel.start;
- var end = channel.end;
- var keys = channel.keys;
- var times = channel.times;
-
- if ( t >= end ) {
- channelInstance.key = 0;
- channelInstance.value = keys[ keys.length - 1 ];
- return;
-
- } else if ( t <= start ) {
- channelInstance.key = 0;
- channelInstance.value = keys[ 0 ];
- return;
- }
-
- var i1 = channelInstance.key;
- if ( t > times[ i1 ] )
- while ( times[ i1 + 1 ] < t ) i1++;
- else if ( t < times[ i1 ] )
- while ( times[ i1 ] > t ) i1--;
-
-
- var t1 = times[ i1 ];
- var t2 = times[ i1 + 1 ];
-
- var index = i1;
- var x1 = keys[ index++ ];
- var x2 = keys[ index++ ];
-
- var r = ( t - t1 ) / ( t2 - t1 );
-
- value = x1 + ( x2 - x1 ) * r;
- channelInstance.key = i1;
- channelInstance.value = value;
-};
-
-var FloatCubicBezierInterpolator = function ( t, channelInstance ) {
- var channel = channelInstance.channel;
- var value = channelInstance.value;
- var start = channel.start;
- var end = channel.end;
- var keys = channel.keys;
- var times = channel.times;
-
- if ( t >= end ) {
- channelInstance.key = 0;
- channelInstance.value = keys[ keys.length - 3 ];
- return;
-
- } else if ( t <= start ) {
- channelInstance.key = 0;
- channelInstance.value = keys[ 0 ];
- return;
- }
-
- var i = channelInstance.key;
- if ( t > times[ i ] )
- while ( times[ i + 1 ] < t ) i++;
- else if ( t < times[ i ] )
- while ( times[ i ] > t ) i--;
-
- var tt = ( t - times[ i ] ) / ( times[ i + 1 ] - times[ i ] );
- var oneMinusT = 1.0 - tt;
- var oneMinusT2 = oneMinusT * oneMinusT;
- var oneMinusT3 = oneMinusT2 * oneMinusT;
- var t2 = tt * tt;
-
- var id = i * 3;
- var v0 = keys[ id ] * oneMinusT3;
- var v1 = keys[ id + 1 ] * ( 3.0 * tt * oneMinusT2 );
- var v2 = keys[ id + 2 ] * ( 3.0 * t2 * oneMinusT );
- var v3 = keys[ id + 3 ] * ( t2 * tt );
-
- value = v0 + v1 + v2 + v3;
- channelInstance.key = i;
- channelInstance.value = value;
-};
-
-var Vec3CubicBezierInterpolator = ( function () {
- var v0 = vec3.create();
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
-
- return function ( t, channelInstance ) {
- var channel = channelInstance.channel;
- var value = channelInstance.value;
- var start = channel.start;
- var end = channel.end;
- var keys = channel.keys;
- var times = channel.times;
-
- if ( t >= end ) {
- channelInstance.key = 0;
- vec3CopyKeyFrame( keys.length - 9, keys, value );
- return;
-
- } else if ( t <= start ) {
- channelInstance.key = 0;
- vec3CopyKeyFrame( 0, keys, value );
- return;
- }
-
- var i = channelInstance.key;
- if ( t > times[ i ] )
- while ( times[ i + 1 ] < t ) i++;
- else if ( t < times[ i ] )
- while ( times[ i ] > t ) i--;
-
- var tt = ( t - times[ i ] ) / ( times[ i + 1 ] - times[ i ] );
- var oneMinusT = 1.0 - tt;
- var oneMinusT2 = oneMinusT * oneMinusT;
- var oneMinusT3 = oneMinusT2 * oneMinusT;
- var t2 = tt * tt;
-
- var id = i * 9;
- vec3.scale( v0, vec3.set( v0, keys[ id++ ], keys[ id++ ], keys[ id++ ] ), oneMinusT3 );
- vec3.scale( v1, vec3.set( v1, keys[ id++ ], keys[ id++ ], keys[ id++ ] ), ( 3.0 * tt * oneMinusT2 ) );
- vec3.scale( v2, vec3.set( v2, keys[ id++ ], keys[ id++ ], keys[ id++ ] ), ( 3.0 * t2 * oneMinusT ) );
- vec3.scale( v3, vec3.set( v3, keys[ id++ ], keys[ id++ ], keys[ id++ ] ), ( t2 * tt ) );
-
- value[ 0 ] = v0[ 0 ] + v1[ 0 ] + v2[ 0 ] + v3[ 0 ];
- value[ 1 ] = v0[ 1 ] + v1[ 1 ] + v2[ 1 ] + v3[ 1 ];
- value[ 2 ] = v0[ 2 ] + v1[ 2 ] + v2[ 2 ] + v3[ 2 ];
- channelInstance.key = i;
- };
-
-} )();
-
-// must be sync wiht Interpolator Type
-var ChannelType = Channel.ChannelType;
-
-var moduleInterpolator = {};
-
-// refrence interpolator by channe enum id
-moduleInterpolator[ ChannelType.Vec3 ] = Vec3LerpInterpolator;
-moduleInterpolator[ ChannelType.Quat ] = QuatLerpInterpolator;
-moduleInterpolator[ ChannelType.QuatSlerp ] = QuatSlerpInterpolator;
-moduleInterpolator[ ChannelType.Float ] = FloatLerpInterpolator;
-moduleInterpolator[ ChannelType.FloatCubicBezier ] = FloatCubicBezierInterpolator;
-moduleInterpolator[ ChannelType.Vec3CubicBezier ] = Vec3CubicBezierInterpolator;
-
-moduleInterpolator.Vec3LerpInterpolator = Vec3LerpInterpolator;
-moduleInterpolator.QuatLerpInterpolator = QuatLerpInterpolator;
-moduleInterpolator.QuatSlerpInterpolator = QuatSlerpInterpolator;
-moduleInterpolator.FloatLerpInterpolator = FloatLerpInterpolator;
-moduleInterpolator.FloatCubicBezierInterpolator = FloatCubicBezierInterpolator;
-moduleInterpolator.Vec3CubicBezierInterpolator = Vec3CubicBezierInterpolator;
-
-module.exports = moduleInterpolator;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/osgAnimation.js b/app/static/app/js/vendor/osgjs/osgAnimation/osgAnimation.js
deleted file mode 100644
index 1e8d349a..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/osgAnimation.js
+++ /dev/null
@@ -1,52 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Animation = require( 'osgAnimation/animation' );
-var SkinningAttribute = require( 'osgAnimation/SkinningAttribute' );
-var AnimationUpdateCallback = require( 'osgAnimation/AnimationUpdateCallback' );
-var BasicAnimationManager = require( 'osgAnimation/BasicAnimationManager' );
-var Bone = require( 'osgAnimation/Bone' );
-var Channel = require( 'osgAnimation/channel' );
-var CollectAnimationUpdateCallbackVisitor = require( 'osgAnimation/CollectAnimationUpdateCallbackVisitor' );
-var Easing = require( 'osgAnimation/easing' );
-var Interpolator = require( 'osgAnimation/interpolator' );
-var MorphAttribute = require( 'osgAnimation/MorphAttribute' );
-var MorphGeometry = require( 'osgAnimation/MorphGeometry' );
-var RigGeometry = require( 'osgAnimation/RigGeometry' );
-var Skeleton = require( 'osgAnimation/Skeleton' );
-var StackedMatrix = require( 'osgAnimation/StackedMatrix' );
-var StackedQuaternion = require( 'osgAnimation/StackedQuaternion' );
-var StackedRotateAxis = require( 'osgAnimation/StackedRotateAxis' );
-var StackedScale = require( 'osgAnimation/StackedScale' );
-var StackedTranslate = require( 'osgAnimation/StackedTranslate' );
-var UpdateBone = require( 'osgAnimation/UpdateBone' );
-var UpdateMatrixTransform = require( 'osgAnimation/UpdateMatrixTransform' );
-var UpdateMorph = require( 'osgAnimation/UpdateMorph' );
-var UpdateSkeleton = require( 'osgAnimation/UpdateSkeleton' );
-
-
-var osgAnimation = {};
-
-MACROUTILS.objectMix( osgAnimation, Easing );
-MACROUTILS.objectMix( osgAnimation, Interpolator );
-osgAnimation.Animation = Animation;
-osgAnimation.SkinningAttribute = SkinningAttribute;
-osgAnimation.AnimationUpdateCallback = AnimationUpdateCallback;
-osgAnimation.BasicAnimationManager = BasicAnimationManager;
-osgAnimation.Bone = Bone;
-osgAnimation.Channel = Channel;
-osgAnimation.CollectAnimationUpdateCallbackVisitor = CollectAnimationUpdateCallbackVisitor;
-osgAnimation.MorphAttribute = MorphAttribute;
-osgAnimation.MorphGeometry = MorphGeometry;
-osgAnimation.RigGeometry = RigGeometry;
-osgAnimation.Skeleton = Skeleton;
-osgAnimation.StackedMatrix = StackedMatrix;
-osgAnimation.StackedQuaternion = StackedQuaternion;
-osgAnimation.StackedRotateAxis = StackedRotateAxis;
-osgAnimation.StackedScale = StackedScale;
-osgAnimation.StackedTranslate = StackedTranslate;
-osgAnimation.UpdateBone = UpdateBone;
-osgAnimation.UpdateMatrixTransform = UpdateMatrixTransform;
-osgAnimation.UpdateMorph = UpdateMorph;
-osgAnimation.UpdateSkeleton = UpdateSkeleton;
-
-module.exports = osgAnimation;
diff --git a/app/static/app/js/vendor/osgjs/osgAnimation/target.js b/app/static/app/js/vendor/osgjs/osgAnimation/target.js
deleted file mode 100644
index 916f92b9..00000000
--- a/app/static/app/js/vendor/osgjs/osgAnimation/target.js
+++ /dev/null
@@ -1,51 +0,0 @@
-'use strict';
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var quat = require( 'osg/glMatrix' ).quat;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var channelType = require( 'osgAnimation/channelType' );
-
-
-var target = {};
-target.InvalidTargetID = -1;
-
-// defaultValue is used when no channels affect the value
-var createTarget = function ( type, value, defaultValue ) {
- return {
- type: type,
- id: target.InvalidTargetID, // -1 means no id assigned yet
- channels: [],
- value: value,
- defaultValue: defaultValue
- };
-};
-
-var createQuatTarget = function ( defaultValue ) {
- return createTarget( channelType.Quat,
- quat.copy( quat.create(), defaultValue ),
- quat.copy( quat.create(), defaultValue ) );
-};
-
-var createMatrixTarget = function ( defaultValue ) {
- return createTarget( channelType.Matrix,
- mat4.copy( mat4.create(), defaultValue ),
- mat4.copy( mat4.create(), defaultValue ) );
-};
-
-var createVec3Target = function ( defaultValue ) {
- return createTarget( channelType.Vec3,
- vec3.copy( vec3.create(), defaultValue ),
- vec3.copy( vec3.create(), defaultValue ) );
-};
-
-var createFloatTarget = function ( defaultValue ) {
- return createTarget( channelType.Float,
- defaultValue,
- defaultValue );
-};
-
-target.createQuatTarget = createQuatTarget;
-target.createVec3Target = createVec3Target;
-target.createFloatTarget = createFloatTarget;
-target.createMatrixTarget = createMatrixTarget;
-
-module.exports = target;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/DatabasePager.js b/app/static/app/js/vendor/osgjs/osgDB/DatabasePager.js
deleted file mode 100644
index 135ddc3b..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/DatabasePager.js
+++ /dev/null
@@ -1,395 +0,0 @@
-'use strict';
-var P = require( 'bluebird' );
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var PagedLOD = require( 'osg/PagedLOD' );
-var Timer = require( 'osg/Timer' );
-
-/**
- * Database paging class which manages the loading of files
- * and synchronizing of loaded models with the main scene graph.
- * @class DatabasePager
- */
-var DatabasePager = function () {
- this._pendingRequests = [];
- this._pendingNodes = [];
- this._loading = false;
- this._progressCallback = undefined;
- this._lastCB = true;
- this._activePagedLODList = new Set();
- this._childrenToRemoveList = new Set();
- this._downloadingRequestsNumber = 0;
- this._maxRequestsPerFrame = 10;
- this._acceptNewRequests = true;
- // In OSG the targetMaximumNumberOfPagedLOD is 300 by default
- // here we set 75 as we need to be more strict with memory in a browser
- // This value can be setted using setTargetMaximumNumberOfPageLOD method.
- this._targetMaximumNumberOfPagedLOD = 75;
-};
-
-var DatabaseRequest = function () {
- this._loadedModel = undefined;
- this._group = undefined;
- this._url = undefined;
- this._function = undefined;
- this._timeStamp = 0.0;
- this._groupExpired = false;
- this._priority = 0.0;
-};
-
-var FindPagedLODsVisitor = function ( pagedLODList, frameNumber ) {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ALL_CHILDREN );
- this._activePagedLODList = pagedLODList;
- this._frameNumber = frameNumber;
-};
-FindPagedLODsVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- apply: function ( node ) {
- if ( node.getTypeID() === PagedLOD.getTypeID() ) {
- node.setFrameNumberOfLastTraversal( this._frameNumber );
- this._activePagedLODList.add( node );
- }
- this.traverse( node );
- }
-} );
-
-var ReleaseVisitor = function () {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ALL_CHILDREN );
-};
-ReleaseVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- apply: function ( node ) {
- // mark GLResources in nodes to be released
- node.releaseGLObjects();
- this.traverse( node );
- }
-} );
-
-var ExpirePagedLODVisitor = function () {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ALL_CHILDREN );
- this._childrenList = [];
-};
-
-ExpirePagedLODVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
-
- apply: function ( node ) {
- if ( node.getTypeID() === PagedLOD.getTypeID() ) {
- this._childrenList.push( node );
- this._markRequestsExpired( node );
- }
- this.traverse( node );
- },
-
- removeExpiredChildrenAndFindPagedLODs: function ( plod, expiryTime, expiryFrame, removedChildren ) {
- if ( !plod.children.length ) return false;
-
- var sizeBefore = removedChildren.length;
- plod.removeExpiredChildren( expiryTime, expiryFrame, removedChildren );
- for ( var i = sizeBefore; i < removedChildren.length; i++ ) {
- removedChildren[ i ].accept( this );
- }
- return sizeBefore !== removedChildren.length;
- },
-
- _markRequestsExpired: function ( plod ) {
- var numRanges = plod._perRangeDataList.length;
- var request;
- for ( var i = 0; i < numRanges; i++ ) {
- request = plod.getDatabaseRequest( i );
- if ( request !== undefined ) {
- request._groupExpired = true;
- request._loadedModel = null;
- }
- }
- }
-} );
-
-DatabasePager.prototype = MACROUTILS.objectLibraryClass( {
-
- setTargetMaximumNumberOfPageLOD: function ( target ) {
- this._targetMaximumNumberOfPagedLOD = target;
- },
-
- getTargetMaximumNumberOfPageLOD: function () {
- return this._targetMaximumNumberOfPagedLOD;
- },
-
- setAcceptNewDatabaseRequests: function ( acceptNewRequests ) {
- this._acceptNewRequests = acceptNewRequests;
- },
- getAcceptNewDatabaseRequests: function () {
- return this._acceptNewRequests;
- },
- reset: function () {
- this._pendingRequests = [];
- this._pendingNodes = [];
- this._loading = false;
- this._lastCB = true;
- this._activePagedLODList.clear();
- this._childrenToRemoveList.clear();
- this._downloadingRequestsNumber = 0;
- this._maxRequestsPerFrame = 10;
- this._acceptNewRequests = true;
- this._targetMaximumNumberOfPagedLOD = 75;
- },
-
- updateSceneGraph: function ( frameStamp ) {
- // Progress callback
- if ( this._progressCallback !== undefined ) {
- // Maybe we should encapsulate this in a promise.
- this.executeProgressCallback();
- }
- // We need to control the time spent in DatabasePager tasks to
- // avoid making the rendering slow.
- // Probably we can have a time parameter to manage all the tasks.
- // Now it is fixed to 0.0025 ms to remove expired childs
- // and 0.005 ms to add to the scene the loaded requests.
-
- // Remove expired nodes
- this.removeExpiredSubgraphs( frameStamp, 0.0025 );
- // Time to do the requests.
- this.takeRequests();
- // Add the loaded data to the graph
- this.addLoadedDataToSceneGraph( frameStamp, 0.005 );
- },
-
-
- executeProgressCallback: function () {
- if ( this._pendingRequests.length > 0 || this._pendingNodes.length > 0 ) {
- this._progressCallback( this._pendingRequests.length + this._downloadingRequestsNumber, this._pendingNodes.length );
- this._lastCB = false;
- } else {
- if ( !this._lastCB ) {
- this._progressCallback( this._pendingRequests.length + this._downloadingRequestsNumber, this._pendingNodes.length );
- this._lastCB = true;
- }
- }
- },
-
- setMaxRequestsPerFrame: function ( numRequests ) {
- this._maxRequestsPerFrame = numRequests;
- },
-
- getMaxRequestsPerFrame: function () {
- return this._maxRequestsPerFrame;
- },
-
- getRequestListSize: function () {
- return this._pendingRequests.length + this._downloadingRequestsNumber;
- },
-
- setProgressCallback: function ( cb ) {
- this._progressCallback = cb;
- },
-
- addLoadedDataToSceneGraph: function ( frameStamp, availableTime ) {
-
- if ( availableTime <= 0.0 ) return 0.0;
-
- // Prune the list of database requests.
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- this._pendingNodes.sort( function ( r1, r2 ) {
- return r2._timeStamp - r1._timeStamp;
- } );
-
- for ( var i = 0; i < this._pendingNodes.length; i++ ) {
- if ( elapsedTime > availableTime ) return 0.0;
-
- var request = this._pendingNodes.shift();
- var frameNumber = frameStamp.getFrameNumber();
- var timeStamp = frameStamp.getSimulationTime();
-
- // If the request is not expired, then add/register new childs
- if ( request._groupExpired === false ) {
-
- var plod = request._group;
- plod.setTimeStamp( plod.children.length, timeStamp );
- plod.setFrameNumber( plod.children.length, frameNumber );
- plod.addChildNode( request._loadedModel );
-
- // Register PagedLODs.
- if ( !this._activePagedLODList.has( plod ) ) {
- this.registerPagedLODs( plod, frameNumber );
- } else {
- this.registerPagedLODs( request._loadedModel, frameNumber );
- }
-
- } else {
-
- // Clean the request
- request._loadedModel = undefined;
- request = undefined;
-
- }
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- }
- availableTime -= elapsedTime;
- return availableTime;
- },
-
- isLoading: function () {
- return this._loading;
- },
-
- registerPagedLODs: function ( subgraph, frameNumber ) {
- if ( !subgraph ) return;
- subgraph.accept( new FindPagedLODsVisitor( this._activePagedLODList, frameNumber ) );
- },
-
- requestNodeFile: function ( func, url, node, timestamp, priority ) {
- // Check if we are currently accepting requests.
- if ( !this._acceptNewRequests ) return undefined;
- // We don't need to determine if the dbrequest is in the queue
- // That is already done in the PagedLOD, so we just create the request
- var dbrequest = new DatabaseRequest();
- dbrequest._group = node;
- dbrequest._function = func;
- dbrequest._url = url;
- dbrequest._timeStamp = timestamp;
- dbrequest._priority = priority;
- this._pendingRequests.push( dbrequest );
- return dbrequest;
- },
-
- takeRequests: function () {
- if ( this._pendingRequests.length ) {
- var numRequests = Math.min( this._maxRequestsPerFrame, this._pendingRequests.length );
- this._pendingRequests.sort( function ( r1, r2 ) {
- // Ask for newer requests first.
- var value = r1._timeStamp - r2._timeStamp;
- // Ask for the greater priority if the timestamp is the same.
- if ( value === 0 ) {
- value = r1._priority - r2._priority;
- }
- return value;
-
- } );
- for ( var i = 0; i < numRequests; i++ ) {
- this._downloadingRequestsNumber++;
- this.processRequest( this._pendingRequests.shift() );
- }
- }
- },
-
- processRequest: function ( dbrequest ) {
-
- this._loading = true;
- var that = this;
- // Check if the request is valid;
- if ( dbrequest._groupExpired ) {
- //Notify.log( 'DatabasePager::processRequest() Request expired.' );
- that._downloadingRequestsNumber--;
- this._loading = false;
- return;
- }
-
- // Load from function
- if ( dbrequest._function !== undefined ) {
- this.loadNodeFromFunction( dbrequest._function, dbrequest._group ).then( function ( child ) {
- that._downloadingRequestsNumber--;
- dbrequest._loadedModel = child;
- that._pendingNodes.push( dbrequest );
- that._loading = false;
- } );
-
- } else if ( dbrequest._url !== '' ) { // Load from URL
- this.loadNodeFromURL( dbrequest._url ).then( function ( child ) {
- that._downloadingRequestsNumber--;
- dbrequest._loadedModel = child;
- that._pendingNodes.push( dbrequest );
- that._loading = false;
- } );
- }
- },
-
- loadNodeFromFunction: function ( func, plod ) {
- // Need to call with pagedLOD as parent, to be able to have multiresolution structures.
- var promise = ( func )( plod );
- // should func always return a promise ?
- if ( !promise ) return P.reject();
- if ( promise && promise.then ) return promise;
- return P.resolve( promise );
- },
-
- loadNodeFromURL: function ( url ) {
- var ReaderParser = require( 'osgDB/readerParser' );
- // Call to ReaderParser just in case there is a custom readNodeURL Callback
- // See osgDB/options.js and/or osgDB/Input.js
- // TODO: We should study if performance can be improved if separating the XHTTP request from
- // the parsing. This way several/many request could be done at the same time.
- // Also we should be able to cancel requests, so there is a need to have access
- // to the HTTPRequest Object
- return ReaderParser.readNodeURL( url );
- },
-
- releaseGLExpiredSubgraphs: function ( availableTime ) {
-
- if ( availableTime <= 0.0 ) return 0.0;
- // We need to test if we have time to flush
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- var that = this;
-
- this._childrenToRemoveList.forEach( function ( node ) {
- // If we don't have more time, break the loop.
- if ( elapsedTime > availableTime ) return;
- that._childrenToRemoveList.delete( node );
- node.accept( new ReleaseVisitor() );
- node.removeChildren();
- node = null;
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- } );
-
- availableTime -= elapsedTime;
- return availableTime;
- },
-
- removeExpiredSubgraphs: function ( frameStamp, availableTime ) {
-
- if ( frameStamp.getFrameNumber() === 0 ) return 0.0;
-
- var numToPrune = this._activePagedLODList.size - this._targetMaximumNumberOfPagedLOD;
- var expiryTime = frameStamp.getSimulationTime() - 0.1;
- var expiryFrame = frameStamp.getFrameNumber() - 1;
- // First traverse and remove inactive PagedLODs, as their children will
- // certainly have expired.
- // TODO: Then traverse active nodes if we still need to prune.
- if ( numToPrune > 0 ) {
- availableTime = this.removeExpiredChildren( numToPrune, expiryTime, expiryFrame, availableTime );
- }
- return availableTime;
- },
-
- removeExpiredChildren: function ( numToPrune, expiryTime, expiryFrame, availableTime ) {
- // Iterate over the activePagedLODList to remove expired children
- // We need to control the time spent in remove childs.
- var elapsedTime = 0.0;
- var beginTime = Timer.instance().tick();
- var that = this;
- var removedChildren = [];
- var expiredPagedLODVisitor = new ExpirePagedLODVisitor();
-
- this._activePagedLODList.forEach( function ( plod ) {
- // Check if we have time, else return 0
- if ( elapsedTime > availableTime ) return 0.0;
- if ( numToPrune < 0 ) return availableTime;
- // See if plod is still active, so we don't have to prune
- if ( expiryFrame < plod.getFrameNumberOfLastTraversal() ) return availableTime;
- expiredPagedLODVisitor.removeExpiredChildrenAndFindPagedLODs( plod, expiryTime, expiryFrame, removedChildren );
- for ( var i = 0; i < expiredPagedLODVisitor._childrenList.length; i++ ) {
- that._activePagedLODList.delete( expiredPagedLODVisitor._childrenList[ i ] );
- numToPrune--;
- }
- // Add to the remove list all the childs deleted
- for ( i = 0; i < removedChildren.length; i++ ) {
- that._childrenToRemoveList.add( removedChildren[ i ] );
- }
- expiredPagedLODVisitor._childrenList.length = 0;
- removedChildren.length = 0;
- elapsedTime = Timer.instance().deltaS( beginTime, Timer.instance().tick() );
- } );
- availableTime -= elapsedTime;
- return availableTime;
- }
-}, 'osgDB', 'DatabasePager' );
-
-module.exports = DatabasePager;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/Input.js b/app/static/app/js/vendor/osgjs/osgDB/Input.js
deleted file mode 100644
index ee0001fa..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/Input.js
+++ /dev/null
@@ -1,656 +0,0 @@
-'use strict';
-var P = require( 'bluebird' );
-var MACROUTILS = require( 'osg/Utils' );
-var osgNameSpace = require( 'osgNameSpace' );
-var _requestFile = require( 'osgDB/requestFile' );
-var Options = require( 'osgDB/options' );
-var zlib = require( 'osgDB/zlib' );
-var Notify = require( 'osg/notify' );
-var Image = require( 'osg/Image' );
-var BufferArray = require( 'osg/BufferArray' );
-var DrawArrays = require( 'osg/DrawArrays' );
-var DrawArrayLengths = require( 'osg/DrawArrayLengths' );
-var DrawElements = require( 'osg/DrawElements' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-
-
-var Input = function ( json, identifier ) {
- this._json = json;
- var map = identifier;
- if ( map === undefined ) {
- map = {};
- }
- this._identifierMap = map;
- this._objectRegistry = {};
-
- this._cacheReadObject = {}; //wrappers
-
- // this._progressXHRCallback = undefined;
- // this._prefixURL = '';
- // this.setImageLoadingOptions( {
- // promise: true,
- // onload: undefined
- // } );
-
- this.setOptions( MACROUTILS.objectMix( {}, Options ) );
-
- // {
- // prefixURL: '',
- // progressXHRCallback: undefined,
- // readImageURL: undefined,
- // imageLoadingUsePromise: undefined,
- // imageOnload: undefined,
- // };
-};
-
-
-// keep one instance of image fallback
-if ( !Input.imageFallback ) {
- Input.imageFallback = ( function () {
- var fallback = new window.Image();
- fallback.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=';
- return fallback;
- } )();
-}
-
-Input.prototype = {
-
- clone: function () {
- var input = new Input();
- input._objectRegistry = this._objectRegistry;
- input._cacheReadObject = this._cacheReadObject;
- return input;
- },
-
- setOptions: function ( options ) {
- this._defaultOptions = options;
- },
- getOptions: function () {
- return this._defaultOptions;
- },
- setProgressXHRCallback: function ( func ) {
- this._defaultOptions.progressXHRCallback = func;
- },
- setReadNodeURLCallback: function ( func ) {
- this._defaultOptions.readNodeURL = func;
- },
- // used to override the type from pathname
- // typically if you want to create proxy object
- registerObject: function ( fullyQualifiedObjectname, constructor ) {
- this._objectRegistry[ fullyQualifiedObjectname ] = constructor;
- },
-
- getJSON: function () {
- return this._json;
- },
-
- setJSON: function ( json ) {
- this._json = json;
- return this;
- },
-
- setPrefixURL: function ( prefix ) {
- this._defaultOptions.prefixURL = prefix;
- },
-
- getPrefixURL: function () {
- return this._defaultOptions.prefixURL;
- },
-
- setDatabasePath: function ( path ) {
- this._defaultOptions.databasePath = path;
- },
-
- getDatabasePath: function () {
- return this._defaultOptions.databasePath;
- },
-
- computeURL: function ( url ) {
-
- if ( typeof this._defaultOptions.prefixURL === 'string' &&
- this._defaultOptions.prefixURL.length > 0 ) {
-
- return this._defaultOptions.prefixURL + url;
- }
-
- return url;
- },
-
-
- requestFile: function ( url, options ) {
- return _requestFile( url, options );
- },
-
- getObjectWrapper: function ( path ) {
- if ( this._objectRegistry[ path ] ) {
- return new( this._objectRegistry[ path ] )();
- }
-
- var scope = osgNameSpace;
- var splittedPath = path.split( '.' );
- for ( var i = 0, l = splittedPath.length; i < l; i++ ) {
- var obj = scope[ splittedPath[ i ] ];
- if ( obj === undefined ) {
- return undefined;
- }
- scope = obj;
- }
- this._objectRegistry[ path ] = scope;
- // create the new obj
- return new( scope )();
- },
-
- fetchImage: function ( image, url, options, defer ) {
- var checkInlineImage = 'data:image/';
- // crossOrigin does not work for inline data image
- var isInlineImage = ( url.substring( 0, checkInlineImage.length ) === checkInlineImage );
- var img = new window.Image();
- img.onerror = function () {
- Notify.warn( 'warning use white texture as fallback instead of ' + url );
- image.setImage( Input.imageFallback );
- if ( defer ) {
- defer.resolve( image );
- }
- };
-
- if ( !isInlineImage && options.imageCrossOrigin ) {
- img.crossOrigin = options.imageCrossOrigin;
- }
-
- img.onload = function () {
-
- if ( defer ) {
- if ( options.imageOnload ) options.imageOnload.call( image );
- defer.resolve( image );
- } else if ( options.imageOnload )
- options.imageOnload.call( image );
-
- };
-
- image.setURL( url );
- image.setImage( img );
-
- img.src = url;
- return image;
- },
-
- readImageURL: function ( url, options ) {
-
- if ( options === undefined ) {
- options = this._defaultOptions;
- }
-
- // hook reader
- if ( options.readImageURL ) {
- // be carefull if you plan to call hook the call and after
- // call the original readImageURL, you will need to remove
- // from options the readImageURL if you dont want an infinte
- // recursion call
- return options.readImageURL.call( this, url, options );
- }
-
- // if image is on inline image skip url computation
- if ( url.substr( 0, 10 ) !== 'data:image' ) {
- url = this.computeURL( url );
- }
-
-
- var image = new Image();
- if ( options.imageLoadingUsePromise !== true ) {
- return this.fetchImage( image, url, options );
- }
-
- var defer = P.defer();
- this.fetchImage( image, url, options, defer );
-
- return defer.promise;
- },
-
-
- readNodeURL: function ( url, opt ) {
-
- var options = opt;
- if ( options === undefined ) {
- options = this._defaultOptions;
- }
-
- // hook reader
- if ( options.readNodeURL ) {
- // be carefull if you plan to call hook the call and after
- // call the original readNodeURL, you will need to remove
- // from options the readNodeURL if you dont want an infinte
- // recursion call
- return options.readNodeURL.call( this, url, options );
- }
-
- url = this.computeURL( url );
-
- var defer = P.defer();
-
- // copy because we are going to modify it to have relative prefix to load assets
- options = MACROUTILS.objectMix( {}, options );
-
- // automatic prefix if non specfied
- if ( !!!options.prefixURL ) {
- var prefix = this.getPrefixURL();
- var index = url.lastIndexOf( '/' );
- if ( index !== -1 ) {
- prefix = url.substring( 0, index + 1 );
- }
- options.prefixURL = prefix;
- }
-
- var self = this;
-
- var ReaderParser = require( 'osgDB/readerParser' );
-
- var readSceneGraph = function ( data ) {
-
- ReaderParser.parseSceneGraph( data, options ).then( function ( child ) {
- defer.resolve( child );
- Notify.log( 'loaded ' + url );
- } ).catch( defer.reject.bind( defer ) );
- };
-
- var ungzipFile = function ( arrayBuffer ) {
-
- function pad( n ) {
- return n.length < 2 ? '0' + n : n;
- }
-
- function uintToString( uintArray ) {
- var str = '';
- for ( var i = 0, len = uintArray.length; i < len; ++i ) {
- str += ( '%' + pad( uintArray[ i ].toString( 16 ) ) );
- }
- str = decodeURIComponent( str );
- return str;
- }
-
-
- var unpacked = arrayBuffer;
- if ( zlib.isGunzipBuffer( arrayBuffer ) ) {
- unpacked = zlib.gunzip( arrayBuffer );
- }
-
- var typedArray = new Uint8Array( unpacked );
- var str = uintToString( typedArray );
- return str;
- };
-
-
- // try to get the file as responseText to parse JSON
- var fileTextPromise = self.requestFile( url );
- fileTextPromise.then( function ( str ) {
-
- var data;
- try {
-
- data = JSON.parse( str );
-
- } catch ( error ) { // can't parse try with ungzip code path
-
- Notify.error( 'cant parse url ' + url + ' try to gunzip' );
-
- }
-
- // we have the json, read it
- if ( data )
- return readSceneGraph( data );
-
-
- // no data try with gunzip
- var fileGzipPromise = self.requestFile( url, {
- responseType: 'arraybuffer'
- } );
- fileGzipPromise.then( function ( file ) {
-
- var str = ungzipFile( file );
- data = JSON.parse( str );
- readSceneGraph( data );
-
- } ).catch( function ( status ) {
-
- Notify.error( 'cant read file ' + url + ' status ' + status );
- defer.reject();
-
- } ).done();
-
- return true;
-
- } ).catch( function ( status ) {
-
- Notify.error( 'cant get file ' + url + ' status ' + status );
- defer.reject();
-
- } ).done();
-
- return defer.promise;
- },
-
- _unzipTypedArray: function ( binary ) {
-
- var typedArray = new Uint8Array( binary );
-
- // check magic number 1f8b
- if ( typedArray[ 0 ] === 0x1f && typedArray[ 1 ] === 0x8b ) {
- var zlib = require( 'zlib' );
-
- if ( !zlib ) {
- Notify.error( 'osg failed to use a gunzip.min.js to uncompress a gz file.\n You can add this vendors to enable this feature or adds the good header in your gzip file served by your server' );
- }
-
- var zdec = new zlib.Gunzip( typedArray );
- var result = zdec.decompress();
- return result.buffer;
- }
-
- return binary;
- },
-
- readBinaryArrayURL: function ( url, options ) {
-
- if ( options === undefined ) {
- options = this._defaultOptions;
- }
-
- if ( options.readBinaryArrayURL ) {
- return options.readBinaryArrayURL.call( this, url, options );
- }
-
- url = this.computeURL( url );
-
-
- if ( this._identifierMap[ url ] !== undefined ) {
- return this._identifierMap[ url ];
- }
- var defer = P.defer();
-
- var filePromise = this.requestFile( url, {
- responseType: 'arraybuffer',
- progress: this._defaultOptions.progressXHRCallback
- } );
-
- this._identifierMap[ url ] = defer.promise;
- filePromise.then( function ( file ) {
- defer.resolve( this._unzipTypedArray( file ) );
- }.bind( this ) );
-
- return defer.promise;
- },
-
- initializeBufferArray: function ( vb, type, buf, options ) {
- if ( options === undefined )
- options = this.getOptions();
- if ( options.initializeBufferArray )
- return options.initializeBufferArray.call( this, vb, type, buf );
-
- var url = vb.File;
- var defer = P.defer();
- this.readBinaryArrayURL( url ).then( function ( array ) {
-
- var typedArray;
- // manage endianness
- var bigEndian;
- ( function () {
- var a = new Uint8Array( [ 0x12, 0x34 ] );
- var b = new Uint16Array( a.buffer );
- bigEndian = ( ( b[ 0 ] ).toString( 16 ) === '1234' );
- } )();
-
- var offset = 0;
- if ( vb.Offset !== undefined ) {
- offset = vb.Offset;
- }
-
- var bytesPerElement = MACROUTILS[ type ].BYTES_PER_ELEMENT;
- var nbItems = vb.Size;
- var nbCoords = buf.getItemSize();
- var totalSizeInBytes = nbItems * bytesPerElement * nbCoords;
-
- if ( bigEndian ) {
- Notify.log( 'big endian detected' );
- var TypedArray = MACROUTILS[ type ];
- var tmpArray = new TypedArray( nbItems * nbCoords );
- var data = new DataView( array, offset, totalSizeInBytes );
- var i = 0,
- l = tmpArray.length;
- if ( type === 'Uint16Array' ) {
- for ( ; i < l; i++ ) {
- tmpArray[ i ] = data.getUint16( i * bytesPerElement, true );
- }
- } else if ( type === 'Float32Array' ) {
- for ( ; i < l; i++ ) {
- tmpArray[ i ] = data.getFloat32( i * bytesPerElement, true );
- }
- }
- typedArray = tmpArray;
- data = null;
- } else {
- typedArray = new MACROUTILS[ type ]( array, offset, nbCoords * nbItems );
- }
-
- buf.setElements( typedArray );
- defer.resolve( buf );
- } ).catch( function () {
- Notify.warn( 'Can\'t read binary array URL' );
- } );
- return defer.promise;
- },
-
- readBufferArray: function ( options ) {
- var jsonObj = this.getJSON();
-
- var uniqueID = jsonObj.UniqueID;
- var osgjsObject;
- if ( uniqueID !== undefined ) {
- osgjsObject = this._identifierMap[ uniqueID ];
- if ( osgjsObject !== undefined ) {
- return osgjsObject;
- }
- }
-
- if ( options === undefined )
- options = this.getOptions();
- if ( options.readBufferArray )
- return options.readBufferArray.call( this );
-
- if ( ( !jsonObj.Elements && !jsonObj.Array ) || !jsonObj.ItemSize || !jsonObj.Type )
- return P.reject();
-
- var promise;
-
- // inline array
- if ( jsonObj.Elements ) {
- promise = P.resolve( new BufferArray( BufferArray[ jsonObj.Type ], jsonObj.Elements, jsonObj.ItemSize ) );
-
- } else if ( jsonObj.Array ) {
-
- var buf = new BufferArray( BufferArray[ jsonObj.Type ] );
- buf.setItemSize( jsonObj.ItemSize );
-
- var vb, type;
- if ( jsonObj.Array.Float32Array ) {
- vb = jsonObj.Array.Float32Array;
- type = 'Float32Array';
- } else if ( jsonObj.Array.Uint16Array ) {
- vb = jsonObj.Array.Uint16Array;
- type = 'Uint16Array';
- } else if ( jsonObj.Array.Uint8Array ) {
- vb = jsonObj.Array.Uint8Array;
- type = 'Uint8Array';
- }
-
- if ( vb === undefined ) {
- Notify.warn( 'Typed Array ' + window.Object.keys( jsonObj.Array )[ 0 ] );
- return P.reject();
- }
-
- if ( vb.File ) {
- promise = this.initializeBufferArray( vb, type, buf );
- } else if ( vb.Elements ) {
- buf.setElements( new MACROUTILS[ type ]( vb.Elements ) );
- promise = P.resolve( buf );
- }
- }
-
- if ( uniqueID !== undefined ) {
- this._identifierMap[ uniqueID ] = promise;
- }
- return promise;
- },
-
- readUserDataContainer: function () {
- var jsonObj = this.getJSON();
- var osgjsObject;
- var uniqueID = jsonObj.UniqueID;
- if ( uniqueID !== undefined ) {
- osgjsObject = this._identifierMap[ uniqueID ];
- if ( osgjsObject !== undefined ) {
- return osgjsObject.Values;
- }
- }
-
- this._identifierMap[ uniqueID ] = jsonObj;
- return jsonObj.Values;
- },
-
- readPrimitiveSet: function () {
- var jsonObj = this.getJSON();
- var uniqueID;
- var osgjsObject;
-
- var defer = P.defer();
- var obj, mode, first, count;
- var drawElementPrimitive = jsonObj.DrawElementUShort || jsonObj.DrawElementUByte || jsonObj.DrawElementUInt || jsonObj.DrawElementsUShort || jsonObj.DrawElementsUByte || jsonObj.DrawElementsUInt || undefined;
- if ( drawElementPrimitive ) {
-
- uniqueID = drawElementPrimitive.UniqueID;
- if ( uniqueID !== undefined ) {
- osgjsObject = this._identifierMap[ uniqueID ];
- if ( osgjsObject !== undefined ) {
- return osgjsObject;
- }
- }
-
- var jsonArray = drawElementPrimitive.Indices;
- var prevJson = jsonObj;
-
- mode = drawElementPrimitive.Mode;
- if ( !mode ) {
- mode = PrimitiveSet.TRIANGLES;
- } else {
- mode = PrimitiveSet[ mode ];
- }
- obj = new DrawElements( mode );
-
- this.setJSON( jsonArray );
- this.readBufferArray().then( function ( array ) {
- obj.setIndices( array );
- defer.resolve( obj );
- } ).catch( function () {
- Notify.warn( 'Error buffer array' );
- } );
- this.setJSON( prevJson );
- }
-
- var drawArrayPrimitive = jsonObj.DrawArray || jsonObj.DrawArrays;
- if ( drawArrayPrimitive ) {
-
- uniqueID = drawArrayPrimitive.UniqueID;
- if ( uniqueID !== undefined ) {
- osgjsObject = this._identifierMap[ uniqueID ];
- if ( osgjsObject !== undefined ) {
- return osgjsObject;
- }
- }
-
- mode = drawArrayPrimitive.Mode || drawArrayPrimitive.mode;
- first = drawArrayPrimitive.First !== undefined ? drawArrayPrimitive.First : drawArrayPrimitive.first;
- count = drawArrayPrimitive.Count !== undefined ? drawArrayPrimitive.Count : drawArrayPrimitive.count;
- var drawArray = new DrawArrays( PrimitiveSet[ mode ], first, count );
- defer.resolve( drawArray );
- }
-
- var drawArrayLengthsPrimitive = jsonObj.DrawArrayLengths || undefined;
- if ( drawArrayLengthsPrimitive ) {
-
- uniqueID = drawArrayLengthsPrimitive.UniqueID;
- if ( uniqueID !== undefined ) {
- osgjsObject = this._identifierMap[ uniqueID ];
- if ( osgjsObject !== undefined ) {
- return osgjsObject;
- }
- }
-
- mode = drawArrayLengthsPrimitive.Mode;
- first = drawArrayLengthsPrimitive.First;
- var array = drawArrayLengthsPrimitive.ArrayLengths;
- var drawArrayLengths = new DrawArrayLengths( PrimitiveSet[ mode ], first, array );
- defer.resolve( drawArrayLengths );
- }
-
- if ( uniqueID !== undefined ) {
- this._identifierMap[ uniqueID ] = defer.promise;
- }
-
- return defer.promise;
- },
-
-
- readObject: function () {
-
- var jsonObj = this.getJSON();
- var prop = window.Object.keys( jsonObj )[ 0 ];
- if ( !prop ) {
- Notify.warn( 'can\'t find property for object ' + jsonObj );
- return P.reject();
- }
-
- var uniqueID = jsonObj[ prop ].UniqueID;
- var osgjsObject;
- if ( uniqueID !== undefined ) {
- osgjsObject = this._identifierMap[ uniqueID ];
- if ( osgjsObject !== undefined ) {
- return osgjsObject;
- }
- }
-
- var obj = this.getObjectWrapper( prop );
-
- if ( !obj ) {
- Notify.warn( 'can\'t instanciate object ' + prop );
- return P.reject();
- }
-
- var ReaderParser = require( 'osgDB/readerParser' );
- var scope = ReaderParser.ObjectWrapper.serializers;
-
- if ( this._cacheReadObject[ prop ] ) {
- scope = this._cacheReadObject[ prop ];
- } else {
-
- var splittedPath = prop.split( '.' );
- for ( var i = 0, l = splittedPath.length; i < l; i++ ) {
- var reader = scope[ splittedPath[ i ] ];
- if ( reader === undefined ) {
- Notify.warn( 'can\'t find function to read object ' + prop + ' - undefined' );
- return P.reject();
- }
- scope = reader;
- }
- this._cacheReadObject[ prop ] = scope;
- }
-
- var promise = scope( this.setJSON( jsonObj[ prop ] ), obj );
-
- if ( uniqueID !== undefined ) {
- this._identifierMap[ uniqueID ] = promise;
- obj._uniqueID = uniqueID;
- }
-
- return promise;
- }
-};
-
-module.exports = Input;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/Registry.js b/app/static/app/js/vendor/osgjs/osgDB/Registry.js
deleted file mode 100644
index 03703a98..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/Registry.js
+++ /dev/null
@@ -1,33 +0,0 @@
-'use strict';
-
-var Notify = require( 'osg/notify' );
-
-/**
- * This is a very simplistic version of the OSG registry, we could
- * expand/improve it in the future
- */
-
-var Registry = {
-
- instance: function () {
- if ( !Registry._instance ) {
- Registry._instance = Registry;
- Registry._instance.plugins = new window.Map();
- }
- return Registry._instance;
- },
-
- // We register directly a plugin for a extension.
- addReaderWriter: function ( extension, plugin ) {
- if ( Registry.instance().plugins.get( extension ) !== undefined )
- Notify.warn( 'the \'' + extension + '\' plugin already exists' );
- Registry.instance().plugins.set( extension, plugin );
- },
-
- getReaderWriterForExtension: function ( name ) {
- return Registry.instance().plugins.get( name );
- }
-};
-
-
-module.exports = Registry;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/options.js b/app/static/app/js/vendor/osgjs/osgDB/options.js
deleted file mode 100644
index 0c31ad63..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/options.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-var defaultOptions = {
-
- // prefix to built url to load resource
- prefixURL: '',
-
- // database URL for PagedLOD structures
- databasePath: '',
-
- // callback used when loading data
- progressXHRCallback: undefined,
-
- // replacement of readImageURL to use your own code to load Nodes
- // the function will be execute in the context of Input, see Input:readNodeURL
- readNodeURL: undefined,
-
- // replacement of readImageURL to use your own code to load osg.Image
- // the function will be execute in the context of Input, see Input:readImageURL
- readImageURL: undefined,
-
- // replacement of readBinaryArrayURL to use your own code to load binary array
- // the function will be execute in the context of Input, see Input:readBinaryArrayURL
- readBinaryArrayURL: undefined,
-
- imageLoadingUsePromise: true, // use promise to load image instead of returning Image
- imageOnload: undefined, // use callback when loading an image
- imageCrossOrigin: undefined // use callback when loading an image
-};
-
-module.exports = defaultOptions;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/osgDB.js b/app/static/app/js/vendor/osgjs/osgDB/osgDB.js
deleted file mode 100644
index 24868fd6..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/osgDB.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Input = require( 'osgDB/Input' );
-var ReaderParser = require( 'osgDB/readerParser' );
-var DatabasePager = require( 'osgDB/DatabasePager' );
-var osgWrappers = require( 'osgWrappers/serializers/osg' );
-var osgAnimationWrappers = require( 'osgWrappers/serializers/osgAnimation' );
-var osgTextWrappers = require( 'osgWrappers/serializers/osgText' );
-var Registry = require( 'osgDB/Registry' );
-
-
-var osgDB = {};
-osgDB.Input = Input;
-MACROUTILS.objectMix( osgDB, ReaderParser );
-osgDB.DatabasePager = DatabasePager;
-osgDB.ObjectWrapper.serializers.osg = osgWrappers;
-osgDB.ObjectWrapper.serializers.osgAnimation = osgAnimationWrappers;
-osgDB.ObjectWrapper.serializers.osgText = osgTextWrappers;
-osgDB.Registry = Registry;
-osgDB.requestFile = require( 'osgDB/requestFile' );
-
-var zlib = require( 'osgDB/zlib' );
-MACROUTILS.objectMix( osgDB, zlib );
-
-module.exports = osgDB;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/readerParser.js b/app/static/app/js/vendor/osgjs/osgDB/readerParser.js
deleted file mode 100644
index be68ba68..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/readerParser.js
+++ /dev/null
@@ -1,269 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var Uniform = require( 'osg/Uniform' );
-var BlendFunc = require( 'osg/BlendFunc' );
-var Geometry = require( 'osg/Geometry' );
-var BufferArray = require( 'osg/BufferArray' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var DrawArrays = require( 'osg/DrawArrays' );
-var DrawElements = require( 'osg/DrawElements' );
-var StateSet = require( 'osg/StateSet' );
-var Node = require( 'osg/Node' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var Projection = require( 'osg/Projection' );
-var Registry = require( 'osgDB/Registry' );
-
-var ReaderParser = {};
-
-ReaderParser.ObjectWrapper = {};
-ReaderParser.ObjectWrapper.serializers = {};
-
-ReaderParser.readImage = function ( url, options ) {
- return ReaderParser.registry().readImageURL( url, options );
-};
-ReaderParser.readImageURL = ReaderParser.readImage; // alias
-
-ReaderParser.readBinaryArrayURL = function ( url, options ) {
- return ReaderParser.registry().readBinaryArrayURL( url, options );
-};
-
-ReaderParser.readNodeURL = function ( url, options ) {
- var extension = url.substr( url.lastIndexOf( '.' ) + 1 );
- var readerWriter = Registry.instance().getReaderWriterForExtension( extension );
- if ( readerWriter !== undefined )
- return readerWriter.readNodeURL( url, options );
- // If we don't have a registered plugin go through the osgjs
- // FIXME: we should have osgjs also as a plugin in the future
- return ReaderParser.registry().readNodeURL( url, options );
-};
-
-ReaderParser.registry = function () {
- var Input = require( 'osgDB/Input' );
- if ( ReaderParser.registry._input === undefined ) {
- ReaderParser.registry._input = new Input();
- }
- return ReaderParser.registry._input;
-};
-
-ReaderParser.parseSceneGraph = function ( node, options ) {
- if ( node.Version !== undefined && node.Version > 0 ) {
- MACROUTILS.time( 'osgjs.metric:ReaderParser.parseSceneGraph' );
-
- var getPropertyValue = function ( o ) {
- var props = window.Object.keys( o );
- for ( var i = 0, l = props.length; i < l; i++ ) {
- if ( props[ i ] !== 'Generator' && props[ i ] !== 'Version' ) {
- return props[ i ];
- }
- }
- return undefined;
- };
-
- var key = getPropertyValue( node );
- if ( key ) {
- var obj = {};
- obj[ key ] = node[ key ];
- var input = ReaderParser.registry().clone();
- input.setJSON( obj );
-
- // copy global options and override with user options
- var opt = MACROUTILS.objectMix( MACROUTILS.objectMix( {}, ReaderParser.registry().getOptions() ), options || {} );
- input.setOptions( opt );
- var object = input.readObject();
- MACROUTILS.timeEnd( 'osgjs.metric:ReaderParser.parseSceneGraph' );
- return object;
- } else {
- Notify.log( 'can\'t parse scenegraph ' + node );
- }
- } else {
- MACROUTILS.time( 'osgjs.metric:ReaderParser.parseSceneGraphDeprecated' );
- var nodeOld = ReaderParser.parseSceneGraphDeprecated( node );
- MACROUTILS.timeEnd( 'osgjs.metric:ReaderParser.parseSceneGraphDeprecated' );
- return nodeOld;
- }
- return undefined;
-};
-
-ReaderParser.parseSceneGraphDeprecated = function ( node ) {
- var getFieldBackwardCompatible = function ( field, json ) {
- var value = json[ field ];
- if ( value === undefined ) {
- value = json[ field.toLowerCase() ];
- }
- return value;
- };
- var setName = function ( osgjs, json ) {
- var name = getFieldBackwardCompatible( 'Name', json );
- if ( name && osgjs.setName !== undefined ) {
- osgjs.setName( name );
- }
- };
-
- var setMaterial = function ( osgjs, json ) {
- setName( osgjs, json );
- osgjs.setAmbient( getFieldBackwardCompatible( 'Ambient', json ) );
- osgjs.setDiffuse( getFieldBackwardCompatible( 'Diffuse', json ) );
- osgjs.setEmission( getFieldBackwardCompatible( 'Emission', json ) );
- osgjs.setSpecular( getFieldBackwardCompatible( 'Specular', json ) );
- osgjs.setShininess( getFieldBackwardCompatible( 'Shininess', json ) );
- };
-
- var setBlendFunc = function ( osgjs, json ) {
- setName( osgjs, json );
- osgjs.setSourceRGB( json.SourceRGB );
- osgjs.setSourceAlpha( json.SourceAlpha );
- osgjs.setDestinationRGB( json.DestinationRGB );
- osgjs.setDestinationAlpha( json.DestinationAlpha );
- };
-
- var setTexture = function ( osgjs, json ) {
- var magFilter = json.MagFilter || json[ 'mag_filter' ] || undefined;
- if ( magFilter ) {
- osgjs.setMagFilter( magFilter );
- }
- var minFilter = json.MinFilter || json[ 'min_filter' ] || undefined;
- if ( minFilter ) {
- osgjs.setMinFilter( minFilter );
- }
- var wrapT = json.WrapT || json[ 'wrap_t' ] || undefined;
- if ( wrapT ) {
- osgjs.setWrapT( wrapT );
- }
- var wrapS = json.WrapS || json[ 'wrap_s' ] || undefined;
- if ( wrapS ) {
- osgjs.setWrapS( wrapS );
- }
- var file = getFieldBackwardCompatible( 'File', json );
- ReaderParser.readImage( file ).then( function ( img ) {
- osgjs.setImage( img );
- } ).catch( function () {
- Notify.log( 'Can\'t read image' );
- } );
- };
-
- var setStateSet = function ( osgjs, json ) {
- setName( osgjs, json );
- var textures = getFieldBackwardCompatible( 'Textures', json ) || getFieldBackwardCompatible( 'TextureAttributeList', json ) || undefined;
- if ( textures ) {
- for ( var t = 0, tl = textures.length; t < tl; t++ ) {
- var file = getFieldBackwardCompatible( 'File', textures[ t ] );
- if ( !file ) {
- Notify.log( 'no texture on unit ' + t + ' skip it' );
- continue;
- }
- var Texture = require( 'osg/Texture' );
- var tex = new Texture();
- setTexture( tex, textures[ t ] );
-
- osgjs.setTextureAttributeAndModes( t, tex );
- osgjs.addUniform( Uniform.createInt1( t, 'Texture' + t ) );
- }
- }
-
- var blendfunc = getFieldBackwardCompatible( 'BlendFunc', json );
- if ( blendfunc ) {
- var newblendfunc = new BlendFunc();
- setBlendFunc( newblendfunc, blendfunc );
- osgjs.setAttributeAndModes( newblendfunc );
- }
-
- var material = getFieldBackwardCompatible( 'Material', json );
- if ( material ) {
- var Material = require( 'osg/Material' );
- var newmaterial = new Material();
- setMaterial( newmaterial, material );
- osgjs.setAttributeAndModes( newmaterial );
- }
- };
-
-
- var newnode;
- var children = node.children;
- var primitives = node.primitives || node.Primitives || undefined;
- var attributes = node.attributes || node.Attributes || undefined;
- if ( primitives || attributes ) {
-
- var geom = new Geometry();
- setName( geom, node );
- geom.stateset = node.stateset;
- node = geom;
-
- for ( var p = 0, lp = primitives.length; p < lp; p++ ) {
- var mode = primitives[ p ].mode;
- if ( primitives[ p ].indices ) {
- var array = primitives[ p ].indices;
- array = new BufferArray( BufferArray[ array.type ], array.elements, array.itemSize );
- if ( !mode ) {
- mode = 'TRIANGLES';
- } else {
- mode = PrimitiveSet[ mode ];
- }
- geom.getPrimitiveSetList().push( new DrawElements( mode, array ) );
- } else {
- mode = PrimitiveSet[ mode ];
- var first = primitives[ p ].first;
- var count = primitives[ p ].count;
-
- geom.getPrimitiveSetList().push( new DrawArrays( mode, first, count ) );
- }
- }
-
- var attrKeys = window.Object.keys( attributes );
- for ( var i = 0, li = attrKeys.length; i < li; i++ ) {
- var key = attrKeys[ i ];
- var attributeArray = attributes[ key ];
- geom.getVertexAttributeList()[ key ] = new BufferArray( attributeArray.type, attributeArray.elements, attributeArray.itemSize );
- }
-
- }
-
- var stateset = getFieldBackwardCompatible( 'StateSet', node );
- if ( stateset ) {
- var newstateset = new StateSet();
- setStateSet( newstateset, stateset );
- node.stateset = newstateset;
- }
-
- var matrix = node.matrix || node.Matrix || undefined;
- if ( matrix ) {
- newnode = new MatrixTransform();
- setName( newnode, node );
-
- MACROUTILS.extend( newnode, node );
- mat4.copy( newnode.getMatrix(), matrix );
- node = newnode;
- }
-
- var projection = node.projection || node.Projection || undefined;
- if ( projection ) {
- newnode = new Projection();
- setName( newnode, node );
- MACROUTILS.extend( newnode, node );
- mat4.copy( newnode.setProjectionMatrix(), projection );
- node = newnode;
- }
-
- // default type
- if ( node.typeID === undefined ) {
- newnode = new Node();
- setName( newnode, node );
- MACROUTILS.extend( newnode, node );
- node = newnode;
- }
-
-
- if ( children ) {
- // disable children, it will be processed in the end
- node.children = [];
-
- for ( var child = 0, childLength = children.length; child < childLength; child++ ) {
- node.addChild( ReaderParser.parseSceneGraphDeprecated( children[ child ] ) );
- }
- }
-
- return node;
-};
-
-module.exports = ReaderParser;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/requestFile.js b/app/static/app/js/vendor/osgjs/osgDB/requestFile.js
deleted file mode 100644
index d132c418..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/requestFile.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var P = require( 'bluebird' );
-
-var requestFile = function ( url, options ) {
-
- var defer = P.defer();
-
- var req = new XMLHttpRequest();
- req.open( 'GET', url, true );
-
- // handle responseType
- if ( options && options.responseType )
- req.responseType = options.responseType;
-
- if ( options && options.progress ) {
- req.addEventListener( 'progress', options.progress, false );
- }
-
- req.addEventListener( 'error', function () {
- defer.reject();
- }, false );
-
- req.addEventListener( 'load', function () {
-
- if ( req.responseType === 'arraybuffer' || req.responseType === 'blob' )
- defer.resolve( req.response );
- else
- defer.resolve( req.responseText );
-
- } );
-
- req.send( null );
- return defer.promise;
-};
-
-module.exports = requestFile;
diff --git a/app/static/app/js/vendor/osgjs/osgDB/zlib.js b/app/static/app/js/vendor/osgjs/osgDB/zlib.js
deleted file mode 100644
index 8a83e5ac..00000000
--- a/app/static/app/js/vendor/osgjs/osgDB/zlib.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var notify = require( 'osg/notify' );
-
-var isBufferGZIP = function ( arrayBuffer ) {
- var typedArray = new Uint8Array( arrayBuffer );
- return ( typedArray[ 0 ] === 0x1f && typedArray[ 1 ] === 0x8b );
-};
-
-var gunzip = function ( arrayBuffer ) {
-
- var typedArray = new Uint8Array( arrayBuffer );
- var zlib = require( 'zlib' );
-
- if ( !zlib ) {
- notify.error( 'osg failed to use a gunzip.min.js to uncompress a gz file.\n You can add this vendors to enable this feature or get it at https://github.com/imaya/zlib.js/blob/master/bin/gunzip.min.js' );
- }
-
- var zdec = new zlib.Gunzip( typedArray );
- var result = zdec.decompress();
- return result.buffer;
-
-};
-
-module.exports = {
- isGunzipBuffer: isBufferGZIP,
- gunzip: gunzip
-};
diff --git a/app/static/app/js/vendor/osgjs/osgGA/CADManipulator.js b/app/static/app/js/vendor/osgjs/osgGA/CADManipulator.js
deleted file mode 100644
index 2e094ba6..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/CADManipulator.js
+++ /dev/null
@@ -1,544 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Manipulator = require( 'osgGA/Manipulator' );
-var OrbitManipulator = require( 'osgGA/OrbitManipulator' );
-var IntersectionVisitor = require( 'osgUtil/IntersectionVisitor' );
-var LineSegmentIntersector = require( 'osgUtil/LineSegmentIntersector' );
-var PolytopeIntersector = require( 'osgUtil/PolytopeIntersector' );
-var ComputeMatrixFromNodePath = require( 'osg/computeMatrixFromNodePath' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec2 = require( 'osg/glMatrix' ).vec2;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var quat = require( 'osg/glMatrix' ).quat;
-var CADManipulatorStandardMouseKeyboardController = require( 'osgGA/CADManipulatorStandardMouseKeyboardController' );
-var CADManipulatorHammerController = require( 'osgGA/CADManipulatorHammerController' );
-
-/**
- * CADManipulator
- * @class Provides a manipulator with rotation and zoom capacities around a pivot point.
- * The pivot point is computed through intersections. If no intersection is computed
- * the manipulator uses the last computed pivot point.
- * - Mousewheel/Pinch zooms in and out on the pivot point.
- * - Double click/tap zooms in on the pivot point.
- * - Left click/pan rotates around the pivot point.
- * - Center/Right click or two-finger drag moves the view.
- * - Spacebar resets the view.
- */
-
-var CADManipulator = function () {
- Manipulator.call( this );
- this._tmpHomePosition = vec3.create();
- this._intersectionVisitor = new IntersectionVisitor();
- this._lineSegmentIntersector = new LineSegmentIntersector();
- this._polytopeIntersector = undefined;
- this._usePolytopeIntersector = false;
- this._dimensionMask = ( 1 << 2 );
- this.init();
-};
-
-CADManipulator.Interpolator = function () {
- this._current = vec2.create();
- this._target = vec2.create();
- this._delta = vec2.create();
- this._reset = false;
- this.reset();
- this._width = undefined;
- this._height = undefined;
-};
-
-CADManipulator.Interpolator.prototype = {
- setWidth: function ( width ) {
- this._width = width;
- },
- setHeight: function ( height ) {
- this._height = height;
- },
- reset: function () {
- for ( var i = 0, l = this._current.length; i < l; i++ ) {
- this._current[ i ] = this._target[ i ] = 0;
- }
- this._reset = true;
- },
- update: function () {
- var d0;
- var d1;
- if ( this._width === undefined ) d0 = 0;
- else d0 = ( this._target[ 0 ] - this._current[ 0 ] ) / this._width;
- this._delta[ 0 ] = d0;
- this._current[ 0 ] = this._target[ 0 ];
- if ( this._height === undefined ) d1 = 0;
- else d1 = ( this._target[ 1 ] - this._current[ 1 ] ) / this._height;
- this._delta[ 1 ] = d1;
- this._current[ 1 ] = this._target[ 1 ];
- return this._delta;
- },
- set: function () {
- for ( var i = 0, l = this._current.length; i < l; i++ ) {
- this._current[ i ] = this._target[ i ] = arguments[ i ];
- }
- this._reset = false;
- },
- isReset: function () {
- return this._reset;
- },
- getCurrent: function () {
- return this._current;
- },
- setTarget: function () {
- for ( var i = 0, l = this._target.length; i < l; i++ ) {
- if ( this._reset ) {
- this._target[ i ] = this._current[ i ] = arguments[ i ];
- } else {
- this._target[ i ] = arguments[ i ];
- }
- }
- this._reset = false;
- },
- addTarget: function () {
- for ( var i = 0; i < arguments.length; i++ ) {
- this._target[ i ] += arguments[ i ];
- }
- },
- getTarget: function () {
- return this._target;
- },
- getDelta: function () {
- return this._delta;
- }
-};
-
-CADManipulator.AvailableControllerList = [ 'StandardMouseKeyboard', 'Hammer' ];
-CADManipulator.ControllerList = [ 'StandardMouseKeyboard', 'Hammer' ];
-
-/** @lends CADManipulator.prototype */
-CADManipulator.prototype = MACROUTILS.objectInherit( Manipulator.prototype, {
- init: function () {
- this._distance = 25.0;
- this._target = vec3.create();
- this._upz = vec3.fromValues( 0.0, 0.0, 1.0 );
- this._right = vec3.fromValues( 1.0, 0.0, 0.0 );
-
- vec3.init( this._target );
-
- var rot1 = mat4.fromRotation( mat4.create(), -Math.PI, this._upz );
- var rot2 = mat4.fromRotation( mat4.create(), Math.PI / 10.0, this._right );
- this._rotation = mat4.create();
- mat4.mul( this._rotation, rot1, rot2 );
- this._time = 0.0;
-
- this._rotate = new CADManipulator.Interpolator();
- this._pan = new CADManipulator.Interpolator();
- this._zoom = new OrbitManipulator.Interpolator( 1 );
-
- this._panFactor = 1.5;
- this._rotateFactor = 1;
- this._zoomFactor = 1;
-
- this._inverseMatrix = mat4.create();
-
- this._homeEye = undefined;
- this._homeCenter = undefined;
- this._homeUp = vec3.fromValues( 0.0, 0.0, 1.0 );
-
- this._orientation = quat.create();
- this._pivotPoint = vec3.create();
-
- this._eye = undefined;
-
-
- this._zoomDir = vec3.create();
-
- // instance of controller
- var self = this;
-
- CADManipulator.ControllerList.forEach( function ( value ) {
- if ( CADManipulator[ value ] !== undefined ) {
- self._controllerList[ value ] = new CADManipulator[ value ]( self );
- }
- } );
- },
-
- setViewer: function ( viewer ) {
- this._viewer = viewer;
- },
-
- reset: function () {
- this.init();
- },
-
- setNode: function ( node ) {
- this._node = node;
- },
-
- setPivotPoint: function ( pivotPoint ) {
- // First calculate offset
- vec3.copy( this._pivotPoint, pivotPoint );
- },
-
- setTarget: ( function () {
- var eyePos = vec3.create();
- return function ( target ) {
- vec3.copy( this._target, target );
- this.getEyePosition( eyePos );
- this._distance = vec3.distance( target, eyePos );
- };
- } )(),
-
- setEyePosition: function ( eye ) {
- vec3.copy( this._eye, eye );
- this._distance = vec3.distance( this._target, eye );
- },
-
- setHomePosition: function ( eye, center, up ) {
- this._homeEye = eye;
- this._homeCenter = center;
- this._homeUp = up;
- },
-
- computeHomePosition: ( function () {
- var f = vec3.create();
- var s = vec3.create();
- var u = vec3.create();
- var result = mat4.create();
- return function ( boundStrategy ) {
-
- var bs = this.getHomeBound( boundStrategy );
- if ( !bs ) return;
-
- this.setDistance( this.getHomeDistance( bs ) );
- this.setTarget( bs.center() );
- this.setPivotPoint( bs.center() );
-
- if ( this._homeEye === undefined ) {
- this._homeEye = vec3.create();
- this.getEyePosition( this._homeEye );
- }
-
- if ( this._homeCenter === undefined ) {
- this._homeCenter = vec3.create();
- vec3.copy( this._homeCenter, bs.center() );
- }
-
- if ( this._eye === undefined ) {
- this._eye = vec3.create();
- }
-
- vec3.copy( this._eye, this._homeEye );
- vec3.copy( this._target, this._homeCenter );
- vec3.copy( this._upz, this._homeUp );
-
- mat4.copy( result, this._rotation );
- var center = this._target;
- var eye = this._eye;
-
- vec3.sub( f, center, eye );
- vec3.normalize( f, f );
-
- vec3.cross( s, f, this._upz );
- vec3.normalize( s, s );
-
- vec3.cross( u, s, f );
- vec3.normalize( u, u );
-
- // s[0], f[0], u[0], 0.0,
- // s[1], f[1], u[1], 0.0,
- // s[2], f[2], u[2], 0.0,
- // 0, 0, 0, 1.0
- result[ 0 ] = s[ 0 ];
- result[ 1 ] = u[ 0 ];
- result[ 2 ] = -f[ 0 ];
- result[ 3 ] = 0.0;
- result[ 4 ] = s[ 1 ];
- result[ 5 ] = u[ 1 ];
- result[ 6 ] = -f[ 1 ];
- result[ 7 ] = 0.0;
- result[ 8 ] = s[ 2 ];
- result[ 9 ] = u[ 2 ];
- result[ 10 ] = -f[ 2 ];
- result[ 11 ] = 0.0;
- result[ 12 ] = 0;
- result[ 13 ] = 0;
- result[ 14 ] = 0;
- result[ 15 ] = 1.0;
-
- mat4.getRotation( this._orientation, result );
- quat.invert( this._orientation, this._orientation );
- };
- } )(),
-
- setZoomFactor: function ( f ) {
- this._zoomFactor = f;
- },
-
- setRotateFactor: function ( f ) {
- this._rotateFactor = f;
- },
-
- setPanFactor: function ( f ) {
- this._panFactor = f;
- },
-
- setDistance: function ( d ) {
- this._distance = d;
- },
-
- // If set to true, intersections are computed against points and lines
- setUsePolytopeIntersector: function ( upi ) {
- this._usePolytopeIntersector = upi;
- },
-
- getUsePolytopeIntersector: function () {
- return this._usePolytopeIntersector;
- },
-
- getDistance: function () {
- return this._distance;
- },
-
- zoom: function ( ratio ) {
- this._distance = ratio;
- },
-
- getRotateInterpolator: function () {
- return this._rotate;
- },
-
- getPanInterpolator: function () {
- return this._pan;
- },
-
- getZoomInterpolator: function () {
- return this._zoom;
- },
-
- getIntersectionVisitor: function () {
- return this._intersectionVisitor;
- },
-
- getLineSegmentIntersector: function () {
- return this._lineSegmentIntersector;
- },
-
- getOrCreatePolytopeIntersector: function () {
- if ( this._polytopeIntersector === undefined ) {
- this._polytopeIntersector = new PolytopeIntersector();
- this._polytopeIntersector.setIntersectionLimit( PolytopeIntersector.LIMIT_ONE_PER_DRAWABLE );
- this._polytopeIntersector.setDimensionMask( PolytopeIntersector.DimZero | PolytopeIntersector.DimOne );
- }
- return this._polytopeIntersector;
- },
-
- getTarget: function ( target ) {
- vec3.copy( target, this._target );
- return target;
- },
-
- getEyePosition: function ( eye ) {
- if ( this._eye === undefined )
- this.computeEyePosition( this._target, this._distance, eye );
- else vec3.copy( eye, this._eye );
- },
-
- computeEyePosition: ( function () {
- var tmpDist = vec3.create();
- var tmpInverse = mat4.create();
- return function ( target, distance, eye ) {
- mat4.invert( tmpInverse, this._rotation );
- tmpDist[ 1 ] = distance;
- vec3.transformMat4( eye, tmpDist, tmpInverse );
- vec3.add( eye, target, eye );
- };
- } )(),
-
- computePan: ( function () {
- var trans = vec3.create();
- var rotPos = vec3.create();
- var speedTmp = vec3.create();
- return function ( dx, dy, rotMat ) {
- var speed = vec3.length( vec3.sub( speedTmp, this._eye, this._pivotPoint ) ) / this._panFactor;
- if ( speed < 10 ) speed = 10;
- trans[ 0 ] = dx * speed / 2;
- trans[ 1 ] = dy * speed / 2;
- trans[ 2 ] = 0;
- vec3.transformMat4( rotPos, trans, rotMat );
- vec3.add( this._eye, this._eye, rotPos );
- };
- } )(),
-
- computeZoom: ( function () {
- var vectorDistance = vec3.create();
- var speedDist = vec3.create();
- return function ( dz ) {
- var zoomSpeed = dz * this._zoomFactor;
- vec3.sub( vectorDistance, this._pivotPoint, this._eye );
- vec3.add( this._eye, this._eye, vec3.scale( speedDist, vectorDistance, zoomSpeed ) );
- };
- } )(),
-
- computeRotation: ( function () {
-
- var rightNormalized = vec3.create();
- var right = vec3.create();
- var dir = vec3.create();
- var offset = vec3.create();
- var pitchQuat = quat.create();
- var yawQuat = quat.create();
- var pitchyawQuat = quat.create();
- var tmp = vec3.create();
- var rightScalar = vec3.create();
-
- return function ( yawDelta, pitchDelta ) {
-
- vec3.transformQuat( right, this._right, this._orientation );
- vec3.normalize( rightNormalized, right );
- vec3.sub( dir, this._eye, this._pivotPoint );
- var scalar = vec3.dot( rightNormalized, dir );
- vec3.sub( offset, dir, vec3.scale( rightScalar, rightNormalized, scalar ) );
- var xy = vec3.fromValues( -offset[ 0 ], -offset[ 1 ], 0 );
-
- var positionPitch = Math.atan2( -offset[ 2 ], vec3.length( xy ) );
- pitchDelta = Math.max( -Math.PI / 2 + 0.01, Math.min( Math.PI / 2 - 0.01, ( positionPitch + pitchDelta ) ) ) - positionPitch;
-
- quat.setAxisAngle( pitchQuat, right, pitchDelta * this._rotateFactor );
- quat.setAxisAngle( yawQuat, this._upz, yawDelta * this._rotateFactor );
-
- quat.mul( pitchyawQuat, yawQuat, pitchQuat );
- vec3.transformQuat( tmp, dir, pitchyawQuat );
- vec3.add( this._eye, tmp, this._pivotPoint );
-
- // Find rotation offset and target
- quat.mul( this._orientation, yawQuat, this._orientation );
-
- vec3.transformQuat( right, this._right, this._orientation );
- quat.setAxisAngle( pitchQuat, right, pitchDelta * this._rotateFactor );
- quat.mul( this._orientation, pitchQuat, this._orientation );
- };
- } )(),
-
-
- update: ( function () {
- var rotMat = mat4.create();
- var transMat = mat4.create();
- return function ( nv ) {
-
- var dt = nv.getFrameStamp().getDeltaTime();
-
- var mouseFactor = 10;
- //Note inverted y
- var delta = this._rotate.update();
- this.computeRotation( -delta[ 0 ] * mouseFactor, delta[ 1 ] * mouseFactor );
- mat4.fromQuat( rotMat, this._orientation );
-
- var deltapan = this._pan.update();
- this.computePan( -deltapan[ 0 ] * mouseFactor, -deltapan[ 1 ] * mouseFactor, rotMat );
-
- delta = this._zoom.update( dt );
- this.computeZoom( -delta[ 0 ] / 10.0 );
-
- mat4.fromTranslation( transMat, this._eye );
- mat4.mul( this._inverseMatrix, transMat, rotMat );
- mat4.invert( this._inverseMatrix, this._inverseMatrix );
- };
- } )(),
- getInverseMatrix: function () {
- return this._inverseMatrix;
- },
-
- computeIntersections: ( function () {
- var hits = [];
- var pTrans = vec3.create();
- return function ( pos ) {
- var viewer = this._camera.getView();
-
- var cam = this._camera;
- var width = cam.getViewport().width();
- var height = cam.getViewport().height();
- this._rotate.setWidth( width );
- this._rotate.setHeight( height );
- this._pan.setWidth( width );
- this._pan.setHeight( height );
-
- var point, matrix;
- if ( ( this._dimensionMask & ( 1 << 2 ) ) !== 0 ) {
- hits = viewer.computeIntersections( pos[ 0 ], pos[ 1 ] );
-
- if ( hits.length > 0 ) {
- point = hits[ 0 ].point;
- hits[ 0 ].nodepath.shift();
- matrix = ComputeMatrixFromNodePath.computeLocalToWorld( hits[ 0 ].nodepath );
- vec3.transformMat4( pTrans, point, matrix );
- this.setPivotPoint( pTrans );
- }
- }
-
- if ( hits.length === 0 && this._usePolytopeIntersector ) {
- var pi = this.getOrCreatePolytopeIntersector();
- pi.reset();
- pi.setPolytopeFromWindowCoordinates( pos[ 0 ] - 5, pos[ 1 ] - 5, pos[ 0 ] + 5, pos[ 1 ] + 5 );
- var iv = this._intersectionVisitor;
- iv.setIntersector( pi );
- viewer.getCamera().accept( iv );
- hits = pi.getIntersections();
- hits.sort( function ( a, b ) {
- return a._distance - b._distance;
- } );
- if ( hits.length > 0 ) {
- point = hits[ 0 ]._center;
- hits[ 0 ].nodePath.shift();
- matrix = ComputeMatrixFromNodePath.computeLocalToWorld( hits[ 0 ].nodePath );
- vec3.transformMat4( pTrans, point, matrix );
- this.setPivotPoint( pTrans );
- }
- }
- };
- } )(),
-
- getPositionRelativeToCanvas: ( function () {
- var offset = vec2.create();
- var pos = vec2.create();
- return function ( x, y ) {
- var canvas = this._camera._graphicContext.canvas;
- this.getOffsetRect( canvas, offset );
- var ratioX = canvas.width / canvas.clientWidth;
- var ratioY = canvas.height / canvas.clientHeight;
- pos[ 0 ] = ( x - offset[ 1 ] ) * ratioX;
- pos[ 1 ] = ( canvas.clientHeight - ( y - offset[ 0 ] ) ) * ratioY;
- return pos;
- };
- } )(),
-
- getCanvasCenter: ( function () {
- var offset = vec2.create();
- var pos = vec2.create();
- return function () {
- var canvas = this._camera.getGraphicContext().canvas;
- this.getOffsetRect( canvas, offset );
- var ratioX = canvas.width / canvas.clientWidth;
- var ratioY = canvas.height / canvas.clientHeight;
- pos[ 0 ] = ( canvas.clientWidth / 2 ) * ratioX;
- pos[ 1 ] = ( canvas.clientHeight / 2 ) * ratioY;
- return pos;
- };
- } )(),
-
- getOffsetRect: function ( elem, offset ) {
- var box = elem.getBoundingClientRect();
- var body = document.body;
- var docElem = document.documentElement;
- var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
- var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
- var clientTop = docElem.clientTop || body.clientTop || 0;
- var clientLeft = docElem.clientLeft || body.clientLeft || 0;
- var top = box.top + scrollTop - clientTop;
- var left = box.left + scrollLeft - clientLeft;
- offset[ 0 ] = Math.round( top );
- offset[ 1 ] = Math.round( left );
- return offset;
- }
-
-} );
-
-CADManipulator.StandardMouseKeyboard = CADManipulatorStandardMouseKeyboardController;
-CADManipulator.Hammer = CADManipulatorHammerController;
-
-module.exports = CADManipulator;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/CADManipulatorHammerController.js b/app/static/app/js/vendor/osgjs/osgGA/CADManipulatorHammerController.js
deleted file mode 100644
index f8eabc4e..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/CADManipulatorHammerController.js
+++ /dev/null
@@ -1,204 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-
-var CADManipulatorHammerController = function ( manipulator ) {
- this._manipulator = manipulator;
- this._timer = false;
- this.init();
-};
-
-CADManipulatorHammerController.prototype = {
- init: function () {
- this._panFactorX = 1.0;
- this._panFactorY = -this._panFactorX;
-
- this._rotateFactorX = 0.6;
- this._rotateFactorY = -this._rotateFactorX;
- this._zoomFactor = 5.0;
-
- this._lastScale = 0;
- this._nbPointerLast = 0; // to check if we the number of pointers has changed
-
- this._lastPos = undefined; // to set the pivot for rotation
- },
- setEventProxy: function ( proxy ) {
- if ( proxy === undefined || ( proxy !== undefined && proxy === this._eventProxy ) ) {
- return;
- }
- this._eventProxy = proxy;
- var self = this;
- var hammer = proxy;
- var computeTouches = function ( event ) {
- if ( event.pointers !== undefined )
- return event.pointers.length;
- return 1; // mouse
- };
-
- var dragCB = function ( ev ) {
- return 'touches ' + computeTouches( ev ) + ' distance ' + ev.distance + ' x ' + ev.deltaX + ' y ' + ev.deltaY;
- };
- // Set a minimal thresold on pinch event, to be detected after pan
- hammer.get( 'pinch' ).set( {
- threshold: 0.1
- } );
- // Let the pan be detected with two fingers.
- hammer.get( 'pan' ).set( {
- threshold: 0,
- pointers: 0
- } );
- hammer.get( 'pinch' ).recognizeWith( hammer.get( 'pan' ) );
-
- hammer.get( 'tap' ).set( {
- taps: 2,
- posThreshold: 300
- } );
-
- this._cbPanStart = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || self._transformStarted || event.pointerType === 'mouse' ) {
- return;
- }
- var gesture = event;
- self._dragStarted = true;
- self._nbPointerLast = computeTouches( gesture );
-
- var pos;
- if ( self._nbPointerLast === 2 ) {
- pos = manipulator.getPositionRelativeToCanvas( event.center.x, event.center.y );
- self._lastPos = pos;
- } else {
- if ( self._lastPos === undefined ) {
- pos = manipulator.getCanvasCenter();
- } else {
- pos = self._lastPos;
- }
- }
-
- manipulator.computeIntersections( pos );
-
- if ( self._nbPointerLast === 2 ) {
- manipulator.getPanInterpolator().reset();
- manipulator.getPanInterpolator().set( event.center.x * self._panFactorX, event.center.y * self._panFactorY );
- } else {
- manipulator.getRotateInterpolator().reset();
- }
- Notify.debug( 'drag start, ' + dragCB( gesture ) );
- };
-
- this._cbPanMove = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || !self._dragStarted || event.pointerType === 'mouse' ) {
- return;
- }
- var gesture = event;
- var nbPointers = computeTouches( gesture );
-
- // prevent sudden big changes in the event.center variables
- if ( self._nbPointerLast !== nbPointers ) {
- if ( nbPointers === 2 ) manipulator.getPanInterpolator().reset();
- else manipulator.getRotateInterpolator().reset();
- self._nbPointerLast = nbPointers;
- }
-
- if ( nbPointers === 2 ) {
- manipulator.getPanInterpolator().setTarget( event.center.x * self._panFactorX, event.center.y * self._panFactorY );
- Notify.debug( 'pan, ' + dragCB( gesture ) );
- } else {
- manipulator.getRotateInterpolator().setTarget( event.center.x * self._rotateFactorX, event.center.y * self._rotateFactorY );
- Notify.debug( 'rotate, ' + dragCB( gesture ) );
- }
- };
-
- this._cbPanEnd = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || !self._dragStarted || event.pointerType === 'mouse' ) {
- return;
- }
- self._dragStarted = false;
- var gesture = event;
- Notify.debug( 'drag end, ' + dragCB( gesture ) );
- };
-
- this._cbPinchStart = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || event.pointerType === 'mouse' ) {
- return;
- }
- self._transformStarted = true;
- var gesture = event;
-
- self._lastScale = gesture.scale;
- manipulator.getZoomInterpolator().reset();
- manipulator.getZoomInterpolator().set( self._lastScale );
- event.preventDefault();
-
- Notify.debug( 'zoom start, ' + dragCB( gesture ) );
- };
-
- this._cbPinchEnd = function ( event ) {
- if ( event.pointerType === 'mouse' ) {
- return;
- }
- self._transformStarted = false;
- Notify.debug( 'zoom end, ' + dragCB( event ) );
- };
-
- this._cbPinchInOut = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || !self._transformStarted || event.pointerType === 'mouse' ) {
- return;
- }
- var gesture = event;
-
- // make the dezoom faster
- var zoomFactor = gesture.scale > self._lastScale ? self._zoomFactor : self._zoomFactor * 4.0;
- var scale = ( gesture.scale - self._lastScale ) * zoomFactor;
- self._lastScale = gesture.scale;
-
- manipulator.getZoomInterpolator().setTarget( manipulator.getZoomInterpolator().getTarget()[ 0 ] - scale );
-
- Notify.debug( 'zoom, ' + dragCB( gesture ) );
- };
-
- this._cbDoubleTap = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || event.pointerType === 'mouse' ) {
- return;
- }
- var gesture = event;
-
- var pos = manipulator.getPositionRelativeToCanvas( event.center.x, event.center.y );
- self._lastPos = pos;
-
- manipulator.getZoomInterpolator().set( 0.0 );
- var zoomTarget = manipulator.getZoomInterpolator().getTarget()[ 0 ] - 10; // Default interval 10
- manipulator.getZoomInterpolator().setTarget( zoomTarget );
-
- Notify.debug( 'tap, ' + dragCB( gesture ) );
- };
-
- hammer.on( 'panstart ', this._cbPanStart );
- hammer.on( 'panmove', this._cbPanMove );
- hammer.on( 'panend', this._cbPanEnd );
- hammer.on( 'pinchstart', this._cbPinchStart );
- hammer.on( 'pinchend', this._cbPinchEnd );
- hammer.on( 'pinchin pinchout', this._cbPinchInOut );
- hammer.on( 'tap', this._cbDoubleTap );
- },
- removeEventProxy: function ( proxy ) {
- if ( !proxy || !this._eventProxy )
- return;
- proxy.off( 'panstart ', this._cbPanStart );
- proxy.off( 'panmove', this._cbPanMove );
- proxy.off( 'panend', this._cbPanEnd );
- proxy.off( 'pinchstart', this._cbPinchStart );
- proxy.off( 'pinchend', this._cbPinchEnd );
- proxy.off( 'pinchin pinchout', this._cbPinchInOut );
- proxy.off( 'tap', this._cbDoubleTap );
- },
- setManipulator: function ( manipulator ) {
- this._manipulator = manipulator;
- }
-};
-
-module.exports = CADManipulatorHammerController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/CADManipulatorStandardMouseKeyboardController.js b/app/static/app/js/vendor/osgjs/osgGA/CADManipulatorStandardMouseKeyboardController.js
deleted file mode 100644
index 3fc7ac14..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/CADManipulatorStandardMouseKeyboardController.js
+++ /dev/null
@@ -1,186 +0,0 @@
-'use strict';
-var OrbitManipulator = require( 'osgGA/OrbitManipulator' );
-
-var CADManipulatorStandardMouseKeyboardController = function ( manipulator ) {
- this._manipulator = manipulator;
- this._timer = false;
- this.init();
-};
-
-CADManipulatorStandardMouseKeyboardController.prototype = {
- init: function () {
- this.releaseButton();
- this._rotateKey = 65; // a
- this._zoomKey = 83; // s
- this._panKey = 68; // d
- this._mode = undefined;
- },
- getMode: function () {
- return this._mode;
- },
- setMode: function ( mode ) {
- this._mode = mode;
- },
- setEventProxy: function ( proxy ) {
- this._eventProxy = proxy;
- },
- setManipulator: function ( manipulator ) {
- this._manipulator = manipulator;
- },
- setDimensionMask: function ( dimMask ) {
- this._dimensionMask = dimMask;
- },
-
- mousemove: function ( ev ) {
- if ( this._buttonup === true ) {
- return;
- }
-
- var manipulator = this._manipulator;
- var pos = manipulator.getPositionRelativeToCanvas( ev.clientX, ev.clientY );
-
- if ( isNaN( pos[ 0 ] ) === false && isNaN( pos[ 1 ] ) === false ) {
-
- var mode = this.getMode();
- if ( mode === OrbitManipulator.Rotate ) {
- manipulator.getRotateInterpolator().setTarget( pos[ 0 ], pos[ 1 ] );
-
- } else if ( mode === OrbitManipulator.Pan ) {
- manipulator.getPanInterpolator().setTarget( pos[ 0 ], pos[ 1 ] );
-
- } else if ( mode === OrbitManipulator.Zoom ) {
- var zoom = manipulator.getZoomInterpolator();
- manipulator.computeIntersections( pos );
-
- if ( zoom.isReset() ) {
- zoom.setStart( pos[ 1 ] );
- zoom.set( 0.0 );
- }
- var dy = pos[ 1 ] - zoom.getStart();
- zoom.setStart( pos[ 1 ] );
- var v = zoom.getTarget()[ 0 ];
- zoom.setTarget( v - dy / 20.0 );
- }
- }
-
- ev.preventDefault();
- },
- mousedown: function ( ev ) {
- var manipulator = this._manipulator;
- var mode = this.getMode();
- if ( mode === undefined ) {
- if ( ev.button === 0 ) {
- if ( ev.shiftKey ) {
- this.setMode( OrbitManipulator.Pan );
- } else if ( ev.ctrlKey ) {
- this.setMode( OrbitManipulator.Zoom );
- } else {
- this.setMode( OrbitManipulator.Rotate );
- }
- } else {
- this.setMode( OrbitManipulator.Pan );
- }
- }
-
- this.pushButton();
-
- //var pos = this.getPositionRelativeToCanvas( ev );
- var pos = manipulator.getPositionRelativeToCanvas( ev.clientX, ev.clientY );
- manipulator.computeIntersections( pos );
-
- mode = this.getMode();
- if ( mode === OrbitManipulator.Rotate ) {
- manipulator.getRotateInterpolator().reset();
- manipulator.getRotateInterpolator().set( pos[ 0 ], pos[ 1 ] );
- } else if ( mode === OrbitManipulator.Pan ) {
- manipulator.getPanInterpolator().reset();
- manipulator.getPanInterpolator().set( pos[ 0 ], pos[ 1 ] );
- } else if ( mode === OrbitManipulator.Zoom ) {
- manipulator.getZoomInterpolator().setStart( pos[ 1 ] );
- manipulator.getZoomInterpolator().set( 0.0 );
- }
- ev.preventDefault();
- },
- mouseup: function ( /*ev */) {
- this.releaseButton();
- this.setMode( undefined );
- },
- mousewheel: function ( ev, intDelta /*, deltaX, deltaY */ ) {
- var manipulator = this._manipulator;
- ev.preventDefault();
- var zoomTarget = manipulator.getZoomInterpolator().getTarget()[ 0 ] - intDelta;
- manipulator.getZoomInterpolator().setTarget( zoomTarget );
- var timer;
- if ( this._timer === false ) {
- this._timer = true;
- var that = this;
- clearTimeout( timer );
- timer = setTimeout( function () {
- that._timer = false;
- }, 200 );
- //var pos = this.getPositionRelativeToCanvas( ev );
- var pos = manipulator.getPositionRelativeToCanvas( ev.clientX, ev.clientY );
- manipulator.computeIntersections( pos );
- }
- },
-
- dblclick: function ( ev ) {
- var manipulator = this._manipulator;
- ev.preventDefault();
-
- manipulator.getZoomInterpolator().set( 0.0 );
- var zoomTarget = manipulator.getZoomInterpolator().getTarget()[ 0 ] - 10; // Default interval 10
- manipulator.getZoomInterpolator().setTarget( zoomTarget );
- //var pos = this.getPositionRelativeToCanvas( ev );
- var pos = manipulator.getPositionRelativeToCanvas( ev.clientX, ev.clientY );
- manipulator.computeIntersections( pos );
- },
-
- pushButton: function () {
- this._buttonup = false;
- },
- releaseButton: function () {
- this._buttonup = true;
- },
-
- keydown: function ( ev ) {
- if ( ev.keyCode === 32 ) {
- this._manipulator.computeHomePosition();
- ev.preventDefault();
-
- } else if ( ev.keyCode === this._panKey &&
- this.getMode() !== OrbitManipulator.Pan ) {
- this.setMode( OrbitManipulator.Pan );
- this._manipulator.getPanInterpolator().reset();
- this.pushButton();
- ev.preventDefault();
- } else if ( ev.keyCode === this._zoomKey &&
- this.getMode() !== OrbitManipulator.Zoom ) {
- this.setMode( OrbitManipulator.Zoom );
- this._manipulator.getZoomInterpolator().reset();
- this.pushButton();
- ev.preventDefault();
- } else if ( ev.keyCode === this._rotateKey &&
- this.getMode() !== OrbitManipulator.Rotate ) {
- this.setMode( OrbitManipulator.Rotate );
- this._manipulator.getRotateInterpolator().reset();
- this.pushButton();
- ev.preventDefault();
- }
-
- },
-
- keyup: function ( ev ) {
- if ( ev.keyCode === this._panKey ) {
- this.mouseup( ev );
- } else if ( ev.keyCode === this._rotateKey ) {
- this.mouseup( ev );
- } else if ( ev.keyCode === this._rotateKey ) {
- this.mouseup( ev );
- }
- this.setMode( undefined );
- },
-
-};
-
-module.exports = CADManipulatorStandardMouseKeyboardController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulator.js b/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulator.js
deleted file mode 100644
index e7907e8b..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulator.js
+++ /dev/null
@@ -1,290 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Manipulator = require( 'osgGA/Manipulator' );
-var OrbitManipulator = require( 'osgGA/OrbitManipulator' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var vec2 = require( 'osg/glMatrix' ).vec2;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var quat = require( 'osg/glMatrix' ).quat;
-var FirstPersonManipulatorDeviceOrientationController = require( 'osgGA/FirstPersonManipulatorDeviceOrientationController' );
-var FirstPersonManipulatorHammerController = require( 'osgGA/FirstPersonManipulatorHammerController' );
-var FirstPersonManipulatorWebVRController = require( 'osgGA/FirstPersonManipulatorWebVRController' );
-var FirstPersonManipulatorStandardMouseKeyboardController = require( 'osgGA/FirstPersonManipulatorStandardMouseKeyboardController' );
-
-
-/**
- * Authors:
- * Matt Fontaine
- * Cedric Pinson
- */
-
-/**
- * FirstPersonManipulator
- * @class
- */
-var FirstPersonManipulator = function ( boundStrategy ) {
- Manipulator.call( this, boundStrategy );
- this.init();
-};
-
-FirstPersonManipulator.AvailableControllerList = [ 'StandardMouseKeyboard', 'WebVR', 'DeviceOrientation', 'Hammer' ];
-FirstPersonManipulator.ControllerList = [ 'StandardMouseKeyboard', 'WebVR', 'DeviceOrientation', 'Hammer' ];
-
-FirstPersonManipulator.prototype = MACROUTILS.objectInherit( Manipulator.prototype, {
-
- computeHomePosition: function ( boundStrategy ) {
- var bs = this.getHomeBound( boundStrategy );
- if ( !bs || !bs.valid() ) return;
-
- this._distance = this.getHomeDistance( bs );
- var cen = bs.center();
- vec3.scale( this._eye, this._direction, -this._distance );
- vec3.add( this._eye, cen, this._eye );
- this.setTarget( cen );
- },
-
- init: function () {
- this._direction = vec3.fromValues( 0.0, 1.0, 0.0 );
- this._eye = vec3.fromValues( 0.0, 25.0, 10.0 );
- this._up = vec3.fromValues( 0.0, 0.0, 1.0 );
- this._distance = 1.0;
- this._forward = new OrbitManipulator.Interpolator( 1 );
- this._side = new OrbitManipulator.Interpolator( 1 );
- this._lookPosition = new OrbitManipulator.Interpolator( 2 );
-
- // direct pan interpolator (not based on auto-move)
- this._pan = new OrbitManipulator.Interpolator( 2 );
- this._zoom = new OrbitManipulator.Interpolator( 1 );
-
- this._stepFactor = 1.0; // meaning radius*stepFactor to move
- this._angleVertical = 0.0;
- this._angleHorizontal = 0.0;
-
- // tmp value use for computation
- this._tmpGetTargetDir = vec3.create();
-
- // vr controls
- this._vrEnable = false;
- this._vrRot = quat.create(); // absolute orientation
- this._vrPos = vec3.create(); // absolute position
- this._vrTrans = vec3.create(); // delta translation since last update
-
- var self = this;
-
- this._controllerList = {};
- FirstPersonManipulator.ControllerList.forEach( function ( value ) {
- if ( FirstPersonManipulator[ value ] !== undefined ) {
- self._controllerList[ value ] = new FirstPersonManipulator[ value ]( self );
- }
- } );
-
- },
-
- setDelay: function ( dt ) {
- this._forward.setDelay( dt );
- this._side.setDelay( dt );
- this._lookPosition.setDelay( dt );
- this._pan.setDelay( dt );
- this._zoom.setDelay( dt );
- },
-
- getEyePosition: function ( eye ) {
- eye[ 0 ] = this._eye[ 0 ];
- eye[ 1 ] = this._eye[ 1 ];
- eye[ 2 ] = this._eye[ 2 ];
- return eye;
- },
-
- setEyePosition: function ( eye ) {
- this._eye[ 0 ] = eye[ 0 ];
- this._eye[ 1 ] = eye[ 1 ];
- this._eye[ 2 ] = eye[ 2 ];
- return this;
- },
-
- getTarget: function ( pos ) {
- var dir = vec3.scale( this._tmpGetTargetDir, this._direction, this._distance );
- vec3.add( pos, this._eye, dir );
- return pos;
- },
-
- setTarget: function ( pos ) {
- var dir = this._tmpGetTargetDir;
- vec3.sub( dir, pos, this._eye );
- dir[ 2 ] = 0.0;
- vec3.normalize( dir, dir );
- this._angleHorizontal = Math.acos( dir[ 1 ] );
- if ( dir[ 0 ] < 0.0 ) {
- this._angleHorizontal = -this._angleHorizontal;
- }
- vec3.sub( dir, pos, this._eye );
- vec3.normalize( dir, dir );
-
- this._angleVertical = -Math.asin( dir[ 2 ] );
- vec3.copy( this._direction, dir );
- },
-
- getLookPositionInterpolator: function () {
- return this._lookPosition;
- },
- getSideInterpolator: function () {
- return this._side;
- },
- getForwardInterpolator: function () {
- return this._forward;
- },
- getPanInterpolator: function () {
- return this._pan;
- },
- getZoomInterpolator: function () {
- return this._zoom;
- },
- getRotateInterpolator: function () {
- // for compatibility with orbit hammer controllers
- return this._lookPosition;
- },
-
- computeRotation: ( function () {
- var first = mat4.create();
- var rotMat = mat4.create();
-
- var right = vec3.fromValues( 1.0, 0.0, 0.0 );
- var upy = vec3.fromValues( 0.0, 1.0, 0.0 );
- var upz = vec3.fromValues( 0.0, 0.0, 1.0 );
- var LIMIT = Math.PI * 0.5;
- return function ( dx, dy ) {
- this._angleVertical += dy * 0.01;
- this._angleHorizontal -= dx * 0.01;
- if ( this._angleVertical > LIMIT ) this._angleVertical = LIMIT;
- else if ( this._angleVertical < -LIMIT ) this._angleVertical = -LIMIT;
-
- if ( this._vrEnable ) {
- vec3.transformQuat( this._direction, upy, this._vrRot );
- vec3.normalize( this._direction, this._direction );
- vec3.transformQuat( this._up, upz, this._vrRot );
-
- } else {
- mat4.fromRotation( first, -this._angleVertical, right );
- mat4.fromRotation( rotMat, -this._angleHorizontal, upz );
- mat4.mul( rotMat, rotMat, first );
-
- vec3.transformMat4( this._direction, upy, rotMat );
- vec3.normalize( this._direction, this._direction );
- vec3.transformMat4( this._up, upz, rotMat );
- }
- };
- } )(),
- reset: function () {
- this.init();
- },
- setDistance: function ( d ) {
- this._distance = d;
- },
- getDistance: function () {
- return this._distance;
- },
- setStepFactor: function ( t ) {
- this._stepFactor = t;
- },
-
- computePosition: ( function () {
- var vec = vec2.create();
-
- return function ( dt ) {
- this._forward.update( dt );
- this._side.update( dt );
-
- // TDOO why check with epsilon ?
- var factor = this._distance < 1e-3 ? 1e-3 : this._distance;
-
- // see comment in orbitManipulator for fov modulation speed
- var proj = this._camera.getProjectionMatrix();
- var vFov = proj[ 15 ] === 1 ? 1.0 : 2.0 / proj[ 5 ];
-
- // time based displacement vector
- vec[ 0 ] = this._forward.getCurrent()[ 0 ];
- vec[ 1 ] = this._side.getCurrent()[ 0 ];
- var len2 = vec2.sqrLen( vec );
- if ( len2 > 1.0 ) vec2.scale( vec, vec, 1.0 / Math.sqrt( len2 ) );
-
- // direct displacement vectors
- var pan = this._pan.update( dt );
- var zoom = this._zoom.update( dt );
-
- var timeFactor = this._stepFactor * factor * vFov * dt;
- var directFactor = this._stepFactor * factor * vFov * 0.005;
-
- this.moveForward( vec[ 0 ] * timeFactor - zoom[ 0 ] * directFactor * 20.0 );
- this.strafe( vec[ 1 ] * timeFactor - pan[ 0 ] * directFactor );
- this.strafeVertical( -pan[ 1 ] * directFactor );
-
- if ( this._vrEnable ) {
- vec3.add( this._eye, this._eye, this._vrTrans );
- // in case setPoseVR skips some frame (possible if tracking is lost temporarily)
- vec3.init( this._vrTrans );
- }
- };
- } )(),
-
-
- update: ( function () {
- var tmpTarget = vec3.create();
-
- return function ( nv ) {
-
- var dt = nv.getFrameStamp().getDeltaTime();
-
- var delta = this._lookPosition.update( dt );
- this.computeRotation( -delta[ 0 ] * 0.5, -delta[ 1 ] * 0.5 );
- this.computePosition( dt );
-
- vec3.add( tmpTarget, this._eye, this._direction );
- mat4.lookAt( this._inverseMatrix, this._eye, tmpTarget, this._up );
-
- this._vrEnable = false; // setPoseVR is called on each frame
- };
- } )(),
-
- setPoseVR: function ( q, pos ) {
- this._vrEnable = true;
- quat.copy( this._vrRot, q );
- vec3.sub( this._vrTrans, pos, this._vrPos );
- vec3.copy( this._vrPos, pos );
- },
-
- moveForward: ( function () {
- var tmp = vec3.create();
- return function ( distance ) {
- vec3.normalize( tmp, this._direction );
- vec3.scale( tmp, tmp, distance );
- vec3.add( this._eye, this._eye, tmp );
- };
- } )(),
-
- strafe: ( function () {
- var tmp = vec3.create();
- return function ( distance ) {
- vec3.cross( tmp, this._direction, this._up );
- vec3.normalize( tmp, tmp );
- vec3.scale( tmp, tmp, distance );
- vec3.add( this._eye, this._eye, tmp );
- };
- } )(),
-
- strafeVertical: ( function () {
- var tmp = vec3.create();
- return function ( distance ) {
- vec3.normalize( tmp, this._up );
- vec3.scale( tmp, tmp, distance );
- vec3.add( this._eye, this._eye, tmp );
- };
- } )()
-
-} );
-
-FirstPersonManipulator.DeviceOrientation = FirstPersonManipulatorDeviceOrientationController;
-FirstPersonManipulator.Hammer = FirstPersonManipulatorHammerController;
-FirstPersonManipulator.WebVR = FirstPersonManipulatorWebVRController;
-FirstPersonManipulator.StandardMouseKeyboard = FirstPersonManipulatorStandardMouseKeyboardController;
-
-module.exports = FirstPersonManipulator;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorDeviceOrientationController.js b/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorDeviceOrientationController.js
deleted file mode 100644
index 1e7f245c..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorDeviceOrientationController.js
+++ /dev/null
@@ -1,143 +0,0 @@
-'use strict';
-var quat = require( 'osg/glMatrix' ).quat;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-var degtorad = Math.PI / 180.0; // Degree-to-Radian conversion
-
-var makeRotateFromEuler = function ( q, x, y, z, order ) {
-
- // http://www.mathworks.com/matlabcentral/fileexchange/
- // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
- // content/SpinCalc.m
-
- var c1 = Math.cos( x / 2 );
- var c2 = Math.cos( y / 2 );
- var c3 = Math.cos( z / 2 );
- var s1 = Math.sin( x / 2 );
- var s2 = Math.sin( y / 2 );
- var s3 = Math.sin( z / 2 );
-
- if ( order === 'XYZ' ) {
-
- q[ 0 ] = s1 * c2 * c3 + c1 * s2 * s3;
- q[ 1 ] = c1 * s2 * c3 - s1 * c2 * s3;
- q[ 2 ] = c1 * c2 * s3 + s1 * s2 * c3;
- q[ 3 ] = c1 * c2 * c3 - s1 * s2 * s3;
-
- } else if ( order === 'YXZ' ) {
-
- q[ 0 ] = s1 * c2 * c3 + c1 * s2 * s3;
- q[ 1 ] = c1 * s2 * c3 - s1 * c2 * s3;
- q[ 2 ] = c1 * c2 * s3 - s1 * s2 * c3;
- q[ 3 ] = c1 * c2 * c3 + s1 * s2 * s3;
-
- } else if ( order === 'ZXY' ) {
-
- q[ 0 ] = s1 * c2 * c3 - c1 * s2 * s3;
- q[ 1 ] = c1 * s2 * c3 + s1 * c2 * s3;
- q[ 2 ] = c1 * c2 * s3 + s1 * s2 * c3;
- q[ 3 ] = c1 * c2 * c3 - s1 * s2 * s3;
-
- } else if ( order === 'ZYX' ) {
-
- q[ 0 ] = s1 * c2 * c3 - c1 * s2 * s3;
- q[ 1 ] = c1 * s2 * c3 + s1 * c2 * s3;
- q[ 2 ] = c1 * c2 * s3 - s1 * s2 * c3;
- q[ 3 ] = c1 * c2 * c3 + s1 * s2 * s3;
-
- } else if ( order === 'YZX' ) {
-
- q[ 0 ] = s1 * c2 * c3 + c1 * s2 * s3;
- q[ 1 ] = c1 * s2 * c3 + s1 * c2 * s3;
- q[ 2 ] = c1 * c2 * s3 - s1 * s2 * c3;
- q[ 3 ] = c1 * c2 * c3 - s1 * s2 * s3;
-
- } else if ( order === 'XZY' ) {
-
- q[ 0 ] = s1 * c2 * c3 - c1 * s2 * s3;
- q[ 1 ] = c1 * s2 * c3 - s1 * c2 * s3;
- q[ 2 ] = c1 * c2 * s3 + s1 * s2 * c3;
- q[ 3 ] = c1 * c2 * c3 + s1 * s2 * s3;
-
- }
- return q;
-};
-
-
-var FirstPersonManipulatorDeviceOrientationController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-FirstPersonManipulatorDeviceOrientationController.computeQuaternion = ( function () {
-
- var screenTransform = quat.create();
- var worldTransform = quat.fromValues( -Math.sqrt( 0.5 ), 0.0, 0.0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
-
- // but on ios alpha is relative to the first question:
- //
- // http://www.html5rocks.com/en/tutorials/device/orientation/
- // For most browsers, alpha returns the compass heading, so when the device is pointed
- // north, alpha is zero. With Mobile Safari, alpha is based on the direction the
- // device was pointing when device orientation was first requested. The compass
- // heading is available in the webkitCompassHeading parameter.
-
- return function ( q, deviceOrientation, screenOrientation ) {
-
- var alpha = deviceOrientation.alpha * degtorad;
- var beta = deviceOrientation.beta * degtorad;
- var gamma = deviceOrientation.gamma * degtorad;
-
- // If the user goes in landscape mode, he rotates his device with a certain angle
- // around the Z axis counterclockwise and the DeviceOrientation contains this
- // rotation To compensate this, we apply a rotation of the same angle in the
- // opposite way
-
- var screenAngle = screenOrientation * degtorad;
-
- // alpha is heading -> X
- // beta -> Z Up
- // Gamma -> Y view direction
- makeRotateFromEuler( q, beta, alpha, -gamma, 'YXZ' );
- // equivalent to
- // var rotateX = mat4.fromRotation( mat4.create(), beta,[ 1,0,0 ] );
- // var rotateY = mat4.fromRotation( mat4.create(), alpha,[ 0,1,0 ] );
- // var rotateZ = mat4.fromRotation( mat4.create(), -gamma,[ 0,0,1 ] );
- // var result = mat4.create();
- // mat4.mul( result, rotateY, rotateX );
- // mat4.mul( result, result, rotateZ );
- // mat4.getRotation( q, result );
-
- var minusHalfAngle = -screenAngle / 2.0;
- screenTransform[ 1 ] = Math.sin( minusHalfAngle );
- screenTransform[ 3 ] = Math.cos( minusHalfAngle );
-
- quat.mul( q, q, screenTransform );
- quat.mul( q, q, worldTransform );
-
- var yTemp = q[ 1 ];
- q[ 1 ] = -q[ 2 ];
- q[ 2 ] = yTemp;
-
- return q;
- };
-
-} )();
-
-FirstPersonManipulatorDeviceOrientationController.prototype = {
-
- init: function () {
- this._stepFactor = 1.0; // meaning radius*stepFactor to move
- this._quat = quat.create();
- this._pos = vec3.create();
- },
-
- update: function ( deviceOrientation, screenOrientation ) {
-
- FirstPersonManipulatorDeviceOrientationController.computeQuaternion( this._quat, deviceOrientation, screenOrientation );
- this._manipulator.setPoseVR( this._quat, this._pos );
- }
-
-};
-
-module.exports = FirstPersonManipulatorDeviceOrientationController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorHammerController.js b/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorHammerController.js
deleted file mode 100644
index 24c5972f..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorHammerController.js
+++ /dev/null
@@ -1,5 +0,0 @@
-'use strict';
-var OrbitManipulatorHammerController = require( 'osgGA/OrbitManipulatorHammerController' );
-
-
-module.exports = OrbitManipulatorHammerController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorStandardMouseKeyboardController.js b/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorStandardMouseKeyboardController.js
deleted file mode 100644
index dadc84f8..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorStandardMouseKeyboardController.js
+++ /dev/null
@@ -1,105 +0,0 @@
-'use strict';
-
-var FirstPersonManipulatorStandardMouseKeyboardController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-FirstPersonManipulatorStandardMouseKeyboardController.prototype = {
- init: function () {
- this.releaseButton();
- this._delay = 0.15;
- this._stepFactor = 1.0; // meaning radius*stepFactor to move
- },
- setEventProxy: function ( proxy ) {
- this._eventProxy = proxy;
- },
- setManipulator: function ( manipulator ) {
- this._manipulator = manipulator;
-
- // we always want to sync speed of controller with manipulator
- this._manipulator.setStepFactor( this._stepFactor );
- },
-
- pushButton: function () {
- this._buttonup = false;
- },
- releaseButton: function () {
- this._buttonup = true;
- },
-
- mousedown: function ( ev ) {
- var pos = this._eventProxy.getPositionRelativeToCanvas( ev );
- var manipulator = this._manipulator;
- manipulator.getLookPositionInterpolator().set( pos[ 0 ], pos[ 1 ] );
- this.pushButton();
- },
- mouseup: function ( /*ev */) {
- this.releaseButton();
- },
- mouseout: function ( /*ev */) {
- this.releaseButton();
- },
- mousemove: function ( ev ) {
- if ( this._buttonup === true ) {
- return;
- }
-
- var pos = this._eventProxy.getPositionRelativeToCanvas( ev );
- this._manipulator.getLookPositionInterpolator().setDelay( this._delay );
- this._manipulator.getLookPositionInterpolator().setTarget( pos[ 0 ], pos[ 1 ] );
- },
- mousewheel: function ( ev, intDelta /*, deltaX, deltaY */ ) {
- ev.preventDefault();
- this._stepFactor = Math.min( Math.max( 0.001, this._stepFactor + intDelta * 0.01 ), 4.0 );
- this._manipulator.setStepFactor( this._stepFactor );
- },
-
- keydown: function ( event ) {
- var manipulator = this._manipulator;
- if ( event.keyCode === 32 ) {
- manipulator.computeHomePosition();
- event.preventDefault();
- } else if ( event.keyCode === 87 || event.keyCode === 90 || event.keyCode === 38 ) { // w/z/up
- manipulator.getForwardInterpolator().setDelay( this._delay );
- manipulator.getForwardInterpolator().setTarget( 1 );
- event.preventDefault();
- return false;
- } else if ( event.keyCode === 83 || event.keyCode === 40 ) { // S/down
- manipulator.getForwardInterpolator().setDelay( this._delay );
- manipulator.getForwardInterpolator().setTarget( -1 );
- event.preventDefault();
- return false;
- } else if ( event.keyCode === 68 || event.keyCode === 39 ) { // D/right
- manipulator.getSideInterpolator().setDelay( this._delay );
- manipulator.getSideInterpolator().setTarget( 1 );
- event.preventDefault();
- return false;
- } else if ( event.keyCode === 65 || event.keyCode === 81 || event.keyCode === 37 ) { // a/q/left
- manipulator.getSideInterpolator().setDelay( this._delay );
- manipulator.getSideInterpolator().setTarget( -1 );
- event.preventDefault();
- return false;
- }
- return undefined;
- },
-
- keyup: function ( event ) {
- var manipulator = this._manipulator;
- if ( event.keyCode === 87 || event.keyCode === 90 || event.keyCode === 38 || // w/z/up
- event.keyCode === 83 || event.keyCode === 40 ) { // S/down
- manipulator.getForwardInterpolator().setDelay( this._delay );
- manipulator.getForwardInterpolator().setTarget( 0 );
- return false;
- } else if ( event.keyCode === 68 || event.keyCode === 39 || // D/right
- event.keyCode === 65 || event.keyCode === 81 || event.keyCode === 37 ) { // a/q/left
- manipulator.getSideInterpolator().setDelay( this._delay );
- manipulator.getSideInterpolator().setTarget( 0 );
- return false;
- }
- return undefined;
- }
-
-};
-
-module.exports = FirstPersonManipulatorStandardMouseKeyboardController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorWebVRController.js b/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorWebVRController.js
deleted file mode 100644
index 706313f5..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/FirstPersonManipulatorWebVRController.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-var FirstPersonManipulatorWebVRController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-FirstPersonManipulatorWebVRController.prototype = {
- init: function () {},
- update: function ( q, position ) {
- this._manipulator.setPoseVR( q, position );
- }
-};
-
-module.exports = FirstPersonManipulatorWebVRController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/Manipulator.js b/app/static/app/js/vendor/osgjs/osgGA/Manipulator.js
deleted file mode 100644
index a626125b..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/Manipulator.js
+++ /dev/null
@@ -1,108 +0,0 @@
-'use strict';
-var BoundingSphere = require( 'osg/BoundingSphere' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Notify = require( 'osg/notify' );
-
-
-// Base class for Camera / User manipulator
-var Manipulator = function ( boundStrategy ) {
- this._boundStrategy = boundStrategy;
- if ( this._boundStrategy === undefined )
- this._boundStrategy = Manipulator.COMPUTE_HOME_USING_SPHERE;
-
- this._controllerList = {};
- this._inverseMatrix = mat4.create();
- this._camera = undefined;
- this._node = undefined;
- this._frustum = {};
- this._computeBoundNodeMaskOverride = ~0x0;
-};
-
-Manipulator.prototype = {
- setCamera: function ( c ) {
- this._camera = c;
- },
- getCamera: function () {
- return this._camera;
- },
- setNode: function ( node ) {
- this._node = node;
- },
- setComputeBoundNodeMaskOverride: function ( mask ) {
- this._computeBoundNodeMaskOverride = mask;
- },
- getComputeBoundNodeMaskOverride: function () {
- return this._computeBoundNodeMaskOverride;
- },
- getHomeBound: function ( overrideStrat ) {
- var node = this._node;
- if ( !node )
- return;
-
- var type = overrideStrat !== undefined ? overrideStrat : this._boundStrategy;
-
- if ( type === true || type === false ) {
- Notify.warn( 'Manipulator.getHomeBound with boolean is deprecated, pass a type instead' );
- type = type ? Manipulator.COMPUTE_HOME_USING_BBOX : Manipulator.COMPUTE_HOME_USING_SPHERE;
- }
-
- if ( type & Manipulator.COMPUTE_HOME_USING_BBOX ) {
- var bs = new BoundingSphere();
-
- var bb = null;
- if ( this._computeBoundNodeMaskOverride === ~0x0 ) {
- bb = node.getBoundingBox();
- } else {
- var ComputeBoundsVisitor = require( 'osg/ComputeBoundsVisitor' );
- var cbv = new ComputeBoundsVisitor();
- cbv.setNodeMaskOverride( this._computeBoundNodeMaskOverride );
- cbv.reset();
-
- cbv.apply( node );
- bb = cbv.getBoundingBox();
- }
-
- if ( bb.valid() )
- bs.expandByBoundingBox( bb );
-
- // minimum between sphere and box
- if ( type & Manipulator.COMPUTE_HOME_USING_SPHERE ) {
- var boundSphere = node.getBound();
- if ( boundSphere.radius() < bs.radius() )
- return boundSphere;
- }
-
- return bs;
- }
-
- return node.getBound();
- },
- getHomeDistance: function ( bs ) {
- var frustum = this._frustum;
- var dist = bs.radius();
- if ( this._camera && mat4.getFrustum( frustum, this._camera.getProjectionMatrix() ) ) {
- var vertical2 = Math.abs( frustum.right - frustum.left ) / frustum.zNear / 2;
- var horizontal2 = Math.abs( frustum.top - frustum.bottom ) / frustum.zNear / 2;
- dist /= Math.sin( Math.atan2( horizontal2 < vertical2 ? horizontal2 : vertical2, 1 ) );
- } else {
- dist *= 1.5;
- }
- return dist;
- },
- // eg: var currentTime = nv.getFrameStamp().getSimulationTime();
- update: function ( /*nv*/) {},
-
- getInverseMatrix: function () {
- return this._inverseMatrix;
- },
-
- getControllerList: function () {
- return this._controllerList;
- }
-};
-
-// flags
-Manipulator.COMPUTE_HOME_USING_SPHERE = 1 << 0;
-Manipulator.COMPUTE_HOME_USING_BBOX = 1 << 1;
-
-module.exports = Manipulator;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulator.js b/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulator.js
deleted file mode 100644
index e89ad9d0..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulator.js
+++ /dev/null
@@ -1,430 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Manipulator = require( 'osgGA/Manipulator' );
-var OrbitManipulatorDeviceOrientationController = require( 'osgGA/OrbitManipulatorDeviceOrientationController' );
-var OrbitManipulatorGamePadController = require( 'osgGA/OrbitManipulatorGamePadController' );
-var OrbitManipulatorHammerController = require( 'osgGA/OrbitManipulatorHammerController' );
-var OrbitManipulatorLeapMotionController = require( 'osgGA/OrbitManipulatorLeapMotionController' );
-var OrbitManipulatorStandardMouseKeyboardController = require( 'osgGA/OrbitManipulatorStandardMouseKeyboardController' );
-var OrbitManipulatorWebVRController = require( 'osgGA/OrbitManipulatorWebVRController' );
-
-
-/**
- * OrbitManipulator
- * @class
- */
-var OrbitManipulator = function ( boundStrategy ) {
- Manipulator.call( this, boundStrategy );
- this._homePosition = vec3.create();
- this._frustum = {};
- this.init();
-};
-
-OrbitManipulator.Interpolator = function ( size, delay ) {
- this._current = new Float32Array( size );
- this._target = new Float32Array( size );
- this._delta = new Float32Array( size );
- this._delay = ( delay !== undefined ) ? delay : 0.15;
- this._reset = false;
- this._start = 0.0;
- this.reset();
-};
-OrbitManipulator.Interpolator.prototype = {
- setDelay: function ( delay ) {
- this._delay = delay;
- },
- reset: function () {
- for ( var i = 0, l = this._current.length; i < l; i++ ) {
- this._current[ i ] = this._target[ i ] = 0.0;
- }
- this._reset = true;
- },
- update: function ( dt ) {
- // assume 60 fps to be consistent with the old _delay values for backward compatibility
- // (otherwise we'd have to adjust the _delay values by multiplying to 60 )
- var dtDelay = Math.min( 1.0, this._delay * dt * 60.0 );
- for ( var i = 0, l = this._current.length; i < l; i++ ) {
- var d = ( this._target[ i ] - this._current[ i ] ) * dtDelay;
- this._delta[ i ] = d;
- this._current[ i ] += d;
- }
- return this._delta;
- },
- set: function () {
- for ( var i = 0, l = this._current.length; i < l; i++ ) {
- this._current[ i ] = this._target[ i ] = arguments[ i ];
- }
- this._reset = false;
- },
- isReset: function () {
- return this._reset;
- },
- getCurrent: function () {
- return this._current;
- },
- setTarget: function () {
- for ( var i = 0, l = this._target.length; i < l; i++ ) {
- if ( this._reset ) {
- this._target[ i ] = this._current[ i ] = arguments[ i ];
- } else {
- this._target[ i ] = arguments[ i ];
- }
- }
- this._reset = false;
- },
- addTarget: function () {
- for ( var i = 0; i < arguments.length; i++ ) {
- this._target[ i ] += arguments[ i ];
- }
- },
- getTarget: function () {
- return this._target;
- },
- getDelta: function () {
- return this._delta;
- },
- getStart: function () {
- return this._start;
- },
- setStart: function ( start ) {
- this._start = start;
- }
-};
-
-OrbitManipulator.AvailableControllerList = [ 'StandardMouseKeyboard',
- 'LeapMotion',
- 'GamePad',
- 'Hammer',
- 'DeviceOrientation',
- 'WebVR'
-];
-
-OrbitManipulator.ControllerList = [ 'StandardMouseKeyboard',
- 'LeapMotion',
- 'GamePad',
- 'Hammer',
- 'DeviceOrientation',
- 'WebVR'
-];
-
-/** @lends OrbitManipulator.prototype */
-OrbitManipulator.prototype = MACROUTILS.objectInherit( Manipulator.prototype, {
- init: function () {
- this._distance = 25.0;
- this._target = vec3.create();
- this._upz = vec3.fromValues( 0.0, 0.0, 1.0 );
- vec3.init( this._target );
-
- var rot1 = mat4.fromRotation( mat4.create(), -Math.PI, this._upz );
- var rot2 = mat4.fromRotation( mat4.create(), Math.PI / 10.0, vec3.fromValues( 1.0, 0.0, 0.0 ) );
- this._rotation = mat4.create();
- mat4.mul( this._rotation, rot1, rot2 );
- this._time = 0.0;
-
- this._vrMatrix = mat4.create();
-
- this._rotate = new OrbitManipulator.Interpolator( 2 );
- this._pan = new OrbitManipulator.Interpolator( 2 );
- this._zoom = new OrbitManipulator.Interpolator( 1 );
-
- this._minSpeed = 1e-4; // set a limit to pan/zoom speed
- this._scaleMouseMotion = 1.0;
-
- this._inverseMatrix = mat4.create();
-
- // distance at which we start pushing the target (so that we can still zoom)
- // with a very low _limitZoomIn, it's like a fps manipulator as long as you don't unzoom
- this._autoPushTarget = true;
-
- // pitch range [-PI/2, PI/2]
- this._limitPitchUp = Math.PI * 0.5 * 0.9;
- this._limitPitchDown = -this._limitPitchUp;
-
- // yaw range [-PI, PI]
- this._limitYawLeft = -Math.PI;
- this._limitYawRight = -this._limitYawLeft;
-
- this._limitZoomIn = 1e-4;
- this._limitZoomOut = Infinity;
-
- // instance of controller
- var self = this;
-
- OrbitManipulator.ControllerList.forEach( function ( value ) {
- if ( OrbitManipulator[ value ] !== undefined ) {
- self._controllerList[ value ] = new OrbitManipulator[ value ]( self );
- }
- } );
- },
- setLimitPitchUp: function ( up ) {
- this._limitPitchUp = up;
- },
- setLimitPitchDown: function ( down ) {
- this._limitPitchDown = down;
- },
- setLimitYawLeft: function ( left ) {
- this._limitYawLeft = left;
- },
- setLimitYawRight: function ( right ) {
- this._limitYawRight = right;
- },
- setLimitZoomOut: function ( zoomOut ) {
- this._limitZoomOut = zoomOut;
- },
- setLimitZoomIn: function ( zoomIn ) {
- this._limitZoomIn = zoomIn;
- },
- setDelay: function ( dt ) {
- this._rotate.setDelay( dt );
- this._pan.setDelay( dt );
- this._zoom.setDelay( dt );
- },
- reset: function () {
- this.init();
- },
- setTarget: function ( target ) {
- vec3.copy( this._target, target );
- var eyePos = vec3.create();
- this.getEyePosition( eyePos );
- this._distance = vec3.distance( target, eyePos );
- },
- setEyePosition: ( function () {
- var f = vec3.create();
- var s = vec3.create();
- var u = vec3.create();
- return function ( eye ) {
- var result = this._rotation;
- var center = this._target;
-
- vec3.sub( f, eye, center );
- vec3.normalize( f, f );
-
- vec3.cross( s, f, this._upz );
- vec3.normalize( s, s );
-
- vec3.cross( u, s, f );
- vec3.normalize( u, u );
-
- // s[0], f[0], u[0], 0.0,
- // s[1], f[1], u[1], 0.0,
- // s[2], f[2], u[2], 0.0,
- // 0, 0, 0, 1.0
- result[ 0 ] = s[ 0 ];
- result[ 1 ] = f[ 0 ];
- result[ 2 ] = u[ 0 ];
- result[ 3 ] = 0.0;
- result[ 4 ] = s[ 1 ];
- result[ 5 ] = f[ 1 ];
- result[ 6 ] = u[ 1 ];
- result[ 7 ] = 0.0;
- result[ 8 ] = s[ 2 ];
- result[ 9 ] = f[ 2 ];
- result[ 10 ] = u[ 2 ];
- result[ 11 ] = 0.0;
- result[ 12 ] = 0;
- result[ 13 ] = 0;
- result[ 14 ] = 0;
- result[ 15 ] = 1.0;
-
- this._distance = vec3.distance( center, eye );
- };
- } )(),
-
- computeHomePosition: function ( boundStrategy ) {
-
- var bs = this.getHomeBound( boundStrategy );
- if ( !bs || !bs.valid() ) return;
-
- this.setDistance( this.getHomeDistance( bs ) );
- this.setTarget( bs.center() );
-
- },
-
- getHomePosition: function () {
-
- if ( this._node !== undefined ) {
-
- var target = this._target;
- var distance = this.getDistance();
-
- this.computeEyePosition( target, distance, this._homePosition );
- }
- return this._homePosition;
- },
-
- setMinSpeed: function ( s ) {
- this._minSpeed = s;
- },
- getMinSpeed: function () {
- return this._minSpeed;
- },
-
- setDistance: function ( d ) {
- this._distance = d;
- },
- getDistance: function () {
- return this._distance;
- },
-
- getSpeedFactor: function () {
- return Math.max( this._distance, this._minSpeed );
- },
- computePan: ( function () {
- var inv = mat4.create();
- var x = vec3.create();
- var y = vec3.create();
- return function ( dx, dy ) {
- var proj = this._camera.getProjectionMatrix();
- // modulate panning speed with verticalFov value
- // if it's an orthographic we don't change the panning speed
- // TODO : manipulators in osgjs don't support well true orthographic camera anyway because they
- // manage the view matrix (and you need to edit the projection matrix to 'zoom' for true ortho camera)
- var vFov = proj[ 15 ] === 1 ? 1.0 : 2.00 / proj[ 5 ];
- var speed = this.getSpeedFactor() * vFov;
- dy *= speed;
- dx *= speed;
-
- mat4.invert( inv, this._rotation );
- x[ 0 ] = inv[ 0 ];
- x[ 1 ] = inv[ 1 ];
- x[ 2 ] = inv[ 2 ];
- vec3.normalize( x, x );
-
- y[ 0 ] = inv[ 8 ];
- y[ 1 ] = inv[ 9 ];
- y[ 2 ] = inv[ 10 ];
- vec3.normalize( y, y );
-
- vec3.scale( x, x, -dx );
- vec3.scale( y, y, dy );
- vec3.add( this._target, this._target, x );
- vec3.add( this._target, this._target, y );
- };
- } )(),
- computeRotation: ( function () {
- var right = vec3.fromValues( 1.0, 0.0, 0.0 );
-
- return function ( dx, dy ) {
- var pitch = Math.atan( -this._rotation[ 6 ] / this._rotation[ 5 ] ) + dy / 10.0;
- pitch = Math.min( Math.max( pitch, this._limitPitchDown ), this._limitPitchUp );
-
- var yaw = Math.atan2( this._rotation[ 4 ], this._rotation[ 0 ] ) + dx / 10.0;
- if ( yaw > Math.PI ) yaw = yaw % Math.PI - Math.PI;
- else if ( yaw < -Math.PI ) yaw = yaw % Math.PI + Math.PI;
- yaw = Math.min( Math.max( yaw, this._limitYawLeft ), this._limitYawRight );
-
- mat4.fromRotation( this._rotation, -pitch, right );
- mat4.rotate( this._rotation, this._rotation, -yaw, this._upz );
- };
- } )(),
- computeZoom: function ( dz ) {
- this.zoom( dz );
- },
-
- setAutoPushTarget: function ( bool ) {
- this._autoPushTarget = bool;
- },
-
- zoom: ( function () {
- var dir = vec3.create();
- return function ( ratio ) {
- var newValue = this._distance + this.getSpeedFactor() * ( ratio - 1.0 );
-
- if ( this._autoPushTarget && newValue < this._limitZoomIn ) {
- // push the target instead of zooming on it
- vec3.sub( dir, this._target, this.getEyePosition( dir ) );
- vec3.normalize( dir, dir );
- vec3.scale( dir, dir, this._limitZoomIn - newValue );
- vec3.add( this._target, this._target, dir );
- }
-
- this._distance = Math.max( this._limitZoomIn, Math.min( this._limitZoomOut, newValue ) );
- };
- } )(),
-
- getRotateInterpolator: function () {
- return this._rotate;
- },
- getPanInterpolator: function () {
- return this._pan;
- },
- getZoomInterpolator: function () {
- return this._zoom;
- },
- getTarget: function ( target ) {
- return vec3.copy( target, this._target );
- },
- getEyePosition: function ( eye ) {
- this.computeEyePosition( this._target, this._distance, eye );
- return eye;
- },
-
- computeEyePosition: ( function () {
- var tmpDist = vec3.create();
- var tmpInverse = mat4.create();
- return function ( target, distance, eye ) {
- mat4.invert( tmpInverse, this._rotation );
- tmpDist[ 1 ] = distance;
- vec3.transformMat4( eye, tmpDist, tmpInverse );
- vec3.add( eye, target, eye );
- };
- } )(),
-
- update: ( function () {
- var eye = vec3.create();
- return function ( nv ) {
- var dt = nv.getFrameStamp().getDeltaTime();
-
- var delta;
- var mouseFactor = 0.1;
- delta = this._rotate.update( dt );
- this.computeRotation( -delta[ 0 ] * mouseFactor * this._scaleMouseMotion, -delta[ 1 ] * mouseFactor * this._scaleMouseMotion );
-
- var panFactor = 0.002;
- delta = this._pan.update( dt );
- this.computePan( -delta[ 0 ] * panFactor, -delta[ 1 ] * panFactor );
-
-
- delta = this._zoom.update( dt );
- this.computeZoom( 1.0 + delta[ 0 ] / 10.0 );
-
- var target = this._target;
- var distance = this._distance;
-
- /* 1. Works but bypass other manipulators */
- // mat4.copy( this._inverseMatrix , this._vrMatrix );
-
- /* 2. Works but gets broken by other manipulators */
- mat4.invert( this._inverseMatrix, this._rotation );
- mat4.mul( this._inverseMatrix, this._vrMatrix, this._inverseMatrix );
-
- /* 3. Doesnt' work */
- // mat4.mul( this._vrMatrix, this._vrMatrix, this._rotation );
- // mat4.invert( this._inverseMatrix, this._vrMatrix );
-
- vec3.set( eye, 0.0, distance, 0.0 );
- vec3.transformMat4( eye, eye, this._inverseMatrix );
-
- mat4.lookAt( this._inverseMatrix, vec3.add( eye, target, eye ), target, this._upz );
-
- };
- } )(),
-
- setPoseVR: function ( q /*, pos*/ ) {
- mat4.fromQuat( this._vrMatrix, q );
- // this._vrMatrix[ 12 ] = pos[ 0 ];
- // this._vrMatrix[ 13 ] = pos[ 1 ];
- // this._vrMatrix[ 14 ] = pos[ 2 ];
- }
-} );
-
-OrbitManipulator.DeviceOrientation = OrbitManipulatorDeviceOrientationController;
-OrbitManipulator.GamePad = OrbitManipulatorGamePadController;
-OrbitManipulator.Hammer = OrbitManipulatorHammerController;
-OrbitManipulator.LeapMotion = OrbitManipulatorLeapMotionController;
-OrbitManipulator.WebVR = OrbitManipulatorWebVRController;
-OrbitManipulator.StandardMouseKeyboard = OrbitManipulatorStandardMouseKeyboardController;
-
-module.exports = OrbitManipulator;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorDeviceOrientationController.js b/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorDeviceOrientationController.js
deleted file mode 100644
index dfe79fc8..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorDeviceOrientationController.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-var quat = require( 'osg/glMatrix' ).quat;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-var FirstPersonDeviceOrientation = require( 'osgGA/FirstPersonManipulatorDeviceOrientationController' );
-
-
-var OrbitManipulatorDeviceOrientationController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-OrbitManipulatorDeviceOrientationController.prototype = {
-
- init: function () {
- this._stepFactor = 1.0; // meaning radius*stepFactor to move
- this._quat = quat.create();
- this._pos = vec3.create();
- },
-
- update: function ( deviceOrientation, screenOrientation ) {
-
- // for now we use the same code in first person and orbit to compute rotation
- FirstPersonDeviceOrientation.computeQuaternion( this._quat, deviceOrientation, screenOrientation );
- this._manipulator.setPoseVR( this._quat, this._pos );
- }
-
-};
-
-module.exports = OrbitManipulatorDeviceOrientationController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorGamePadController.js b/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorGamePadController.js
deleted file mode 100644
index a299b19a..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorGamePadController.js
+++ /dev/null
@@ -1,113 +0,0 @@
-'use strict';
-var vec2 = require( 'osg/glMatrix' ).vec2;
-
-
-var OrbitManipulatorGamePadController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-OrbitManipulatorGamePadController.prototype = {
- init: function () {
- this._delay = 0.15;
- this._threshold = 0.08;
- this._mode = 0;
- this._padFactor = 10.0;
- this._zoomFactor = 0.5;
- this._rotateFactor = 5.0;
- },
-
-
- addPan: function ( pan, x, y ) {
- pan.setDelay( this._delay );
- pan.addTarget( x * this._padFactor, y * this._padFactor );
- },
-
- addZoom: function ( zoom, z ) {
- zoom.setDelay( this._delay );
- zoom.addTarget( z * this._zoomFactor );
- },
-
- addRotate: function ( rotate, x, y ) {
- rotate.setDelay( this._delay );
- //var rotateTarget = rotate.getTarget();
- rotate.addTarget( x * this._rotateFactor, y * this._rotateFactor );
- },
-
- gamepadaxes: function ( axes ) {
-
- // Block badly balanced controllers
- var AXIS_THRESHOLD = 0.005;
-
- //var rotateTarget, panTarget;
- var rotate = this._manipulator.getRotateInterpolator();
- var zoom = this._manipulator.getZoomInterpolator();
- var pan = this._manipulator.getPanInterpolator();
- // Regular gamepads
- if ( axes.length === 4 ) {
-
- if ( Math.abs( axes[ 0 ] ) > AXIS_THRESHOLD || Math.abs( axes[ 1 ] ) > AXIS_THRESHOLD ) {
- this.addRotate( rotate, -axes[ 0 ], axes[ 1 ] );
- }
- if ( Math.abs( axes[ 3 ] ) > AXIS_THRESHOLD ) {
- this.addZoom( zoom, -axes[ 3 ] );
- }
-
- //SpaceNavigator & 6-axis controllers
- } else if ( axes.length >= 5 ) {
- //Notify.log(axes);
- if ( Math.abs( axes[ 0 ] ) > AXIS_THRESHOLD || Math.abs( axes[ 1 ] ) > AXIS_THRESHOLD ) {
- this.addPan( pan, -axes[ 0 ], axes[ 1 ] );
- }
-
- if ( Math.abs( axes[ 2 ] ) > AXIS_THRESHOLD ) {
- this.addZoom( zoom, -axes[ 2 ] );
- }
-
- if ( Math.abs( axes[ 3 ] ) > AXIS_THRESHOLD || Math.abs( axes[ 4 ] ) > AXIS_THRESHOLD ) {
- this.addRotate( rotate, axes[ 4 ], axes[ 3 ] );
- }
- }
-
- },
-
- gamepadbuttondown: function ( event /*, pressed */ ) {
- // Buttons 12 to 15 are the d-pad.
- if ( event.button >= 12 && event.button <= 15 ) {
- var pan = this._manipulator.getPanInterpolator();
- var panTarget = pan.getTarget();
- var delta = {
- 12: vec2.fromValues( 0, -1 ),
- 13: vec2.fromValues( 0, 1 ),
- 14: vec2.fromValues( -1, 0 ),
- 15: vec2.fromValues( 1, 0 )
- }[ event.button ];
- pan.setDelay( this._delay );
- pan.setTarget( panTarget[ 0 ] - delta[ 0 ] * 10, panTarget[ 1 ] + delta[ 1 ] * 10 );
- }
- },
-
- update: function ( gm ) {
- if ( !gm ) {
- return;
- }
-
- var axis = gm.axes;
- var buttons = gm.buttons;
-
- this.gamepadaxes( axis );
-
- // Dummy event wrapper
- var emptyFunc = function () {};
- for ( var i = 0; i < buttons.length; i++ ) {
- if ( buttons[ i ] ) {
- this.gamepadbuttondown( {
- preventDefault: emptyFunc,
- gamepad: gm,
- button: i
- }, !!buttons[ i ] );
- }
- }
- }
-};
-module.exports = OrbitManipulatorGamePadController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorHammerController.js b/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorHammerController.js
deleted file mode 100644
index adc64564..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorHammerController.js
+++ /dev/null
@@ -1,162 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-
-
-var OrbitManipulatorHammerController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-OrbitManipulatorHammerController.prototype = {
- init: function () {
- this._panFactorX = 1.0;
- this._panFactorY = -this._panFactorX;
-
- this._rotateFactorX = 0.6;
- this._rotateFactorY = -this._rotateFactorX;
- this._zoomFactor = 5.0;
-
- this._lastScale = 0;
- this._nbPointerLast = 0; // to check if we the number of pointers has changed
- this._delay = 0.15;
- },
- setEventProxy: function ( proxy ) {
- if ( proxy === undefined || ( proxy !== undefined && proxy === this._eventProxy ) ) {
- return;
- }
- this._eventProxy = proxy;
- var self = this;
- var hammer = proxy;
- var computeTouches = function ( event ) {
- if ( event.pointers !== undefined )
- return event.pointers.length;
- return 1; // mouse
- };
-
- var dragCB = function ( ev ) {
- return 'touches ' + computeTouches( ev ) + ' distance ' + ev.distance + ' x ' + ev.deltaX + ' y ' + ev.deltaY;
- };
- // Set a minimal thresold on pinch event, to be detected after pan
- hammer.get( 'pinch' ).set( {
- threshold: 0.1
- } );
- // Let the pan be detected with two fingers.
- hammer.get( 'pan' ).set( {
- threshold: 0,
- pointers: 0
- } );
- hammer.get( 'pinch' ).recognizeWith( hammer.get( 'pan' ) );
-
- this._cbPanStart = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || self._transformStarted || event.pointerType === 'mouse' ) {
- return;
- }
- var gesture = event;
- self._dragStarted = true;
- self._nbPointerLast = computeTouches( gesture );
-
- if ( self._nbPointerLast === 2 ) {
- manipulator.getPanInterpolator().reset();
- manipulator.getPanInterpolator().set( event.center.x * self._panFactorX, event.center.y * self._panFactorY );
- } else {
- manipulator.getRotateInterpolator().reset();
- manipulator.getRotateInterpolator().set( event.center.x * self._rotateFactorX, event.center.y * self._rotateFactorY );
- }
- Notify.debug( 'drag start, ' + dragCB( gesture ) );
- };
-
- this._cbPanMove = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || !self._dragStarted || event.pointerType === 'mouse' ) {
- return;
- }
- var gesture = event;
- var nbPointers = computeTouches( gesture );
- // prevent sudden big changes in the event.center variables
- if ( self._nbPointerLast !== nbPointers ) {
- if ( nbPointers === 2 ) manipulator.getPanInterpolator().reset();
- else manipulator.getRotateInterpolator().reset();
- self._nbPointerLast = nbPointers;
- }
-
- if ( nbPointers === 2 ) {
- manipulator.getPanInterpolator().setTarget( event.center.x * self._panFactorX, event.center.y * self._panFactorY );
- Notify.debug( 'pan, ' + dragCB( gesture ) );
- } else {
- manipulator.getRotateInterpolator().setDelay( self._delay );
- manipulator.getRotateInterpolator().setTarget( event.center.x * self._rotateFactorX, event.center.y * self._rotateFactorY );
- Notify.debug( 'rotate, ' + dragCB( gesture ) );
- }
- };
-
- this._cbPanEnd = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || !self._dragStarted || event.pointerType === 'mouse' ) {
- return;
- }
- self._dragStarted = false;
- var gesture = event;
- Notify.debug( 'drag end, ' + dragCB( gesture ) );
- };
-
- this._cbPinchStart = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || event.pointerType === 'mouse' ) {
- return;
- }
- self._transformStarted = true;
- var gesture = event;
-
- self._lastScale = gesture.scale;
- manipulator.getZoomInterpolator().reset();
- manipulator.getZoomInterpolator().set( self._lastScale );
- event.preventDefault();
- Notify.debug( 'zoom start, ' + dragCB( gesture ) );
- };
-
- this._cbPinchEnd = function ( event ) {
- if ( event.pointerType === 'mouse' ) {
- return;
- }
- self._transformStarted = false;
- Notify.debug( 'zoom end, ' + dragCB( event ) );
- };
-
- this._cbPinchInOut = function ( event ) {
- var manipulator = self._manipulator;
- if ( !manipulator || !self._transformStarted || event.pointerType === 'mouse' ) {
- return;
- }
- var gesture = event;
- // make the dezoom faster
- var zoomFactor = gesture.scale > self._lastScale ? self._zoomFactor : self._zoomFactor * 4.0;
- var scale = ( gesture.scale - self._lastScale ) * zoomFactor;
- self._lastScale = gesture.scale;
-
- manipulator.getZoomInterpolator().setTarget( manipulator.getZoomInterpolator().getTarget()[ 0 ] - scale );
- Notify.debug( 'zoom, ' + dragCB( gesture ) );
- };
-
- hammer.on( 'panstart ', this._cbPanStart );
- hammer.on( 'panmove', this._cbPanMove );
- hammer.on( 'panend', this._cbPanEnd );
- hammer.on( 'pinchstart', this._cbPinchStart );
- hammer.on( 'pinchend', this._cbPinchEnd );
- hammer.on( 'pinchin pinchout', this._cbPinchInOut );
- },
- removeEventProxy: function ( proxy ) {
- if ( !proxy || !this._eventProxy )
- return;
- proxy.off( 'panstart ', this._cbPanStart );
- proxy.off( 'panmove', this._cbPanMove );
- proxy.off( 'panend', this._cbPanEnd );
- proxy.off( 'pinchstart', this._cbPinchStart );
- proxy.off( 'pinchend', this._cbPinchEnd );
- proxy.off( 'pinchin pinchout', this._cbPinchInOut );
- },
- setManipulator: function ( manipulator ) {
- this._manipulator = manipulator;
- }
-};
-module.exports = OrbitManipulatorHammerController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorLeapMotionController.js b/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorLeapMotionController.js
deleted file mode 100644
index c3c86c3a..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorLeapMotionController.js
+++ /dev/null
@@ -1,181 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec2 = require( 'osg/glMatrix' ).vec2;
-
-
-var OrbitManipulatorLeapMotionController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-var ModeConfig = {
- 'rotate': {
- dtx: -1.2 * 1.2,
- dty: -0.9 * 1.2,
- dtz: -0.1,
- delay: 0.05,
- method: 'getRotateInterpolator'
- },
- 'pan': {
- dtx: -1.2 * 1.2,
- dty: -0.9 * 1.2,
- delay: 0.05,
- method: 'getPanInterpolator'
- },
- 'zoom': {
- dtx: 0.0,
- dty: -0.5,
- delay: 0.05,
- method: 'getZoomInterpolator'
- },
- 'zoom-twohands': {
- dtx: -0.05,
- dty: 0.0,
- delay: 0.05,
- method: 'getZoomInterpolator'
- }
-};
-
-OrbitManipulatorLeapMotionController.prototype = {
- init: function () {
- this._virtualCursor = vec2.fromValues( 0.0, 0.0 );
- this._targetPosition = vec2.fromValues( 0.0, 0.0 );
- this._previousFrame = undefined;
- this._displacement = vec2.fromValues( 0.0, 0.0 );
- this._top = vec2.fromValues( 0.0, 1.0 );
- this._motion = vec2.fromValues( 0.0, 0.0 );
- this._delay = 0.05;
- this._threshold = 0.08;
- this._directionDotThreshold = 0.5;
- this._mode = 'rotate';
- },
-
- update: function ( frame ) {
- if ( !this._previousFrame ) {
- this._previousFrame = frame;
- }
-
- // no fingers ? return
- if ( frame.fingers.length === 0 ) {
- return;
- }
-
- var deltaFrame = this._previousFrame.translation( frame );
-
- this._previousFrame = frame;
-
- if ( frame.hands.length === 0 ) {
- return;
- }
-
- // filter noise
- if ( Math.abs( deltaFrame[ 0 ] ) < this._threshold &&
- Math.abs( deltaFrame[ 1 ] ) < this._threshold ) {
- return;
- }
-
- var mode = this._mode;
- var dist = 0;
-
- // scale is when there two hands with but with two hand with more than 1 fingers
- if ( frame.gestures.length > 0 ) {
- for ( var i = 0; i < frame.gestures.length; i++ ) {
- var gesture = frame.gestures[ i ];
- if ( gesture.type === 'circle' ) {
- this._manipulator.computeHomePosition();
- return;
- }
- }
- }
-
- if ( frame.hands.length === 1 ) {
- if ( frame.hands[ 0 ].fingers.length >= 3 ) {
- mode = 'zoom';
- dist = frame.hands[ 0 ].palmPosition[ 1 ] / 10.0;
- dist = Math.max( dist - 4, 0.01 );
-
- } else if ( frame.hands[ 0 ].fingers.length > 1 ) {
- mode = 'pan';
- } else {
- // by default onw hand moving means rotation
- mode = 'rotate';
- }
- } else if ( frame.hands.length === 2 ) {
- var d0 = Math.abs( vec3.dot( frame.hands[ 0 ].palmNormal, this._top ) ),
- d1 = Math.abs( vec3.dot( frame.hands[ 1 ].palmNormal, this._top ) );
-
- // two hands : zoom
- if ( d0 < this._directionDotThreshold && d1 < this._directionDotThreshold ) {
- mode = 'zoom-twohands';
- } else {
- // if hands flat do nothing
- mode = undefined;
- this._handsDistanceOld = undefined;
- }
- }
- var zoom = this._manipulator.getZoomInterpolator();
-
- if ( mode === undefined ) {
- return;
- }
- // change mode reset counter and skip this frame
- if ( mode !== this._mode ) {
- Notify.info( 'Switch to mode ' + mode );
-
- this._motion[ 0 ] = 0;
- this._motion[ 1 ] = 0;
- this._mode = mode;
-
- if ( mode === 'zoom' || mode === 'zoom-twohands' ) {
- if ( zoom.isReset() ) {
- zoom.setStart( 1.0 );
- zoom.set( 0.0 );
- }
- }
- return;
- }
-
- var dtx, dty, dtz;
- dtx = ModeConfig[ mode ].dtx;
- dty = ModeConfig[ mode ].dty;
- dtz = ModeConfig[ mode ].dtz;
-
- this._motion[ 0 ] += deltaFrame[ 0 ] * dtx;
- this._motion[ 1 ] += deltaFrame[ 1 ] * dty;
-
- var delay = ModeConfig[ mode ].delay;
-
- // we use the mode enum to get the good method
- var method = ModeConfig[ mode ].method;
- this._manipulator[ method ]().setDelay( delay );
-
- if ( mode === 'zoom' ) {
- Notify.log( dist );
- zoom.setTarget( dist );
- } else if ( mode === 'zoom-twohands' ) { // two hands zoom
- // distance between two hands
- var handsDistance = vec3.distance( frame.hands[ 1 ].palmPosition, frame.hands[ 0 ].palmPosition );
-
- if ( this._handsDistanceOld !== undefined ) {
- // compare distance with lastframe and zoom if they get nearer, unzoom if they separate
- var vel = dtx * ( handsDistance - this._handsDistanceOld );
-
- dist = zoom._target;
- dist[ 0 ] += vel;
- }
- this._handsDistanceOld = handsDistance;
- } else {
- if ( mode === 'rotate' ) {
- dist = zoom._target[ 0 ];
- dist += deltaFrame[ 2 ] * dtz;
- dist = Math.max( dist, 0.01 );
- zoom.setTarget( dist );
- }
- this._manipulator[ method ]().addTarget( this._motion[ 0 ], this._motion[ 1 ] );
- }
-
- this._motion[ 1 ] = this._motion[ 0 ] = 0;
- }
-};
-module.exports = OrbitManipulatorLeapMotionController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorStandardMouseKeyboardController.js b/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorStandardMouseKeyboardController.js
deleted file mode 100644
index 45f731db..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorStandardMouseKeyboardController.js
+++ /dev/null
@@ -1,163 +0,0 @@
-'use strict';
-var osgMath = require( 'osg/math' );
-var OrbitManipulatorEnums = require( 'osgGA/orbitManipulatorEnums' );
-
-
-var OrbitManipulatorStandardMouseKeyboardController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-OrbitManipulatorStandardMouseKeyboardController.prototype = {
- init: function () {
- this.releaseButton();
- this._rotateKey = 65; // a
- this._zoomKey = 83; // s
- this._panKey = 68; // d
-
- this._mode = undefined;
- this._delay = 0.15;
- },
- getMode: function () {
- return this._mode;
- },
- setMode: function ( mode ) {
- this._mode = mode;
- },
- setEventProxy: function ( proxy ) {
- this._eventProxy = proxy;
- },
- setManipulator: function ( manipulator ) {
- this._manipulator = manipulator;
- },
- mousemove: function ( ev ) {
- if ( this._buttonup === true ) {
- return;
- }
- var pos = this._eventProxy.getPositionRelativeToCanvas( ev );
- var manipulator = this._manipulator;
- if ( osgMath.isNaN( pos[ 0 ] ) === false && osgMath.isNaN( pos[ 1 ] ) === false ) {
-
- var mode = this.getMode();
- if ( mode === OrbitManipulatorEnums.ROTATE ) {
- manipulator.getRotateInterpolator().setDelay( this._delay );
- manipulator.getRotateInterpolator().setTarget( pos[ 0 ], pos[ 1 ] );
-
- } else if ( mode === OrbitManipulatorEnums.PAN ) {
- manipulator.getPanInterpolator().setTarget( pos[ 0 ], pos[ 1 ] );
-
- } else if ( mode === OrbitManipulatorEnums.ZOOM ) {
- var zoom = manipulator.getZoomInterpolator();
- if ( zoom.isReset() ) {
- zoom.setStart( pos[ 1 ] );
- zoom.set( 0.0 );
- }
- var dy = pos[ 1 ] - zoom.getStart();
- zoom.setStart( pos[ 1 ] );
- var v = zoom.getTarget()[ 0 ];
- zoom.setTarget( v - dy / 20.0 );
- }
- }
-
- ev.preventDefault();
- },
- mousedown: function ( ev ) {
- var manipulator = this._manipulator;
- var mode = this.getMode();
- if ( mode === undefined ) {
- if ( ev.button === 0 ) {
- if ( ev.shiftKey ) {
- this.setMode( OrbitManipulatorEnums.PAN );
- } else if ( ev.ctrlKey ) {
- this.setMode( OrbitManipulatorEnums.ZOOM );
- } else {
- this.setMode( OrbitManipulatorEnums.ROTATE );
- }
- } else {
- // For users on Mac machines for who CTRL+LeftClick is naturally converted
- // into a RightClick in Firefox.
- if ( ev.button === 2 && ev.ctrlKey ) {
- this.setMode( OrbitManipulatorEnums.ZOOM );
- } else {
- this.setMode( OrbitManipulatorEnums.PAN );
- }
- }
- }
-
- this.pushButton();
-
- var pos = this._eventProxy.getPositionRelativeToCanvas( ev );
- mode = this.getMode();
- if ( mode === OrbitManipulatorEnums.ROTATE ) {
- manipulator.getRotateInterpolator().reset();
- manipulator.getRotateInterpolator().set( pos[ 0 ], pos[ 1 ] );
- } else if ( mode === OrbitManipulatorEnums.PAN ) {
- manipulator.getPanInterpolator().reset();
- manipulator.getPanInterpolator().set( pos[ 0 ], pos[ 1 ] );
- } else if ( mode === OrbitManipulatorEnums.ZOOM ) {
- manipulator.getZoomInterpolator().setStart( pos[ 1 ] );
- manipulator.getZoomInterpolator().set( 0.0 );
- }
- ev.preventDefault();
- },
- mouseup: function ( /*ev */) {
- this.releaseButton();
- this.setMode( undefined );
- },
- mouseout: function ( /*ev */) {
- this.releaseButton();
- this.setMode( undefined );
- },
- mousewheel: function ( ev, intDelta /*, deltaX, deltaY */ ) {
- var manipulator = this._manipulator;
- ev.preventDefault();
- var zoomTarget = manipulator.getZoomInterpolator().getTarget()[ 0 ] - intDelta;
- manipulator.getZoomInterpolator().setTarget( zoomTarget );
- },
-
- pushButton: function () {
- this._buttonup = false;
- },
- releaseButton: function () {
- this._buttonup = true;
- },
-
- keydown: function ( ev ) {
- if ( ev.keyCode === 32 ) {
- this._manipulator.computeHomePosition();
- ev.preventDefault();
- } else if ( ev.keyCode === this._panKey &&
- this.getMode() !== OrbitManipulatorEnums.PAN ) {
- this.setMode( OrbitManipulatorEnums.PAN );
- this._manipulator.getPanInterpolator().reset();
- this.pushButton();
- ev.preventDefault();
- } else if ( ev.keyCode === this._zoomKey &&
- this.getMode() !== OrbitManipulatorEnums.ZOOM ) {
- this.setMode( OrbitManipulatorEnums.ZOOM );
- this._manipulator.getZoomInterpolator().reset();
- this.pushButton();
- ev.preventDefault();
- } else if ( ev.keyCode === this._rotateKey &&
- this.getMode() !== OrbitManipulatorEnums.ROTATE ) {
- this.setMode( OrbitManipulatorEnums.ROTATE );
- this._manipulator.getRotateInterpolator().reset();
- this.pushButton();
- ev.preventDefault();
- }
-
- },
-
- keyup: function ( ev ) {
- if ( ev.keyCode === this._panKey ) {
- this.mouseup( ev );
- } else if ( ev.keyCode === this._rotateKey ) {
- this.mouseup( ev );
- } else if ( ev.keyCode === this._rotateKey ) {
- this.mouseup( ev );
- }
- this.setMode( undefined );
- }
-
-};
-module.exports = OrbitManipulatorStandardMouseKeyboardController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorWebVRController.js b/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorWebVRController.js
deleted file mode 100644
index dd7f3db5..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/OrbitManipulatorWebVRController.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-var OrbitManipulatorWebVRController = function ( manipulator ) {
- this._manipulator = manipulator;
- this.init();
-};
-
-OrbitManipulatorWebVRController.prototype = {
- init: function () {},
- update: function ( q, position ) {
- this._manipulator.setPoseVR( q, position );
- }
-};
-
-module.exports = OrbitManipulatorWebVRController;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/SwitchManipulator.js b/app/static/app/js/vendor/osgjs/osgGA/SwitchManipulator.js
deleted file mode 100644
index b91f55fb..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/SwitchManipulator.js
+++ /dev/null
@@ -1,85 +0,0 @@
-'use strict';
-
-/**
- * OrbitManipulator
- * @class
- */
-var SwitchManipulator = function () {
- this._manipulatorList = [];
- this._currentManipulator = undefined;
-};
-
-/** @lends SwitchManipulator.prototype */
-SwitchManipulator.prototype = {
- getCamera: function () {
- return this.getCurrentManipulator().getCamera();
- },
- setCamera: function ( cam ) {
- var cbList = this.getManipulatorList();
- for ( var i = 0, nb = cbList.length; i < nb; ++i )
- cbList[ i ].setCamera( cam );
- },
- update: function ( nv ) {
- var manipulator = this.getCurrentManipulator();
- if ( manipulator !== undefined ) {
- return manipulator.update( nv );
- }
- return undefined;
- },
- getNode: function () {
- // we should add an accessor in the osgjs manipulator
- return this.getCurrentManipulator()._node;
- },
- setNode: function ( node ) {
- var cbList = this.getManipulatorList();
- for ( var i = 0, nb = cbList.length; i < nb; ++i )
- cbList[ i ].setNode( node );
- },
- getControllerList: function () {
- return this.getCurrentManipulator().getControllerList();
- },
- getNumManipulator: function () {
- return this._manipulatorList.length;
- },
- addManipulator: function ( manipulator ) {
- this._manipulatorList.push( manipulator );
- if ( this._currentManipulator === undefined ) {
- this.setManipulatorIndex( 0 );
- }
- },
- getManipulatorList: function () {
- return this._manipulatorList;
- },
- setManipulatorIndex: function ( index ) {
- this._currentManipulator = index;
- },
- getCurrentManipulatorIndex: function () {
- return this._currentManipulator;
- },
- getCurrentManipulator: function () {
- return this._manipulatorList[ this._currentManipulator ];
- },
- reset: function () {
- this.getCurrentManipulator().reset();
- },
- computeHomePosition: function ( useBoundingBox ) {
- var manipulator = this.getCurrentManipulator();
- if ( manipulator !== undefined ) {
- manipulator.computeHomePosition( useBoundingBox );
- }
- },
- getInverseMatrix: function () {
- var manipulator = this.getCurrentManipulator();
- if ( manipulator !== undefined ) {
- return manipulator.getInverseMatrix();
- }
- },
- getHomeBound: function ( boundStrategy ) {
- return this.getCurrentManipulator().getHomeBound( boundStrategy );
- },
- getHomeDistance: function ( bs ) {
- return this.getCurrentManipulator().getHomeDistance( bs );
- }
-};
-
-module.exports = SwitchManipulator;
diff --git a/app/static/app/js/vendor/osgjs/osgGA/orbitManipulatorEnums.js b/app/static/app/js/vendor/osgjs/osgGA/orbitManipulatorEnums.js
deleted file mode 100644
index 3d6dd56d..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/orbitManipulatorEnums.js
+++ /dev/null
@@ -1,6 +0,0 @@
-'use strict';
-module.exports = {
- ROTATE: 0,
- PAN: 1,
- ZOOM: 2
-};
diff --git a/app/static/app/js/vendor/osgjs/osgGA/osgGA.js b/app/static/app/js/vendor/osgjs/osgGA/osgGA.js
deleted file mode 100644
index aa5d17f6..00000000
--- a/app/static/app/js/vendor/osgjs/osgGA/osgGA.js
+++ /dev/null
@@ -1,74 +0,0 @@
-'use strict';
-var Hammer = require( 'hammer' );
-var CADManipulator = require( 'osgGA/CADManipulator' );
-var CADManipulatorStandardMouseKeyboardController = require( 'osgGA/CADManipulatorStandardMouseKeyboardController' );
-var CADManipulatorHammerController = require( 'osgGA/CADManipulatorHammerController' );
-var FirstPersonManipulator = require( 'osgGA/FirstPersonManipulator' );
-var FirstPersonManipulatorDeviceOrientationController = require( 'osgGA/FirstPersonManipulatorDeviceOrientationController' );
-var FirstPersonManipulatorHammerController = require( 'osgGA/FirstPersonManipulatorHammerController' );
-var FirstPersonManipulatorStandardMouseKeyboardController = require( 'osgGA/FirstPersonManipulatorStandardMouseKeyboardController' );
-var FirstPersonManipulatorWebVRController = require( 'osgGA/FirstPersonManipulatorWebVRController' );
-var Manipulator = require( 'osgGA/Manipulator' );
-var OrbitManipulator = require( 'osgGA/OrbitManipulator' );
-var OrbitManipulatorDeviceOrientationController = require( 'osgGA/OrbitManipulatorDeviceOrientationController' );
-var OrbitManipulatorGamePadController = require( 'osgGA/OrbitManipulatorGamePadController' );
-var OrbitManipulatorHammerController = require( 'osgGA/OrbitManipulatorHammerController' );
-var OrbitManipulatorLeapMotionController = require( 'osgGA/OrbitManipulatorLeapMotionController' );
-var OrbitManipulatorStandardMouseKeyboardController = require( 'osgGA/OrbitManipulatorStandardMouseKeyboardController' );
-var OrbitManipulatorWebVRController = require( 'osgGA/OrbitManipulatorWebVRController' );
-var SwitchManipulator = require( 'osgGA/SwitchManipulator' );
-var OrbitManipulatorEnums = require( 'osgGA/orbitManipulatorEnums' );
-
-
-var osgGA = {};
-
-Hammer.NO_MOUSEEVENTS = true; // disable hammer js mouse events
-
-osgGA.CADManipulator = CADManipulator;
-osgGA.getCADManipulatorStandardMouseKeyboardController = function () {
- return CADManipulatorStandardMouseKeyboardController;
-};
-osgGA.getCADManipulatorHammerController = function () {
- return CADManipulatorHammerController;
-};
-osgGA.FirstPersonManipulator = FirstPersonManipulator;
-osgGA.getFirstPersonDeviceOrientationController = function () {
- return FirstPersonManipulatorDeviceOrientationController;
-};
-osgGA.getFirstPersonManipulatorHammerController = function () {
- return FirstPersonManipulatorHammerController;
-};
-osgGA.getFirstPersonStandardMouseKeyboardControllerClass = function () {
- return FirstPersonManipulatorStandardMouseKeyboardController;
-};
-osgGA.getFirstPersonWebVRControllerClass = function () {
- return FirstPersonManipulatorWebVRController;
-};
-osgGA.Manipulator = Manipulator;
-osgGA.OrbitManipulator = OrbitManipulator;
-osgGA.getOrbitManipulatorDeviceOrientationController = function () {
- return OrbitManipulatorDeviceOrientationController;
-};
-osgGA.getOrbitManipulatorGamePadController = function () {
- return OrbitManipulatorGamePadController;
-};
-osgGA.getOrbitManipulatorHammerController = function () {
- return OrbitManipulatorHammerController;
-};
-osgGA.getOrbitManipulatorLeapMotionController = function () {
- return OrbitManipulatorLeapMotionController;
-};
-osgGA.getOrbitManipulatorStandardMouseKeyboardController = function () {
- return OrbitManipulatorStandardMouseKeyboardController;
-};
-osgGA.getOrbitManipulatorWebVRController = function () {
- return OrbitManipulatorWebVRController;
-};
-
-osgGA.SwitchManipulator = SwitchManipulator;
-
-osgGA.OrbitManipulator.Rotate = OrbitManipulatorEnums.ROTATE;
-osgGA.OrbitManipulator.Pan = OrbitManipulatorEnums.PAN;
-osgGA.OrbitManipulator.Zoom = OrbitManipulatorEnums.ZOOM;
-
-module.exports = osgGA;
diff --git a/app/static/app/js/vendor/osgjs/osgNameSpace.js b/app/static/app/js/vendor/osgjs/osgNameSpace.js
deleted file mode 100644
index 545bc4e2..00000000
--- a/app/static/app/js/vendor/osgjs/osgNameSpace.js
+++ /dev/null
@@ -1,9 +0,0 @@
-'use strict';
-
-var pkg = require( 'json!./package.json' );
-
-module.exports = {
- name: pkg.name,
- version: pkg.version,
- author: pkg.author
-};
diff --git a/app/static/app/js/vendor/osgjs/osgPlugins/ReaderWriterGLTF.js b/app/static/app/js/vendor/osgjs/osgPlugins/ReaderWriterGLTF.js
deleted file mode 100644
index 2ae1006c..00000000
--- a/app/static/app/js/vendor/osgjs/osgPlugins/ReaderWriterGLTF.js
+++ /dev/null
@@ -1,1150 +0,0 @@
-'use strict';
-
-var requestFile = require( 'osgDB/requestFile.js' );
-var Notify = require( 'osg/notify' );
-var Registry = require( 'osgDB/Registry' );
-var Input = require( 'osgDB/Input' );
-var animation = require( 'osgAnimation/animation' );
-var BasicAnimationManager = require( 'osgAnimation/BasicAnimationManager' );
-var Skeleton = require( 'osgAnimation/Skeleton' );
-var Bone = require( 'osgAnimation/Bone' );
-var StackedTranslate = require( 'osgAnimation/StackedTranslate' );
-var StackedQuaternion = require( 'osgAnimation/StackedQuaternion' );
-var StackedScale = require( 'osgAnimation/StackedScale' );
-var RigGeometry = require( 'osgAnimation/RigGeometry' );
-var channel = require( 'osgAnimation/channel' );
-var createQuatChannel = channel.createQuatChannel;
-var createVec3Channel = channel.createVec3Channel;
-
-var Geometry = require( 'osg/Geometry' );
-var Texture = require( 'osg/Texture' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var Material = require( 'osg/Material' );
-var DrawElements = require( 'osg/DrawElements' );
-var primitiveSet = require( 'osg/primitiveSet' );
-var BufferArray = require( 'osg/BufferArray' );
-var UpdateBone = require( 'osgAnimation/UpdateBone' );
-var UpdateMatrixTransform = require( 'osgAnimation/UpdateMatrixTransform' );
-
-var Uniform = require( 'osg/Uniform' );
-
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var quat = require( 'osg/glMatrix' ).quat;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-
-var GLTFLoader = function () {
-
- // Contains all the needed glTF files (.gltf, .bin, etc...)
- this._files = null;
- this._loadedFiles = null;
- this._localPath = null;
- this._bufferViewCache = null;
-
- this._basicAnimationManager = null;
-
- this._visitedNodes = null;
- this._animatedNodes = null;
- this._skeletons = null;
- this._bones = null;
- this._skeletonToInfluenceMap = null;
-
- this._cachepromise = null;
- this._inputImgReader = null;
-
-};
-
-GLTFLoader.WEBGL_COMPONENT_TYPES = {
- 5120: Int8Array,
- 5121: Uint8Array,
- 5122: Int16Array,
- 5123: Uint16Array,
- 5125: Uint32Array,
- 5126: Float32Array
-};
-
-GLTFLoader.TYPE_TABLE = {
- SCALAR: 1,
- VEC2: 2,
- VEC3: 3,
- VEC4: 4,
- MAT2: 4,
- MAT3: 9,
- MAT4: 16
-};
-
-GLTFLoader.TEXTURE_FORMAT = {
- 6406: Texture.ALPHA,
- 6407: Texture.RGB,
- 6408: Texture.RGBA,
- 6409: Texture.LUMINANCE,
- 6410: Texture.LUMINANCE_ALPHA
-};
-
-GLTFLoader.PBR_EXTENSION = 'FRAUNHOFER_materials_pbr';
-GLTFLoader.PBR_METAL_MODE = 'PBR_metal_roughness';
-GLTFLoader.PBR_SPEC_MODE = 'PBR_specular_glossiness';
-
-GLTFLoader.ALBEDO_TEXTURE_UNIT = 2;
-GLTFLoader.DIFFUSE_TEXTURE_UNIT = 2;
-GLTFLoader.ROUGHNESS_TEXTURE_UNIT = 3;
-GLTFLoader.GLOSSINESS_TEXTURE_UNIT = 3;
-GLTFLoader.METALNESS_TEXTURE_UNIT = 4;
-GLTFLoader.SPECULAR_TEXTURE_UNIT = 4;
-GLTFLoader.NORMAL_TEXTURE_UNIT = 5;
-GLTFLoader.AO_TEXTURE_UNIT = 6;
-
-GLTFLoader.ALBEDO_UNIFORM = 'albedoMap';
-GLTFLoader.ROUGHNESS_UNIFORM = 'roughnessMap';
-GLTFLoader.SPECULAR_UNIFORM = 'specularMap';
-GLTFLoader.NORMAL_UNIFORM = 'normalMap';
-GLTFLoader.AO_UNIFORM = 'aoMap';
-
-GLTFLoader.prototype = {
-
- init: function () {
-
- this._files = null;
- this._loadedFiles = {};
- this._localPath = null;
-
- this._bufferViewCache = {};
-
-
- this._basicAnimationManager = null;
-
- this._visitedNodes = {};
- this._animatedNodes = {};
- this._skeletons = {};
- this._bones = {};
- this._skeletonToInfluenceMap = {};
- this._stateSetMap = {};
-
- this._cachepromise = {};
- this._inputImgReader = new Input();
-
- },
-
- getFileName: function ( urlOrFile ) {
-
- if ( typeof ( urlOrFile ) === 'string' ) {
- var fileName = urlOrFile.split( '/' ).pop();
- return fileName;
- }
-
- if ( !( urlOrFile instanceof File ) )
- return null;
-
- return urlOrFile.name;
- },
-
- findFileFromURI: function ( urlOrFiles, uri ) {
-
- if ( typeof ( urlOrFiles ) === 'string' ) return uri;
-
- for ( var i = 0; i < urlOrFiles.length; ++i ) {
-
- var fileName = this.getFileName( urlOrFiles[ i ] );
-
- if ( fileName === uri )
- return urlOrFiles[ i ];
-
- }
-
- return null;
- },
-
- getFileType: function ( urlOrFile ) {
-
- var fileName = this.getFileName( urlOrFile );
- if ( !fileName ) return null;
-
- var ext = fileName.split( '.' ).pop();
- if ( ext === 'bin' )
- return 'arraybuffer';
- else if ( ext === 'gltf' )
- return 'text';
-
- return 'blob';
- },
-
- loadGLTFJson: function ( urlOrFiles ) {
-
- if ( this._preloaded ) {
-
- var keys = window.Object.keys( this._loadedFiles );
- for ( var j = 0; j < keys.length; ++j ) {
-
- if ( keys[ j ].indexOf( '.gltf' ) !== -1 )
- return Promise.resolve( this._loadedFiles[ keys[ j ] ] );
-
- }
-
- Notify.warn( 'You did not provide any glTF file' );
- return Promise.resolve( null );
-
- }
-
- var glTFFileOrUrl = null;
- if ( typeof ( urlOrFiles ) === 'string' ) {
-
- var ext = urlOrFiles.split( '.' ).pop();
- if ( ext !== 'gltf' ) {
-
- Notify.warn( 'The given URL does not point toward a valid glTF file' );
- return Promise.resolve( null );
-
- }
-
- var index = urlOrFiles.lastIndexOf( '/' );
- this._localPath = ( index === -1 ) ? '' : urlOrFiles.substr( 0, index + 1 );
-
- glTFFileOrUrl = urlOrFiles;
-
- } else {
-
- if ( !( urlOrFiles instanceof FileList ) && !this._preloaded ) {
-
- Notify.warn( 'The provided argument is neither a FileList nor a valid URL' );
- return Promise.resolve( null );
-
- }
-
- for ( var i = 0; i < urlOrFiles.length; ++i ) {
-
- var fileName = this.getFileName( urlOrFiles[ i ] );
-
- if ( fileName.split( '.' ).pop() === 'gltf' ) {
-
- glTFFileOrUrl = urlOrFiles[ i ];
- break;
-
- }
-
- }
-
- }
-
- if ( !glTFFileOrUrl ) {
-
- Notify.warn( 'You did not provided any glTF file' );
- return Promise.resolve( null );
-
- }
-
- return this.loadFile( glTFFileOrUrl, 'gltf' );
-
- },
-
- requestFileFromReader: function ( file, fileType ) {
-
- var defer = Promise.defer();
-
- if ( !( file instanceof File ) )
- return defer.reject();
-
- var reader = new window.FileReader();
- reader.onload = function ( data ) {
-
- if ( fileType !== 'blob' )
- defer.resolve( data.target.result );
- else {
- var img = new window.Image();
- img.src = data.target.result;
-
- defer.resolve( img );
- }
-
- };
-
- if ( fileType === 'arraybuffer' )
- reader.readAsArrayBuffer( file );
- else if ( fileType === 'text' )
- reader.readAsText( file );
- else
- reader.readAsDataURL( file );
-
- return defer.promise;
- },
-
- loadFile: function ( urlOrFile, uri ) {
-
- if ( this._cachepromise[ uri ] )
- return this._cachepromise[ uri ];
-
- if ( !urlOrFile ) {
-
- Notify.warn( '\'' + uri + '\' file not found' );
- return Promise.resolve( null );
-
- }
-
- var fileType = this.getFileType( urlOrFile );
-
- if ( typeof ( urlOrFile ) === 'string' ) {
-
- // Checks whether the url is relative or absolute
- if ( uri !== 'gltf' ) {
-
- if ( urlOrFile.indexOf( 'http://' ) !== 0 && urlOrFile.indexOf( 'https://' ) !== 0 ||
- urlOrFile.indexOf( 'www.' ) !== 0 ) {
-
- urlOrFile = this._localPath + uri;
-
- }
- }
-
- // Checks whether the url poins toward an image
- if ( fileType === 'blob' ) {
-
- var imagePromise = this._inputImgReader.readImageURL( urlOrFile, {
- imageLoadingUsePromise: true
- } );
- this._cachepromise[ uri ] = imagePromise;
-
- return imagePromise;
-
- }
-
- var promise = requestFile( urlOrFile, {
- responseType: fileType
- } ).then( function ( data ) {
-
- return data;
-
- } );
- this._cachepromise[ uri ] = promise;
-
- return promise;
-
- }
-
- var promiseFile = this.requestFileFromReader( urlOrFile, fileType );
- this._cachepromise[ uri ] = promiseFile;
-
- return promiseFile;
- },
-
-
- preloadFiles: function ( files ) {
-
- var keys = window.Object.keys( files );
- for ( var i = 0; i < keys.length; ++i ) {
- this._cachepromise[ keys[ i ] ] = Promise.resolve( files[ keys[ i ] ] );
- }
-
- this._loadedFiles = files;
-
- },
-
- /**
- * Loads a osg.BufferArray from a TypeArray obtained by using a glTF accessor.
- * No memory allocation is done, the result is a subarray obtained from a glTF binary file
- * @param {Object} accessor
- * @param {osg.BufferArray.ARRAY_BUFFER | osg.BufferArray.ELEMENT_ARRAY_BUFFER} type WebGL buffer type
- * @param {TypedArray} BufferType specific TypedArray type used for extraction
- * @return {osg.BufferArray} OSG readable buffer contaning the extracted data
- */
- loadAccessorBuffer: function ( accessor, type ) {
-
- var json = this._loadedFiles.glTF;
-
- var bufferView = json.bufferViews[ accessor.bufferView ];
- var buffer = json.buffers[ bufferView.buffer ];
-
- var urlOrFile = this.findFileFromURI( this._files, buffer.uri );
- var filePromise = this.loadFile( urlOrFile, buffer.uri );
-
- var self = this;
-
- return filePromise.then( function ( data ) {
-
- if ( !data )
- return Promise.resolve( null );
-
- var TypedArray = GLTFLoader.WEBGL_COMPONENT_TYPES[ accessor.componentType ];
- var typedArray = null;
-
- if ( !self._bufferViewCache[ accessor.bufferView ] )
- self._bufferViewCache[ accessor.bufferView ] = data.slice( bufferView.byteOffset, bufferView.byteOffset + bufferView.byteLength );
-
- var bufferViewArray = self._bufferViewCache[ accessor.bufferView ];
- typedArray = new TypedArray( bufferViewArray, accessor.byteOffset, accessor.count * GLTFLoader.TYPE_TABLE[ accessor.type ] );
-
- if ( type )
- return Promise.resolve( new BufferArray( type, typedArray, GLTFLoader.TYPE_TABLE[ accessor.type ] ) );
-
- return Promise.resolve( typedArray );
- } );
- },
-
- findByKey: function ( obj, key ) {
-
- if ( !obj )
- return null;
-
- var keys = window.Object.keys( obj );
- for ( var i = 0; i < keys.length; ++i ) {
-
- if ( keys[ i ] === key )
- return obj[ keys[ i ] ];
-
- }
-
- return null;
-
- },
-
- registerUpdateCallback: function ( callbackName, node ) {
-
- var json = this._loadedFiles.glTF;
-
- var animationCallback = null;
- if ( json.nodes[ callbackName ].jointName )
- animationCallback = new UpdateBone();
- else
- animationCallback = new UpdateMatrixTransform();
-
- animationCallback.setName( callbackName );
-
- var translation = vec3.create();
- mat4.getTranslation( translation, node.getMatrix() );
-
- var rotationQuat = quat.create();
- mat4.getRotation( rotationQuat, node.getMatrix() );
-
- var scale = vec3.create();
- mat4.getScale( scale, node.getMatrix() );
-
- animationCallback.getStackedTransforms().push( new StackedTranslate( 'translation', translation ) );
- animationCallback.getStackedTransforms().push( new StackedQuaternion( 'rotation', rotationQuat ) );
- animationCallback.getStackedTransforms().push( new StackedScale( 'scale', scale ) );
-
- node.addUpdateCallback( animationCallback );
- },
-
- createTextureAndSetAttrib: function ( glTFTextureId, osgStateSet, location, uniform ) {
-
- var defer = Promise.defer();
- if ( !glTFTextureId ) return defer.resolve();
-
- var texture = new Texture();
-
- var json = this._loadedFiles.glTF;
- var glTFTexture = json.textures[ glTFTextureId ];
-
- if ( !glTFTexture ) return defer.resolve();
-
- var image = json.images[ glTFTexture.source ];
-
- if ( !image ) return defer.resolve();
-
- var urlOrFile = this.findFileFromURI( this._files, image.uri );
-
- this.loadFile( urlOrFile, image.uri ).then( function ( data ) {
-
- if ( !data ) return defer.resolve();
-
- texture.setImage( data, GLTFLoader.TEXTURE_FORMAT[ glTFTexture.format ] );
- texture.setFlipY( glTFTexture.flipY );
- var extras = glTFTexture.extras;
- if ( extras )
- osgStateSet.addUniform( Uniform.createInt1( extras.yUp ? 0 : 1, 'uFlipNormalY' ) );
-
- osgStateSet.setTextureAttributeAndModes( location, texture );
-
- if ( uniform )
- osgStateSet.addUniform( Uniform.createInt( location, uniform ) );
-
- return defer.resolve();
-
- } );
-
- return defer.promise;
-
- },
-
- /**
- * Creates a MatrixTransform node by using
- * glTF node's properties (matrix, translation, rotation, scale)
- * @param {Object} glTFNode glTF node
- * @return {OSG.MatrixTransform} MatrixTransform node containing the glTF node transform
- */
- loadTransform: function ( glTFNode ) {
-
- var mat = mat4.create();
-
- // The transform is given under a matrix form
- if ( glTFNode.matrix ) {
-
- mat4.copy( mat, glTFNode.matrix );
- return mat;
- }
-
- // The transform is given under the form
- // translation, rotation, scale
- var scale = glTFNode.scale || vec3.ONE;
- var rot = glTFNode.rotation || quat.IDENTITY;
- var trans = glTFNode.translation || vec3.ZERO;
-
- mat4.fromRotationTranslationScale( mat, rot, trans, scale );
- return mat;
- },
-
- preprocessChannel: function ( glTFChannel, glTFAnim, glTFAnimParams ) {
-
- var json = this._loadedFiles.glTF;
- var promisesArray = [];
-
- var glTFSampler = glTFAnim.samplers[ glTFChannel.sampler ];
-
- var timeAccessor = json.accessors[ glTFAnimParams[ glTFSampler.input ] ];
- var valueAccessor = json.accessors[ glTFAnimParams[ glTFSampler.output ] ];
-
- var timePromise = this.loadAccessorBuffer( timeAccessor, null );
- var valuePromise = this.loadAccessorBuffer( valueAccessor, null );
-
- promisesArray.push( timePromise, valuePromise );
-
- var self = this;
-
- return Promise.all( promisesArray ).then( function ( timeAndValue ) {
-
- var timeKeys = timeAndValue[ 0 ];
- var valueKeys = timeAndValue[ 1 ];
-
- var osgChannel = null;
-
- if ( GLTFLoader.TYPE_TABLE[ valueAccessor.type ] === 4 ) {
-
- osgChannel = createQuatChannel( valueKeys, timeKeys, glTFChannel.target.id, glTFSampler.output, null );
-
- } else if ( GLTFLoader.TYPE_TABLE[ valueAccessor.type ] === 3 ) {
-
- osgChannel = createVec3Channel( valueKeys, timeKeys, glTFChannel.target.id, glTFSampler.output, null );
-
- }
-
- self._animatedNodes[ glTFChannel.target.id ] = true;
-
- return osgChannel;
-
- } );
- },
-
- createAnimationFromChannels: function ( channelsPromiseArray, animName ) {
-
- return Promise.all( channelsPromiseArray ).then( function ( channels ) {
-
- return animation.createAnimation( channels, animName );
-
- } );
-
- },
-
- /**
- * Loads all the solid animations registering
- * them in a BasicAnimationManager instance
- * @return {BasicAnimationManager} the animation manager containing the animations
- */
- preprocessAnimations: function () {
-
- var json = this._loadedFiles.glTF;
-
- if ( !json.animations )
- return Promise.resolve();
-
- var animPromiseArray = [];
-
- var animationsObjectKeys = window.Object.keys( json.animations );
- for ( var i = 0; i < animationsObjectKeys.length; ++i ) {
-
- var glTFAnim = json.animations[ animationsObjectKeys[ i ] ];
- var glTFAnimParams = glTFAnim.parameters;
-
- var channelsPromiseArray = [];
- // Creates each OSGJS channel
- for ( var j = 0; j < glTFAnim.channels.length; ++j ) {
-
- var glTFChannel = glTFAnim.channels[ j ];
-
- var osgChannel = this.preprocessChannel( glTFChannel, glTFAnim, glTFAnimParams );
- channelsPromiseArray.push( osgChannel );
- }
-
- var animPromise = this.createAnimationFromChannels( channelsPromiseArray, animationsObjectKeys[ i ] );
- animPromiseArray.push( animPromise );
- }
-
- var self = this;
- return Promise.all( animPromiseArray ).then( function ( animations ) {
-
- var animationManager = new BasicAnimationManager();
- animationManager.init( animations );
-
- self._basicAnimationManager = animationManager;
-
- } );
-
- },
-
- loadBone: function ( boneId, skin ) {
-
- var json = this._loadedFiles.glTF;
- var node = json.nodes[ boneId ];
-
- var self = this;
-
- var inverseBindMatricesAccessor = json.accessors[ skin.inverseBindMatrices ];
- var bonePromise = this.loadAccessorBuffer( inverseBindMatricesAccessor, null );
- return bonePromise.then( function ( data ) {
-
- // Creates the current bone
- // initializing it with initial pose
- for ( var i = 0; i < skin.jointNames.length; ++i ) {
-
- if ( skin.jointNames[ i ] === node.jointName ) break;
-
- }
-
- var boneNode = new Bone( node.jointName );
- var invMat = data.subarray( i * 16, i * 16 + 16 );
- boneNode.setInvBindMatrixInSkeletonSpace( invMat );
-
- self._bones[ boneId ] = boneNode;
-
- return boneNode;
- } );
-
- },
-
- buildInfluenceMap: function ( rootBoneId, skin ) {
-
- if ( this._skeletonToInfluenceMap[ rootBoneId ] )
- return;
-
- this._skeletonToInfluenceMap[ rootBoneId ] = {};
-
- for ( var j = 0; j < skin.jointNames.length; j++ ) {
-
- var jointName = skin.jointNames[ j ];
- this._skeletonToInfluenceMap[ rootBoneId ][ jointName ] = j;
-
- }
-
- },
-
- mapBonesToSkin: function () {
-
- var json = this._loadedFiles.glTF;
-
- var boneToSkin = {};
-
- // Maps each bone ID to its skin
- var skinsKeys = window.Object.keys( json.skins );
- for ( var i = 0; i < skinsKeys.length; ++i ) {
-
- var skin = json.skins[ skinsKeys[ i ] ];
-
- for ( var j = 0; j < skin.jointNames.length; ++j ) {
-
- var jName = skin.jointNames[ j ];
-
- var nodesKeys = window.Object.keys( json.nodes );
- for ( var k = 0; k < nodesKeys.length; ++k ) {
-
- var node = json.nodes[ nodesKeys[ k ] ];
-
- if ( node.jointName && node.jointName === jName )
- boneToSkin[ nodesKeys[ k ] ] = skin;
- }
- }
-
- }
-
- return boneToSkin;
-
- },
-
- preprocessBones: function ( bonesToSkin ) {
-
- var json = this._loadedFiles.glTF;
- var nodesKeys = window.Object.keys( json.nodes );
-
- var promises = [];
-
- for ( var i = 0; i < nodesKeys.length; ++i ) {
-
- var boneId = nodesKeys[ i ];
- var boneNode = json.nodes[ boneId ];
-
- if ( !boneNode.jointName )
- continue;
-
- var bonePromise = this.loadBone( boneId, bonesToSkin[ boneId ] );
- promises.push( bonePromise );
-
- }
-
- return Promise.all( promises );
-
- },
-
- preprocessSkeletons: function () {
-
- var json = this._loadedFiles.glTF;
-
- if ( !json.skins )
- return Promise.resolve();
-
- var bonesToSkin = this.mapBonesToSkin();
-
- // Saves each skeleton in the skeleton maprep
- var nodesKeys = window.Object.keys( json.nodes );
- for ( var j = 0; j < nodesKeys.length; ++j ) {
-
- var nodeId = nodesKeys[ j ];
- var node = json.nodes[ nodeId ];
- var skin = json.skins[ node.skin ];
-
- if ( !node.skeletons )
- continue;
-
- for ( var i = 0; i < node.skeletons.length; ++i ) {
-
- var rootBoneId = null;
- var rootJointId = node.skeletons[ i ];
-
- for ( var k = 0; k < nodesKeys.length; ++k ) {
-
- var subnodeId = nodesKeys[ k ];
- var subnode = json.nodes[ subnodeId ];
-
- if ( !subnode.jointName )
- continue;
-
- if ( subnode.jointName === rootJointId ) {
-
- rootBoneId = subnodeId;
- break;
-
- }
-
- }
-
- if ( rootBoneId && !this._skeletons[ rootBoneId ] ) {
-
- this._skeletons[ rootJointId ] = new Skeleton();
-
- // Adds missing bone to the boneMap
- bonesToSkin[ rootBoneId ] = skin;
- }
-
- this.buildInfluenceMap( rootJointId, skin );
- }
- }
-
- var bonesPromise = this.preprocessBones( bonesToSkin );
-
- return bonesPromise;
- },
-
- loadPBRMaterial: function ( materialId, glTFmaterial, geometryNode ) {
-
- var model = glTFmaterial.materialModel;
- var values = glTFmaterial.values;
-
- if ( !values ) return Promise.resolve();
-
- var osgStateSet = geometryNode.getOrCreateStateSet();
-
- var promises = [];
- if ( model === GLTFLoader.PBR_METAL_MODE ) {
-
- promises.push( this.createTextureAndSetAttrib( values.baseColorTexture, osgStateSet, GLTFLoader.ALBEDO_TEXTURE_UNIT, GLTFLoader.ALBEDO_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.roughnessTexture, osgStateSet, GLTFLoader.ROUGHNESS_TEXTURE_UNIT, GLTFLoader.ROUGHNESS_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.metallicTexture, osgStateSet, GLTFLoader.METALNESS_TEXTURE_UNIT, GLTFLoader.SPECULAR_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.normalTexture, osgStateSet, GLTFLoader.NORMAL_TEXTURE_UNIT, GLTFLoader.NORMAL_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.aoTexture, osgStateSet, GLTFLoader.AO_TEXTURE_UNIT, GLTFLoader.AO_UNIFORM ) );
-
- } else if ( model === GLTFLoader.PBR_SPEC_MODE ) {
-
- promises.push( this.createTextureAndSetAttrib( values.diffuseTexture, osgStateSet, GLTFLoader.DIFFUSE_TEXTURE_UNIT, GLTFLoader.ALBEDO_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.glossinessTexture, osgStateSet, GLTFLoader.GLOSSINESS_TEXTURE_UNIT, GLTFLoader.ROUGHNESS_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.specularTexture, osgStateSet, GLTFLoader.SPECULAR_TEXTURE_UNIT, GLTFLoader.SPECULAR_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.normalTexture, osgStateSet, GLTFLoader.NORMAL_TEXTURE_UNIT, GLTFLoader.NORMAL_UNIFORM ) );
- promises.push( this.createTextureAndSetAttrib( values.aoTexture, osgStateSet, GLTFLoader.AO_TEXTURE_UNIT, GLTFLoader.AO_UNIFORM ) );
-
- }
-
- geometryNode.setUserData( {
- pbrWorklow: model
- } );
-
- geometryNode.stateset = osgStateSet;
- this._stateSetMap[ materialId ] = osgStateSet;
-
- return Promise.all( promises );
- },
-
- loadMaterial: function ( materialId, geometryNode ) {
-
- var json = this._loadedFiles.glTF;
- var glTFmaterial = json.materials[ materialId ];
-
- if ( this._stateSetMap[ materialId ] ) {
- geometryNode.stateset = this._stateSetMap[ materialId ];
- return Promise.resolve();
- }
-
- var extension = this.findByKey( glTFmaterial.extensions, GLTFLoader.PBR_EXTENSION );
- if ( extension )
- return this.loadPBRMaterial( materialId, extension, geometryNode );
-
- var values = glTFmaterial.values;
- if ( !values ) return Promise.resolve();
-
- // Handles basic material attributes
- var osgMaterial = new Material();
- var osgStateSet = geometryNode.getOrCreateStateSet();
- osgStateSet.setAttribute( osgMaterial );
-
- if ( values.ambient )
- osgMaterial.setAmbient( values.ambient );
- if ( values.emission )
- osgMaterial.setEmission( values.emission );
- if ( values.shininess )
- osgMaterial.setShininess( values.shininess );
- if ( values.specular )
- osgMaterial.setSpecular( values.specular );
-
- // Create a texture for the diffuse, if any
- if ( values.diffuse ) {
-
- if ( typeof ( values.diffuse ) !== 'string' )
- osgMaterial.setDiffuse( values.diffuse );
- else
- return this.createTextureAndSetAttrib( values.diffuse, osgStateSet, 0 );
- }
-
- geometryNode.stateset = osgStateSet;
- this._stateSetMap[ materialId ] = osgStateSet;
-
- return Promise.resolve();
- },
-
- createGeometry: function ( primitive, skeletonJointId ) {
-
- var json = this._loadedFiles.glTF;
- var promisesArray = [];
-
- // Builds the geometry from the extracted vertices & normals
- var geom = new Geometry();
- var rigOrGeom = geom;
-
- var cbSetBuffer = function ( name, buffer ) {
-
- if ( !buffer )
- return;
-
- this.getVertexAttributeList()[ name ] = buffer;
-
- };
-
- if ( skeletonJointId ) {
-
- rigOrGeom = new RigGeometry();
- rigOrGeom._boneNameID = this._skeletonToInfluenceMap[ skeletonJointId ];
-
- }
-
- var attributeWeight = function ( data ) {
-
- if ( !data )
- return;
-
- rigOrGeom.getAttributes().Weights = data;
-
- var elts = rigOrGeom.getAttributes().Weights.getElements();
- for ( var i = 0, l = elts.length / 4; i < l; ++i ) {
- var sum = elts[ i * 4 ] + elts[ i * 4 + 1 ] + elts[ i * 4 + 2 ] + elts[ i * 4 + 3 ];
- var correc = 1.0 / sum;
- elts[ i * 4 ] *= correc;
- elts[ i * 4 + 1 ] *= correc;
- elts[ i * 4 + 2 ] *= correc;
- elts[ i * 4 + 3 ] *= correc;
- }
-
- };
-
- // Registers each glTF primitive attributes
- // into a respective geometry attribute
- var attributesKeys = window.Object.keys( primitive.attributes );
- for ( var i = 0; i < attributesKeys.length; ++i ) {
-
- var accessor = json.accessors[ primitive.attributes[ attributesKeys[ i ] ] ];
- var promise = this.loadAccessorBuffer( accessor, BufferArray.ARRAY_BUFFER );
-
- if ( attributesKeys[ i ].indexOf( 'POSITION' ) !== -1 ) {
-
- promise.then( cbSetBuffer.bind( geom, 'Vertex' ) );
-
- } else if ( attributesKeys[ i ].indexOf( 'NORMAL' ) !== -1 ) {
-
- promise.then( cbSetBuffer.bind( geom, 'Normal' ) );
-
- } else if ( attributesKeys[ i ].indexOf( 'TANGENT' ) !== -1 ) {
-
- promise.then( cbSetBuffer.bind( geom, 'Tangent' ) );
-
- } else if ( attributesKeys[ i ].indexOf( 'JOINT' ) !== -1 ) {
-
- promise.then( cbSetBuffer.bind( rigOrGeom, 'Bones' ) );
-
- } else if ( attributesKeys[ i ].indexOf( 'WEIGHT' ) !== -1 ) {
-
- promise.then( attributeWeight );
-
- } else if ( attributesKeys[ i ].indexOf( 'TEXCOORD' ) !== -1 ) {
-
- var texCoordId = attributesKeys[ i ].substr( 9 );
- promise.then( cbSetBuffer.bind( geom, 'TexCoord' + texCoordId ) );
-
- }
-
- promisesArray.push( promise );
-
- }
-
- var indicesAccessor = json.accessors[ primitive.indices ];
- var indicesPromise = this.loadAccessorBuffer( indicesAccessor, BufferArray.ELEMENT_ARRAY_BUFFER );
- indicesPromise.then( function ( data ) {
-
- if ( !data )
- return;
-
- var osgPrimitive = new DrawElements( primitiveSet.TRIANGLES, data );
- geom.getPrimitives().push( osgPrimitive );
-
- } );
-
- promisesArray.push( indicesPromise );
-
- if ( primitive.material )
- promisesArray.push( this.loadMaterial( primitive.material, geom ) );
-
- return Promise.all( promisesArray ).then( function () {
-
- if ( skeletonJointId ) {
-
- rigOrGeom.setSourceGeometry( geom );
- rigOrGeom.mergeChildrenData();
-
- rigOrGeom.computeBoundingBox = geom.computeBoundingBox;
- }
-
- return rigOrGeom;
-
- } );
- },
-
- loadGLTFPrimitives: function ( meshId, resultMeshNode, skeletonJointId ) {
-
- var json = this._loadedFiles.glTF;
- var mesh = json.meshes[ meshId ];
-
- var primitives = mesh.primitives;
-
- var promisesArray = [];
-
- for ( var i = 0; i < primitives.length; ++i ) {
-
- var primitive = primitives[ i ];
- var promiseGeom = this.createGeometry( primitive, skeletonJointId );
-
- promisesArray.push( promiseGeom );
-
- }
-
- return Promise.all( promisesArray ).then( function ( geoms ) {
-
- for ( var i = 0; i < geoms.length; ++i )
- resultMeshNode.addChild( geoms[ i ] );
-
- return geoms;
-
- } );
- },
-
- loadGLTFNode: function ( nodeId, root ) {
-
- if ( this._visitedNodes[ nodeId ] )
- return Promise.resolve();
-
- var json = this._loadedFiles.glTF;
- var glTFNode = json.nodes[ nodeId ];
- var children = glTFNode.children;
-
- var i = 0;
-
- var currentNode = null;
-
- if ( glTFNode.jointName ) {
-
- currentNode = this._bones[ nodeId ];
-
- } else {
-
- currentNode = new MatrixTransform();
-
- }
-
- if ( glTFNode.jointName && this._skeletons[ glTFNode.jointName ] ) {
-
- var skeleton = this._skeletons[ glTFNode.jointName ];
- skeleton.addChild( currentNode );
- root.addChild( skeleton );
-
- }
-
- currentNode.setName( nodeId );
- mat4.copy( currentNode.getMatrix(), this.loadTransform( glTFNode ) );
-
- // Recurses on children before
- // processing the current node
- var promises = [];
- if ( children ) {
-
- for ( i = 0; i < children.length; ++i ) {
-
- var nodePromise = this.loadGLTFNode( children[ i ], currentNode );
- promises.push( nodePromise );
-
- }
-
- }
-
- // Loads meshes contained in the node
- // Adds RigGeometry to corresponding skeleton if any
- if ( glTFNode.meshes ) {
-
- for ( i = 0; i < glTFNode.meshes.length; ++i ) {
-
- var meshId = glTFNode.meshes[ i ];
- if ( !glTFNode.skeletons ) {
-
- var geomPromise = this.loadGLTFPrimitives( meshId, currentNode, null );
- promises.push( geomPromise );
- continue;
-
- }
-
- for ( var j = 0; j < glTFNode.skeletons.length; ++j ) {
-
- var rootJointId = glTFNode.skeletons[ j ];
- var skeletonNode = this._skeletons[ rootJointId ];
-
- var meshTransformNode = new MatrixTransform();
- mat4.copy( meshTransformNode.getMatrix(), currentNode.getMatrix() );
-
- var geomP = this.loadGLTFPrimitives( meshId, meshTransformNode, rootJointId );
-
- skeletonNode.addChild( meshTransformNode );
-
- promises.push( geomP );
- }
-
- }
-
- }
-
- // Loads solid animations
- // by adding an update callback
- if ( this._animatedNodes[ nodeId ] )
- this.registerUpdateCallback( nodeId, currentNode );
-
- if ( !this._skeletons[ nodeId ] )
- root.addChild( currentNode );
-
- this._visitedNodes[ nodeId ] = true;
-
- return Promise.all( promises );
- },
-
- readNodeURL: function ( files, options ) {
-
- var self = this;
-
- this.init();
- this._files = files;
-
- this._preloaded = options ? options.preloaded : null;
- if ( this._preloaded )
- this.preloadFiles( files );
-
- var glTFFilePromise = this.loadGLTFJson( this._files );
-
- // Creates the root node
- // adding a PI / 2 rotation arround the X-axis
- var root = new MatrixTransform();
- root.setName( 'root' );
-
- return glTFFilePromise.then( function ( glTFFile ) {
-
- self._loadedFiles.glTF = JSON.parse( glTFFile );
- var json = self._loadedFiles.glTF;
-
- if ( !json )
- return Promise.resolve( null );
-
- var promisesArray = [];
-
- // Preprocesses animations
- var animPromise = self.preprocessAnimations();
-
- // Preprocesses skin animations if any
- var skeletonPromise = self.preprocessSkeletons();
-
- promisesArray.push( skeletonPromise, animPromise );
- return Promise.all( promisesArray ).then( function () {
-
- var promises = [];
- // Loops through each scene
- // loading geometry nodes, transform nodes, etc...s
- var sceneKeys = window.Object.keys( json.scenes );
-
- for ( var i = 0; i < sceneKeys.length; ++i ) {
-
- var scene = json.scenes[ sceneKeys[ i ] ];
-
- if ( !scene )
- continue;
-
- for ( var j = 0; j < scene.nodes.length; ++j ) {
-
- var p = self.loadGLTFNode( scene.nodes[ j ], root );
- promises.push( p );
-
- }
- }
-
- // Register the animation manager
- // if the glTF file contains animations
- if ( self._basicAnimationManager )
- root.addUpdateCallback( self._basicAnimationManager );
-
- return Promise.all( promises ).then( function () {
-
- return root;
-
- } );
-
- } );
-
- } );
- }
-
-};
-
-Registry.instance().addReaderWriter( 'gltf', new GLTFLoader() );
-
-module.exports = GLTFLoader;
diff --git a/app/static/app/js/vendor/osgjs/osgPlugins/osgPlugins.js b/app/static/app/js/vendor/osgjs/osgPlugins/osgPlugins.js
deleted file mode 100644
index 3819bb41..00000000
--- a/app/static/app/js/vendor/osgjs/osgPlugins/osgPlugins.js
+++ /dev/null
@@ -1,8 +0,0 @@
-'use strict';
-var ReaderWriterGLTF = require( 'osgPlugins/ReaderWriterGLTF' );
-
-var osgPlugins = {};
-
-osgPlugins.ReaderWriterGLTF = ReaderWriterGLTF;
-
-module.exports = osgPlugins;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/Compiler.js b/app/static/app/js/vendor/osgjs/osgShader/Compiler.js
deleted file mode 100644
index 9896620d..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/Compiler.js
+++ /dev/null
@@ -1,728 +0,0 @@
-'use strict';
-
-var Notify = require( 'osg/notify' );
-var Uniform = require( 'osg/Uniform' );
-var factory = require( 'osgShader/nodeFactory' );
-var MACROUTILS = require( 'osg/Utils' );
-var CompilerVertex = require( 'osgShader/CompilerVertex' );
-var CompilerFragment = require( 'osgShader/CompilerFragment' );
-
-var Compiler = function ( attributes, textureAttributes, shaderProcessor ) {
- this._attributes = attributes;
- this._textureAttributes = textureAttributes;
-
- this._fragmentShaderMode = false; // current context
-
- this._activeNodeList = {};
- this._compiledNodeList = {};
- this._traversedNodeList = {};
-
- this._variables = {};
- this._varyings = {};
- this._vertexShader = [];
- this._fragmentShader = [];
-
- this._shaderProcessor = shaderProcessor;
- this._texturesByName = {};
-
- // TODO: Have to handle better textures
- // 4 separate loop over texture list: one here, one for declareTexture, 2 for vertexShader (varying decl + varying store)
- // (not counting loops done above in shader generator)
-
- this._shadowsTextures = [];
- this._lights = [];
- this._shadows = [];
- this._textures = [];
- this._material = null;
-
- this._invariantPosition = false;
- this._isBillboard = false;
-
- // Important: if not using Compiler for Both VS and FS Check either of those
- // it allow override by custom Processor of some check between the VS & FS pass (varying mostly)
- this._customVertexShader = false;
- this._customFragmentShader = false;
-
- // from Attributes to variables to build shader nodes graph from
- this.initAttributes();
- this.initTextureAttributes();
-};
-
-Compiler.prototype = MACROUTILS.extend( {}, CompilerVertex, CompilerFragment, {
-
- getOrCreateProjectionMatrix: function () {
- return this.getOrCreateUniform( 'mat4', 'uProjectionMatrix' );
- },
-
- getFragmentShaderName: function () {
- return this._material ? 'CompilerOSGJS' : 'NoMaterialCompilerOSGJS';
- },
-
- getVertexShaderName: function () {
- return this.getFragmentShaderName();
- },
-
- getOrCreateConstantOne: function ( type ) {
- return this.getOrCreateConstant( type, type + 'White' ).setValue( type + '(1.0)' );
- },
-
- getOrCreateConstantZero: function ( type ) {
- return this.getOrCreateConstant( type, type + 'Black' ).setValue( type + '(0.0)' );
- },
-
- initAttributes: function () {
- var attributes = this._attributes;
- var lights = this._lights;
- var shadows = this._shadows;
- for ( var i = 0, l = attributes.length; i < l; i++ ) {
-
- var type = attributes[ i ].className();
-
- // Test one light at a time
- if ( type === 'Light' ) { // && lights.length === 0) {
- lights.push( attributes[ i ] );
- } else if ( type === 'Material' ) {
- this._material = attributes[ i ];
- } else if ( type === 'ShadowReceiveAttribute' ) {
- shadows.push( attributes[ i ] );
- } else if ( type === 'Billboard' ) {
- this._isBillboard = !!attributes[ i ];
- } else if ( type === 'SkinningAttribute' ) {
- this._skinningAttribute = attributes[ i ];
- } else if ( type === 'MorphAttribute' ) {
- this._morphAttribute = attributes[ i ];
- }
- }
- },
-
- initTextureAttributes: function () {
-
- var textureAttributes = this._textureAttributes;
- var texturesNum = textureAttributes.length;
- this._textures.length = this._shadowsTextures.length = texturesNum;
-
- for ( var j = 0; j < texturesNum; j++ ) {
- var tu = textureAttributes[ j ];
- if ( tu === undefined )
- continue;
-
- for ( var t = 0, tl = tu.length; t < tl; t++ ) {
- this.registerTextureAttributes( tu[ t ], j );
- }
- }
- },
-
- registerTextureAttributes: function ( tuTarget, tunit ) {
- var tType = tuTarget.className();
- if ( tType === 'Texture' ) return this.registerTexture( tuTarget, tunit );
- if ( tType === 'ShadowTexture' ) return this.registerTextureShadow( tuTarget, tunit );
- },
-
- registerTexture: function ( tuTarget, texUnit ) {
- var tName = tuTarget.getName();
- if ( !tName ) {
- tName = 'Texture' + texUnit;
- tuTarget.setName( tName );
- }
- this._textures[ texUnit ] = tuTarget;
-
- this._texturesByName[ tName ] = {
- texture: tuTarget,
- variable: undefined,
- textureUnit: texUnit
- };
- },
-
- registerTextureShadow: function ( tuTarget, texUnit ) {
- var tName = tuTarget.getName();
- if ( !tName ) {
- tName = 'Texture' + texUnit;
- tuTarget.setName( tName );
- }
- this._shadowsTextures[ texUnit ] = tuTarget;
-
- this._texturesByName[ tName ] = {
- texture: tuTarget,
- variable: undefined,
- textureUnit: texUnit,
- shadow: true
- };
- },
-
- getTextureByName: function ( name ) {
- var texObj = this._texturesByName[ name ];
- if ( !texObj || texObj.variable )
- return texObj;
-
- var texture = texObj.texture;
- var texCoordUnit = texObj.textureUnit;
-
- var textureSampler;
-
- var className = texture.className();
- var samplerName = 'Texture' + texCoordUnit;
- if ( className === 'Texture' ) {
- textureSampler = this.getOrCreateSampler( 'sampler2D', samplerName );
- } else if ( className === 'TextureCubeMap' ) {
- textureSampler = this.getOrCreateSampler( 'samplerCube', samplerName );
- } else {
- return;
- }
-
- var texCoord = this._fragmentShaderMode ? this.getOrCreateVarying( 'vec2', 'vTexCoord' + texCoordUnit ) : this.getOrCreateAttribute( 'vec2', 'TexCoord' + texCoordUnit );
-
- texObj.variable = this.createTextureRGBA( texture, textureSampler, texCoord );
-
- return texObj;
- },
-
- // The Compiler Main Code called on Vertex or Fragment Shader Graph
- createShaderFromGraphs: function ( roots ) {
- this._compiledNodeList = {};
-
- // list all vars
- var vars = window.Object.keys( this._variables );
- var variables = [];
- for ( var j = 0, jl = vars.length; j < jl; j++ ) {
-
- var varNode = this._variables[ vars[ j ] ];
- var d = varNode.declare();
- if ( d ) {
- variables.push( d );
- }
- }
-
- // defines and extensions are added by process shader
- var extensions = this.evaluateExtensions( roots );
- var defines = this.evaluateDefines( roots );
-
- var shaderStack = [];
- shaderStack.push( '\n' );
- shaderStack.push( this.evaluateGlobalVariableDeclaration( roots ) );
- if ( this._invariantPosition && !this._fragmentShaderMode ) shaderStack.push( '\ninvariant gl_Position;' );
- shaderStack.push( '\n' );
- shaderStack.push( this.evaluateGlobalFunctionDeclaration( roots ) );
-
- shaderStack.push( 'void main() {' );
-
- // declare variables in main
- if ( variables.length !== 0 ) {
- shaderStack.push( '// vars\n' );
- shaderStack.push( variables.join( ' ' ) );
- shaderStack.push( '\n// end vars\n' );
- }
-
- // make sure we have at least one output
- if ( roots.length === 0 ) {
- Notify.error( 'shader without any final Node output (need at least one)' );
- }
-
- shaderStack.push( this.evaluate( roots ) );
-
- shaderStack.push( '}' );
-
- // Shader Graph has been outputed an array of string
- // we concatenate it to a shader string program
- var shaderStr = shaderStack.join( '\n' );
-
- // Process defines, add precision, resolve include pragma
- var shader = this._shaderProcessor.processShader( shaderStr, defines, extensions, this._fragmentShaderMode ? 'fragment' : 'vertex' );
-
- /*develblock:start*/
- // Check
- var compiledNodes = window.Object.keys( this._compiledNodeList );
- var activeNodes = window.Object.keys( this._activeNodeList );
- activeNodes.filter( function ( i ) {
- var found = compiledNodes.indexOf( i ) !== -1;
- if ( !found ) {
- var node = this._activeNodeList[ i ];
- var name = node.getName();
- if ( name === 'Variable' ) name += ' ' + node.getVariable() + ' (' + node.getType() + ')';
- Notify.warn( 'Nodes requested, but not compiled: ' + i + ' ' + name + ' ' + node.toString() );
- }
- return found;
- }, this );
- /*develblock:end*/
-
- return shader;
- },
-
- getNode: function ( /*name, arg1, etc*/) {
- var n = factory.getNode.apply( factory, arguments );
- var cacheID = n.getID();
- this._activeNodeList[ cacheID ] = n;
- return n;
- },
-
- getVariable: function ( nameID ) {
- return this._variables[ nameID ];
- },
-
- getAttributeType: function ( type ) {
-
- for ( var i = 0; i < this._attributes.length; i++ ) {
- if ( this._attributes[ i ].getType() === type )
- return this._attributes[ i ];
- }
- return undefined;
-
- },
-
- // TODO: add Precision qualifier
- // if doesn't exist create a new on
- // if nameID given and var already exist, create a varname +
- createVariable: function ( type, varname, deepness ) {
-
- var nameID = varname;
-
- if ( nameID === undefined ) {
-
- var len = window.Object.keys( this._variables ).length;
- nameID = 'tmp_' + len;
-
- } else if ( this._variables[ nameID ] ) {
- // create a new variable
- // if we want to reuse a variable we should NOT
- // call this function in the first place and do the
- // test before...
- // however for uniform, varying and sampler, we return
- // the variable if it already exists, because they are
- // meant to be read only
- nameID = nameID + deepness;
- if ( deepness === undefined ) {
- return this.createVariable( type, varname, 1 );
- } else if ( this._variables[ nameID ] ) {
- deepness++;
- return this.createVariable( type, varname, deepness );
- }
-
- }
-
- var v = this.getNode( 'Variable', type, nameID );
- this._variables[ nameID ] = v;
- return v;
- },
-
- // Map of uniform from a StateAttribute or TextureStateAttribute
- getOrCreateUniformFromUniformMap: function ( uniforms, prefix ) {
- var keys = window.Object.keys( uniforms );
- var object = {};
-
- var prefixUniform = prefix ? prefix : '';
-
- for ( var i = 0; i < keys.length; i++ ) {
- var k = prefixUniform + keys[ i ];
- object[ k ] = this.getOrCreateUniform( uniforms[ keys[ i ] ] );
- }
-
- return object;
- },
-
- // specialized for texture, enforcing last parameter usage.
- getOrCreateTextureStateAttributeUniforms: function ( stateAttribute, prefix, unit ) {
-
- var uniforms = stateAttribute.getOrCreateUniforms( unit );
- return this.getOrCreateUniformFromUniformMap( uniforms, prefix );
- },
-
- getOrCreateStateAttributeUniforms: function ( stateAttribute, prefix ) {
-
- var uniforms = stateAttribute.getOrCreateUniforms();
- return this.getOrCreateUniformFromUniformMap( uniforms, prefix );
- },
-
- getOrCreateUniform: function ( type, varname, size ) {
-
- var nameID = varname;
-
- // accept uniform as parameter to simplify code
- if ( type instanceof Uniform ) {
-
- var uniform = type;
- type = uniform.getType();
- nameID = uniform.getName();
-
- } else if ( nameID === undefined ) {
- Notify.error( 'Cannot create unamed Uniform' );
- }
-
- var exist = this._variables[ nameID ];
- if ( exist ) {
- if ( exist.getType() === type ) {
- return exist;
- }
-
- /*develblock:start*/
- // texture has a particular "dual" type of uniform a sampler2D
- // a int pointing to the texture unit the sampler2D represents
- if ( exist.getType() === 'sampler2D' && type !== 'sampler2D' ) {
- Notify.error( 'Same uniform, but different type (' + type + ', ' + exist.getType() + ', ' + exist.getVariable() + ')' );
- }
- /*develblock:end*/
- }
-
- var v = this.getNode( 'Uniform', type, nameID, size );
- this._variables[ nameID ] = v;
-
- return v;
- },
-
- // make sure we get correct Node
- getOrCreateSampler: function ( type, varname ) {
-
- if ( varname === undefined ) {
- Notify.error( 'No name given for sampler type : ' + type );
- }
-
- var exist = this._variables[ varname ];
- if ( exist ) {
- return exist; // see comment in Variable function
- }
-
- var v = this.getNode( 'Sampler', type, varname );
- this._variables[ varname ] = v;
-
- return v;
- },
-
- // make sure we get correct Node
- getOrCreateAttribute: function ( type, nameID ) {
-
- if ( this._fragmentShaderMode ) {
- Notify.error( 'No Vertex Attribute in Fragment Shader' );
- }
-
- var exist = this._variables[ nameID ];
- if ( exist ) {
-
- /*develblock:start*/
- if ( exist.getType() !== type ) {
- Notify.error( 'Same attribute, but different type' );
- }
- /*develblock:end*/
-
- return exist;
- }
-
- var v = this.getNode( 'Attribute', type, nameID );
- this._variables[ nameID ] = v;
- return v;
- },
-
- getOrCreateConstant: function ( type, varname ) {
- var nameID = varname;
- if ( nameID === undefined ) {
- // TODO: temp constant ? or enforcing reuse ?
- // maybe could parse variable to find other constant
- // but would need having scope info
- var len = window.Object.keys( this._variables ).length;
- nameID = 'tmp_' + len;
-
- } else {
-
- var exist = this._variables[ nameID ];
- if ( exist ) {
-
- /*develblock:start*/
- if ( exist.getType() !== type ) {
- Notify.error( 'Same constant name, but different type' );
- }
- /*develblock:end*/
-
- // see comment in Variable function
- return exist;
- }
-
- }
-
- var v = this.getNode( 'Constant', type, nameID );
- this._variables[ nameID ] = v;
- return v;
- },
-
- // make sure we get correct Node
- getOrCreateVarying: function ( type, nameID ) {
-
- if ( nameID === undefined ) {
- Notify.error( 'Error: Mandatory to name varying (as you need to retrieve them)' );
- }
-
- var variable = this._variables[ nameID ];
- if ( variable ) {
- if ( !this._varyings[ nameID ] ) {
- Notify.error( 'Error: requesting a varying not declared with getOrCreateVarying previously' );
- }
-
- if ( variable.getType() !== type ) {
- Notify.error( 'Error: Same varying, but different type' );
- }
-
- return variable;
- }
-
- // if it's not in Varying Cache, but requested from vertex shader it means => error
- if ( !this._fragmentShaderMode && !this._customFragmentShader ) {
- Notify.error( 'Error: requesting a varying not declared in Fragment Shader Graph (for Custom Vertex Shader, add this._customFragmentShader to the processor): ' + nameID + ' ' + type );
- }
-
- variable = this._variables[ nameID ] = this._varyings[ nameID ] = this.getNode( 'Varying', type, nameID );
-
- return variable;
- },
-
- //////////////////
- // TRAVERSE STUFFS
- //////////////////
-
- markNodeAsVisited: function ( n ) {
- var cacheID = n.getID();
- if ( this._activeNodeList[ cacheID ] === n ) {
- this._compiledNodeList[ cacheID ] = n;
- } else {
- Notify.warn( 'Node not requested by using Compiler getNode and/or not registered in nodeFactory ' + n.toString() );
- }
- },
-
- // make sure we traverse once per evaluation of graph
- checkOrMarkNodeAsTraversed: function ( n ) {
- var cacheID = n.getID();
- if ( this._traversedNodeList[ cacheID ] ) {
- return true;
- }
- this._traversedNodeList[ cacheID ] = n;
- return false;
- },
-
- // TODO: add a visitor to debug the graph
- traverse: function ( functor, node ) {
-
- if ( this.checkOrMarkNodeAsTraversed( node ) ) return;
-
- var inputs = node.getInputs();
- if ( !Array.isArray( inputs ) ) {
- var keys = window.Object.keys( inputs );
- var objectToArray = [];
- for ( var j = 0; j < keys.length; j++ )
- objectToArray.push( inputs[ keys[ j ] ] );
- inputs = objectToArray;
- }
-
- for ( var i = 0, l = inputs.length; i < l; i++ ) {
- node.checkInputsOutputs();
-
- var child = inputs[ i ];
-
- if ( child !== undefined &&
- child !== node ) {
- this.traverse( functor, child );
- }
- }
- functor.call( functor, node );
-
- // keep trace we visited
- this.markNodeAsVisited( node );
-
- },
-
- // clean necessary bits before traversing called in each evaluate func belows
- preTraverse: function ( visitor ) {
-
- // store traversed list to prevent double traverse
- this._traversedNodeList = {};
-
- visitor._map = {};
- visitor._text = [];
-
- return visitor;
- },
-
- // Gather a particular output field
- // for now one of
- // ['define', 'extensions']
- //
- // from a nodeGraph
- //
- // In case a node of same Type have different outputs (shadow with different defines)
- // it use ID rather than Type as map index UNIQUE PER TYPE
- // TODO: adds includes so that we can remove it from the eval Global Functions ?
- evaluateAndGatherField: function ( nodes, field ) {
-
- var func = function ( node ) {
-
- var idx = node.getType();
- if ( idx === undefined || idx === '' ) {
- Notify.error( 'Your node ' + node + ' has no type' );
- }
- if ( node[ field ] && this._map[ idx ] === undefined ) {
-
- this._map[ idx ] = true;
- var c = node[ field ]();
- // push all elements of the array on text array
- // node[field]() must return an array
- Array.prototype.push.apply( this._text, c );
-
- }
-
- };
-
- this.preTraverse( func );
-
- for ( var j = 0, jl = nodes.length; j < jl; j++ ) {
- this.traverse( func, nodes[ j ] );
- }
-
- return func._text;
- },
-
- // Gather a functions declartions of nodesfrom a nodeGraph
- // (for now pragma include done here too. could be done with define/etc...)
- // Node of same Type has to share exact same "node.globalFunctionDeclaration" output
- // as it use Type rather than ID as map index
- evaluateGlobalFunctionDeclaration: function ( nodes ) {
-
- var func = function ( node ) {
-
- // UNIQUE PER TYPE
- var idx = node.getType();
-
- if ( idx === undefined || idx === '' ) {
- Notify.error( 'Your node ' + node + ' has no type' );
- }
- if ( node.globalFunctionDeclaration &&
- this._map[ idx ] === undefined ) {
-
- this._map[ idx ] = true;
- var c = node.globalFunctionDeclaration();
- if ( c !== undefined ) {
- this._text.push( c );
- }
-
- }
-
- };
-
- this.preTraverse( func );
-
- for ( var j = 0, jl = nodes.length; j < jl; j++ ) {
- this.traverse( func, nodes[ j ] );
- }
-
- return func._text.join( '\n' );
- },
-
- // Gather a Variables declarations of nodes from a nodeGraph to be outputted
- // outside the VOID MAIN code ( Uniforms, Varying )
- // Node of same Type has different output as it use Type rather than ID as map index
- evaluateGlobalVariableDeclaration: function ( nodes ) {
-
- var func = function ( node ) {
-
- // UNIQUE PER NODE
- var idx = node.getID();
-
- if ( node.globalDeclaration &&
- this._map[ idx ] === undefined ) {
-
- this._map[ idx ] = true;
- var c = node.globalDeclaration();
- if ( c !== undefined ) {
- this._text.push( c );
- }
- }
- };
-
-
- this.preTraverse( func );
-
- var i = 0;
- var nbNodes = nodes.length;
- for ( i = 0; i < nbNodes; i++ ) {
- this.traverse( func, nodes[ i ] );
- }
-
- // beautify/formatting with empty line between type of var
- var declarations = func._text;
- var len = declarations.length;
- if ( len > 0 ) {
- this.sortDeclarations( declarations );
-
- var type = declarations[ 0 ][ 0 ];
- for ( i = 0; i < len; ++i ) {
- var iType = declarations[ i ][ 0 ];
- if ( iType !== type ) {
- type = iType;
- declarations[ i - 1 ] += '\n';
- }
- }
- }
-
- return declarations.join( '\n' );
- },
-
- sortDeclarations: function ( declarations ) {
- // sort in alphabetical order attr, unif, sample, varying
- declarations.sort();
-
- if ( this._fragmentShaderMode ) return;
-
- // making sure Vertex is always coming first (because of webgl warning)
- for ( var i = 0, len = declarations.length; i < len; ++i ) {
- var vatt = declarations[ i ];
-
- if ( vatt[ 0 ] !== 'a' ) break;
-
- if ( vatt.indexOf( 'Vertex' ) !== -1 ) {
- declarations.splice( i, 1 );
- declarations.unshift( vatt );
- break;
- }
- }
- },
-
- evaluate: function ( nodes ) {
-
-
- var func = function ( node ) {
-
- var id = node.getID();
- if ( this._map[ id ] !== undefined ) {
- return;
- }
-
- var c = node.computeShader();
- if ( c !== undefined ) {
-
- if ( node.getComment !== undefined ) {
-
- var comment = node.getComment();
- if ( comment !== undefined ) {
- this._text.push( comment );
- }
-
- }
-
- this._text.push( c );
- }
-
- this._map[ id ] = true;
- };
-
- this.preTraverse( func );
-
- for ( var j = 0, jl = nodes.length; j < jl; j++ ) {
- this.traverse( func, nodes[ j ] );
- }
- return func._text.join( '\n' );
- },
-
- evaluateDefines: function ( roots ) {
- return this.evaluateAndGatherField( roots, 'getDefines' );
- },
-
- evaluateExtensions: function ( roots ) {
- return this.evaluateAndGatherField( roots, 'getExtensions' );
- }
-} );
-
-
-module.exports = Compiler;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/CompilerFragment.js b/app/static/app/js/vendor/osgjs/osgShader/CompilerFragment.js
deleted file mode 100644
index 260c22bb..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/CompilerFragment.js
+++ /dev/null
@@ -1,513 +0,0 @@
-'use strict';
-
-var Light = require( 'osg/Light' );
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-
-var CompilerFragment = {
-
- createFragmentShader: function () {
-
- this._fragmentShaderMode = true;
-
- // Call to specialised inhenrited shader Compiler
- var roots = this.createFragmentShaderGraph();
- var fname = this.getFragmentShaderName();
- if ( fname ) roots.push( this.getNode( 'Define', 'SHADER_NAME' ).setValue( fname ) );
-
- var shader = this.createShaderFromGraphs( roots );
-
- Notify.debug( shader );
-
- this.cleanAfterFragment();
-
- return shader;
- },
-
- cleanAfterFragment: function () {
- // reset for next
- this._variables = {};
- this._activeNodeList = {};
-
- // clean texture cache variable (for vertex shader re-usage)
- var textures = this._texturesByName;
- var keys = window.Object.keys( textures );
- for ( var i = 0; i < keys.length; i++ ) {
- textures[ keys[ i ] ].variable = undefined;
- }
-
- var varyings = this._varyings;
- var vars = window.Object.keys( varyings );
- for ( var j = 0, jl = vars.length; j < jl; j++ ) {
- var name = vars[ j ];
- var varying = varyings[ name ];
- varying.reset();
- this._activeNodeList[ varying.getID() ] = varying;
- this._variables[ name ] = varying;
- }
- },
-
- createDefaultFragmentShaderGraph: function () {
- var fofd = this.getOrCreateConstant( 'vec4', 'fofd' ).setValue( 'vec4(1.0, 0.0, 1.0, 0.7)' );
- var fragCol = this.getNode( 'glFragColor' );
- this.getNode( 'SetFromNode' ).inputs( fofd ).outputs( fragCol );
- return fragCol;
- },
-
- createFragmentShaderGraph: function () {
-
- // shader graph can have multiple output (glPointsize, varyings)
- // here named roots all outputs must be pushed inside
- var roots = [];
-
- // no material then return a default shader
- if ( !this._material ) {
- roots.push( this.createDefaultFragmentShaderGraph() );
- return roots;
- }
-
- var materialUniforms = this.getOrCreateStateAttributeUniforms( this._material );
-
- // vertex color needs to be computed to diffuse
- var diffuseColor = this.getVertexColor( materialUniforms.diffuse );
-
- var finalColor;
-
- if ( this._lights.length > 0 ) {
-
- var lightedOutput = this.createLighting( {
- materialdiffuse: diffuseColor
- } );
- finalColor = lightedOutput;
-
- } else {
- finalColor = diffuseColor;
- }
-
- if ( materialUniforms.emission ) {
- // add emission if any
- var outputDiffEm = this.createVariable( 'vec3' ).setValue( 'vec3(0.0)' );
- this.getNode( 'Add' ).inputs( finalColor, materialUniforms.emission ).outputs( outputDiffEm );
- finalColor = outputDiffEm;
- }
-
- // finalColor = primary color * texture color
- var textureColor = this.getDiffuseColorFromTextures();
- if ( textureColor !== undefined ) {
- this.getNode( 'InlineCode' ).code( '%color.rgb *= %texture.rgb;' ).inputs( {
- texture: textureColor
- } ).outputs( {
- color: finalColor
- } );
- }
-
- // compute alpha
- var alpha = this.createVariable( 'float' );
- var textureTexel = this.getFirstValidTexture();
- var alphaCompute;
- if ( textureTexel ) // use alpha of the first valid texture if has texture
- alphaCompute = '%alpha = %color.a * %texelAlpha.a;';
- else
- alphaCompute = '%alpha = %color.a;';
-
- // Discard fragments totally transparents when rendering billboards
- if ( this._isBillboard )
- alphaCompute += 'if ( %alpha == 0.0) discard;';
-
- this.getNode( 'InlineCode' ).code( alphaCompute ).inputs( {
- color: materialUniforms.diffuse,
- texelAlpha: textureTexel
- } ).outputs( {
- alpha: alpha
- } );
-
- // premult alpha
- finalColor = this.getPremultAlpha( finalColor, alpha );
-
- var fragColor = this.getNode( 'glFragColor' );
-
- // todo add gamma corrected color, but it would also mean to handle correctly srgb texture
- // so it should be done at the same time. see osg.Tetxure to implement srgb
- this.getNode( 'SetAlpha' ).inputs( {
- color: finalColor,
- alpha: alpha
- } ).outputs( {
- color: fragColor
- } );
-
- roots.push( fragColor );
-
- return roots;
- },
-
- getOrCreateFrontTangent: function () {
- var frontTangent = this.createVariable( 'vec4', 'frontTangent' );
-
- this.getNode( 'FrontNormal' ).inputs( {
- normal: this.getOrCreateVarying( 'vec4', 'vViewTangent' )
- } ).outputs( {
- normal: frontTangent
- } );
-
- return frontTangent;
- },
-
- getOrCreateFrontNormal: function () {
- var frontNormal = this.createVariable( 'vec3', 'frontNormal' );
-
- this.getNode( 'FrontNormal' ).inputs( {
- normal: this.getOrCreateVarying( 'vec3', 'vViewNormal' )
- } ).outputs( {
- normal: frontNormal
- } );
-
- return frontNormal;
- },
-
- getOrCreateNormalizedNormal: function () {
- var normal = this._variables[ 'normal' ];
- if ( normal )
- return normal;
-
- var out = this.createVariable( 'vec3', 'normal' );
- this.getNode( 'Normalize' ).inputs( {
- vec: this.getOrCreateFrontNormal()
- } ).outputs( {
- vec: out
- } );
- return out;
- },
- getOrCreateNormalizedPosition: function () {
- var eye = this._variables[ 'eyeVector' ];
- if ( eye )
- return eye;
- var nor = this.createVariable( 'vec3' );
- var castEye = this.createVariable( 'vec3' );
- this.getNode( 'SetFromNode' ).inputs( this.getOrCreateVarying( 'vec4', 'vViewVertex' ) ).outputs( castEye );
- this.getNode( 'Normalize' ).inputs( {
- vec: castEye
- } ).outputs( {
- vec: nor
- } );
- var out = this.createVariable( 'vec3', 'eyeVector' );
- this.getNode( 'Mult' ).inputs( nor, this.createVariable( 'float' ).setValue( '-1.0' ) ).outputs( out );
- return out;
- },
-
- getPremultAlpha: function ( finalColor, alpha ) {
-
- if ( alpha === undefined )
- return finalColor;
-
- var premultAlpha = this.createVariable( 'vec4' );
-
- this.getNode( 'PreMultAlpha' ).inputs( {
- color: finalColor,
- alpha: alpha
- } ).outputs( {
- color: premultAlpha
- } );
-
- return premultAlpha;
- },
-
-
- getColorsRGB: function ( finalColor ) {
- var finalSrgbColor = this.createVariable( 'vec3' );
- this.getNode( 'LinearTosRGB' ).inputs( {
- color: finalColor
- } ).outputs( {
- color: finalSrgbColor
- } );
-
- return finalSrgbColor;
- },
-
-
- // Declare variable / varying to handle vertex color
- // return a variable that contains the following operation
- // newDiffuseColor = diffuseColor * vertexColor
- // TODO: this code should move in the shader instead
- getVertexColor: function ( diffuseColor ) {
-
- if ( diffuseColor === undefined )
- return undefined;
-
- var vertexColor = this.getOrCreateVarying( 'vec4', 'vVertexColor' );
- var vertexColorUniform = this.getOrCreateUniform( 'float', 'uArrayColorEnabled' );
- var tmp = this.createVariable( 'vec4' );
-
- var str = [ '',
- '%color.rgb = %diffuse.rgb;',
- 'if ( %hasVertexColor == 1.0)',
- ' %color *= %vertexColor.rgba;'
- ].join( '\n' );
-
- this.getNode( 'InlineCode' ).code( str ).inputs( {
- diffuse: diffuseColor,
- hasVertexColor: vertexColorUniform,
- vertexColor: vertexColor
- } ).outputs( {
- color: tmp
- } ).comment( 'diffuse color = diffuse color * vertex color' );
-
- return tmp;
- },
-
- getDiffuseColorFromTextures: function () {
-
- var texturesInput = [];
- var textures = this._texturesByName;
-
- var keys = window.Object.keys( textures );
- for ( var i = 0; i < keys.length; i++ ) {
- var name = keys[ i ];
- var texture = textures[ name ];
-
- if ( texture.shadow )
- continue;
-
- texturesInput.push( this.getTextureByName( name ).variable );
- }
-
- // if multi texture multiply them all with diffuse
- // but if only one, return the first
- if ( texturesInput.length > 1 ) {
-
- var texAccum = this.createVariable( 'vec3', 'texDiffuseAccum' );
-
- this.getNode( 'Mult' ).inputs( texturesInput ).outputs( texAccum );
- return texAccum;
-
- } else if ( texturesInput.length === 1 ) {
-
- return texturesInput[ 0 ];
- }
-
- return undefined;
- },
-
- getFirstValidTexture: function () {
- var textures = this._textures;
- for ( var i = 0, nb = textures.length; i < nb; ++i ) {
- var tex = textures[ i ];
- if ( tex ) return this.getTextureByName( tex.getName() ).variable;
- }
- return undefined;
- },
-
- createShadowingLight: function ( light, inputs, lightedOutput ) {
-
- var k;
- var shadow;
- var shadowTexture;
- var hasShadows = false;
- var shadowTextures = new Array( this._shadowsTextures.length );
- var lightIndex = -1;
-
- // seach current light its corresponding shadow and shadowTextures.
- // if none, no shadow, hop we go.
- // TODO: harder Link shadowTexture and shadowAttribute ?
- // TODO: multi shadow textures for 1 light
- var lightNum = light.getLightNumber();
- for ( k = 0; k < this._shadows.length; k++ ) {
- shadow = this._shadows[ k ];
- if ( shadow.getLightNumber() !== lightNum ) continue;
-
- lightIndex = k;
- for ( var p = 0; p < this._shadowsTextures.length; p++ ) {
- shadowTexture = this._shadowsTextures[ p ];
- if ( shadowTexture && shadowTexture.getLightUnit() === lightNum ) {
- shadowTextures[ p ] = shadowTexture;
- hasShadows = true;
- }
- }
- }
-
- if ( !hasShadows ) return undefined;
-
- // Varyings
- var vertexWorld = this.getOrCreateVarying( 'vec3', 'vModelVertex' );
-
- // asserted we have a shadow we do the shadow node allocation
- // and mult with lighted output
- var shadowedOutput = this.createVariable( 'float' );
-
- // shadow Attribute uniforms
- var shadowUniforms = this.getOrCreateStateAttributeUniforms( this._shadows[ lightIndex ], 'shadow' );
- var shadowInputs = MACROUTILS.objectMix( inputs, shadowUniforms );
-
- // shadowTexture Attribute uniforms AND varying
- // TODO: better handle multi texture shadow (CSM/PSM/etc.)
- for ( k = 0; k < shadowTextures.length; k++ ) {
- shadowTexture = shadowTextures[ k ];
- if ( shadowTexture ) {
- shadowInputs = this.createShadowTextureInputVarying( shadowTexture, shadowInputs, vertexWorld, k );
- }
-
- }
- // TODO: shadow Attributes in node, is this the legit way
- this.getNode( 'ShadowReceive' ).inputs( inputs ).outputs( {
- float: shadowedOutput
- } ).setShadowAttribute( shadow );
-
- // allow overwrite by inheriting compiler where shadow inputs ( NDotL notably) can be used for non standard shadows
- return this.connectShadowLightNode( light, lightedOutput, shadowedOutput, shadowInputs );
-
- },
-
- connectShadowLightNode: function ( light, lightedOutput, shadowedOutput ) {
-
- var lightAndShadowTempOutput = this.createVariable( 'vec3', 'lightAndShadowTempOutput' );
-
- this.getNode( 'Mult' ).inputs( lightedOutput, shadowedOutput ).outputs( lightAndShadowTempOutput );
-
- return lightAndShadowTempOutput;
-
- },
-
- createShadowTextureInputVarying: function ( shadowTexture, inputs, vertexWorld, tUnit ) {
- var shadowTexSamplerName = 'Texture' + tUnit;
-
- // we declare first this uniform so that the Int one
- var tex = this.getOrCreateSampler( 'sampler2D', shadowTexSamplerName );
-
- // per texture uniforms
- var uniforms = shadowTexture.getOrCreateUniforms( tUnit );
- var backupInt = uniforms[ shadowTexSamplerName ];
- // remove the uniform texture unit uniform
- delete uniforms[ shadowTexSamplerName ];
- var shadowTextureUniforms = this.getOrCreateTextureStateAttributeUniforms( shadowTexture, 'shadowTexture', tUnit );
- uniforms[ shadowTexSamplerName ] = backupInt;
-
- var inputsShadow = MACROUTILS.objectMix( inputs, shadowTextureUniforms );
-
- inputsShadow.shadowTexture = tex;
-
- var shadowVarying = {
- vertexWorld: vertexWorld,
- lightEyeDir: inputsShadow.lightEyeDir,
- lightNDL: inputsShadow.lightNDL
- };
- inputsShadow = MACROUTILS.objectMix( inputsShadow, shadowVarying );
- return inputsShadow;
- },
-
- createCommonLightingVars: function ( /*materials, enumLights*/) {
- // Shared var between all lights and shadows useful for compilers overriding default compiler
- return {};
- },
-
- // Shared var between each light and its respective shadow
- createLightAndShadowVars: function ( materials, enumLights, lightNum ) {
-
- var type = this._lights[ lightNum ].getLightType();
-
- var lighted = this.createVariable( 'bool', 'lighted' + lightNum );
- var lightPos;
- if ( type === Light.SPOT || type === Light.POINT ) {
- lightPos = this.createVariable( 'vec3', 'lightEyePos' + lightNum );
- }
- var lightDir = this.createVariable( 'vec3', 'lightEyeDir' + lightNum );
- var lightNDL = this.createVariable( 'float', 'lightNDL' + lightNum );
-
-
- return {
- lighted: lighted,
- lightEyePos: lightPos,
- lightEyeDir: lightDir,
- lightNDL: lightNDL
- };
-
- },
-
- createLighting: function ( materials, overrideNodeName ) {
-
- var output = this.createVariable( 'vec3' );
- var lightOutputVarList = [];
-
- var enumToNodeName = overrideNodeName || {
- DIRECTION: 'SunLight',
- SPOT: 'SpotLight',
- POINT: 'PointLight',
- HEMI: 'HemiLight'
- };
-
-
- var materialUniforms = this.getOrCreateStateAttributeUniforms( this._material, 'material' );
- var sharedLightingVars = this.createCommonLightingVars( materials, enumToNodeName );
-
- for ( var i = 0; i < this._lights.length; i++ ) {
-
- var light = this._lights[ i ];
-
- var lightedOutput = this.createVariable( 'vec3' );
- var nodeName = enumToNodeName[ light.getLightType() ];
-
- // create uniforms from stateAttribute and mix them with materials
- // to pass the result as input for light node
- var lightUniforms = this.getOrCreateStateAttributeUniforms( this._lights[ i ], 'light' );
- var lightOutShadowIn = this.createLightAndShadowVars( materials, enumToNodeName, i );
-
- var inputs = MACROUTILS.objectMix( {}, lightUniforms );
- inputs = MACROUTILS.objectMix( inputs, materialUniforms );
- inputs = MACROUTILS.objectMix( inputs, materials );
- inputs = MACROUTILS.objectMix( inputs, sharedLightingVars );
- inputs = MACROUTILS.objectMix( inputs, lightOutShadowIn );
-
- if ( !inputs.normal )
- inputs.normal = this.getOrCreateNormalizedNormal();
- if ( !inputs.eyeVector )
- inputs.eyeVector = this.getOrCreateNormalizedPosition();
-
- this.getNode( nodeName ).inputs( inputs ).outputs( {
- color: lightedOutput,
- lightEyePos: inputs.lightEyePos, // spot and point only
- lightEyeDir: inputs.lightEyeDir,
- ndl: inputs.lightNDL,
- lighted: inputs.lighted
- } );
-
- var shadowedOutput = this.createShadowingLight( light, inputs, lightedOutput );
- if ( shadowedOutput ) {
- lightOutputVarList.push( shadowedOutput );
- } else {
- lightOutputVarList.push( lightedOutput );
- }
-
- var lightMatAmbientOutput = this.createVariable( 'vec3', 'lightMatAmbientOutput' );
-
- this.getNode( 'Mult' ).inputs( inputs.materialambient, lightUniforms.lightambient ).outputs( lightMatAmbientOutput );
-
-
- lightOutputVarList.push( lightMatAmbientOutput );
- }
-
- // do not delete on the assumption that light list is always filled
- // in case CreateLighting is called with a empty lightList
- // when Compiler is overriden.
- if ( lightOutputVarList.length === 0 )
- lightOutputVarList.push( this.createVariable( 'vec3' ).setValue( 'vec3(0.0)' ) );
-
- this.getNode( 'Add' ).inputs( lightOutputVarList ).outputs( output );
-
- return output;
- },
-
- createTextureRGBA: function ( texture, textureSampler, texCoord ) {
- // but we could later implement srgb inside and read differents flag
- // as read only in the texture
-
- var texel = this.createVariable( 'vec4' );
- this.getNode( 'TextureRGBA' ).inputs( {
- sampler: textureSampler,
- uv: texCoord
- } ).outputs( {
- color: texel
- } );
-
- return texel;
- }
-};
-
-module.exports = CompilerFragment;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/CompilerVertex.js b/app/static/app/js/vendor/osgjs/osgShader/CompilerVertex.js
deleted file mode 100644
index f18314e2..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/CompilerVertex.js
+++ /dev/null
@@ -1,400 +0,0 @@
-'use strict';
-
-var Notify = require( 'osg/notify' );
-
-var CompilerVertex = {
-
- createVertexShader: function () {
-
- this._fragmentShaderMode = false;
-
- // Call to specialised inhenrited shader Compiler
- var roots = this.declareVertexMain();
- var vname = this.getVertexShaderName();
- if ( vname ) roots.push( this.getNode( 'Define', 'SHADER_NAME' ).setValue( vname ) );
-
- // call the graph compiler itself
- var shader = this.createShaderFromGraphs( roots );
-
- Notify.debug( shader );
-
- return shader;
- },
-
- declareVertexMain: function () {
-
- var glPointSize = this.getNode( 'glPointSize' );
- this.getNode( 'SetFromNode' ).inputs( this.getOrCreateConstantOne( 'float' ) ).outputs( glPointSize );
-
- // Because of a weird bug on iOS, glPosition should be computed in the vertex shader before some varyings
- var roots = [ glPointSize, this.declareVertexPosition() ];
-
- this.declareVertexVaryings( roots );
-
- return roots;
- },
-
- declareVertexVaryings: function ( roots ) {
- var varyings = this._varyings;
-
- if ( varyings.vModelVertex ) this.getNode( 'SetFromNode' ).inputs( this.getOrCreateModelVertex() ).outputs( varyings.vModelVertex );
- if ( varyings.vModelNormal ) this.getNode( 'SetFromNode' ).inputs( this.getOrCreateModelNormal() ).outputs( varyings.vModelNormal );
- if ( varyings.vModelTangent ) this.getNode( 'SetFromNode' ).inputs( this.getOrCreateModelTangent() ).outputs( varyings.vModelTangent );
-
- if ( varyings.vViewVertex ) this.getNode( 'SetFromNode' ).inputs( this.getOrCreateViewVertex() ).outputs( varyings.vViewVertex );
- if ( varyings.vViewNormal ) this.getNode( 'SetFromNode' ).inputs( this.getOrCreateViewNormal() ).outputs( varyings.vViewNormal );
- if ( varyings.vViewTangent ) this.getNode( 'SetFromNode' ).inputs( this.getOrCreateViewTangent() ).outputs( varyings.vViewTangent );
-
- if ( varyings.vVertexColor ) {
- this.getNode( 'InlineCode' ).code( '%vcolor = %venabled == 1.0 ? %acolor : vec4(1.0, 1.0, 1.0, 1.0);' ).inputs( {
- venabled: this.getOrCreateUniform( 'float', 'uArrayColorEnabled' ),
- acolor: this.getOrCreateAttribute( 'vec4', 'Color' )
- } ).outputs( {
- vcolor: this.getOrCreateVarying( 'vec4', 'vVertexColor' )
- } );
- }
-
- var vars = window.Object.keys( varyings );
- for ( var j = 0, jl = vars.length; j < jl; j++ ) {
- var varying = varyings[ vars[ j ] ];
- roots.push( varying );
-
- var name = varying.getVariable();
- if ( name.indexOf( 'vTexCoord' ) !== -1 ) {
- this.getNode( 'SetFromNode' ).inputs( this.getOrCreateAttribute( 'vec2', name.substring( 1 ) ) ).outputs( varying );
- }
- }
- },
-
- declareVertexPosition: function () {
- var glPosition = this.getNode( 'glPosition' );
- if ( this._isBillboard ) this.declareVertexTransformBillboard( glPosition );
- else this.declareScreenVertex( glPosition );
- return glPosition;
- },
-
- getOrCreateModelVertex: function () {
- var out = this._variables.modelVertex;
- if ( out ) return out;
- out = this.createVariable( 'vec3', 'modelVertex' );
-
- this.getNode( 'MatrixMultPosition' ).inputs( {
- matrix: this.getOrCreateUniform( 'mat4', 'uModelMatrix' ),
- vec: this.getOrCreateLocalVertex()
- } ).outputs( {
- vec: out
- } );
-
- return out;
- },
-
- getOrCreateModelNormal: function () {
- var out = this._variables.modelNormal;
- if ( out ) return out;
- out = this.createVariable( 'vec3', 'modelNormal' );
-
- this.getNode( 'MatrixMultDirection' ).inputs( {
- matrix: this.getOrCreateUniform( 'mat4', 'uModelMatrix' ), // ModelNormalMatrix
- vec: this.getOrCreateLocalNormal()
- } ).outputs( {
- vec: out
- } );
-
- // not normalized
-
- return out;
- },
-
- getOrCreateModelTangent: function () {
- var out = this._variables.modelTangent;
- if ( out ) return out;
- out = this.createVariable( 'vec4', 'modelTangent' );
-
- this.getNode( 'MatrixMultDirection' ).setOverwriteW( false ).inputs( {
- matrix: this.getOrCreateUniform( 'mat4', 'uModelMatrix' ), // ModelNormalMatrix
- vec: this.getOrCreateLocalTangent()
- } ).outputs( {
- vec: out
- } );
-
- // not normalized
-
- return out;
- },
-
- getOrCreateViewVertex: function () {
- var out = this._variables.viewVertex;
- if ( out ) return out;
- out = this.createVariable( 'vec4', 'viewVertex' );
-
- this.getNode( 'MatrixMultPosition' ).inputs( {
- matrix: this.getOrCreateUniform( 'mat4', 'uModelViewMatrix' ),
- vec: this.getOrCreateLocalVertex()
- } ).outputs( {
- vec: out
- } );
-
- return out;
- },
-
- getOrCreateViewNormal: function () {
- var out = this._variables.viewNormal;
- if ( out ) return out;
- out = this.createVariable( 'vec3', 'viewNormal' );
-
- this.getNode( 'MatrixMultDirection' ).inputs( {
- matrix: this.getOrCreateUniform( 'mat4', 'uModelViewNormalMatrix' ),
- vec: this.getOrCreateLocalNormal()
- } ).outputs( {
- vec: out
- } );
-
- return out;
- },
-
- getOrCreateViewTangent: function () {
- var out = this._variables.viewTangent;
- if ( out ) return out;
- out = this.createVariable( 'vec4', 'viewTangent' );
-
- this.getNode( 'MatrixMultDirection' ).setOverwriteW( false ).inputs( {
- matrix: this.getOrCreateUniform( 'mat4', 'uModelViewNormalMatrix' ),
- vec: this.getOrCreateLocalTangent()
- } ).outputs( {
- vec: out
- } );
-
- return out;
- },
-
- declareScreenVertex: function ( glPosition ) {
- this.getNode( 'MatrixMultPosition' ).inputs( {
- matrix: this.getOrCreateProjectionMatrix(),
- vec: this.getOrCreateViewVertex()
- } ).outputs( {
- vec: glPosition
- } );
- },
-
- declareVertexTransformBillboard: function ( glPosition ) {
- this.getNode( 'Billboard' ).inputs( {
- Vertex: this.getOrCreateAttribute( 'vec3', 'Vertex' ),
- ModelViewMatrix: this.getOrCreateUniform( 'mat4', 'uModelViewMatrix' ),
- ProjectionMatrix: this.getOrCreateUniform( 'mat4', 'uProjectionMatrix' )
- } ).outputs( {
- vec: glPosition
- } );
- },
-
- getOrCreateBoneMatrix: function () {
- // reusable BoneMatrix between Vertex, Normal, Tangent
- // Manadatory: scale animations must be uniform scale
- var boneMatrix = this._variables[ 'boneMatrix' ];
- if ( boneMatrix )
- return boneMatrix;
-
- boneMatrix = this.createVariable( 'mat4', 'boneMatrix' );
-
- var inputWeights = this.getOrCreateAttribute( 'vec4', 'Weights' );
- var inputBones = this.getOrCreateAttribute( 'vec4', 'Bones' );
- var matrixPalette = this.getOrCreateUniform( 'vec4', 'uBones', this._skinningAttribute.getBoneUniformSize() );
-
- this.getNode( 'Skinning' ).inputs( {
- weights: inputWeights,
- bonesIndex: inputBones,
- matrixPalette: matrixPalette
- } ).outputs( {
- mat4: boneMatrix
- } );
-
- return boneMatrix;
- },
-
- getTarget: function ( name, i ) {
- var type = name.indexOf( 'Tangent' ) !== -1 ? 'vec4' : 'vec3';
- return this.getOrCreateAttribute( type, name + '_' + i );
- },
-
- morphTangentApproximation: function ( inputVertex, outputVertex ) {
- var normalizedMorph = this.getOrCreateLocalNormal();
- // kind of tricky, here we retrieve the normalized normal after morphing
- // if there is no rigging we do not recompute it
- if ( this._skinningAttribute ) {
-
- normalizedMorph = this.createVariable( 'vec3' );
- this.getNode( 'Normalize' ).inputs( {
- vec: this.getOrCreateMorphNormal()
- } ).outputs( {
- vec: normalizedMorph
- } );
-
- }
-
- this.getNode( 'InlineCode' ).code( '%out = %tangent.rgb - dot(%tangent.rgb, %normal) * %normal;' ).inputs( {
- tangent: inputVertex,
- normal: normalizedMorph
- } ).outputs( {
- out: outputVertex
- } );
-
- return outputVertex;
- },
-
- morphTransformVec3: function ( inputVertex, outputVertex ) {
- var inputs = {
- vertex: inputVertex,
- weights: this.getOrCreateUniform( 'vec4', 'uTargetWeights' )
- };
-
- var numTargets = this._morphAttribute.getNumTargets();
- for ( var i = 0; i < numTargets; i++ )
- inputs[ 'target' + i ] = this.getTarget( inputVertex.getVariable(), i );
-
- this.getNode( 'Morph' ).inputs( inputs ).outputs( {
- out: outputVertex
- } );
-
- return outputVertex;
- },
-
- skinTransformVertex: function ( inputVertex, outputVertex ) {
- this.getNode( 'MatrixMultPosition' ).setInverse( true ).inputs( {
- matrix: this.getOrCreateBoneMatrix(),
- vec: inputVertex
- } ).outputs( {
- vec: outputVertex
- } );
- return outputVertex;
- },
-
- skinTransformNormal: function ( inputVertex, outputVertex ) {
- this.getNode( 'MatrixMultDirection' ).setInverse( true ).inputs( {
- matrix: this.getOrCreateBoneMatrix(),
- vec: inputVertex
- } ).outputs( {
- vec: outputVertex
- } );
- return outputVertex;
- },
-
- getOrCreateMorphVertex: function () {
- var vecOut = this.getVariable( 'morphVertex' );
- if ( vecOut ) return vecOut;
-
- var inputVertex = this.getOrCreateAttribute( 'vec3', 'Vertex' );
- if ( !this._morphAttribute || !this._morphAttribute.hasTarget( 'Vertex' ) ) return inputVertex;
-
- return this.morphTransformVec3( inputVertex, this.createVariable( 'vec3', 'morphVertex' ) );
- },
-
- getOrCreateMorphNormal: function () {
- var vecOut = this.getVariable( 'morphNormal' );
- if ( vecOut ) return vecOut;
-
- var inputNormal = this.getOrCreateAttribute( 'vec3', 'Normal' );
- if ( !this._morphAttribute || !this._morphAttribute.hasTarget( 'Normal' ) ) return inputNormal;
-
- return this.morphTransformVec3( inputNormal, this.createVariable( 'vec3', 'morphNormal' ) );
- },
-
- getOrCreateMorphTangent: function () {
- var vecOut = this.getVariable( 'morphTangent' );
- if ( vecOut ) return vecOut;
-
- var inputTangent = this.getOrCreateAttribute( 'vec4', 'Tangent' );
- var hasMorphTangent = this._morphAttribute && this._morphAttribute.hasTarget( 'Tangent' );
-
- if ( !hasMorphTangent ) return inputTangent;
-
- return this.morphTransformVec3( inputTangent, this.createVariable( 'vec3', 'morphTangent' ) );
-
- // if ( !hasMorphTangent && !this._morphAttribute && !this._morphAttribute.hasTarget( 'Normal' ) ) return inputTangent;
-
- // if ( hasMorphTangent ) return this.morphTransformVec3( inputTangent, this.createVariable( 'vec3', 'morphTangent' ) );
-
- // // Approximate tangent morphing depending of the normal morphing (disabled as we are not sure it's worth it for now)
- // return this.morphTangentApproximation( inputTangent, this.createVariable( 'vec3', 'morphTangent' ) );
- },
-
- getOrCreateSkinVertex: function () {
- var vecOut = this.getVariable( 'skinVertex' );
- if ( vecOut ) return vecOut;
-
- var inputVertex = this.getOrCreateMorphVertex();
- if ( !this._skinningAttribute ) return inputVertex;
-
- return this.skinTransformVertex( inputVertex, this.createVariable( 'vec3', 'skinVertex' ) );
- },
-
- getOrCreateSkinNormal: function () {
- var vecOut = this.getVariable( 'skinNormal' );
- if ( vecOut ) return vecOut;
-
- var inputNormal = this.getOrCreateMorphNormal();
- if ( !this._skinningAttribute ) return inputNormal;
-
- return this.skinTransformNormal( inputNormal, this.createVariable( 'vec3', 'skinNormal' ) );
- },
-
- getOrCreateSkinTangent: function () {
- var vecOut = this.getVariable( 'skinTangent' );
- if ( vecOut ) return vecOut;
-
- var inputTangent = this.getOrCreateMorphTangent();
- if ( !this._skinningAttribute ) return inputTangent;
-
- return this.skinTransformNormal( inputTangent, this.createVariable( 'vec3', 'skinTangent' ) );
- },
-
- getOrCreateLocalVertex: function () {
- return this.getOrCreateSkinVertex();
- },
-
- getOrCreateLocalNormal: function () {
- var vecOut = this.getVariable( 'localNormal' );
- if ( vecOut ) return vecOut;
-
- var normal = this.getOrCreateSkinNormal();
- if ( normal === this.getOrCreateAttribute( 'vec3', 'Normal' ) ) return normal;
-
- vecOut = this.createVariable( 'vec3', 'localNormal' );
- this.getNode( 'Normalize' ).inputs( {
- vec: normal
- } ).outputs( {
- vec: vecOut
- } );
-
- return vecOut;
- },
-
- getOrCreateLocalTangent: function () {
- var vecOut = this.getVariable( 'localTangent' );
- if ( vecOut ) return vecOut;
-
- var inputTangent = this.getOrCreateAttribute( 'vec4', 'Tangent' );
- var tangent = this.getOrCreateSkinTangent();
- if ( tangent === inputTangent ) return tangent;
-
- return this.normalizeAndSetAlpha( tangent, inputTangent, this.createVariable( 'vec4', 'localTangent' ) );
- },
-
- normalizeAndSetAlpha: function ( tang3, tang4, vecOut ) {
- var tangNormalized = this.createVariable( 'vec3' );
- this.getNode( 'Normalize' ).inputs( {
- vec: tang3
- } ).outputs( {
- vec: tangNormalized
- } );
-
- this.getNode( 'SetAlpha' ).inputs( {
- color: tangNormalized,
- alpha: tang4
- } ).outputs( {
- color: vecOut
- } );
-
- return vecOut;
- }
-};
-
-module.exports = CompilerVertex;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/ShaderGenerator.js b/app/static/app/js/vendor/osgjs/osgShader/ShaderGenerator.js
deleted file mode 100644
index 174ac39b..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/ShaderGenerator.js
+++ /dev/null
@@ -1,251 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var Program = require( 'osg/Program' );
-var Shader = require( 'osg/Shader' );
-var Map = require( 'osg/Map' );
-var Compiler = require( 'osgShader/Compiler' );
-var ShaderProcessor = require( 'osgShader/ShaderProcessor' );
-
-// this is the list of attributes type we support by default to generate shader
-// if you need to adjust for your need provide or modify this list
-// if you still need more fine tuning to the filter, override the filterAttributeTypes
-var DefaultsAcceptAttributeTypes = [
- 'ShadowReceive',
- 'Skinning',
- 'Morph',
- 'ShadowTexture',
- 'Texture',
- 'Light',
- 'Material',
- 'Billboard'
-];
-
-var ShaderGenerator = function () {
- this._cache = new window.Map();
-
- // ShaderProcessor singleton used by ShaderGenerator
- // but user can replace it if needed
- this._shaderProcessor = new ShaderProcessor();
- this._acceptAttributeTypes = new window.Set( DefaultsAcceptAttributeTypes );
-
- // ShaderCompiler Object to instanciate
- this._ShaderCompiler = Compiler;
-};
-
-ShaderGenerator.prototype = {
-
- // setShaderCompiler that will be used to createShader
- setShaderCompiler: function ( compiler ) {
- this._ShaderCompiler = compiler;
- },
-
- getShaderCompiler: function () {
- return this._ShaderCompiler;
- },
-
-
- // return a Set of accepted attribtues to generate shader
- getAcceptAttributeTypes: function () {
- return this._acceptAttributeTypes;
- },
-
-
- getShaderProcessor: function () {
- return this._shaderProcessor;
- },
-
- setShaderProcessor: function ( shaderProcessor ) {
- this._shaderProcessor = shaderProcessor;
- },
-
- // filter input types and write the result in the outputs array
- filterAttributeTypes: function ( attribute ) {
-
- // TODO: use same mechanism as acceptAttributesTypes ?
- // with a default set in a var and use overwrittable Set
- // when inheriting the class
- // Faster && Flexiblier
- if ( attribute.libraryName() !== 'osg' && attribute.libraryName() !== 'osgShadow' && attribute.libraryName() !== 'osgAnimation' )
- return true;
-
- var attributeType = attribute.getType();
-
- // accept only attribute listed in the container
- if ( !this._acceptAttributeTypes.has( attributeType ) )
- return true;
-
- // works for attribute that contains isEnabled
- // Light, Shadow. It let us to filter them to build a shader if not enabled
- if ( attribute.isEnabled && !attribute.isEnabled() )
- return true;
- // // if it's a light and it's not enable we filter it
- // if ( attribute.typeID === Light.typeID && !attribute.isEnabled() ) {
- // return true;
- // }
-
- return false;
- },
-
- // get actives attribute that comes from state
- getActiveAttributeList: function ( state, list ) {
-
- var hash = '';
- var attributeMap = state.attributeMap;
- var attributeMapKeys = attributeMap.getKeys();
-
- for ( var j = 0, k = attributeMapKeys.length; j < k; j++ ) {
-
- var keya = attributeMapKeys[ j ];
- var attributeStack = attributeMap[ keya ];
- var attr = attributeStack.lastApplied;
-
- if ( this.filterAttributeTypes( attr ) )
- continue;
-
- if ( attr.getHash ) {
- hash += attr.getHash();
- } else {
- hash += attr.getType();
- }
- list.push( attr );
- }
- return hash;
- },
-
- // get actives texture attribute that comes from state
- getActiveTextureAttributeList: function ( state, list ) {
- var hash = '';
- var attributeMapList = state.textureAttributeMapList;
- var i, l;
-
- for ( i = 0, l = attributeMapList.length; i < l; i++ ) {
- var attributeMapForUnit = attributeMapList[ i ];
- if ( !attributeMapForUnit ) {
- continue;
- }
- list[ i ] = [];
-
- var attributeMapForUnitKeys = attributeMapForUnit.getKeys();
-
- for ( var j = 0, m = attributeMapForUnitKeys.length; j < m; j++ ) {
-
- var key = attributeMapForUnitKeys[ j ];
- var attributeStack = attributeMapForUnit[ key ];
- if ( attributeStack.values().length === 0 ) {
- continue;
- }
-
- var attr = attributeStack.lastApplied;
- if ( this.filterAttributeTypes( attr ) )
- continue;
-
- if ( attr.isTextureNull() )
- continue;
-
- if ( attr.getHash ) {
- hash += attr.getHash();
- } else {
- hash += attr.getType();
- }
- list[ i ].push( attr );
- }
- }
- return hash;
- },
-
- getActiveUniforms: function ( state, attributeList, textureAttributeList ) {
-
- var uniforms = {};
-
- for ( var i = 0, l = attributeList.length; i < l; i++ ) {
-
- var at = attributeList[ i ];
- if ( at.getOrCreateUniforms ) {
- var attributeUniformMap = at.getOrCreateUniforms();
- // It could happen that uniforms are declared conditionally
- if ( attributeUniformMap !== undefined ) {
- var attributeUniformMapKeys = attributeUniformMap.getKeys();
-
- for ( var j = 0, m = attributeUniformMapKeys.length; j < m; j++ ) {
- var name = attributeUniformMapKeys[ j ];
- var uniform = attributeUniformMap[ name ];
- uniforms[ uniform.getName() ] = uniform;
- }
- }
- }
- }
-
- for ( var a = 0, n = textureAttributeList.length; a < n; a++ ) {
- var tat = textureAttributeList[ a ];
- if ( tat ) {
- for ( var b = 0, o = tat.length; b < o; b++ ) {
- var attr = tat[ b ];
-
- var texUniformMap = attr.getOrCreateUniforms( a );
- var texUniformMapKeys = texUniformMap.getKeys();
-
- for ( var t = 0, tl = texUniformMapKeys.length; t < tl; t++ ) {
- var tname = texUniformMapKeys[ t ];
- var tuniform = texUniformMap[ tname ];
- uniforms[ tuniform.getName() ] = tuniform;
- }
- }
- }
- }
-
- return new Map( uniforms );
- },
-
- getOrCreateProgram: ( function () {
- // TODO: double check GC impact of this stack
- // TODO: find a way to get a hash dirty/cache on stateAttribute
- var textureAttributes = [];
- var attributes = [];
-
- return function ( state ) {
- // extract valid attributes
- var hash = '';
- attributes.length = 0;
- textureAttributes.length = 0;
- hash += this.getActiveAttributeList( state, attributes );
- hash += this.getActiveTextureAttributeList( state, textureAttributes );
-
- var cache = this._cache.get( hash );
- if ( cache !== undefined ) {
- return cache;
- }
-
-
- // use ShaderCompiler, it can be overrided by a custom one
- var ShaderCompiler = this._ShaderCompiler;
- var shaderGen = new ShaderCompiler( attributes, textureAttributes, this._shaderProcessor );
-
- /* develblock:start */
- // Logs hash, attributes and compiler
- Notify.debug( 'New Compilation ', false, true );
- Notify.debug( {
- Attributes: attributes,
- Texture: textureAttributes,
- Hash: hash,
- Compiler: shaderGen.getFragmentShaderName()
- }, false, true );
- /* develblock:end */
-
- var fragmentshader = shaderGen.createFragmentShader();
- var vertexshader = shaderGen.createVertexShader();
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vertexshader ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentshader ) );
-
- program.hash = hash;
- program.setActiveUniforms( this.getActiveUniforms( state, attributes, textureAttributes ) );
- program.generated = true;
-
- this._cache.set( hash, program );
- return program;
- };
- } )()
-};
-
-module.exports = ShaderGenerator;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/ShaderGeneratorProxy.js b/app/static/app/js/vendor/osgjs/osgShader/ShaderGeneratorProxy.js
deleted file mode 100644
index 9ea54634..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/ShaderGeneratorProxy.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict';
-var ShaderGenerator = require( 'osgShader/ShaderGenerator' );
-var ShadowCastShaderGenerator = require( 'osgShadow/ShadowCastShaderGenerator' );
-var DisplayNormalVisitor = require( 'osgUtil/DisplayNormalVisitor' );
-var DisplayGeometryVisitor = require( 'osgUtil/DisplayGeometryVisitor' );
-
-var ShaderGeneratorProxy = function () {
-
- // object of shader generators
- this._generators = new window.Map();
- this.addShaderGenerator( 'default', new ShaderGenerator() );
- this.addShaderGenerator( 'ShadowCast', new ShadowCastShaderGenerator() );
- this.addShaderGenerator( 'debugNormal', new DisplayNormalVisitor.ShaderGeneratorCompilerOffsetNormal() );
- this.addShaderGenerator( 'debugTangent', new DisplayNormalVisitor.ShaderGeneratorCompilerOffsetTangent() );
- this.addShaderGenerator( 'debugGeometry', new DisplayGeometryVisitor.ShaderGeneratorCompilerColorGeometry() );
- this.addShaderGenerator( 'debugSkinning', new DisplayGeometryVisitor.ShaderGeneratorCompilerColorSkinning() );
-
- return this;
-};
-
-ShaderGeneratorProxy.prototype = {
-
- getShaderGenerator: function ( name ) {
-
- if ( !name )
- return this._generators.get( 'default' );
-
- return this._generators.get( name );
- },
-
- // user-space facility to provide its own
- addShaderGenerator: function ( name, sg ) {
-
- this._generators.set( name, sg );
-
- }
-
-};
-
-module.exports = ShaderGeneratorProxy;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/ShaderProcessor.js b/app/static/app/js/vendor/osgjs/osgShader/ShaderProcessor.js
deleted file mode 100644
index 3e3b89ad..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/ShaderProcessor.js
+++ /dev/null
@@ -1,217 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var shaderLib = require( 'osgShader/shaderLib' );
-var shadowShaderLib = require( 'osgShadow/shaderLib' );
-
-
-// Shader as vert/frag/glsl files Using requirejs text plugin
-// Preprocess features like: //
-// - Handle (recursive) include, avoiding code repeat and help code factorization
-// - Handle per shader and global define/precision
-
-
-var ShaderProcessor = function ( createInstance ) {
-
- if ( !createInstance ) {
- if ( ShaderProcessor.instance ) {
- return ShaderProcessor.instance;
- }
- ShaderProcessor.instance = this;
- }
-
- this.addShaders( shaderLib );
- this.addShaders( shadowShaderLib );
- return this;
-};
-
-ShaderProcessor.prototype = {
- _shadersText: {},
- _shadersList: {},
- _globalDefaultprecision: '#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n#endif',
- _debugLines: false,
- _includeR: /#pragma include "([^"]+)"/g,
- _includeCondR: /#pragma include (["^+"]?["\ "[a-zA-Z_0-9](.*)"]*?)/g,
- _defineR: /\#define\s+([a-zA-Z_0-9]+)/,
- _precisionR: /precision\s+(high|low|medium)p\s+float/,
-
-
- // {
- // 'functions.glsl': textShaderFunctions,
- // 'lights.glsl': textShaderFunctions,
- // 'textures.glsl': textShaderFunctions
- // };
- addShaders: function ( shaders ) {
-
- var keys = window.Object.keys( shaders );
-
- keys.forEach( function ( key ) {
-
- this._shadersList[ key ] = key;
- this._shadersText[ key ] = shaders[ key ];
-
- }, this );
-
- },
-
-
- instrumentShaderlines: function ( content, sourceID ) {
- // TODO instrumentShaderlines
- // http://immersedcode.org/2012/1/12/random-notes-on-webgl/
- // one ID per "file"
- // Each file has its line number starting at 0
- // handle include, the do that numbering also in preprocess...
- // Then on shader error using sourceID and line you can point the correct line...
- // has to attach that info to osg.shader object.
- /*
- var allLines = content.split('\n');
- var i = 0;
- for (var k = 0; k _< allLines.length; k++) {
- if (!this._includeR.test(allLines[k])) {
- allLines[k] = "#line " + (i++) + " " + sourceID + '\n' + allLines[k] ;
- }
- }
- content = allLines.join('\n');
- */
-
- // seems just prefixing first line seems ok to help renumbering error mesg
- return '\n#line ' + 0 + ' ' + sourceID + '\n' + content;
- },
-
- getShaderTextPure: function ( shaderName ) {
-
- var preShader = this._shadersText[ shaderName ];
-
- if ( !preShader ) {
- Notify.error( 'shader file/text: ' + shaderName + ' not registered' );
- preShader = '';
- }
-
- return preShader;
- },
-
- getShader: function ( shaderName, defines, extensions, type ) {
- var shader = this.getShaderTextPure( shaderName );
- return this.processShader( shader, defines, extensions, type );
- },
-
- // recursively handle #include external glsl
- // files (for now in the same folder.)
- preprocess: function ( content, sourceID, includeList, inputsDefines /*, type */ ) {
- var self = this;
- return content.replace( this._includeCondR, function ( _, name ) {
- var includeOpt = name.split( ' ' );
- var includeName = includeOpt[ 0 ].replace( /"/g, '' );
-
- // pure include is
- // \#pragma include "name";
-
- // conditionnal include is name included if _PCF defined
- // \#pragma include "name" "_PCF";
- if ( includeOpt.length > 1 && inputsDefines ) {
-
- // some conditions here.
- // if not defined we do not include
- var found = false;
- var defines = inputsDefines.map( function ( defineString ) {
- // find '#define', remove duplicate whitespace, split on space and return the define Text
- return self._defineR.test( defineString ) && defineString.replace( /\s+/g, ' ' ).split( ' ' )[ 1 ];
- } );
-
- for ( var i = 1; i < includeOpt.length && !found; i++ ) {
- var key = includeOpt[ i ].replace( /"/g, '' );
- for ( var k = 0; k < defines.length && !found; k++ ) {
-
- if ( defines[ k ] !== false && defines[ k ] === key ) {
- found = true;
- break;
- }
-
- }
- }
- if ( !found )
- return '';
- }
-
- // already included
- if ( includeList.indexOf( includeName ) !== -1 ) return '';
- // avoid endless loop, not calling the impure
- var txt = this.getShaderTextPure( includeName );
- // make sure it's not included twice
- includeList.push( includeName );
- if ( this._debugLines ) {
- txt = this.instrumentShaderlines( txt, sourceID );
- }
- sourceID++;
- // to the infinite and beyond !
- txt = this.preprocess( txt, sourceID, includeList, inputsDefines );
- return txt;
- }.bind( this ) );
-
- },
-
- // process a shader and define
- // get a full expanded single shader source code
- // resolving include dependencies
- // adding defines
- // adding line instrumenting.
- processShader: function ( shader, defines, extensions, type ) {
-
- var includeList = [];
- var preShader = shader;
- var sourceID = 0;
- if ( this._debugLines ) {
- preShader = this.instrumentShaderlines( preShader, sourceID );
- sourceID++;
- }
-
- // removes duplicates
- if ( defines !== undefined ) {
- defines = defines.sort().filter( function ( item, pos ) {
- return !pos || item !== defines[ pos - 1 ];
- } );
- }
- if ( extensions !== undefined ) {
- extensions = extensions.sort().filter( function ( item, pos ) {
- return !pos || item !== extensions[ pos - 1 ];
- } );
- }
-
- var postShader = this.preprocess( preShader, sourceID, includeList, defines, type );
-
- var prePrend = '';
- prePrend += '#version 100\n'; // webgl1 (webgl2 #version 130 ?)
-
- // then
- // it's extensions first
- // See https://khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf
- // p14-15: before any non-processor token
- // add them
- if ( extensions !== undefined ) {
- // could add an extension check support warning there...
- prePrend += extensions.join( '\n' ) + '\n';
- }
-
- // vertex shader doesn't need precision, it's highp per default, enforced per spec
- // but then not giving precision on uniform/varying might make conflicts arise
- // between both FS and VS if FS default is mediump !
- // && type !== 'vertex'
- if ( this._globalDefaultprecision ) {
- if ( !this._precisionR.test( postShader ) ) {
- // use the shaderhighprecision flag at shaderloader start
- //var highp = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
- //var highpSupported = highp.precision != 0;
- prePrend += this._globalDefaultprecision + '\n';
- }
- }
-
- // if defines
- // add them
- if ( defines !== undefined ) {
- prePrend += defines.join( '\n' ) + '\n';
- }
- postShader = prePrend + postShader;
-
- return postShader;
- }
-};
-module.exports = ShaderProcessor;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node.js b/app/static/app/js/vendor/osgjs/osgShader/node.js
deleted file mode 100644
index e2d2ee4e..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node.js
+++ /dev/null
@@ -1,32 +0,0 @@
-'use strict';
-
-var subnamespace = [
- require( 'osgShader/node/skinning' ),
- require( 'osgShader/node/morph' ),
- require( 'osgShader/node/data' ),
- require( 'osgShader/node/textures' ),
- require( 'osgShader/node/functions' ),
- require( 'osgShader/node/lights' ),
- require( 'osgShader/node/operations' )
-];
-
-var lib = {};
-
-// add all sub component to root level of the lib
-subnamespace.forEach( function ( component /*, index */ ) {
-
- window.Object.keys( component ).forEach( function ( key ) {
-
- var element = component[ key ];
-
- if ( this[ key ] !== undefined ) { // if exist throw exception
- throw 'duplicate entry in node library';
- }
-
- this[ key ] = element;
-
- }, this );
-
-}, lib );
-
-module.exports = lib;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/Node.js b/app/static/app/js/vendor/osgjs/osgShader/node/Node.js
deleted file mode 100644
index 50c62280..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/Node.js
+++ /dev/null
@@ -1,161 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-
-var instance = 0;
-var Node = function () {
- this._name = 'AbstractNode';
- this._inputs = [];
- this._outputs = null;
-
- // category of node
- // same name implies same
- // define/function
- //this.type = '';
-
- // uuid: unicity
- // allows multipe node of same type
- // declaring multipe code paths
- // inside the main
- this._id = instance++;
-
- this._text = undefined;
-};
-
-Node.prototype = {
-
- getID: function () {
- return this._id;
- },
- getName: function () {
- return this._name;
- },
-
- getType: function () {
- return this.type;
- },
-
- toString: function () {
- var str = 'name : ' + this._name;
- if ( this.type ) str += ' (' + this.type + ')';
- return str;
- },
-
- getInputs: function () {
- return this._inputs;
- },
-
- getOutputs: function () {
- return this._outputs;
- },
-
- checkInputsOutputs: function () {
-
- var i, key;
- if ( this.validInputs ) {
-
- for ( i = 0; i < this.validInputs.length; i++ ) {
- key = this.validInputs[ i ];
- if ( !this._inputs[ key ] ) {
- Notify.error( 'Shader node ' + this.type + ' validation error input ' + key + ' is missing' );
- return false;
- }
- }
- }
-
- if ( this.validOutputs ) {
-
- for ( i = 0; i < this.validOutputs.length; i++ ) {
- key = this.validOutputs[ i ];
- if ( !this._outputs[ key ] ) {
- Notify.error( 'Shader node ' + this.type + ' validation error output ' + key + ' is missing' );
- return false;
- }
- }
- }
-
- return true;
- },
-
- // accepts inputs like that:
- // inputs( [ a, b, c , d] )
- // inputs( { a: x, b: y } )
- // inputs( a, b, c, d )
- inputs: function () {
- // handle inputs ( a, b, c, d)
- for ( var i = 0, l = arguments.length; i < l; i++ ) {
-
- var input = arguments[ i ];
- if ( !input ) {
- Notify.error( 'Shader node ' + this.type + ' input number ' + l + ' is undefined ' );
- break;
- }
-
- // handle inputs( [a, b, c ,d] )
- if ( Array.isArray( input ) ) {
-
- this.inputs.apply( this, input );
- return this;
-
- // check for an object {} and not something from base class Node
- } else if ( typeof input === 'object' && input !== null && ( input instanceof Node === false ) ) {
- this._inputs = input;
- return this;
-
- } else { // add argument to the array
- this._inputs.push( input );
- }
- }
-
- return this;
- },
-
- // accepts inputs like that:
- // outputs( { a: x, b: y } )
- // outputs( a )
- outputs: function ( outputs ) {
-
- this._outputs = outputs;
-
- // single output
- if ( this._outputs instanceof Node === true ) {
-
- this.autoLink( this._outputs );
-
- } else {
-
- // iterate on objects keys
- var keys = window.Object.keys( this._outputs );
- for ( var i = 0; i < keys.length; i++ ) {
- var key = keys[ i ];
- this.autoLink( this._outputs[ key ] );
- }
- }
-
- return this;
- },
-
- autoLink: function ( output ) {
-
- if ( output === undefined )
- return this;
-
- output.inputs( this );
-
- return this;
- },
-
- computeShader: function () {
- return this._text;
- },
-
- comment: function ( txt ) {
- this._comment = '//' + txt;
- },
-
- getComment: function () {
- return this._comment;
- }
-};
-
-
-module.exports = Node;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/billboard.glsl b/app/static/app/js/vendor/osgjs/osgShader/node/billboard.glsl
deleted file mode 100644
index a6956288..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/billboard.glsl
+++ /dev/null
@@ -1,16 +0,0 @@
-vec3 getScale( const in mat4 matrix ) {
- // Only working with positive scales.
- float xs = matrix[0][0] * matrix[0][1] * matrix[0][2] * matrix[0][3] < 0. ? -1. : 1.;
- float ys = matrix[1][0] * matrix[1][1] * matrix[1][2] * matrix[1][3] < 0. ? -1. : 1.;
- float zs = matrix[2][0] * matrix[2][1] * matrix[2][2] * matrix[2][3] < 0. ? -1. : 1.;
- vec3 scale;
- scale.x = xs * sqrt( matrix[0][0] * matrix[0][0] + matrix[0][1] * matrix[0][1] + matrix[0][2] * matrix[0][2]);
- scale.y = ys * sqrt( matrix[1][0] * matrix[1][0] + matrix[1][1] * matrix[1][1] + matrix[1][2] * matrix[1][2]);
- scale.z = zs * sqrt( matrix[2][0] * matrix[2][0] + matrix[2][1] * matrix[2][1] + matrix[2][2] * matrix[2][2]);
- return scale;
-}
-
-vec4 billboard( const in vec3 vertex, const in mat4 modelViewMatrix, const in mat4 projectionMatrix ) {
- vec3 scale = getScale( modelViewMatrix );
- return projectionMatrix * ( vec4( scale.x* vertex.x , scale.y * vertex.y, scale.z * vertex.z, 1.0 ) + vec4( modelViewMatrix[ 3 ].xyz, 0.0 ) );
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/billboard.js b/app/static/app/js/vendor/osgjs/osgShader/node/billboard.js
deleted file mode 100644
index 9ffc2f24..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/billboard.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var ShaderUtils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-var Billboard = function () {
- Node.apply( this );
-};
-
-Billboard.prototype = MACROUTILS.objectInherit( Node.prototype, {
- type: 'Billboard',
- validInputs: [ 'Vertex', 'ModelViewMatrix', 'ProjectionMatrix' ],
- validOutputs: [ 'vec' ],
-
- globalFunctionDeclaration: function () {
- return '#pragma include "billboard.glsl"';
- },
- computeShader: function () {
- return ShaderUtils.callFunction( 'billboard', this._outputs.vec, [ this._inputs.Vertex, this._inputs.ModelViewMatrix, this._inputs.ProjectionMatrix ] );
- }
-} );
-
-module.exports = {
- Billboard: Billboard
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/colorEncode.glsl b/app/static/app/js/vendor/osgjs/osgShader/node/colorEncode.glsl
deleted file mode 100644
index bcf7b653..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/colorEncode.glsl
+++ /dev/null
@@ -1,26 +0,0 @@
-
-float decodeFloatRGBA( vec4 rgba ) {
- return dot( rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) );
-}
-
-vec4 encodeFloatRGBA( float v ) {
- vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
- enc = fract(enc);
- enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);
- return enc;
-}
-
-vec2 decodeHalfFloatRGBA( vec4 rgba ) {
- return vec2(rgba.x + (rgba.y / 255.0), rgba.z + (rgba.w / 255.0));
-}
-
-vec4 encodeHalfFloatRGBA( vec2 v ) {
- const vec2 bias = vec2(1.0 / 255.0, 0.0);
- vec4 enc;
- enc.xy = vec2(v.x, fract(v.x * 255.0));
- enc.xy = enc.xy - (enc.yy * bias);
-
- enc.zw = vec2(v.y, fract(v.y * 255.0));
- enc.zw = enc.zw - (enc.ww * bias);
- return enc;
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/data.js b/app/static/app/js/vendor/osgjs/osgShader/node/data.js
deleted file mode 100644
index 4581e3b7..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/data.js
+++ /dev/null
@@ -1,191 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var utils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-var sprintf = utils.sprintf;
-
-// Base Class for all variables Nodes
-// TODO: add precision
-// type {string} vec3/4/2, float, int, etc.
-// prefix {string} vec3/4/2, float, int, etc.
-var Variable = function ( type, prefix ) {
- Node.call( this );
- this._name = 'Variable';
- this._prefix = prefix;
- this._type = type;
- this._value = undefined;
-};
-
-Variable.prototype = MACROUTILS.objectInherit( Node.prototype, {
-
- getType: function () {
- return this._type;
- },
-
- getVariable: function () {
- return this._prefix;
- },
-
- setValue: function ( value ) {
- this._value = value;
- return this;
- },
-
- toString: function () {
- var str = 'prefix : ' + this._prefix;
- str += ', name : ' + this._prefix;
- if ( this.type ) str += ' (' + this.type + ')';
- return str;
- },
-
- declare: function () {
- if ( this._value !== undefined ) {
- return sprintf( '%s %s = %s;', [ this._type, this.getVariable(), this._value ] );
- } else {
- return sprintf( '%s %s;', [ this._type, this.getVariable() ] );
- }
- },
-
- isEmpty: function () {
- return this._value === undefined && this._inputs.length === 0;
- },
-
- reset: function () {
- this._inputs = [];
- this._outputs = null;
- this._value = undefined;
- this._text = undefined;
- }
-} );
-
-// Constant Variable
-// help glsl compiler and make sure no one writes in it :)
-var Constant = function ( type, prefix ) {
- Variable.call( this, type, prefix );
-};
-Constant.prototype = MACROUTILS.objectInherit( Variable.prototype, {
-
- declare: function () {
- return sprintf( 'const %s %s = %s;', [ this._type, this.getVariable(), this._value ] );
- }
-} );
-
-var Uniform = function ( type, prefix, size ) {
- Variable.call( this, type, prefix );
- this._size = size;
-};
-
-Uniform.prototype = MACROUTILS.objectInherit( Variable.prototype, {
- declare: function () {
- return undefined;
- },
-
- globalDeclaration: function () {
- if ( this._size ) {
- return sprintf( 'uniform %s %s[%s];', [ this._type, this.getVariable(), this._size ] );
- } else {
- return sprintf( 'uniform %s %s;', [ this._type, this.getVariable() ] );
- }
- }
-
-} );
-
-// Vertex Attribute Variables
-var Attribute = function ( type, prefix ) {
- Variable.call( this, type, prefix );
-};
-
-Attribute.prototype = MACROUTILS.objectInherit( Variable.prototype, {
- declare: function () {
- return undefined;
- },
-
- globalDeclaration: function () {
- return sprintf( 'attribute %s %s;', [ this._type, this.getVariable() ] );
- }
-
-} );
-
-
-var Varying = function ( type, prefix ) {
- Variable.call( this, type, prefix );
-};
-
-Varying.prototype = MACROUTILS.objectInherit( Variable.prototype, {
- declare: function () {
- return undefined;
- },
-
- globalDeclaration: function () {
- return sprintf( 'varying %s %s;', [ this._type, this.getVariable() ] );
- }
-} );
-
-var Sampler = function ( type, prefix ) {
- Variable.call( this, type, prefix );
-};
-
-Sampler.prototype = MACROUTILS.objectInherit( Variable.prototype, {
- declare: function () {
- return undefined;
- },
-
- globalDeclaration: function () {
- return sprintf( 'uniform %s %s;', [ this._type, this.getVariable() ] );
- }
-
-} );
-
-// Graph Root Node Abstract Class
-// Derive from that for new outputs
-// gl_FragDepth, etc.
-var Output = function ( type, wholeName ) {
- Variable.call( this, type, wholeName );
-};
-
-Output.prototype = MACROUTILS.objectInherit( Variable.prototype, {
- _unique: true,
- isUnique: function () {
- return this._unique;
- },
- outputs: function () { /* do nothing for variable */
- return this;
- },
- getVariable: function () {
- return this._prefix;
- }
-} );
-
-// Graph Root Nodes
-var glFragColor = function () {
- Output.call( this, 'vec4', 'gl_FragColor' );
- this._name = 'glFragColor';
-};
-glFragColor.prototype = MACROUTILS.objectInherit( Output.prototype, {} );
-
-var glPosition = function () {
- Output.call( this, 'vec4', 'gl_Position' );
- this._name = 'glPosition';
-};
-glPosition.prototype = MACROUTILS.objectInherit( Output.prototype, {} );
-
-
-var glPointSize = function () {
- Output.call( this, 'float', 'gl_PointSize' );
- this._name = 'glPointSize';
-};
-glPointSize.prototype = MACROUTILS.objectInherit( Output.prototype, {} );
-
-module.exports = {
- Output: Output,
- glPointSize: glPointSize,
- glPosition: glPosition,
- glFragColor: glFragColor,
- Sampler: Sampler,
- Variable: Variable,
- Constant: Constant,
- Attribute: Attribute,
- Varying: Varying,
- Uniform: Uniform
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/functions.glsl b/app/static/app/js/vendor/osgjs/osgShader/node/functions.glsl
deleted file mode 100644
index 167609e5..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/functions.glsl
+++ /dev/null
@@ -1,70 +0,0 @@
-// the approximation :
-// http://chilliant.blogspot.fr/2012/08/srgb-approximations-for-hlsl.html
-// introduced slightly darker colors and more slight banding in the darks.
-// The reference implementation (or even a single pow approx) did not introduced these effects.
-
-// so for now we stick with the reference implementation :
-// https://www.khronos.org/registry/gles/extensions/EXT/EXT_sRGB.txt
-// with the slight changes :
-// - we always assume the color is >= 0.0 (so no check)
-// - unlike the previous approximation, linear to srgb is monotonic so we don't need to check if the color is > 1
-
-#define LIN_SRGB(x) x < 0.0031308 ? x * 12.92 : 1.055 * pow(x, 1.0/2.4) - 0.055
-float linearTosRGB(const in float c) {
- return LIN_SRGB(c);
-}
-vec3 linearTosRGB(const in vec3 c) {
- return vec3(LIN_SRGB(c.r), LIN_SRGB(c.g), LIN_SRGB(c.b));
-}
-vec4 linearTosRGB(const in vec4 c) {
- return vec4(LIN_SRGB(c.r), LIN_SRGB(c.g), LIN_SRGB(c.b), c.a);
-}
-
-#define SRGB_LIN(x) x < 0.04045 ? x * (1.0 / 12.92) : pow((x + 0.055) * (1.0 / 1.055), 2.4)
-float sRGBToLinear(const in float c) {
- return SRGB_LIN(c);
-}
-vec3 sRGBToLinear(const in vec3 c) {
- return vec3(SRGB_LIN(c.r), SRGB_LIN(c.g), SRGB_LIN(c.b));
-}
-vec4 sRGBToLinear(const in vec4 c) {
- return vec4(SRGB_LIN(c.r), SRGB_LIN(c.g), SRGB_LIN(c.b), c.a);
-}
-
-//http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html
-vec3 RGBMToRGB( const in vec4 rgba ) {
- const float maxRange = 8.0;
- return rgba.rgb * maxRange * rgba.a;
-}
-
-const mat3 LUVInverse = mat3( 6.0013, -2.700, -1.7995,
- -1.332, 3.1029, -5.7720,
- 0.3007, -1.088, 5.6268 );
-
-vec3 LUVToRGB( const in vec4 vLogLuv ) {
- float Le = vLogLuv.z * 255.0 + vLogLuv.w;
- vec3 Xp_Y_XYZp;
- Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);
- Xp_Y_XYZp.z = Xp_Y_XYZp.y / vLogLuv.y;
- Xp_Y_XYZp.x = vLogLuv.x * Xp_Y_XYZp.z;
- vec3 vRGB = LUVInverse * Xp_Y_XYZp;
- return max(vRGB, 0.0);
-}
-
-// http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html
-vec4 encodeRGBM(const in vec3 col, const in float range) {
- if(range <= 0.0)
- return vec4(col, 1.0);
- vec4 rgbm;
- vec3 color = col / range;
- rgbm.a = clamp( max( max( color.r, color.g ), max( color.b, 1e-6 ) ), 0.0, 1.0 );
- rgbm.a = ceil( rgbm.a * 255.0 ) / 255.0;
- rgbm.rgb = color / rgbm.a;
- return rgbm;
-}
-
-vec3 decodeRGBM(const in vec4 col, const in float range) {
- if(range <= 0.0)
- return col.rgb;
- return range * col.rgb * col.a;
-}
\ No newline at end of file
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/functions.js b/app/static/app/js/vendor/osgjs/osgShader/node/functions.js
deleted file mode 100644
index dc6aedf5..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/functions.js
+++ /dev/null
@@ -1,142 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var utils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-var sprintf = utils.sprintf;
-
-// base to avoid redundant global declarations
-// it's to keep node more readable
-var NodeFunctions = function () {
- Node.call( this );
-};
-
-NodeFunctions.prototype = MACROUTILS.objectInherit( Node.prototype, {
-
- globalFunctionDeclaration: function () {
- return '#pragma include "functions.glsl"';
- }
-
-} );
-
-
-var Normalize = function () {
- NodeFunctions.call( this );
-};
-Normalize.prototype = MACROUTILS.objectInherit( NodeFunctions.prototype, {
- type: 'Normalize',
- validInputs: [ 'vec' ],
- validOuputs: [ 'vec' ],
- computeShader: function () {
- return utils.callFunction( 'normalize', this._outputs.vec, [ this._inputs.vec ] );
- }
-} );
-
-
-var sRGBToLinear = function () {
- NodeFunctions.call( this );
-};
-
-sRGBToLinear.prototype = MACROUTILS.objectInherit( NodeFunctions.prototype, {
-
- type: 'sRGBToLinear',
-
- validInputs: [ 'color' ],
- validOuputs: [ 'color' ],
-
- computeShader: function () {
- return this.computeConversion( 'sRGBToLinear' );
- },
- computeConversion: function ( funcName ) {
- var out = this._outputs.color;
- var color = this._inputs.color;
- var rgb = out.getType() !== color.getType() ? '.rgb' : '';
-
- return utils.callFunction( funcName, out.getVariable() + rgb, [ color.getVariable() + rgb ] );
- }
-
-} );
-
-var LinearTosRGB = function () {
- sRGBToLinear.call( this );
-};
-
-LinearTosRGB.prototype = MACROUTILS.objectInherit( sRGBToLinear.prototype, {
- type: 'LinearTosRGB',
- computeShader: function () {
- return this.computeConversion( 'linearTosRGB' );
- }
-} );
-
-var FrontNormal = function () {
- NodeFunctions.call( this );
-};
-
-FrontNormal.prototype = MACROUTILS.objectInherit( NodeFunctions.prototype, {
-
- type: 'FrontNormal',
- validInputs: [ 'normal' ],
- validOuputs: [ 'normal' ],
-
- computeShader: function () {
- return sprintf( '%s = gl_FrontFacing ? %s : -%s ;', [
- this._outputs.normal.getVariable(),
- this._inputs.normal.getVariable(),
- this._inputs.normal.getVariable()
- ] );
- }
-} );
-
-var getVec3 = function ( vec ) {
- return vec.getType && vec.getType() === 'vec4' ? vec.getVariable() + '.rgb' : vec;
-};
-var EncodeRGBM = function () {
- NodeFunctions.call( this );
-};
-EncodeRGBM.prototype = MACROUTILS.objectInherit( NodeFunctions.prototype, {
- type: 'EncodeRGBM',
- validInputs: [ 'color', 'range' ],
- validOutputs: [ 'color' ],
- computeShader: function () {
- return utils.callFunction( 'encodeRGBM', this._outputs.color, [ getVec3( this._inputs.color ), this._inputs.range ] );
- }
-} );
-
-var DecodeRGBM = function () {
- NodeFunctions.call( this );
-};
-DecodeRGBM.prototype = MACROUTILS.objectInherit( NodeFunctions.prototype, {
- type: 'DecodeRGBM',
- validInputs: [ 'color', 'range' ],
- validOutputs: [ 'color' ],
- computeShader: function () {
- return utils.callFunction( 'decodeRGBM', this._outputs.color, [ this._inputs.color, this._inputs.range ] );
- }
-} );
-
-var Define = function ( name ) {
- Node.call( this );
- this._defineName = name;
- this._defineValue = '';
-};
-Define.prototype = MACROUTILS.objectInherit( Node.prototype, {
- type: 'Define',
- setValue: function ( value ) {
- this._defineValue = value;
- return this;
- },
- getDefines: function () {
- return [ '#define ' + this._defineName + ' ' + this._defineValue ];
- }
-} );
-
-module.exports = {
- NodeFunctions: NodeFunctions,
- Normalize: Normalize,
- sRGBToLinear: sRGBToLinear,
- LinearTosRGB: LinearTosRGB,
- FrontNormal: FrontNormal,
- DecodeRGBM: DecodeRGBM,
- EncodeRGBM: EncodeRGBM,
- Define: Define
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/lights.glsl b/app/static/app/js/vendor/osgjs/osgShader/node/lights.glsl
deleted file mode 100644
index 2b51118c..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/lights.glsl
+++ /dev/null
@@ -1,241 +0,0 @@
-////////////////
-// ATTENUATION
-/////////////
-float getLightAttenuation(const in float dist, const in vec4 lightAttenuation)
-{
- // lightAttenuation(constantEnabled, linearEnabled, quadraticEnabled)
- // TODO find a vector alu instead of 4 scalar
- float constant = lightAttenuation.x;
- float linear = lightAttenuation.y*dist;
- float quadratic = lightAttenuation.z*dist*dist;
- return 1.0 / ( constant + linear + quadratic );
-}
-//
-// LIGHTING EQUATION TERMS
-///
-void specularCookTorrance(const in vec3 n, const in vec3 l, const in vec3 v, const in float hard, const in vec3 materialSpecular, const in vec3 lightSpecular, out vec3 specularContrib)
-{
- vec3 h = normalize(v + l);
- float nh = dot(n, h);
- float specfac = 0.0;
-
- if(nh > 0.0) {
- float nv = max( dot(n, v), 0.0 );
- float i = pow(nh, hard);
- i = i / (0.1 + nv);
- specfac = i;
- }
- // ugly way to fake an energy conservation (mainly to avoid super bright stuffs with low glossiness)
- float att = hard > 100.0 ? 1.0 : smoothstep(0.0, 1.0, hard * 0.01);
- specularContrib = specfac*materialSpecular*lightSpecular*att;
-}
-
-void lambert(const in float ndl, const in vec3 materialDiffuse, const in vec3 lightDiffuse, out vec3 diffuseContrib)
-{
- diffuseContrib = ndl*materialDiffuse*lightDiffuse;
-}
-////////////////////////
-/// Main func
-///////////////////////
-
-/// for each light
-//direction, dist, NDL, attenuation, compute diffuse, compute specular
-
-vec3 computeSpotLightShading(
- const in vec3 normal,
- const in vec3 eyeVector,
-
- const in vec3 materialAmbient,
- const in vec3 materialDiffuse,
- const in vec3 materialSpecular,
- const in float materialShininess,
-
- const in vec3 lightAmbient,
- const in vec3 lightDiffuse,
- const in vec3 lightSpecular,
-
- const in vec3 lightSpotDirection,
- const in vec4 lightAttenuation,
- const in vec4 lightSpotPosition,
- const in float lightCosSpotCutoff,
- const in float lightSpotBlend,
-
- const in mat4 lightMatrix,
- const in mat4 lightInvMatrix,
-
- out vec3 eyeLightPos,
- out vec3 eyeLightDir,
- out float NdotL,
- out bool lighted)
-{
- lighted = false;
- eyeLightPos = vec3(lightMatrix * lightSpotPosition);
- eyeLightDir = eyeLightPos - vViewVertex.xyz;
- // compute dist
- float dist = length(eyeLightDir);
- // compute attenuation
- float attenuation = getLightAttenuation(dist, lightAttenuation);
- if (attenuation != 0.0)
- {
- // compute direction
- eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );
- if (lightCosSpotCutoff > 0.0)
- {
- //compute lightSpotBlend
- vec3 lightSpotDirectionEye = normalize(mat3(vec3(lightInvMatrix[0]), vec3(lightInvMatrix[1]), vec3(lightInvMatrix[2]))*lightSpotDirection);
-
- float cosCurAngle = dot(-eyeLightDir, lightSpotDirectionEye);
- float diffAngle = cosCurAngle - lightCosSpotCutoff;
- float spot = 1.0;
- if ( diffAngle < 0.0 ) {
- spot = 0.0;
- } else {
- if ( lightSpotBlend > 0.0 )
- spot = cosCurAngle * smoothstep(0.0, 1.0, (cosCurAngle - lightCosSpotCutoff) / (lightSpotBlend));
- }
-
- if (spot > 0.0)
- {
- // compute NdL
- NdotL = dot(eyeLightDir, normal);
- if (NdotL > 0.0)
- {
- lighted = true;
- vec3 diffuseContrib;
- lambert(NdotL, materialDiffuse, lightDiffuse, diffuseContrib);
- vec3 specularContrib;
- specularCookTorrance(normal, eyeLightDir, eyeVector, materialShininess, materialSpecular, lightSpecular, specularContrib);
- return spot * attenuation * (diffuseContrib + specularContrib);
- }
- }
- }
- }
- return vec3(0.0);
-}
-
-vec3 computePointLightShading(
- const in vec3 normal,
- const in vec3 eyeVector,
-
- const in vec3 materialAmbient,
- const in vec3 materialDiffuse,
- const in vec3 materialSpecular,
- const in float materialShininess,
-
- const in vec3 lightAmbient,
- const in vec3 lightDiffuse,
- const in vec3 lightSpecular,
-
- const in vec4 lightPosition,
- const in vec4 lightAttenuation,
-
- const in mat4 lightMatrix,
-
- out vec3 eyeLightPos,
- out vec3 eyeLightDir,
- out float NdotL,
- out bool lighted)
-{
-
- eyeLightPos = vec3(lightMatrix * lightPosition);
- eyeLightDir = eyeLightPos - vViewVertex.xyz;
- float dist = length(eyeLightDir);
- // compute dist
- // compute attenuation
- float attenuation = getLightAttenuation(dist, lightAttenuation);
- if (attenuation != 0.0)
- {
- // compute direction
- eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );
- // compute NdL
- NdotL = dot(eyeLightDir, normal);
- if (NdotL > 0.0)
- {
- lighted = true;
- vec3 diffuseContrib;
- lambert(NdotL, materialDiffuse, lightDiffuse, diffuseContrib);
- vec3 specularContrib;
- specularCookTorrance(normal, eyeLightDir, eyeVector, materialShininess, materialSpecular, lightSpecular, specularContrib);
- return attenuation * (diffuseContrib + specularContrib);
- }
- }
- return vec3(0.0);
-}
-
-vec3 computeSunLightShading(
-
- const in vec3 normal,
- const in vec3 eyeVector,
-
- const in vec3 materialAmbient,
- const in vec3 materialDiffuse,
- const in vec3 materialSpecular,
- const in float materialShininess,
-
- const in vec3 lightAmbient,
- const in vec3 lightDiffuse,
- const in vec3 lightSpecular,
-
- const in vec4 lightPosition,
-
- const in mat4 lightMatrix,
-
- out vec3 eyeLightDir,
- out float NdotL,
- out bool lighted)
-{
-
- lighted = false;
- eyeLightDir = normalize( vec3(lightMatrix * lightPosition ) );
- // compute NdL // compute NdL
- NdotL = dot(eyeLightDir, normal);
- if (NdotL > 0.0)
- {
- lighted = true;
- vec3 diffuseContrib;
- lambert(NdotL, materialDiffuse, lightDiffuse, diffuseContrib);
- vec3 specularContrib;
- specularCookTorrance(normal, eyeLightDir, eyeVector, materialShininess, materialSpecular, lightSpecular, specularContrib);
- return (diffuseContrib + specularContrib);
- }
- return vec3(0.0);
-}
-
-vec3 computeHemiLightShading(
-
- const in vec3 normal,
- const in vec3 eyeVector,
-
- const in vec3 materialDiffuse,
- const in vec3 materialSpecular,
- const in float materialShininess,
-
- const in vec3 lightDiffuse,
- const in vec3 lightGround,
-
- const in vec4 lightPosition,
-
- const in mat4 lightMatrix,
-
- out vec3 eyeLightDir,
- out float NdotL,
- out bool lighted)
-{
- lighted = false;
-
- eyeLightDir = normalize( vec3(lightMatrix * lightPosition ) );
- NdotL = dot(eyeLightDir, normal);
- float weight = 0.5 * NdotL + 0.5;
- vec3 diffuseContrib = materialDiffuse * mix(lightGround, lightDiffuse, weight);
-
- // same cook-torrance as above for sky/ground
- float skyWeight = 0.5 * dot(normal, normalize(eyeVector + eyeLightDir)) + 0.5;
- float gndWeight = 0.5 * dot(normal, normalize(eyeVector - eyeLightDir)) + 0.5;
- float skySpec = pow(skyWeight, materialShininess);
- float skyGround = pow(gndWeight, materialShininess);
- float divisor = (0.1 + max( dot(normal, eyeVector), 0.0 ));
- float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);
- vec3 specularContrib = lightDiffuse * materialSpecular * weight * att * (skySpec + skyGround) / divisor;
-
- return diffuseContrib + specularContrib;
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/lights.js b/app/static/app/js/vendor/osgjs/osgShader/node/lights.js
deleted file mode 100644
index 52b8f52d..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/lights.js
+++ /dev/null
@@ -1,275 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var shaderUtils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-// base class for all point based light: Point/Directional/Spot/Hemi
-// avoid duplicate code
-var NodeLights = function () {
- Node.call( this );
-};
-
-NodeLights.prototype = MACROUTILS.objectInherit( Node.prototype, {
-
- validOutputs: [ 'color' ],
- globalFunctionDeclaration: function () {
- return '#pragma include "lights.glsl"';
- }
-
-} );
-
-var getVec3 = function ( vec ) {
- return vec.getType() === 'vec4' ? vec.getVariable() + '.rgb' : vec;
-};
-
-var PointLight = function () {
- NodeLights.call( this );
-};
-
-PointLight.prototype = MACROUTILS.objectInherit( NodeLights.prototype, {
-
- type: 'PointLight',
-
- validInputs: [
- 'normal',
- 'eyeVector',
- 'materialambient',
- 'materialdiffuse',
- 'materialspecular',
- 'materialshininess',
-
- 'lightambient',
- 'lightdiffuse',
- 'lightspecular',
-
- 'lightposition',
- 'lightattenuation',
-
- 'lightmatrix',
-
- 'lighted',
- 'lightEyePos',
- 'lightEyeDir',
- 'lightNDL'
-
- ],
-
- computeShader: function () {
-
- return shaderUtils.callFunction(
- 'computePointLightShading',
- this._outputs.color, [ this._inputs.normal,
- this._inputs.eyeVector,
-
- getVec3( this._inputs.materialambient ),
- getVec3( this._inputs.materialdiffuse ),
- getVec3( this._inputs.materialspecular ),
- this._inputs.materialshininess,
-
- getVec3( this._inputs.lightambient ),
- getVec3( this._inputs.lightdiffuse ),
- getVec3( this._inputs.lightspecular ),
-
- this._inputs.lightposition,
- this._inputs.lightattenuation,
-
- this._inputs.lightmatrix,
-
- this._inputs.lightEyePos,
- this._inputs.lightEyeDir,
- this._inputs.lightNDL,
- this._inputs.lighted
- ] );
- }
-
-} );
-
-
-
-var SpotLight = function () {
- NodeLights.call( this );
-};
-
-SpotLight.prototype = MACROUTILS.objectInherit( NodeLights.prototype, {
-
- type: 'SpotLight',
-
- validInputs: [
- 'normal',
- 'eyeVector',
-
- 'materialambient',
- 'materialdiffuse',
- 'materialspecular',
- 'materialshininess',
-
- 'lightambient',
- 'lightdiffuse',
- 'lightspecular',
-
- 'lightdirection',
- 'lightattenuation',
- 'lightposition',
- 'lightspotCutOff',
- 'lightspotBlend',
-
- 'lightmatrix',
- 'lightinvMatrix',
-
- 'lighted',
- 'lightEyePos',
- 'lightEyeDir',
- 'lightNDL'
-
- ],
-
- computeShader: function () {
-
- return shaderUtils.callFunction(
- 'computeSpotLightShading',
- this._outputs.color, [ this._inputs.normal,
- this._inputs.eyeVector,
-
- getVec3( this._inputs.materialambient ),
- getVec3( this._inputs.materialdiffuse ),
- getVec3( this._inputs.materialspecular ),
- this._inputs.materialshininess,
-
- getVec3( this._inputs.lightambient ),
- getVec3( this._inputs.lightdiffuse ),
- getVec3( this._inputs.lightspecular ),
-
- this._inputs.lightdirection,
- this._inputs.lightattenuation,
- this._inputs.lightposition,
- this._inputs.lightspotCutOff,
- this._inputs.lightspotBlend,
-
- this._inputs.lightmatrix,
- this._inputs.lightinvMatrix,
-
- this._inputs.lightEyePos,
- this._inputs.lightEyeDir,
- this._inputs.lightNDL,
- this._inputs.lighted
- ] );
- }
-
-} );
-
-
-var SunLight = function () {
- NodeLights.call( this );
-};
-
-SunLight.prototype = MACROUTILS.objectInherit( NodeLights.prototype, {
-
- type: 'SunLight',
-
- validInputs: [
- 'normal',
- 'eyeVector',
- 'materialambient',
- 'materialdiffuse',
- 'materialspecular',
- 'materialshininess',
-
- 'lightambient',
- 'lightdiffuse',
- 'lightspecular',
-
- 'lightposition',
-
- 'lightmatrix',
-
- 'lighted',
- 'lightEyeDir',
- 'lightNDL'
-
- ],
-
- computeShader: function () {
-
- return shaderUtils.callFunction(
- 'computeSunLightShading',
- this._outputs.color, [ this._inputs.normal,
- this._inputs.eyeVector,
-
- getVec3( this._inputs.materialambient ),
- getVec3( this._inputs.materialdiffuse ),
- getVec3( this._inputs.materialspecular ),
- this._inputs.materialshininess,
-
- getVec3( this._inputs.lightambient ),
- getVec3( this._inputs.lightdiffuse ),
- getVec3( this._inputs.lightspecular ),
-
- this._inputs.lightposition,
-
- this._inputs.lightmatrix,
-
- this._inputs.lightEyeDir,
- this._inputs.lightNDL,
- this._inputs.lighted
- ] );
- }
-} );
-
-var HemiLight = function () {
- NodeLights.call( this );
-};
-
-HemiLight.prototype = MACROUTILS.objectInherit( NodeLights.prototype, {
-
- type: 'HemiLight',
-
- validInputs: [
- 'normal',
- 'eyeVector',
- 'materialdiffuse',
- 'materialspecular',
- 'materialshininess',
-
- 'lightdiffuse',
- 'lightground',
-
- 'lightposition',
-
- 'lightmatrix',
-
- 'lighted',
- 'lightEyeDir',
- 'lightNDL'
- ],
-
- computeShader: function () {
-
- return shaderUtils.callFunction(
- 'computeHemiLightShading',
- this._outputs.color, [ this._inputs.normal,
- this._inputs.eyeVector,
-
- getVec3( this._inputs.materialdiffuse ),
- getVec3( this._inputs.materialspecular ),
- this._inputs.materialshininess,
-
- getVec3( this._inputs.lightdiffuse ),
- getVec3( this._inputs.lightground ),
-
- this._inputs.lightposition,
-
- this._inputs.lightmatrix,
-
- this._inputs.lightEyeDir,
- this._inputs.lightNDL,
- this._inputs.lighted
- ] );
- }
-} );
-
-module.exports = {
- PointLight: PointLight,
- SpotLight: SpotLight,
- SunLight: SunLight,
- HemiLight: HemiLight
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/morph.js b/app/static/app/js/vendor/osgjs/osgShader/node/morph.js
deleted file mode 100644
index 8668001f..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/morph.js
+++ /dev/null
@@ -1,75 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var ShaderUtils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-var Morph = function () {
- Node.call( this );
-};
-
-var getVec3 = function ( vec ) {
- return vec.getType() === 'vec4' ? vec.getVariable() + '.rgb' : vec;
-};
-
-Morph.prototype = MACROUTILS.objectInherit( Node.prototype, {
- type: 'Morph',
- validInputs: [ 'weights', 'vertex', 'target0', /*'target1','target2','target3'*/ ],
- validOutputs: [ 'out' ],
-
- globalFunctionDeclaration: function () {
-
- //vec3 morphTransform( const in vec4 weights, const in vec3 vertex, const in vec3 target0, const in vec3 target1, const in vec3 target2 ) {
- // return vertex * (1.0 - ( + weights[0] + weights[1] + weights[2])) + target0 * weights[0] + target1 * weights[1] + target2 * weights[2];
- //}
- var nbTargets = window.Object.keys( this._inputs ).length - 2;
- var i = 0;
-
- // TODO: this should be rewrote with sprintf
- ////// Signature
- var str = 'vec3 morphTransform( const in vec4 weights, const in vec3 vertex, const in vec3 target0';
- for ( i = 1; i < nbTargets; ++i )
- str += ', const in vec3 target' + i;
- str += ' ) { \n';
-
- ////// Morphing
- if ( nbTargets === 1 ) {
-
- str += 'return mix(vertex, target0, weights[0])';
-
- } else {
-
- str += '\tvec3 vecOut = vertex * (1.0 - ( weights[0]';
- for ( i = 1; i < nbTargets; ++i )
- str += ' + weights[' + i + ']';
- str += '));\n';
-
- for ( i = 0; i < nbTargets; ++i )
- str += '\tvecOut += target' + i + ' * weights[' + i + '];\n';
-
- str += '\treturn vecOut';
- }
-
- str += ';\n}\n';
- return str;
- },
-
- computeShader: function () {
-
- var inps = this._inputs;
- var inputs = [ inps.weights, getVec3( inps.vertex ) ];
-
- for ( var i = 0; i < 4; i++ ) {
-
- if ( !inps[ 'target' + i ] ) break;
- inputs.push( getVec3( inps[ 'target' + i ] ) );
-
- }
-
- return ShaderUtils.callFunction( 'morphTransform', this._outputs.out, inputs );
-
- }
-} );
-
-module.exports = {
- Morph: Morph
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/noise.glsl b/app/static/app/js/vendor/osgjs/osgShader/node/noise.glsl
deleted file mode 100644
index f979b841..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/noise.glsl
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma include "hash.glsl"
-
-//// noise glsl
-
-// Based on Morgan McGuire @morgan3d
-// https://www.shadertoy.com/view/4dS3Wd
-float noise2D(const in vec2 x) {
- vec2 i = floor(x);
- vec2 f = fract(x);
-
- // Four corners in 2D of a tile
- float a = hash21(i);
- float b = hash21(i + vec2(1.0, 0.0));
- float c = hash21(i + vec2(0.0, 1.0));
- float d = hash21(i + vec2(1.0, 1.0));
-
- vec2 u = f * f * (3.0 - 2.0 * f);
- return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
-}
-
-//// end noise glsl
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/operations.js b/app/static/app/js/vendor/osgjs/osgShader/node/operations.js
deleted file mode 100644
index cf85c37e..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/operations.js
+++ /dev/null
@@ -1,271 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var Node = require( 'osgShader/node/Node' );
-var utils = require( 'osgShader/utils' );
-
-var sprintf = utils.sprintf;
-
-// Abstract class
-// base operator contains helper for the constructor
-// it helps to do that:
-// arg0 = output
-// arg1 = input0 or [ inputs ]
-// arg2 = input1
-// ...
-var BaseOperator = function () {
- Node.call( this );
-};
-
-BaseOperator.prototype = Node.prototype;
-
-
-// Add support this syntax:
-// new Add( output, input0, input1, ... )
-// new Add( output, [ inputs ] )
-// glsl code output = input0 + input1 +...
-var Add = function () {
- BaseOperator.call( this );
-};
-
-Add.prototype = MACROUTILS.objectInherit( BaseOperator.prototype, {
-
- type: 'Add',
-
- operator: '+',
-
- computeShader: function () {
- // force inputs type to be all the same from the output
- var outputType = this._outputs.getType();
- var addType = '';
-
- if ( outputType === 'vec4' )
- addType = '.rgba';
- else if ( outputType === 'vec3' )
- addType = '.rgb';
- else if ( outputType === 'vec2' )
- addType = '.rg';
-
-
- var str = this._outputs.getVariable() + ' = ' + this._inputs[ 0 ].getVariable() + addType;
- for ( var i = 1, l = this._inputs.length; i < l; i++ ) {
- var input = this._inputs[ i ];
- str += this.operator + input.getVariable();
- // special var case that doesn't need any postfix
- if ( input.getType() !== 'float' )
- str += addType;
- }
- str += ';';
- return str;
- }
-} );
-
-
-
-// Mult works like Add
-// glsl code output = input0 * input1 * ...
-var Mult = function () {
- Add.call( this );
-};
-
-Mult.prototype = MACROUTILS.objectInherit( Add.prototype, {
- type: 'Mult',
- operator: '*'
-} );
-
-// basic assignement alias: output = input
-// glsl code output = input0
-var SetFromNode = function () {
- Add.call( this );
-};
-SetFromNode.prototype = MACROUTILS.objectInherit( Add.prototype, {
- type: 'SetFromNode'
-} );
-
-// Mult Matrix * vector4
-// making the cast vector4(input.xyz, 0)
-// if needed
-// glsl code output = matrix * vector4(vec.xyz, 0)
-var MatrixMultDirection = function () {
- Add.call( this );
- this._overwriteW = true; // if set to false, we copy the input alpha in the output alpha
- this._forceComplement = true;
- this._inverseOp = false;
-};
-
-MatrixMultDirection.prototype = MACROUTILS.objectInherit( Add.prototype, {
- type: 'MatrixMultDirection',
- operator: '*',
- validInputs: [ 'vec', 'matrix' ],
- validOutputs: [ 'vec' ],
- complement: '0.',
- setInverse: function ( bool ) {
- this._inverseOp = bool;
- return this;
- },
- setForceComplement: function ( bool ) {
- this._forceComplement = bool;
- return this;
- },
- setOverwriteW: function ( bool ) {
- this._overwriteW = bool;
- return this;
- },
- computeShader: function () {
- // force inputs type to be all the same from the output
- // and handle vector complement
- var vecIn = this._inputs.vec.getVariable();
- var matrix = this._inputs.matrix.getVariable();
- var vecOut = this._outputs.vec.getVariable();
-
- var inputType = this._inputs.vec.getType();
- var outputType = this._outputs.vec.getType();
-
- var strOut = vecOut + ' = ';
-
- if ( outputType !== 'vec4' )
- strOut += outputType + '(';
-
- var strCasted = vecIn;
- if ( this._forceComplement || inputType !== 'vec4' )
- strCasted = 'vec4(' + vecIn + '.xyz, ' + this.complement + ')';
-
- strOut += this._inverseOp ? strCasted + this.operator + matrix : matrix + this.operator + strCasted;
-
- if ( outputType !== 'vec4' )
- strOut += ')';
-
- strOut += ';';
-
- if ( !this._overwriteW && inputType === 'vec4' )
- strOut += '\n' + vecOut + '.a = ' + vecIn + '.a;';
-
- return strOut;
- }
-} );
-
-// override only for complement.
-// glsl code output = matrix * vector4(vec.xyz, 1)
-var MatrixMultPosition = function () {
- MatrixMultDirection.call( this );
- this._forceComplement = false;
-};
-MatrixMultPosition.prototype = MACROUTILS.objectInherit( MatrixMultDirection.prototype, {
- type: 'MatrixMultPosition',
- complement: '1.'
-} );
-
-// For all you custom needs.
-//
-// call Code() with variable input/output replace
-// indexed by the '%'
-// getNode( 'InlineCode' ).code( '%out = %input;' ).inputs( {
-// input: this.getOrCreateConstant( 'float', 'unitFloat' ).setValue( '1.0' )
-// } ).outputs( {
-// out: this.getNode( 'glPointSize' )
-// }
-//
-var InlineCode = function () {
- Node.call( this );
-};
-
-InlineCode.prototype = MACROUTILS.objectInherit( Node.prototype, {
- type: 'InlineCode',
- code: function ( txt ) {
- this._text = txt;
- return this;
- },
- computeShader: function () {
-
- // merge inputs and outputs dict to search in both
- var replaceVariables = MACROUTILS.objectMix( {}, this._inputs );
- replaceVariables = MACROUTILS.objectMix( replaceVariables, this._outputs );
-
- // find all %string
- var r = new RegExp( '%[A-Za-z0-9_]+', 'gm' );
- var text = this._text;
- var result = this._text.match( r );
-
- var done = new Set(); // keep trace of replaced string
-
- for ( var i = 0; i < result.length; i++ ) {
-
- var str = result[ i ].substr( 1 );
- if ( !done.has( str ) ) {
- if ( !replaceVariables[ str ] ) {
- Notify.error( 'error with inline code\n' + this._text );
- Notify.error( 'input ' + str + ' not provided for ' + result[ i ] );
- }
- var reg = new RegExp( result[ i ].toString(), 'gm' );
- text = text.replace( reg, replaceVariables[ str ].getVariable() );
- done.add( str );
- }
- }
-
- return text;
- }
-} );
-
-
-// glsl code output = vec4( color.rgb, alpha )
-var SetAlpha = function () {
- BaseOperator.call( this );
-};
-
-SetAlpha.prototype = MACROUTILS.objectInherit( BaseOperator.prototype, {
- type: 'SetAlpha',
- validInputs: [ 'color', 'alpha' ],
- validOuputs: [ 'color' ],
- computeShader: function () {
- var alpha = this._inputs.alpha;
- return sprintf( '%s = vec4( %s.rgb, %s );', [
- this._outputs.color.getVariable(),
- this._inputs.color.getVariable(),
- alpha.getType() !== 'float' ? alpha.getVariable() + '.a' : alpha.getVariable()
- ] );
- }
-} );
-
-
-
-// alpha is optional, if not provided the following operation is generated:
-// glsl code output.rgb = color.rgb * color.a;
-var PreMultAlpha = function () {
- BaseOperator.call( this );
-};
-
-// TODO put the code in glsl
-PreMultAlpha.prototype = MACROUTILS.objectInherit( BaseOperator.prototype, {
-
- type: 'PreMultAlpha',
- validInputs: [ 'color' /*,'alpha'*/ ],
- validOuputs: [ 'color' ],
-
- computeShader: function () {
- var variable = this._inputs.alpha !== undefined ? this._inputs.alpha : this._inputs.color;
-
- var srcAlpha;
- if ( variable.getType() !== 'float' )
- srcAlpha = variable.getVariable() + '.a';
- else
- srcAlpha = variable.getVariable();
-
- return sprintf( '%s.rgb = %s.rgb * %s;', [
- this._outputs.color.getVariable(),
- this._inputs.color.getVariable(),
- srcAlpha
- ] );
- }
-} );
-
-module.exports = {
- BaseOperator: BaseOperator,
- Mult: Mult,
- MatrixMultPosition: MatrixMultPosition,
- MatrixMultDirection: MatrixMultDirection,
- Add: Add,
- InlineCode: InlineCode,
- SetAlpha: SetAlpha,
- SetFromNode: SetFromNode,
- PreMultAlpha: PreMultAlpha
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/shadows.js b/app/static/app/js/vendor/osgjs/osgShader/node/shadows.js
deleted file mode 100644
index c82a7968..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/shadows.js
+++ /dev/null
@@ -1,104 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var ShaderUtils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-var ShadowReceive = function () {
- Node.call( this );
-
-};
-
-ShadowReceive.prototype = MACROUTILS.objectInherit( Node.prototype, {
- type: 'ShadowReceiveNode',
- validInputs: [ 'lighted', 'shadowTexture', 'shadowTextureMapSize', 'shadowTextureProjectionMatrix', 'shadowTextureViewMatrix', 'shadowTextureDepthRange', 'lightNDL', 'vertexWorld', 'shadowbias', /* 'shadowexponent0', 'shadowexponent1', 'shadowepsilonVSM' */ ],
- validOutputs: [ 'float' ],
-
- globalFunctionDeclaration: function () {
- return '#pragma include "shadowsReceive.glsl"';
- },
-
- setShadowAttribute: function ( shadowAttr ) {
- this._shadow = shadowAttr;
- },
-
- // must return an array of defines
- // because it will be passed to the ShaderGenerator
- getDefines: function () {
- return this._shadow.getDefines();
- },
- getExtensions: function () {
- return this._shadow.getExtensions();
- },
- computeShader: function () {
-
- var inp = this._inputs;
-
- // common inputs
- var inputs = [
- inp.lighted,
- inp.shadowTexture,
- inp.shadowTextureMapSize,
- inp.shadowTextureProjectionMatrix,
- inp.shadowTextureViewMatrix,
- inp.shadowTextureDepthRange,
- inp.lightNDL,
- inp.vertexWorld,
- inp.shadowbias
- ];
-
- var algo = this._shadow.getAlgorithm();
- if ( algo === 'ESM' ) {
- inputs.push( this._inputs.shadowexponent0 );
- inputs.push( this._inputs.shadowexponent1 );
- } else if ( algo === 'EVSM' ) {
- inputs.push( this._inputs.shadowepsilonVSM );
- inputs.push( this._inputs.shadowexponent0 );
- inputs.push( this._inputs.shadowexponent1 );
- } else if ( algo === 'VSM' ) {
- inputs.push( this._inputs.shadowepsilonVSM );
- }
-
- return ShaderUtils.callFunction( 'computeShadow', this._outputs.float, inputs );
- }
-
-} );
-
-var ShadowCast = function () {
- Node.call( this );
-
-};
-
-ShadowCast.prototype = MACROUTILS.objectInherit( Node.prototype, {
- type: 'ShadowCast',
- validInputs: [ 'exponent0', 'exponent1', 'shadowDepthRange', 'fragEye' ],
- validOutputs: [ 'color' ],
-
- globalFunctionDeclaration: function () {
- return '#pragma include "shadowsCastFrag.glsl"';
- },
- setShadowCastAttribute: function ( shadowAttr ) {
- this._shadowCast = shadowAttr;
- return this;
- },
- // must return an array of defines
- // because it will be passed to the ShaderGenerator
- getDefines: function () {
- return this._shadowCast.getDefines();
- },
- computeShader: function () {
- var inp = this._inputs;
-
- var algo = this._shadowCast.getAlgorithm();
- if ( algo === 'NONE' || algo === 'PCF' ) {
- return ShaderUtils.callFunction( 'computeShadowDepth', this._outputs.color, [ inp.fragEye, inp.shadowDepthRange ] );
- }
-
- return ShaderUtils.callFunction( 'computeShadowDepth', this._outputs.color, [ inp.fragEye, inp.shadowDepthRange, inp.exponent0, inp.exponent1 ] );
- }
-
-} );
-
-module.exports = {
- ShadowCast: ShadowCast,
- ShadowReceive: ShadowReceive
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/skinning.glsl b/app/static/app/js/vendor/osgjs/osgShader/node/skinning.glsl
deleted file mode 100644
index b635bfa0..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/skinning.glsl
+++ /dev/null
@@ -1,99 +0,0 @@
-//////////////////////////////
-// OPTIMIZED VERSION (NO IF)
-//////////////////////////////
-mat4 skeletalTransform( const in vec4 weightsVec, const in vec4 bonesIdx ) {
- mat4 outMat_1;
- mat4 tmpMat_2;
- highp ivec4 tmpvar_3;
- tmpvar_3 = (3 * ivec4(bonesIdx));
- tmpMat_2 = mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
- vec4 tmpvar_4;
- tmpvar_4 = -(abs(weightsVec));
- tmpMat_2[0] = uBones[tmpvar_3.x];
- tmpMat_2[1] = uBones[(tmpvar_3.x + 1)];
- tmpMat_2[2] = uBones[(tmpvar_3.x + 2)];
- outMat_1 = ((float(
- ((tmpvar_4.x + tmpvar_4.y) >= -((tmpvar_4.z + tmpvar_4.w)))
- ) * mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0)) + (weightsVec.x * tmpMat_2));
- tmpMat_2[0] = uBones[tmpvar_3.y];
- tmpMat_2[1] = uBones[(tmpvar_3.y + 1)];
- tmpMat_2[2] = uBones[(tmpvar_3.y + 2)];
- outMat_1 = (outMat_1 + (weightsVec.y * tmpMat_2));
- tmpMat_2[0] = uBones[tmpvar_3.z];
- tmpMat_2[1] = uBones[(tmpvar_3.z + 1)];
- tmpMat_2[2] = uBones[(tmpvar_3.z + 2)];
- outMat_1 = (outMat_1 + (weightsVec.z * tmpMat_2));
- tmpMat_2[0] = uBones[tmpvar_3.w];
- tmpMat_2[1] = uBones[(tmpvar_3.w + 1)];
- tmpMat_2[2] = uBones[(tmpvar_3.w + 2)];
- outMat_1 = (outMat_1 + (weightsVec.w * tmpMat_2));
-
- return outMat_1;
-}
-
-//////////////////////////////
-// UN-OPTIMIZED VERSION (WITH IF)
-//////////////////////////////
-
-// //http://http.developer.nvidia.com/GPUGems/gpugems_ch04.html
-// mat4 getMat4FromVec4( const int index, inout mat4 myMat ) {
-// // We have to use a global variable because we can't access dynamically
-// // matrix is transpose so we should do vec * matrix
-// myMat[0] = uBones[ index ];
-// myMat[1] = uBones[ index + 1];
-// myMat[2] = uBones[ index + 2];
-// return myMat;
-// }
-
-// mat4 skeletalTransform( const in vec4 weightsVec, const in vec4 bonesIdx ) {
-// ivec4 idx = 3 * ivec4(bonesIdx);
-// mat4 tmpMat = mat4(1.0);
-// mat4 outMat = mat4(0.0);
-
-// // we handle negative weights
-// if(all(equal(weightsVec, vec4(0.0)))) return tmpMat;
-
-// if(weightsVec.x != 0.0) outMat += weightsVec.x * getMat4FromVec4( idx.x, tmpMat );
-// if(weightsVec.y != 0.0) outMat += weightsVec.y * getMat4FromVec4( idx.y, tmpMat );
-// if(weightsVec.z != 0.0) outMat += weightsVec.z * getMat4FromVec4( idx.z, tmpMat );
-// if(weightsVec.w != 0.0) outMat += weightsVec.w * getMat4FromVec4( idx.w, tmpMat );
-// return outMat;
-// }
-
-//////////////////////////////
-// UN-OPTIMIZED VERSION (NO IF)
-//////////////////////////////
-
-// mat4 skeletalTransform( const in vec4 weightsVec, const in vec4 bonesIdx ) {
-// ivec4 idx = 3 * ivec4(bonesIdx);
-// mat4 tmpMat = mat4(1.0);
-
-// // if sum is 0, return identity
-// vec4 absWeights = -abs(weightsVec);
-// mat4 outMat = step(0.0, absWeights.x + absWeights.y + absWeights.z + absWeights.w) * tmpMat;
-
-// // we handle negative weights
-// // outMat[3][3] += weightsVec.x + weightsVec.y + weightsVec.z + weightsVec.w;
-
-// tmpMat[0] = uBones[ idx.x ];
-// tmpMat[1] = uBones[ idx.x + 1];
-// tmpMat[2] = uBones[ idx.x + 2];
-// outMat += weightsVec.x * tmpMat;
-
-// tmpMat[0] = uBones[ idx.y ];
-// tmpMat[1] = uBones[ idx.y + 1];
-// tmpMat[2] = uBones[ idx.y + 2];
-// outMat += weightsVec.y * tmpMat;
-
-// tmpMat[0] = uBones[ idx.z ];
-// tmpMat[1] = uBones[ idx.z + 1];
-// tmpMat[2] = uBones[ idx.z + 2];
-// outMat += weightsVec.z * tmpMat;
-
-// tmpMat[0] = uBones[ idx.w ];
-// tmpMat[1] = uBones[ idx.w + 1];
-// tmpMat[2] = uBones[ idx.w + 2];
-// outMat += weightsVec.w * tmpMat;
-
-// return outMat;
-// }
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/skinning.js b/app/static/app/js/vendor/osgjs/osgShader/node/skinning.js
deleted file mode 100644
index 7b8c8194..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/skinning.js
+++ /dev/null
@@ -1,27 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var ShaderUtils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-var Skinning = function () {
- Node.call( this );
-};
-
-Skinning.prototype = MACROUTILS.objectInherit( Node.prototype, {
- type: 'Skinning',
- validInputs: [ 'weights', 'bonesIndex', 'matrixPalette' ],
- validOutputs: [ 'mat4' ],
-
- globalFunctionDeclaration: function () {
- return '#pragma include "skinning.glsl"';
- },
-
- computeShader: function () {
- // For now matrixPalette is used as a global (uBones) because an array means a dynamic function signature in the glsl...
- return ShaderUtils.callFunction( 'skeletalTransform', this._outputs.mat4, [ this._inputs.weights, this._inputs.bonesIndex ] );
- }
-} );
-
-module.exports = {
- Skinning: Skinning
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/textures.glsl b/app/static/app/js/vendor/osgjs/osgShader/node/textures.glsl
deleted file mode 100644
index fd8560e5..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/textures.glsl
+++ /dev/null
@@ -1,15 +0,0 @@
-vec3 textureRGB(const in sampler2D texture, const in vec2 uv) {
- return texture2D(texture, uv.xy ).rgb;
-}
-
-vec4 textureRGBA(const in sampler2D texture, const in vec2 uv) {
- return texture2D(texture, uv.xy ).rgba;
-}
-
-float textureIntensity(const in sampler2D texture, const in vec2 uv) {
- return texture2D(texture, uv).r;
-}
-
-float textureAlpha(const in sampler2D texture, const in vec2 uv) {
- return texture2D(texture, uv.xy ).a;
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShader/node/textures.js b/app/static/app/js/vendor/osgjs/osgShader/node/textures.js
deleted file mode 100644
index cc1cc6d3..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/node/textures.js
+++ /dev/null
@@ -1,95 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var utils = require( 'osgShader/utils' );
-var Node = require( 'osgShader/node/Node' );
-
-var NodeTextures = function () {
- Node.call( this );
-};
-
-NodeTextures.prototype = MACROUTILS.objectInherit( Node.prototype, {
-
- type: 'TextureAbstractNode',
-
- // functionName is here to simplify all texture base functions
- // it's possible later it will have to move into another class
- // if base class needs to be more generic. But right now it simplify
- // all simple class to fetch texture ( seed above )
- functionName: 'noTextureFunction',
-
- validInputs: [ 'sampler', 'uv' ],
- validOutputs: [ 'color' ],
-
- computeShader: function () {
-
- return utils.callFunction( this.functionName,
- this._outputs.color, [
- this._inputs.sampler,
- this._inputs.uv.getVariable() + '.xy'
- ] );
- },
-
- globalFunctionDeclaration: function () {
- return '#pragma include "textures.glsl"';
- }
-
-} );
-
-
-
-var TextureRGB = function () {
- NodeTextures.call( this );
-};
-
-TextureRGB.prototype = MACROUTILS.objectInherit( NodeTextures.prototype, {
-
- type: 'TextureRGB',
- functionName: 'textureRGB'
-
-} );
-
-
-
-var TextureRGBA = function () {
- TextureRGB.call( this );
-};
-
-TextureRGBA.prototype = MACROUTILS.objectInherit( TextureRGB.prototype, {
-
- type: 'TextureRGBA',
- functionName: 'textureRGBA'
-
-} );
-
-
-var TextureAlpha = function () {
- TextureRGB.call( this );
-};
-
-TextureAlpha.prototype = MACROUTILS.objectInherit( TextureRGB.prototype, {
-
- type: 'TextureAlpha',
- functionName: 'textureAlpha'
-
-} );
-
-
-
-var TextureIntensity = function () {
- TextureRGB.call( this );
-};
-
-TextureIntensity.prototype = MACROUTILS.objectInherit( TextureRGB.prototype, {
-
- type: 'TextureIntensity',
- functionName: 'textureIntensity'
-
-} );
-
-module.exports = {
- NodeTextures: NodeTextures,
- TextureRGB: TextureRGB,
- TextureRGBA: TextureRGBA,
- TextureAlpha: TextureAlpha,
- TextureIntensity: TextureIntensity
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/nodeFactory.js b/app/static/app/js/vendor/osgjs/osgShader/nodeFactory.js
deleted file mode 100644
index d13dc424..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/nodeFactory.js
+++ /dev/null
@@ -1,70 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var skinning = require( 'osgShader/node/skinning' );
-var data = require( 'osgShader/node/data' );
-var functions = require( 'osgShader/node/functions' );
-var lights = require( 'osgShader/node/lights' );
-var shadows = require( 'osgShader/node/shadows' );
-var operations = require( 'osgShader/node/operations' );
-var textures = require( 'osgShader/node/textures' );
-var morph = require( 'osgShader/node/morph' );
-var billboard = require( 'osgShader/node/billboard' );
-
-var Factory = function () {
-
- this._nodes = new window.Map();
-
- this.registerNodes( skinning );
- this.registerNodes( data );
- this.registerNodes( textures );
- this.registerNodes( functions );
- this.registerNodes( lights );
- this.registerNodes( morph );
- this.registerNodes( shadows );
- this.registerNodes( operations );
- this.registerNodes( billboard );
-};
-
-Factory.prototype = {
-
- registerNodes: function ( obj ) {
- var self = this;
- window.Object.keys( obj ).forEach( function ( key ) {
- self.registerNode( key, obj[ key ] );
- } );
- },
-
- registerNode: function ( name, constructor ) {
-
- if ( this._nodes.has( name ) ) {
- Notify.warn( 'Node ' + name + ' already registered' );
- }
- this._nodes.set( name, constructor );
-
- },
- // extra argument are passed to the constructor of the node
- getNode: function ( name ) {
-
- var Constructor = this._nodes.get( name );
- if ( !Constructor ) {
- // Means either:
- // - the node isn't registered by methods above
- // - you mistyped the name
- // - Core Node has changed its Name
- Notify.warn( 'Node ' + name + ' does not exist' );
- return undefined;
- }
-
- // call a constructor with array arguments
- // http://www.ecma-international.org/ecma-262/5.1/#sec-13.2.2
- var instance = window.Object.create( Constructor.prototype );
- Constructor.apply( instance, Array.prototype.slice.call( arguments, 1 ) );
-
- return instance;
- }
-
-};
-
-var instance = new Factory();
-
-module.exports = instance;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/osgShader.js b/app/static/app/js/vendor/osgjs/osgShader/osgShader.js
deleted file mode 100644
index 9745bf62..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/osgShader.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict';
-var Compiler = require( 'osgShader/Compiler' );
-var ShaderGenerator = require( 'osgShader/ShaderGenerator' );
-var ShaderGeneratorProxy = require( 'osgShader/ShaderGeneratorProxy' );
-var ShaderProcessor = require( 'osgShader/ShaderProcessor' );
-var nodeFactory = require( 'osgShader/nodeFactory' );
-var node = require( 'osgShader/node' );
-var utils = require( 'osgShader/utils' );
-
-
-var lib = {};
-
-lib.Compiler = Compiler;
-lib.ShaderGenerator = ShaderGenerator;
-lib.ShaderGeneratorProxy = ShaderGeneratorProxy;
-lib.ShaderProcessor = ShaderProcessor;
-lib.nodeFactory = nodeFactory;
-lib.node = node;
-
-lib.utils = utils;
-
-
-// debug utility: set it to one to have verbose in shaders
-lib.debugShaderNode = false;
-/*develblock:start*/
-lib.debugShaderNode = true;
-/*develblock:end*/
-
-module.exports = lib;
diff --git a/app/static/app/js/vendor/osgjs/osgShader/shaderLib.js b/app/static/app/js/vendor/osgjs/osgShader/shaderLib.js
deleted file mode 100644
index ed2958bf..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/shaderLib.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-var functions = require( 'osgShader/node/functions.glsl' );
-var lights = require( 'osgShader/node/lights.glsl' );
-var skinning = require( 'osgShader/node/skinning.glsl' );
-var textures = require( 'osgShader/node/textures.glsl' );
-var colorEncode = require( 'osgShader/node/colorEncode.glsl' );
-var noise = require( 'osgShader/node/noise.glsl' );
-var billboard = require( 'osgShader/node/billboard.glsl' );
-module.exports = {
- 'functions.glsl': functions,
- 'lights.glsl': lights,
- 'skinning.glsl': skinning,
- 'textures.glsl': textures,
- 'colorEncode.glsl': colorEncode,
- 'noise.glsl': noise,
- 'billboard.glsl': billboard
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShader/utils.js b/app/static/app/js/vendor/osgjs/osgShader/utils.js
deleted file mode 100644
index 424f7f59..00000000
--- a/app/static/app/js/vendor/osgjs/osgShader/utils.js
+++ /dev/null
@@ -1,144 +0,0 @@
-'use strict';
-
-var sprintf = function ( string, args ) {
- if ( !string || !args ) {
- return '';
- }
-
- var arg;
-
- for ( var index in args ) {
- arg = args[ index ];
-
- if ( arg === undefined )
- continue;
-
- if ( arg.getVariable ) {
- arg = arg.getVariable();
- }
- string = string.replace( '%s', arg );
- }
- return string;
-};
-
-
-var checkVariableType = function ( vars, optionalPrefix ) {
-
- var inputs = vars;
- var varsList = [];
- var prefix = optionalPrefix;
- if ( optionalPrefix === undefined ) {
- prefix = '';
- }
-
- for ( var i = 0, l = inputs.length; i < l; i++ ) {
-
- var variable = inputs[ i ];
- var output;
-
- if ( variable === undefined ) {
- output = 'undefined';
- } else if ( typeof variable === 'string' ) {
- output = variable;
- } else if ( variable.getType ) {
- output = variable.getType() + ' ' + variable.getVariable();
- } else {
- output = variable.getVariable();
- }
-
- varsList.push( prefix + output );
- }
-
- return varsList;
-
-};
-
-
-// call glsl function
-// generate a string with output = funcName ( inputs )
-// useful when debuging to print inputs / outputs
-// TODO check type of arguments with regexp in glsl
-// shader function regex
-// [\r\n]\s[(vec4)|(vec3)|(vec2)|(float)|(bool)|(int)].*\(.*[.|\r\n]*\).*[\r\n]*{
-// doesn't handle multiline
-// then split(',')
-// then substring (out,in)
-// then type matching
-// (works by hand here.)
-// for instance, gather types from input and compare themt to glsl decl
-// var inputTypes = [
-// 'vec4',
-// 'vec4',
-// 'sampler2D',
-// 'vec4',
-// 'vec4',
-// 'vec3',
-// 'float',
-// 'vec3',
-// 'float',
-// 'float',
-// 'float',
-// 'float',
-// 'float'
-// ];
-// console.assert( inputs.length === inputTypes.length );
-// var i = inputs.length;
-// while ( i-- ) {
-// console.assert( inputs[ i ]._type === inputTypes[ i ], inputs[ i ]._prefix );
-// }
-var callFunction = function ( funcName, output, inputs ) {
-
- var osgShader = require( 'osgShader/osgShader' );
-
- var debug = [];
- var callString = '';
-
- // debug
- if ( osgShader.debugShaderNode ) {
- debug.push( '\n// output' );
- Array.prototype.push.apply( debug, checkVariableType( [ output ], '// ' ) );
- }
-
- if ( output ) {
- if ( output.getVariable )
- output = output.getVariable();
- callString = output + ' = ';
- }
-
- callString = callString + funcName + '( ';
-
- if ( inputs && inputs.length > 0 ) {
-
- // debug
- if ( osgShader.debugShaderNode ) {
- debug.push( '// inputs' );
- Array.prototype.push.apply( debug, checkVariableType( inputs, '// ' ) );
- }
-
- for ( var i = 0, l = inputs.length; i < l; i++ ) {
-
- // check if it's a variable and not a constant
- if ( inputs[ i ].getVariable )
- callString += inputs[ i ].getVariable();
- else
- callString += inputs[ i ];
-
- if ( i !== l - 1 )
- callString += ', ';
- }
- }
-
- callString += ' );\n';
-
- if ( osgShader.debugShaderNode )
- return debug.join( '\n' ) + '\n' + callString;
-
- return callString;
-};
-
-
-module.exports = {
- callFunction: callFunction,
- checkVariableType: checkVariableType,
- sprintf: sprintf
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastAttribute.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastAttribute.js
deleted file mode 100644
index f8937491..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastAttribute.js
+++ /dev/null
@@ -1,44 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-
-
-// Used to notify the Compiler to create a Depth Casting optimized shader
-var ShadowCastAttribute = function ( disable, shadowReceiveAttribute ) {
- StateAttribute.call( this );
- this._enable = !disable;
- this._shadowReceiveAttribute = shadowReceiveAttribute;
-};
-ShadowCastAttribute.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
- attributeType: 'ShadowCast',
- cloneType: function () {
- return new ShadowCastAttribute( true );
- },
- //
- setReceiveAttribute: function ( shadowReceiveAttribute ) {
- this._shadowReceiveAttribute = shadowReceiveAttribute;
- },
- getReceiveAttribute: function () {
- return this._shadowReceiveAttribute;
- },
- getDefines: function () {
- if ( !this._shadowReceiveAttribute ) return undefined; // test here because of cloneType
- return this._shadowReceiveAttribute.getDefines();
- },
- getAlgorithm: function () {
- if ( !this._shadowReceiveAttribute ) return undefined; // test here because of cloneType
- return this._shadowReceiveAttribute.getAlgorithm();
- },
- getHash: function () {
- return 'ShadowCast' + this._enable + this._shadowReceiveAttribute.getAlgorithm() + this._shadowReceiveAttribute.getPrecision();
- },
- // need a isEnabled to let the ShaderGenerator to filter
- // StateAttribute from the shader compilation
- isEnabled: function () {
- return this._enable;
- }
-} ), 'osgShadow', 'ShadowCastAttribute' );
-
-MACROUTILS.setTypeID( ShadowCastAttribute );
-
-module.exports = ShadowCastAttribute;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastCompiler.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastCompiler.js
deleted file mode 100644
index 3fb8fb0d..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastCompiler.js
+++ /dev/null
@@ -1,68 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Compiler = require( 'osgShader/Compiler' );
-
-
-var CompilerShadowCast = function () {
- Compiler.apply( this, arguments );
-};
-
-CompilerShadowCast.prototype = MACROUTILS.objectInherit( Compiler.prototype, {
- getCompilerName: function () {
- return 'ShadowCast';
- },
-
- getFragmentShaderName: function () {
- return this.getCompilerName();
- },
-
- initAttributes: function () {
- var attributes = this._attributes;
-
- for ( var i = 0, l = attributes.length; i < l; i++ ) {
-
- var type = attributes[ i ].className();
-
- if ( type === 'ShadowCastAttribute' ) {
- this._shadowCastAttribute = attributes[ i ];
- } else if ( type === 'Billboard' ) {
- this._isBillboard = !!attributes[ i ];
- } else if ( type === 'SkinningAttribute' ) {
- this._skinningAttribute = attributes[ i ];
- } else if ( type === 'MorphAttribute' ) {
- this._morphAttribute = attributes[ i ];
- }
- }
- },
-
- registerTextureAttributes: function () {},
-
- // Depth Shadow Map Casted from Light POV Depth encoded in color buffer
- createShadowCastDepth: function ( out ) {
-
- this.getNode( 'ShadowCast' ).setShadowCastAttribute( this._shadowCastAttribute ).inputs( {
-
- exponent0: this.getOrCreateUniform( 'float', 'exponent0' ),
- exponent1: this.getOrCreateUniform( 'float', 'exponent1' ),
- shadowDepthRange: this.getOrCreateUniform( 'vec4', 'uShadowDepthRange' ),
- fragEye: this.getOrCreateVarying( 'vec4', 'vViewVertex' )
-
- } ).outputs( {
-
- color: out
-
- } );
-
- return out;
- },
-
- // encapsulate for easier overwrite by user defined compiler
- // that would inherint from this compiler Do not merge with above method
- createFragmentShaderGraph: function () {
- var frag = this.getNode( 'glFragColor' );
- return [ this.createShadowCastDepth( frag ) ];
- }
-
-} );
-
-module.exports = CompilerShadowCast;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastShaderGenerator.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastShaderGenerator.js
deleted file mode 100644
index c147e447..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCastShaderGenerator.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-var ShaderGenerator = require( 'osgShader/ShaderGenerator' );
-var ShadowCompiler = require( 'osgShadow/ShadowCastCompiler' );
-
-var ShaderGeneratorShadowCast = function () {
-
- ShaderGenerator.apply( this, arguments );
- this.setShaderCompiler( ShadowCompiler );
- // only one attribute makes change to the compilation
- // ignore all others
- this._acceptAttributeTypes = new window.Set( [ 'ShadowCast', 'Skinning', 'Morph' ] );
-
-};
-
-ShaderGeneratorShadowCast.prototype = ShaderGenerator.prototype;
-
-module.exports = ShaderGeneratorShadowCast;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCasterVisitor.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowCasterVisitor.js
deleted file mode 100644
index a80f9d64..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowCasterVisitor.js
+++ /dev/null
@@ -1,120 +0,0 @@
-'use strict';
-var BlendFunc = require( 'osg/BlendFunc' );
-var Camera = require( 'osg/Camera' );
-var Depth = require( 'osg/Depth' );
-var Light = require( 'osg/Light' );
-var LightSource = require( 'osg/LightSource' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var MACROUTILS = require( 'osg/Utils' );
-
-
-
-/*
- * Remove nodes that shouldn't not be culled when casting
- * like lights, camera with render texture targets,
- * transparent (alphablended) geometries
- * (otherwise it might break things)
- * visits whole underlying scene recursively
- */
-var ShadowCasterVisitor = function ( mask ) {
- NodeVisitor.call( this );
- // mask setting to avoid casting shadows
- this._noCastMask = mask;
- this._nodeList = [];
-};
-
-ShadowCasterVisitor.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( NodeVisitor.prototype, {
- reset: function () {
- this._nodeList = [];
- },
- removeNodeFromCasting: function ( node ) {
-
- /*jshint bitwise: false */
-
- var nm = node.getNodeMask();
- // ~0x0 as not to be processed
-
- if ( nm === ~0x0 ) {
-
- // set to avoid casting shadow
- nm = this._noCastMask;
- node.setNodeMask( nm );
- this._nodeList.push( node );
-
- } else if ( ( nm & ~( this._noCastMask ) ) !== 0 ) {
-
- // set to avoid casting shadow
- node.setNodeMask( nm | this._noCastMask );
- this._nodeList.push( node );
-
- }
- /*jshint bitwise: true */
-
- },
- // Visiting whole casting scene recursively
- apply: function ( node ) {
-
- // check that and other things ?
- // TODO: should check whole hierarchy to check for override/protected/etc
- // Depth, BlendFunc Attributes...
- var st = node.getStateSet();
- if ( st ) {
-
- // check for transparency not casting shadows
- // as no alpha blending transparency shadow (no transmittance support)
- var blend = st.getAttribute( 'BlendFunc' );
- if ( blend !== undefined && blend.getSource() !== BlendFunc.DISABLE ) {
- var depth = st.getAttribute( 'Depth' );
- if ( depth && ( depth.getFunc() === Depth.DISABLE || depth.getWriteMask() === false ) ) {
- this.removeNodeFromCasting( node );
- return;
- }
- }
- }
-
- // check for lights, as lights are positionned attributes
- if ( node.getTypeID() === Light.typeID || node.getTypeID() === LightSource.typeID ) {
- this.removeNodeFromCasting( node );
- return;
- } else if ( node.getTypeID() === Camera.typeID && node.isRenderToTextureCamera() ) {
- // no "Subrender" when rendering the shadow map as from light point of view
- this.removeNodeFromCasting( node );
- return;
- }
- this.traverse( node );
- },
-
- setNoCastMask: function ( mask ) {
- this._noCastMask = mask;
- },
-
- // restore to any previous mask avoiding any breaks
- // in other application mask usage.
- restore: function () {
-
- for ( var i = 0, l = this._nodeList.length; i < l; i++ ) {
-
- var node = this._nodeList[ i ];
- var nm = node.getNodeMask();
-
- if ( nm === this._noCastMask ) {
-
- node.setNodeMask( ~0x0 );
-
- } else {
-
- node.setNodeMask( nm & ~this._noCastMask );
-
- }
-
- }
-
- }
-
-
-} ), 'osgShadow', 'ShadowCasterVisitor' );
-
-
-MACROUTILS.setTypeID( ShadowCasterVisitor );
-
-module.exports = ShadowCasterVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowFrustumIntersection.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowFrustumIntersection.js
deleted file mode 100644
index 8a320f36..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowFrustumIntersection.js
+++ /dev/null
@@ -1,184 +0,0 @@
-'use strict';
-var BoundingBox = require( 'osg/BoundingBox' );
-var BoundingSphere = require( 'osg/BoundingSphere' );
-var Camera = require( 'osg/Camera' );
-var Geometry = require( 'osg/Geometry' );
-var Light = require( 'osg/Light' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixMemoryPool = require( 'osg/MatrixMemoryPool' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Plane = require( 'osg/Plane' );
-var MACROUTILS = require( 'osg/Utils' );
-
-/**
- * [ComputeFrustumBoundsVisitor get a scene bounds limited by a light and camera frustum]
- */
-var ComputeMultiFrustumBoundsVisitor = function () {
-
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ALL_CHILDREN );
- this._matrixStack = [ mat4.create() ];
- this._reservedMatrixStack = new MatrixMemoryPool();
- this._bb = new BoundingBox();
- this._bs = new BoundingSphere();
-
-};
-
-/*
- * TODO: apply world matrix on the traverse instead of per node
- */
-ComputeMultiFrustumBoundsVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- reset: function ( traversalMask, worldLightPos, cameraFrustum, cameraNearFar, lightFrustum ) {
-
- this.setTraversalMask( traversalMask );
-
- this._cameraFrustum = cameraFrustum;
- this._lightFrustum = lightFrustum;
-
- // what plane to exclude from shadowedscene
- this.getCameraPlaneMaskForLightNear( worldLightPos, cameraFrustum, cameraNearFar ? 6 : 4 );
-
- this._reservedMatrixStack.reset();
- this._matrixStack.length = 1;
- this._bb.init();
- },
-
- getBoundingBox: function () {
- return this._bb;
- },
-
-
- getCameraPlaneMaskForLightNear: function ( point, cameraFrustum, len ) {
- var selectorMask = 0x1;
- var resultMask = 15;
- var i;
-
- for ( i = 0; i < len; ++i ) {
- resultMask = ( resultMask << 1 ) | 1;
- }
-
- var planeList = cameraFrustum.getPlanes();
- for ( i = 0; i < len; ++i ) {
- if ( Plane.distanceToPlane( planeList[ i ], point ) < 0.0 ) {
- // Ligth frustum source poitn is outside this plane.
- // subsequent checks against this plane not required.
- // as light position is behind those,
- // and culling that would cull light near
- resultMask ^= selectorMask;
- }
- selectorMask <<= 1;
- }
- this._cameraPlaneMaskedByLightNear = resultMask;
-
- cameraFrustum.setResultMask( resultMask );
- cameraFrustum.pushCurrentMask( resultMask );
- return resultMask;
- },
-
- applyTransform: function ( transform ) {
-
- var matrix = this._reservedMatrixStack.get();
- var stackLength = this._matrixStack.length;
- mat4.copy( matrix, this._matrixStack[ stackLength - 1 ] );
- transform.computeLocalToWorldMatrix( matrix, this );
-
- var bs = this._bs;
- transform.getBound().transformMat4( this._bs, matrix );
-
- // camera cull
- if ( this._cameraFrustum.getCurrentMask() !== 0 ) {
- // father bounding sphere is not totally inside
- // now test this one
- if ( !this._cameraFrustum.containsBoundingSphere( bs ) )
- return; // culled
- }
-
- // light cull
- if ( this._lightFrustum.getCurrentMask() !== 0 ) {
- // father bounding sphere is not totally inside
- // now test this one
- if ( !this._lightFrustum.containsBoundingSphere( bs ) )
- return; // culled
- }
-
- this._cameraFrustum.pushCurrentMask();
- this._lightFrustum.pushCurrentMask();
-
- this.pushMatrix( matrix );
-
- this.traverse( transform );
-
- this._cameraFrustum.popCurrentMask();
- this._lightFrustum.popCurrentMask();
-
- this.popMatrix();
- },
- applyBoundingBox: ( function () {
- var bbOut = new BoundingBox();
- return function ( bbox ) {
- var stackLength = this._matrixStack.length;
- var matrix = this._matrixStack[ stackLength - 1 ];
- if ( mat4.exactEquals( matrix, mat4.IDENTITY ) ) {
- this._bb.expandByBoundingBox( bbox );
- } else if ( bbox.valid() ) {
- bbox.transformMat4( bbOut, matrix );
- this._bb.expandByBoundingBox( bbOut );
- }
- };
- } )(),
-
- apply: function ( node ) {
-
- var typeID = node.getTypeID();
-
- if ( node instanceof MatrixTransform ) {
- this.applyTransform( node );
- return;
-
- } else if ( typeID === Geometry.getTypeID() ) {
- var bs = this._bs;
- var matrix = this._matrixStack[ this._matrixStack.length - 1 ];
- node.getBound().transformMat4( bs, matrix );
-
- // camera cull
- if ( this._cameraFrustum.getCurrentMask() !== 0 ) {
- // father bounding sphere is not totally inside
- // now test this one
- if ( !this._cameraFrustum.containsBoundingSphere( bs ) )
- return; // culled
- }
-
- // light cull
- if ( this._lightFrustum.getCurrentMask() !== 0 ) {
- // father bounding sphere is not totally inside
- // now test this one
- if ( !this._lightFrustum.containsBoundingSphere( bs ) )
- return; // culled
- }
-
- // Visible: we enlarge the bbox
- this.applyBoundingBox( node.getBoundingBox() );
-
- return;
- } else if ( typeID === Camera.getTypeID() ) {
-
- } else if ( typeID === Light.getTypeID() ) {
-
- }
-
-
- this.traverse( node );
-
- },
-
- pushMatrix: function ( matrix ) {
- this._matrixStack.push( matrix );
- },
-
- popMatrix: function () {
- this._matrixStack.pop();
- },
-
-} );
-
-module.exports = ComputeMultiFrustumBoundsVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowMap.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowMap.js
deleted file mode 100644
index 07cd8e9f..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowMap.js
+++ /dev/null
@@ -1,1105 +0,0 @@
-'use strict';
-var Camera = require( 'osg/Camera' );
-var CullVisitor = require( 'osg/CullVisitor' );
-var BlendFunc = require( 'osg/BlendFunc' );
-var ComputeBoundsVisitor = require( 'osg/ComputeBoundsVisitor' );
-var Depth = require( 'osg/Depth' );
-var FrameBufferObject = require( 'osg/FrameBufferObject' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var Notify = require( 'osg/notify' );
-var Shape = require( 'osg/shape' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var StateSet = require( 'osg/StateSet' );
-var Debug = require( 'osgUtil/debug' );
-var Texture = require( 'osg/Texture' );
-var Transform = require( 'osg/Transform' );
-var Uniform = require( 'osg/Uniform' );
-var MACROUTILS = require( 'osg/Utils' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var Viewport = require( 'osg/Viewport' );
-var WebGLCaps = require( 'osg/WebGLCaps' );
-var ShadowReceiveAttribute = require( 'osgShadow/ShadowReceiveAttribute' );
-var ShadowCasterVisitor = require( 'osgShadow/ShadowCasterVisitor' );
-var ShadowFrustumIntersection = require( 'osgShadow/ShadowFrustumIntersection' );
-var ShadowCastAttribute = require( 'osgShadow/ShadowCastAttribute' );
-var ShadowTechnique = require( 'osgShadow/ShadowTechnique' );
-var ShadowTexture = require( 'osgShadow/ShadowTexture' );
-
-
-// Custom camera cull callback
-// we customize it just to avoid to add extra 'virtual' function
-// on the shadowTecnique class
-var CameraCullCallback = function ( shadowTechnique ) {
- this._shadowTechnique = shadowTechnique;
-};
-
-CameraCullCallback.prototype = {
- cull: function ( node, nv ) {
-
- this._shadowTechnique.getShadowedScene().nodeTraverse( nv );
-
- var cs = nv.getCurrentCullingSet();
- var m = nv.getCurrentProjectionMatrix();
- var near = nv.getComputedNear(),
- far = nv.getComputedFar();
-
- mat4.getFrustumPlanes( cs.getFrustum().getPlanes(), m, nv.getCurrentModelViewMatrix(), false );
- cs.getFrustum().setupMask( 6 );
-
- this._shadowTechnique.setLightFrustum( cs.getFrustum(), near, far );
-
-
- return false;
- }
-};
-
-/**
- * ShadowMap provides an implementation of shadow textures.
- * @class ShadowMap
- */
-var ShadowMap = function ( settings ) {
- ShadowTechnique.call( this );
-
- this._projectionMatrix = mat4.create();
- this._viewMatrix = mat4.create();
-
- this._lightUp = vec3.fromValues( 0.0, 0.0, 1.0 );
-
- this._light = settings.light;
-
- // data
- this._cameraShadow = new Camera();
- this._cameraShadow.setCullCallback( new CameraCullCallback( this ) );
- this._cameraShadow.setRenderOrder( Camera.PRE_RENDER, 0 );
- this._cameraShadow.setReferenceFrame( Transform.ABSOLUTE_RF );
- this._cameraShadow.setClearColor( vec4.fromValues( 1.0, 1.0, 1.0, 1.0 ) );
-
- this._texture = new ShadowTexture();
- this._textureUnitBase = 4;
- this._textureUnit = this._textureUnitBase;
-
- // see shadowSettings.js header for param explanations
- this._textureMagFilter = undefined;
- this._textureMinFilter = undefined;
- this._textureSize = 256;
-
- this._receivingStateset = undefined;
-
- this._casterStateSet = new StateSet();
- this._casterStateSet.addUniform( Uniform.createFloat1( 0, 'exponent0' ) );
- this._casterStateSet.addUniform( Uniform.createFloat1( 0, 'exponent1' ) );
- this._casterStateSet.addUniform( Uniform.createFloat1( 0.005, 'bias' ) );
-
- this._texelSizeUniform = Uniform.createFloat1( 1.0 / this._textureSize, 'texelSize' );
- this._casterStateSet.addUniform( this._texelSizeUniform );
-
- var unifRenderSize = Uniform.createFloat2( 'RenderSize' );
- this._casterStateSet.addUniform( unifRenderSize );
- this._renderSize = unifRenderSize.getInternalArray();
- this._renderSize[ 0 ] = this._renderSize[ 1 ] = this._textureSize;
-
- // make sure no unintended blend happens
- // if casting semi-transparent (alphablend material with full opaque pixels) shadow
- this._casterStateSet.setAttributeAndModes( new Depth( Depth.LESS ), StateAttribute.ON | StateAttribute.OVERRIDE );
- this._casterStateSet.setAttributeAndModes( new BlendFunc(), StateAttribute.ON | StateAttribute.OVERRIDE );
-
- this._shadowReceiveAttribute = new ShadowReceiveAttribute( this._light.getLightNumber() );
- this._casterStateSet.setAttributeAndModes( this._shadowReceiveAttribute, StateAttribute.ON | StateAttribute.OVERRIDE );
-
- // default name, overridable with shadow settings
- this._shadowCastShaderGeneratorName = 'ShadowCast';
-
-
- var near = 0.001;
- var far = 1000;
- var unifRange = Uniform.createFloat4( 'uShadowDepthRange' );
- this._casterStateSet.addUniform( unifRange );
- this._depthRange = unifRange.getInternalArray();
- this._depthRange[ 0 ] = near;
- this._depthRange[ 1 ] = far;
- this._depthRange[ 2 ] = far - near;
- this._depthRange[ 3 ] = 1.0 / ( far - near );
-
- this._worldLightPos = vec4.create();
- this._worldLightPos[ 3 ] = 0;
- this._worldLightDir = vec4.create();
- this._worldLightDir[ 3 ] = 1;
-
- this._castsShadowDrawTraversalMask = 0xffffffff;
- this._castsShadowBoundsTraversalMask = 0xffffffff;
-
-
- this._shaderProcessor = undefined;
-
- // tmp variables
- this._tmpVec = vec3.create();
- this._tmpVecBis = vec3.create();
- this._tmpVecTercio = vec3.create();
- this._tmpMatrix = mat4.create();
-
- if ( settings )
- this.setShadowSettings( settings );
-
- this._computeFrustumBounds = new ShadowFrustumIntersection();
- this._computeBoundsVisitor = new ComputeBoundsVisitor();
-
- // Overridable Visitor so that user can override the visitor to enable disable
- // in its own shadowmap implementation
- // settings.userShadowCasterVisitor:
- // - undefined means using default
- // - false means no removal visitor needed
- // - otherwise must be an instance of a class inherited from shadowCaster
- if ( settings.userShadowCasterVisitor !== false ) {
-
- this._removeNodesNeverCastingVisitor = settings.userShadowCasterVisitor || new ShadowCasterVisitor( this._castsShadowTraversalMask );
-
- }
-
- this._infiniteFrustum = true;
- var shadowStateAttribute = new ShadowCastAttribute( false, this._shadowReceiveAttribute );
-
- this._casterStateSet.setAttributeAndModes( shadowStateAttribute, StateAttribute.ON | StateAttribute.OVERRIDE );
- this._casterStateSet.setShaderGeneratorName( this._shadowCastShaderGeneratorName, StateAttribute.OVERRIDE | StateAttribute.ON );
-
- this._debug = false;
-};
-
-
-/** @lends ShadowMap.prototype */
-ShadowMap.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( ShadowTechnique.prototype, {
-
- getDepthRange: function () {
- return this._depthRange;
- },
- setLightFrustum: function ( lf, near, far ) {
-
- this._lightFrustum = lf;
-
- this._depthRange[ 0 ] = near;
- this._depthRange[ 1 ] = far;
- this.nearFarBounding();
-
- if ( this._debug ) {
-
- this._debugGeomFrustum.updateGeometry( this._projectionMatrix, this._depthRange );
- mat4.invert( this._debugNodeFrustum.getMatrix(), this._viewMatrix );
-
- }
-
- },
- getCamera: function () {
- return this._cameraShadow;
- },
-
- getTexture: function () {
- return this._texture;
- },
-
- isDirty: function () {
- return this._dirty;
- },
- /**
- * at which Texture unit number we start adding texture shadow
- */
- setTextureUnitBase: function ( unitBase ) {
- this._textureUnitBase = unitBase;
- this._textureUnit = unitBase;
- },
-
- /* Sets shadowSettings
- */
- setShadowSettings: function ( shadowSettings ) {
-
- if ( !shadowSettings )
- return;
-
- this._light = shadowSettings.light;
- this._shadowCastShaderGeneratorName = shadowSettings.getShadowCastShaderGeneratorName();
-
- this.setCastsShadowDrawTraversalMask( shadowSettings.castsShadowDrawTraversalMask );
- this.setCastsShadowBoundsTraversalMask( shadowSettings.castsShadowBoundsTraversalMask );
-
- this.setLight( this._light );
- this.setTextureSize( shadowSettings.textureSize );
- this.setTexturePrecision( shadowSettings.textureType );
-
- this.setFakePCF( shadowSettings.fakePCF );
- this.setRotateOffset( shadowSettings.rotateOffset );
- this.setKernelSizePCF( shadowSettings.kernelSizePCF );
- this.setAlgorithm( shadowSettings.algorithm );
- this.setBias( shadowSettings.bias );
- this.setExponent0( shadowSettings.exponent );
- this.setExponent1( shadowSettings.exponent1 );
- this.setEpsilonVSM( shadowSettings.epsilonVSM );
-
-
- },
-
- setCastsShadowDrawTraversalMask: function ( mask ) {
- this._castsShadowDrawTraversalMask = mask;
- },
-
- getCastsShadowDrawTraversalMask: function () {
- return this._castsDrawShadowTraversalMask;
- },
-
- setCastsShadowBoundsTraversalMask: function ( mask ) {
- this._castsShadowBoundsTraversalMask = mask;
- },
-
- getCastsShadowBoundsTraversalMask: function () {
- return this._castsShadowBoundsTraversalMask;
- },
-
-
- getBias: function () {
- return this._shadowReceiveAttribute.getBias();
- },
-
- setBias: function ( value ) {
- this._shadowReceiveAttribute.setBias( value );
- this._casterStateSet.getUniformList()[ 'bias' ].getUniform().setFloat( value );
- },
-
- getExponent0: function () {
- return this._shadowReceiveAttribute.getExponent0();
- },
-
- setExponent0: function ( value ) {
- this._shadowReceiveAttribute.setExponent0( value );
- this._casterStateSet.getUniformList()[ 'exponent0' ].getUniform().setFloat( value );
- },
-
- getExponent1: function () {
- return this._shadowReceiveAttribute.getExponent1();
- },
-
- setExponent1: function ( value ) {
- this._shadowReceiveAttribute.setExponent1( value );
- this._casterStateSet.getUniformList()[ 'exponent1' ].getUniform().setFloat( value );
- },
-
- getEpsilonVSM: function () {
- return this._shadowReceiveAttribute.getEpsilonVSM();
- },
-
- setEpsilonVSM: function ( value ) {
- this._shadowReceiveAttribute.setEpsilonVSM( value );
- },
-
- getKernelSizePCF: function () {
- return this._shadowReceiveAttribute.getKernelSizePCF();
- },
-
- setKernelSizePCF: function ( value ) {
- this._shadowReceiveAttribute.setKernelSizePCF( value );
- },
-
- getFakePCF: function () {
- return this._shadowReceiveAttribute.getFakePCF();
- },
-
- setFakePCF: function ( value ) {
- if ( this._shadowReceiveAttribute.getFakePCF() !== value ) {
- this._shadowReceiveAttribute.setFakePCF( value );
- this.setTextureFiltering();
- }
- },
-
- getRotateOffset: function () {
- return this._shadowReceiveAttribute.getRotateOffset();
- },
-
- setRotateOffset: function ( value ) {
- if ( this._shadowReceiveAttribute.getRotateOffset() !== value ) {
- this._shadowReceiveAttribute.setRotateOffset( value );
- }
- },
-
- setShadowedScene: function ( shadowedScene ) {
- ShadowTechnique.prototype.setShadowedScene.call( this, shadowedScene );
- this._receivingStateset = this._shadowedScene.getReceivingStateSet();
- this.dirty();
- },
-
- checkLightNumber: function () {
- var lightNumber = this._light.getLightNumber();
-
- // if light number changed we need to remove cleanly
- // attributes from receiveStateSet
- // it's because it use a typemember like light attribute
- // so the number if very important to keep State clean
- if ( this._shadowReceiveAttribute.getLightNumber() !== lightNumber ) {
- if ( this._receivingStateset.getAttribute( this._shadowReceiveAttribute.getTypeMember() ) === this._shadowReceiveAttribute )
- this._receivingStateset.removeAttribute( this._shadowReceiveAttribute.getTypeMember() );
- }
-
- /*develblock:start*/
- Notify.assert( this._shadowReceiveAttribute.getTypeMember() === this._shadowReceiveAttribute.attributeType + lightNumber, 'TypeMember isnt reflecting light number' + this._shadowReceiveAttribute.getTypeMember() + ' !== ' + this._shadowReceiveAttribute.attributeType + lightNumber );
- /*develblock:end*/
-
-
- if ( this._texture && this._texture.getLightUnit() !== lightNumber ) {
- // remove this._texture, but not if it's not this._texture
- if ( this._receivingStateset.getTextureAttribute( this._textureUnit, this._texture.getTypeMember() ) === this._texture )
- this._receivingStateset.removeTextureAttribute( this._textureUnit, this._texture.getTypeMember() );
- }
-
- },
-
- /** initialize the ShadowedScene and local cached data structures.*/
- init: function () {
-
- if ( !this._shadowedScene ) return;
-
- this._filledOnce = false;
-
- this.checkLightNumber();
-
- if ( !this._cameraShadow ) {
- this._cameraShadow = new Camera();
- this._cameraShadow.setCullCallback( new CameraCullCallback( this ) );
- this._cameraShadow.setRenderOrder( Camera.PRE_RENDER, 0 );
- this._cameraShadow.setReferenceFrame( Transform.ABSOLUTE_RF );
- this._cameraShadow.setClearColor( vec4.fromValues( 1.0, 1.0, 1.0, 1.0 ) );
- }
-
- this.initTexture();
-
- var lightNumber = this._light.getLightNumber();
- this._textureUnit = this._textureUnitBase + lightNumber;
- this._cameraShadow.setName( 'light_shadow_camera' + this._light.getName() );
-
- this._texture.setLightUnit( lightNumber );
- this._texture.setName( 'ShadowTexture' + this._textureUnit );
-
- this._shadowReceiveAttribute.setLightNumber( lightNumber );
-
-
- // Idea is to make sure the null texture is "binded" to all shadow casting scene
- // so we override all existing texture bind in the scene, preventing any texture bind.
- // When user implements alpha mask casting, they use PROTECTED to prevent OVERRIDE to remove their alpha mask texture needed.
- var fullOverride = StateAttribute.OVERRIDE | StateAttribute.ON;
-
-
- this._receivingStateset.setAttributeAndModes( this._shadowReceiveAttribute, fullOverride );
-
- // prevent unnecessary texture bindings
- this._preventTextureBindingDuringShadowCasting();
-
- // Mandatory: prevent binding shadow textures themselves
- // ( ShadowedScene StateSet is applied just above in StateSet hierarchy)
- // that would mean undefined values as it would be read/write access...
- // So we force it against Texture.null binding done just above (PROTECTED)
- // and Prevent any under hierarchy bind with OVERRIDE
- // must be done AFTER the prevent binding.
- this._casterStateSet.setTextureAttributeAndModes( this._textureUnit, Texture.textureNull, StateAttribute.PROTECTED );
-
-
- // add shadow texture to the receivers
- // should make sure somehow that
- // alpha blender transparent receiver doesn't use it
- // compiler wise at least
- this._receivingStateset.setTextureAttributeAndModes( this._textureUnit, this._texture, fullOverride );
-
- this._dirty = false;
- },
- // Make sure we don't bind texture and thus make GPU work for nothing
- // as shadow casting just output Depth ( no color )
- // os we set a null texture and OVERRIDE StateAttribute flag
- // only case you want to use a texture is
- // alpha masked material, then you have StateAttribute to 'PROTECTED'
- _preventTextureBindingDuringShadowCasting: function () {
-
- // prevent unnecessary texture bindings on all texture unit
- var shouldGetMaxTextureUnits = WebGLCaps.instance().getWebGLParameter( 'MAX_TEXTURE_IMAGE_UNITS' );
- for ( var k = 0; k < shouldGetMaxTextureUnits; k++ ) {
- // bind null texture which OSGJS will not bind,
- // effectively preventing any other texture bind
- // just not touching texture unit state.
- this._casterStateSet.setTextureAttributeAndModes( k, Texture.textureNull, StateAttribute.OVERRIDE | StateAttribute.ON );
- }
-
- },
- valid: function () {
- // checks
- return true;
- },
-
- updateShadowTechnique: function ( /*nv*/) {
-
- var camera = this._cameraShadow;
- var texture = this._texture;
-
- if ( camera && texture ) {
-
- var vp = camera.getViewport();
- if ( !vp ) {
- vp = new Viewport();
- camera.setViewport( vp );
- }
-
- // if texture size changed update the camera rtt params
- if ( vp.width() !== texture.getWidth() ||
- vp.height() !== texture.getHeight() ) {
-
- camera.detachAll();
-
- camera.attachTexture( FrameBufferObject.COLOR_ATTACHMENT0, texture );
- camera.attachRenderBuffer( FrameBufferObject.DEPTH_ATTACHMENT, FrameBufferObject.DEPTH_COMPONENT16 );
-
- camera.getViewport().setViewport( 0, 0, texture.getWidth(), texture.getHeight() );
- }
- }
- },
-
- updateShadowTechnic: function ( /*nv*/) {
- Notify.log( 'ShadowMap.updateShadowTechnic() is deprecated, use updateShadowTechnique instead' );
- this.updateShadowTechnique();
- },
-
- setTextureFiltering: function () {
-
- var textureType, texFilterMin, texFilterMag;
- var texType = this.getTexturePrecision();
- if ( this._texture ) {
- // see shadowSettings.js header
- switch ( this.getAlgorithm() ) {
- case 'ESM':
- case 'VSM':
- case 'EVSM':
- texFilterMin = Texture.LINEAR;
- texFilterMag = Texture.LINEAR;
- break;
-
- default:
- case 'PCF':
- case 'NONE':
- if ( this.getFakePCF() ) {
- texFilterMin = Texture.LINEAR;
- texFilterMag = Texture.LINEAR;
-
- // // TODO try anisotropy with better biaspcf
- // texFilterMin = Texture.LINEAR_MIPMAP_LINEAR;
- // texFilterMag = Texture.LINEAR_MIPMAP_LINEAR;
- // this._texture.setMaxAnisotropy( 16 );
-
-
- } else {
- texFilterMin = Texture.NEAREST;
- texFilterMag = Texture.NEAREST;
- }
- break;
- }
-
- switch ( texType ) {
- case 'HALF_FLOAT':
- textureType = Texture.HALF_FLOAT;
- texFilterMin = Texture.NEAREST;
- texFilterMag = Texture.NEAREST;
- break;
- case 'HALF_FLOAT_LINEAR':
- textureType = Texture.HALF_FLOAT;
- texFilterMin = Texture.LINEAR;
- texFilterMag = Texture.LINEAR;
- break;
- case 'FLOAT':
- textureType = Texture.FLOAT;
- texFilterMin = Texture.NEAREST;
- texFilterMag = Texture.NEAREST;
- break;
- case 'FLOAT_LINEAR':
- textureType = Texture.FLOAT;
- texFilterMin = Texture.LINEAR;
- texFilterMag = Texture.LINEAR;
- break;
- default:
- case 'UNSIGNED_BYTE':
- textureType = Texture.UNSIGNED_BYTE;
- break;
- }
- }
-
- this._texture.setInternalFormatType( textureType );
- this._texture.setMinFilter( texFilterMin );
- this._texture.setMagFilter( texFilterMag );
- this._textureMagFilter = texFilterMag;
- this._textureMinFilter = texFilterMin;
-
- },
-
- // internal texture allocation
- // handle any change like resize, filter param, etc.
- initTexture: function () {
-
- if ( !this._dirty ) return;
-
- if ( !this._texture ) {
- this._texture = new ShadowTexture();
- this._textureUnit = this._textureUnitBase;
- }
-
-
- this._texture.setTextureSize( this._textureSize, this._textureSize );
- this._texelSizeUniform.setFloat( 1.0 / this._textureSize );
- this._renderSize[ 0 ] = this._textureSize;
- this._renderSize[ 1 ] = this._textureSize;
-
- var textureFormat;
- // luminance Float format ?
- textureFormat = Texture.RGBA;
-
- this.setTextureFiltering();
- this._texture.setInternalFormat( textureFormat );
-
- this._texture.setWrapS( Texture.CLAMP_TO_EDGE );
- this._texture.setWrapT( Texture.CLAMP_TO_EDGE );
-
- this._texture.dirty();
-
- },
- setTexturePrecision: function ( format ) {
- if ( format === this._shadowReceiveAttribute.getPrecision() ) return;
-
- this._shadowReceiveAttribute.setPrecision( format );
- this.dirty();
- },
-
- getTexturePrecision: function () {
- return this._shadowReceiveAttribute.getPrecision();
- },
-
- setTextureSize: function ( mapSize ) {
-
- if ( mapSize === this._textureSize ) return;
-
- this._textureSize = mapSize;
-
- this.dirty();
- },
-
- setAlgorithm: function ( algo ) {
-
- if ( algo === this.getAlgorithm() ) return;
- this._shadowReceiveAttribute.setAlgorithm( algo );
- this.dirty();
- },
-
- getAlgorithm: function () {
- return this._shadowReceiveAttribute.getAlgorithm();
- },
-
- setLight: function ( light ) {
-
- if ( !light || light === this._light )
- return;
-
- this._light = light;
- this.dirty();
- },
-
- getUp: function ( dir ) {
- //avoid dir/up wrong angle breaking computation
-
- // compute a up vector ensuring avoiding parallel vectors
- // also might reverting to it once got the change here done once
- // vec3.fromValues( 0.0, 0.0, 1.0 );
-
- if ( Math.abs( vec3.dot( this._lightUp, dir ) ) >= 1.0 ) {
- // another camera up
- // vec3.fromValues( 1.0, 0.0, 0.0 );
- if ( this._lightUp[ 0 ] === 1.0 ) {
- this._lightUp[ 0 ] = 0.0;
- this._lightUp[ 1 ] = 1.0;
- this._lightUp[ 2 ] = 0.0;
- } else {
- this._lightUp[ 0 ] = 1.0;
- this._lightUp[ 1 ] = 0.0;
- this._lightUp[ 2 ] = 0.0;
- }
- }
- return this._lightUp;
- },
-
- // makes sure we don't have incorrect near/far
- // or we actually have to render something.
- // Empty or Bad Frustums
- // No objects, handle it gracefully
- nearFarBounding: function () {
-
- var zNear = this._depthRange[ 0 ];
- var zFar = this._depthRange[ 1 ];
-
- var epsilon = ShadowMap.EPSILON;
- if ( zFar < zNear - epsilon ) {
- // early out
- this._emptyCasterScene = true;
- zFar = 1;
- zNear = epsilon;
- } else if ( zNear < epsilon ) {
- zNear = epsilon;
- }
-
- this._depthRange[ 0 ] = zNear;
- this._depthRange[ 1 ] = zFar;
-
- },
-
- makePerspectiveFromBoundingBox: function ( bbox, fov, eyePos, eyeDir, view, projection ) {
-
- var center = bbox.center( this._tmpVec );
- var radius = bbox.radius();
- var epsilon = ShadowMap.EPSILON;
- var zNear = epsilon;
- var zFar = 1.0;
-
- this._radius = radius;
-
- var distance = vec3.distance( center, eyePos );
- // inside or not have influence
- // on using radius for fov
- if ( distance < -radius ) {
- // won't render anything the object is behind..
- this._emptyCasterScene = true;
- } else if ( distance <= 0.0 ) {
- // shhh.. we're inside !
- // sphere center is behind
- zNear = epsilon;
- zFar = distance + radius;
- } else if ( distance < radius ) {
- // shhh.. we're inside !
- // sphere center is in front
- zNear = epsilon;
- zFar = distance + radius;
- } else {
- // Sphere totally in front
- // long distance runner
- // we must make a nicer zNear here!
- zNear = distance - radius;
- zFar = distance + radius;
- }
-
- this._depthRange[ 0 ] = zNear;
- this._depthRange[ 1 ] = zFar;
- this.nearFarBounding();
-
- // positional light: spot, point, area
- // fov < 180.0
- // statically defined by spot, only needs zNear zFar estimates
- var fovRadius = this._depthRange[ 0 ] * Math.tan( fov * Math.PI / 180.0 );
- // if scene radius is smaller than fov on scene
- // Tighten and enhance precision
- fovRadius = fovRadius > radius ? radius : fovRadius;
-
- var ymax = fovRadius;
- var ymin = -ymax;
-
- var xmax = fovRadius;
- var xmin = -xmax;
-
- var up = this.getUp( eyeDir );
-
- if ( this._infiniteFrustum ) {
- mat4.infiniteFrustum( projection, xmin, xmax, ymin, ymax, this._depthRange[ 0 ] );
- } else {
- mat4.frustum( projection, xmin, xmax, ymin, ymax, this._depthRange[ 0 ], this._depthRange[ 1 ] );
-
- }
-
- mat4.lookAtDirection( view, eyePos, eyeDir, up );
-
- },
-
- makeOrthoFromBoundingBox: function ( bbox, eyeDir, view, projection ) {
-
- var center = bbox.center( this._tmpVecTercio );
-
- var radius = bbox.radius();
- var diameter = radius + radius;
-
- var zNear = 0.0001;
- var zFar = diameter + 0.0001;
-
- // compute eye Pos from a inverted lightDir Ray shot from center of bbox
- // firs make a RAY then move the eye to the that far pos following the ray
- var eyePos = this._tmpVec;
- vec3.scaleAndAdd( eyePos, center, eyeDir, -diameter );
-
- zNear = radius;
- zFar += radius;
-
- var zNearRatio = 0.001;
- if ( zNear < zFar * zNearRatio ) {
- zNear = zFar * zNearRatio;
- }
-
- var up = this.getUp( eyeDir );
- mat4.lookAtDirection( view, eyePos, eyeDir, up );
-
-
- var right, top;
- top = radius;
- right = top;
- mat4.ortho( projection, -right, right, -top, top, zNear, zFar );
-
- this._depthRange[ 0 ] = zNear;
- this._depthRange[ 1 ] = zFar;
-
- },
- /*
- * Sync camera and light vision so that
- * shadow map render using a camera whom
- * settings come from the light
- * and the scene being shadowed
- */
- aimShadowCastingCamera: function ( cullVisitor, frustumBound ) {
-
- var light = this._light;
-
- if ( !light ) {
- this._emptyCasterScene = true;
- return;
- }
-
- var camera = this._cameraShadow;
-
- var worldLightPos = this._worldLightPos;
- var worldLightDir = this._worldLightDir;
-
- // make sure it's not modified outside our computations
- // camera matrix can be modified by cullvisitor afterwards...
- mat4.copy( this._projectionMatrix, camera.getProjectionMatrix() );
- mat4.copy( this._viewMatrix, camera.getViewMatrix() );
- var projection = this._projectionMatrix;
- var view = this._viewMatrix;
-
- // inject camera world matrix.
- // from light current world/pos and camera eye pos.
- // inject camera world matrix.
- // from light current world/pos
- // NEED same camera eye pos
- var positionedAttribute = cullVisitor.getCurrentRenderBin().getPositionedAttribute();
-
- var lightMatrix;
- positionedAttribute = positionedAttribute.find( function ( element ) {
- if ( element.length > 0 && element[ 1 ] === light ) {
- lightMatrix = element[ 0 ];
- return true;
- }
- return false;
- } );
- if ( lightMatrix === undefined ) {
- Notify.warn( 'light isnt inside children of shadowedScene Node' );
- this._emptyCasterScene = true;
- return;
- }
-
- var eyeToWorld = this._tmpMatrix;
- mat4.invert( eyeToWorld, cullVisitor.getCurrentModelViewMatrix() );
-
- // light pos & lightTarget in World Space
- if ( !this._light.isDirectionLight() ) {
-
- mat4.mul( this._tmpMatrix, eyeToWorld, lightMatrix );
- var worldMatrix = this._tmpMatrix;
-
- // same code as light spot shader
- vec3.transformMat4( worldLightPos, light.getPosition(), worldMatrix );
- worldMatrix[ 12 ] = 0;
- worldMatrix[ 13 ] = 0;
- worldMatrix[ 14 ] = 0;
- mat4.invert( worldMatrix, worldMatrix );
- mat4.transpose( worldMatrix, worldMatrix );
-
- // not a directional light, compute the world light dir
- vec3.copy( worldLightDir, light.getDirection() );
- vec4.transformMat4( worldLightDir, worldLightDir, worldMatrix );
- vec3.normalize( worldLightDir, worldLightDir );
-
- // and compute a perspective frustum
- this.makePerspectiveFromBoundingBox( frustumBound, light.getSpotCutoff(), worldLightPos, worldLightDir, view, projection );
-
-
- } else {
-
- vec4.transformMat4( worldLightPos, light.getPosition(), lightMatrix );
- vec4.transformMat4( worldLightPos, worldLightPos, eyeToWorld );
- // same code as light sun shader
- // lightpos is a light dir
- // so we now have to normalize
- // since the transform to world above
- vec3.scale( worldLightPos, worldLightPos, -1.0 );
- vec3.normalize( worldLightPos, worldLightPos );
- this.makeOrthoFromBoundingBox( frustumBound, worldLightPos, view, projection );
-
- if ( this._debug ) {
- // project box by view to get projection debug bbox
- mat4.invert( this._debugNodeFrustum.getMatrix(), view );
- }
- }
-
- mat4.copy( camera.getProjectionMatrix(), this._projectionMatrix );
- mat4.copy( camera.getViewMatrix(), this._viewMatrix );
-
- // set values now
- this.setShadowUniformsDepthValue();
-
- },
-
- // culling is done,
- // now try for a the tightest frustum
- // possible for shadowcasting
- frameShadowCastingFrustum: function ( cullVisitor ) {
-
- if ( !this._infiniteFrustum ) {
-
- CullVisitor.prototype.clampProjectionMatrix( this._projectionMatrix, this._depthRange[ 0 ], this._depthRange[ 1 ], cullVisitor.getNearFarRatio(), this._depthRange );
- }
-
- this.setShadowUniformsDepthValue();
-
- // overwrite any cullvisitor wrongness done by any clampProjectionMatrix
- var camera = this._cameraShadow;
- mat4.copy( camera.getProjectionMatrix(), this._projectionMatrix );
- mat4.copy( camera.getViewMatrix(), this._viewMatrix );
-
- },
-
- setShadowUniformsDepthValue: function () {
-
- // set values now
- this._depthRange[ 2 ] = this._depthRange[ 1 ] - this._depthRange[ 0 ];
- this._depthRange[ 3 ] = 1.0 / ( this._depthRange[ 2 ] );
-
- var castUniforms = this._casterStateSet.getUniformList();
- castUniforms.uShadowDepthRange.getUniform().setVec4( this._depthRange );
-
- this._texture.setViewMatrix( this._viewMatrix );
- this._texture.setProjectionMatrix( this._projectionMatrix );
- this._texture.setDepthRange( this._depthRange );
-
- },
-
- noDraw: function () {
-
- this._depthRange[ 0 ] = 0.0;
- this._depthRange[ 1 ] = 0.0;
- this._depthRange[ 2 ] = 0.0;
- this._depthRange[ 3 ] = 0.0;
-
- var castUniforms = this._casterStateSet.getUniformList();
-
- castUniforms.uShadowDepthRange.getUniform().setVec4( this._depthRange );
- this._texture.setDepthRange( this._depthRange );
-
- var camera = this._cameraShadow;
-
- // make sure it's not modified outside our computations
- // camera matrix can be modified by cullvisitor afterwards...
- mat4.copy( this._projectionMatrix, camera.getProjectionMatrix() );
- mat4.copy( this._viewMatrix, camera.getViewMatrix() );
-
- this._texture.setViewMatrix( this._viewMatrix );
- this._texture.setProjectionMatrix( this._projectionMatrix );
-
- this._filledOnce = true;
- },
-
- // Defines the frustum from light param.
- //
- cullShadowCasting: function ( cullVisitor ) {
-
- var bbox;
-
- if ( this._removeNodesNeverCastingVisitor ) {
-
- this._removeNodesNeverCastingVisitor.setNoCastMask( ~( this._castsShadowBoundsTraversalMask | this._castsShadowDrawTraversalMask ) );
- this._removeNodesNeverCastingVisitor.reset();
- this.getShadowedScene().accept( this._removeNodesNeverCastingVisitor );
-
- }
-
- this._computeBoundsVisitor.setTraversalMask( this._castsShadowBoundsTraversalMask );
- this._computeBoundsVisitor.reset();
- this.getShadowedScene().accept( this._computeBoundsVisitor );
- bbox = this._computeBoundsVisitor.getBoundingBox();
-
- if ( !bbox.valid() ) {
-
- // nothing to draw Early out.
- this.noDraw();
-
- if ( this._removeNodesNeverCastingVisitor ) {
-
- // remove our flags changes on any bitmask
- // not to break things
- this._removeNodesNeverCastingVisitor.restore();
-
- }
-
- return;
-
- }
-
-
- if ( this._debug ) {
-
- var min = bbox.getMin();
- var max = bbox.getMax();
- bbox.center( this._tmpVec );
- var matrix = this._debugNodeSceneCast.getMatrix();
-
- mat4.fromScaling( matrix, [ max[ 0 ] - min[ 0 ],
- max[ 1 ] - min[ 1 ],
- max[ 2 ] - min[ 2 ], 1
- ] );
- mat4.setTranslation( matrix,
- this._tmpVec );
-
- }
-
- // HERE we get the shadowedScene Current World Matrix
- // to get any world transform ABOVE the shadowedScene
- var worldMatrix = cullVisitor.getCurrentModelMatrix();
- // it does fuck up the results.
- bbox.transformMat4( bbox, worldMatrix );
-
- this._emptyCasterScene = false;
- this.aimShadowCastingCamera( cullVisitor, bbox );
-
- if ( this._emptyCasterScene ) {
- // nothing to draw Early out.
- //console.log( 'shadow early OUT' );
- this.noDraw();
-
- if ( this._removeNodesNeverCastingVisitor ) {
-
- // remove our flags changes on any bitmask
- // not to break things
- this._removeNodesNeverCastingVisitor.restore();
-
- }
-
- return;
- }
-
-
- // get renderer to make the cull program
- // record the traversal mask on entry so we can reapply it later.
- var traversalMask = cullVisitor.getTraversalMask();
-
- cullVisitor.setTraversalMask( this._castsShadowDrawTraversalMask );
-
- // cast geometries into depth shadow map
- cullVisitor.pushStateSet( this._casterStateSet );
-
- this._cameraShadow.setEnableFrustumCulling( true );
- this._cameraShadow.setComputeNearFar( true );
-
- if ( this._debug ) {
- this._debugNode.accept( cullVisitor );
- }
-
-
- // do RTT from the camera traversal mimicking light pos/orient
- this._cameraShadow.accept( cullVisitor );
-
- // make sure no negative near
- this.nearFarBounding();
-
- // Here culling is done, we do have near/far.
- // and cull/non-culled info
- // if we wanted a tighter frustum.
- this.frameShadowCastingFrustum( cullVisitor );
-
- // disabling to prevent cullvisitor breaking
- // the projection matrix by "clamping" it
- this._cameraShadow.setComputeNearFar( false );
-
- if ( this._removeNodesNeverCastingVisitor ) {
-
- // remove our flags changes on any bitmask
- // not to break things
- this._removeNodesNeverCastingVisitor.restore();
-
- }
-
- cullVisitor.popStateSet();
-
- // re-apply the original traversal mask
- cullVisitor.setTraversalMask( traversalMask );
- this._filledOnce = true;
- },
-
- cleanReceivingStateSet: function () {
- if ( this._receivingStateset ) {
-
- if ( this._texture ) {
- // remove this._texture, but not if it's not this._texture
- if ( this._receivingStateset.getTextureAttribute( this._textureUnit, this._texture.getTypeMember() ) === this._texture )
- this._receivingStateset.removeTextureAttribute( this._textureUnit, this._texture.getTypeMember() );
- }
-
- if ( this._receivingStateset.getAttribute( this._shadowReceiveAttribute.getTypeMember() ) === this._shadowReceiveAttribute )
- this._receivingStateset.removeAttribute( this._shadowReceiveAttribute.getTypeMember() );
- }
-
- },
- cleanSceneGraph: function () {
- // well release a lot more things when it works
- this._cameraShadow = undefined;
- this._filledOnce = false;
-
-
- this.cleanReceivingStateSet();
-
- // TODO: need state
- //this._texture.releaseGLObjects();
- //this._shadowReceiveAttribute = undefined;
- this._texture = undefined;
- this._shadowedScene = undefined;
- },
-
- setDebug: function ( enable ) {
-
- if ( enable && !this._debug ) {
-
- if ( !this._debugNode ) {
-
- this._debugGeomFrustum = Debug.createDebugFrustumGeometry();
-
- this._debugGeomSceneCast = Shape.createBoundingBoxGeometry();
-
- this._debugGeomSceneCast.getPrimitives()[ 0 ].mode = PrimitiveSet.LINES;
-
-
- this._debugNode = new MatrixTransform();
- this._debugNodeFrustum = new MatrixTransform();
- this._debugNodeSceneCast = new MatrixTransform();
-
-
- this._debugNodeFrustum.addChild( this._debugGeomFrustum );
- this._debugNodeSceneCast.addChild( this._debugGeomSceneCast );
-
- this._debugNode.addChild( this._debugNodeFrustum );
- this._debugNode.addChild( this._debugNodeSceneCast );
-
- }
- }
- this._debug = enable;
-
- },
- getDebug: function () {
- return this._debug;
- }
-
-} ), 'osgShadow', 'ShadowMap' );
-
-ShadowMap.EPSILON = 5e-3;
-
-MACROUTILS.setTypeID( ShadowMap );
-
-module.exports = ShadowMap;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowReceiveAttribute.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowReceiveAttribute.js
deleted file mode 100644
index c415e7e5..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowReceiveAttribute.js
+++ /dev/null
@@ -1,314 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var StateAttribute = require( 'osg/StateAttribute' );
-var Uniform = require( 'osg/Uniform' );
-var Map = require( 'osg/Map' );
-var Notify = require( 'osg/notify' );
-
-
-/**
- * ShadowReceiveAttribute encapsulate Shadow Main State object
- * @class ShadowReceiveAttribute
- * @inherits StateAttribute
- */
-var ShadowReceiveAttribute = function ( lightNum, disable ) {
- StateAttribute.call( this );
-
- this._lightNumber = lightNum;
-
-
- // see shadowSettings.js header for shadow algo param explanations
- // hash change var
- this._algoType = 'NONE';
-
- // shadow depth bias as projected in shadow camera space texture
- // and viewer camera space projection introduce its bias
- this._bias = 0.001;
- // algo dependant
- // Exponential shadow maps use exponential
- // to allows fuzzy depth
- this._exponent0 = 0.001;
- this._exponent1 = 0.001;
- // Variance Shadow mapping use One more epsilon
- this._epsilonVSM = 0.001;
- // shader compilation different upon texture precision
- this._precision = 'UNSIGNED_BYTE';
- // kernel size & type for pcf
- this._kernelSizePCF = undefined;
-
- this._fakePCF = true;
-
- this._rotateOffset = false;
-
- this._enable = !disable;
-
-};
-
-ShadowReceiveAttribute.uniforms = {};
-ShadowReceiveAttribute.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( StateAttribute.prototype, {
-
- attributeType: 'ShadowReceive',
-
- cloneType: function () {
- return new ShadowReceiveAttribute( this._lightNumber, true );
- },
-
- getTypeMember: function () {
- return this.attributeType + this.getLightNumber();
- },
-
- getLightNumber: function () {
- return this._lightNumber;
- },
-
- getUniformName: function ( name ) {
- var prefix = this.getType() + this.getLightNumber().toString();
- return 'u' + prefix + '_' + name;
- },
-
- getRotateOffset: function () {
- return this._rotateOffset;
- },
-
- setRotateOffset: function ( v ) {
- this._rotateOffset = v;
- },
-
- setAlgorithm: function ( algo ) {
- this._algoType = algo;
- },
-
- getAlgorithm: function () {
- return this._algoType;
- },
-
- setBias: function ( bias ) {
- this._bias = bias;
- },
-
- getBias: function () {
- return this._bias;
- },
-
- setExponent0: function ( exp ) {
- this._exponent0 = exp;
- },
-
- getExponent0: function () {
- return this._exponent0;
- },
-
- setExponent1: function ( exp ) {
- this._exponent1 = exp;
- },
-
- getExponent1: function () {
- return this._exponent1;
- },
-
- setEpsilonVSM: function ( epsilon ) {
- this._epsilonVSM = epsilon;
- },
-
- getEpsilonVSM: function () {
- return this._epsilonVSM;
- },
-
- getKernelSizePCF: function () {
- return this._kernelSizePCF;
- },
-
- setKernelSizePCF: function ( v ) {
- this._kernelSizePCF = v;
- },
-
- getFakePCF: function () {
- return this._fakePCF;
- },
-
- setFakePCF: function ( v ) {
- this._fakePCF = v;
- },
-
- setPrecision: function ( precision ) {
- this._precision = precision;
- },
-
- getPrecision: function () {
- return this._precision;
- },
-
- setLightNumber: function ( lightNum ) {
- this._lightNumber = lightNum;
- },
-
- getOrCreateUniforms: function () {
- // uniform are once per CLASS attribute, not per instance
- var obj = ShadowReceiveAttribute;
-
- var typeMember = this.getTypeMember();
-
- if ( obj.uniforms[ typeMember ] ) return obj.uniforms[ typeMember ];
-
- // Variance Shadow mapping use One more epsilon
- var uniforms = {
- bias: Uniform.createFloat( this.getUniformName( 'bias' ) ),
- exponent0: Uniform.createFloat( this.getUniformName( 'exponent0' ) ),
- exponent1: Uniform.createFloat( this.getUniformName( 'exponent1' ) ),
- epsilonVSM: Uniform.createFloat( this.getUniformName( 'epsilonVSM' ) )
- };
-
- obj.uniforms[ typeMember ] = new Map( uniforms );
-
- return obj.uniforms[ typeMember ];
- },
-
- getExtensions: function () {
- var algo = this.getAlgorithm();
- if ( algo === 'PCF' ) {
- return [ '#extension GL_OES_standard_derivatives : enable' ];
- }
- return [];
- },
-
- // Here to be common between caster and receiver
- // (used by shadowMap and shadow node shader)
- getDefines: function () {
-
- var textureType = this.getPrecision();
- var algo = this.getAlgorithm();
- var defines = [];
-
- var isFloat = false;
- var isLinearFloat = false;
-
- if ( textureType !== 'UNSIGNED_BYTE' )
- isFloat = true;
-
- if ( isFloat && ( textureType === 'HALF_FLOAT_LINEAR' || textureType === 'FLOAT_LINEAR' ) )
- isLinearFloat = true;
-
-
- if ( algo === 'ESM' ) {
- defines.push( '#define _ESM' );
- } else if ( algo === 'NONE' ) {
- defines.push( '#define _NONE' );
- } else if ( algo === 'PCF' ) {
- defines.push( '#define _PCF' );
- var pcf = this.getKernelSizePCF();
-
- if ( this._fakePCF ) {
- defines.push( '#define _FAKE_PCF 1' );
- }
-
- switch ( pcf ) {
- case '4Poisson(16texFetch)':
- defines.push( '#define _POISSON_PCF' );
- defines.push( '#define _PCFx4' );
- break;
- case '8Poisson(32texFetch)':
- defines.push( '#define _POISSON_PCF' );
- defines.push( '#define _PCFx9' );
- break;
- case '16Poisson(64texFetch)':
- defines.push( '#define _POISSON_PCF' );
- defines.push( '#define _PCFx16' );
- break;
- case '25Poisson(100texFetch)':
- defines.push( '#define _POISSON_PCF' );
- defines.push( '#define _PCFx25' );
- break;
- case '32Poisson(128texFetch)':
- defines.push( '#define _POISSON_PCF' );
- defines.push( '#define _PCFx32' );
- break;
- case '1Band(1texFetch)':
- defines.push( '#define _NONE' );
- defines.push( '#define _PCFx1' );
- break;
- case '4Band(4texFetch)':
- defines.push( '#define _BAND_PCF' );
- defines.push( '#define _PCFx4' );
- break;
- case '9Band(9texFetch)':
- defines.push( '#define _BAND_PCF' );
- defines.push( '#define _PCFx9' );
- break;
- case '16Band(16texFetch)':
- defines.push( '#define _BAND_PCF' );
- defines.push( '#define _PCFx16' );
- break;
- case '4Tap(16texFetch)':
- defines.push( '#define _TAP_PCF' );
- defines.push( '#define _PCFx4' );
- break;
- case '9Tap(36texFetch)':
- defines.push( '#define _TAP_PCF' );
- defines.push( '#define _PCFx9' );
- break;
- case '16Tap(64texFetch)':
- defines.push( '#define _TAP_PCF' );
- defines.push( '#define _PCFx25' );
- break;
- default:
- case '1Tap(4texFetch)':
- defines.push( '#define _TAP_PCF' );
- defines.push( '#define _PCFx1' );
- break;
- }
- } else if ( algo === 'VSM' ) {
- defines.push( '#define _VSM' );
- } else if ( algo === 'EVSM' ) {
- defines.push( '#define _EVSM' );
- }
-
- if ( isFloat ) {
- defines.push( '#define _FLOATTEX' );
- }
-
- if ( isLinearFloat ) {
- defines.push( '#define _FLOATLINEAR' );
- }
-
- if ( this.getRotateOffset() ) {
- defines.push( '#define _ROTATE_OFFSET' );
- }
-
- return defines;
- },
-
- apply: function () {
-
- if ( !this._enable ) return;
-
- var uniformMap = this.getOrCreateUniforms();
-
- uniformMap.bias.setFloat( this._bias );
- uniformMap.exponent0.setFloat( this._exponent0 );
- uniformMap.exponent1.setFloat( this._exponent1 );
- uniformMap.epsilonVSM.setFloat( this._epsilonVSM );
-
- },
-
- // need a isEnabled to let the ShaderGenerator to filter
- // StateAttribute from the shader compilation
- isEnabled: function () {
- return this._enable;
- },
-
- // Deprecated methods, should be removed in the future
- isEnable: function () {
- Notify.log( 'ShadowAttribute.isEnable() is deprecated, use isEnabled() instead' );
- return this.isEnabled();
- },
-
- getHash: function () {
- return this.getTypeMember() + '_' + this.getAlgorithm() + '_' + this.getKernelSizePCF() + '_' + this.getFakePCF() + '_' + this.getRotateOffset();
-
- }
-
-} ), 'osgShadow', 'ShadowReceiveAttribute' );
-
-MACROUTILS.setTypeID( ShadowReceiveAttribute );
-
-module.exports = ShadowReceiveAttribute;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/ShadowSettings.js b/app/static/app/js/vendor/osgjs/osgShadow/ShadowSettings.js
deleted file mode 100644
index 6779067f..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/ShadowSettings.js
+++ /dev/null
@@ -1,149 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Texture = require( 'osg/Texture' );
-
-var kernelSizeList = [ '1Band(1texFetch)', '4Band(4texFetch)', '9Band(9texFetch)', '16Band(16texFetch)', '1Tap(4texFetch)', '4Tap(16texFetch)', '9Tap(36texFetch)', '16Tap(64texFetch)', '4Poisson(16texFetch)', '8Poisson(32texFetch)', '16Poisson(64texFetch)', '25Poisson(100texFetch)', '32Poisson(128texFetch)' ];
-
-/**
- * ShadowSettings provides the parameters that the ShadowTechnique should use as a guide for setting up shadowing
- * @class ShadowSettings
- */
-var ShadowSettings = function ( options ) {
-
- this.castsShadowDrawTraversalMask = 0xffffffff;
- this.castsShadowBoundsTraversalMask = 0xffffffff;
-
- this.textureSize = 1024;
-
- // important note:
- // comparison shadow is: DepthShadow > DephFragment => shadowed
- // which is d 0 ) {
- if ( this._shadowTechniques.indexOf( technique ) !== -1 ) return;
- }
-
- this._shadowTechniques.push( technique );
-
- if ( technique.valid() ) {
- technique.setShadowedScene( this );
- technique.dirty();
- }
- },
- removeShadowTechnique: function ( technique ) {
-
- if ( this._shadowTechniques.length > 0 ) {
- var idx = this._shadowTechniques.indexOf( technique );
- if ( idx !== -1 ) {
-
- if ( this._shadowTechniques[ idx ].valid() ) {
- this._shadowTechniques[ idx ].cleanSceneGraph();
- }
- this._shadowTechniques.splice( idx, 1 );
- }
- }
- },
- /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
- cleanSceneGraph: function () {
- for ( var i = 0, lt = this._shadowTechniques.length; i < lt; i++ ) {
- if ( this._shadowTechniques[ i ] && this._shadowTechniques[ i ].valid() ) {
- this._shadowTechniques[ i ].cleanSceneGraph();
- }
- }
- },
-
- /** Dirty any cache data structures held in the attached ShadowTechnique.*/
- dirty: function () {
- for ( var i = 0; i < this._shadowTechniques.length; i++ )
- this._shadowTechniques[ i ].dirty();
- },
-
- nodeTraverse: function ( nv ) {
- Node.prototype.traverse.call( this, nv );
- },
-
- traverse: function ( nv ) {
-
- // update the scene
- if ( nv.getVisitorType() === NodeVisitor.CULL_VISITOR ) {
-
- var i, st, lt = this._shadowTechniques.length;
-
- // cull Shadowed Scene
- if ( lt ) nv.pushStateSet( this._receivingStateset );
- this.nodeTraverse( nv );
- if ( lt ) nv.popStateSet();
-
- // cull Casters
- for ( i = 0; i < lt; i++ ) {
- st = this._shadowTechniques[ i ];
- // dirty check for user playing with shadows inside update traverse
- if ( st && st.valid() ) {
-
- // those two checks
- // here
- // in case people update it from
- // any update/cull/callback
- if ( st.isDirty() )
- st.init();
-
- if ( st.isEnabled() || !st.isFilledOnce() ) {
- st.updateShadowTechnique( nv );
- st.cullShadowCasting( nv );
- }
- }
- }
-
- } else {
- this.nodeTraverse( nv );
- }
- }
-
-
-} ), 'osgShadow', 'ShadowedScene' );
-MACROUTILS.setTypeID( ShadowedScene );
-
-// same code like Node
-CullVisitor.prototype[ ShadowedScene.typeID ] = CullVisitor.prototype[ Node.typeID ];
-
-module.exports = ShadowedScene;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/osgShadow.js b/app/static/app/js/vendor/osgjs/osgShadow/osgShadow.js
deleted file mode 100644
index 2ec69cef..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/osgShadow.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-var ShadowCastAttribute = require( 'osgShadow/ShadowCastAttribute' );
-var ShadowCastCompiler = require( 'osgShadow/ShadowCastCompiler' );
-var ShadowCastShaderGenerator = require( 'osgShadow/ShadowCastShaderGenerator' );
-var ShadowCasterVisitor = require( 'osgShadow/ShadowCasterVisitor' );
-var ShadowFrustumIntersection = require( 'osgShadow/ShadowFrustumIntersection' );
-var ShadowMap = require( 'osgShadow/ShadowMap' );
-var ShadowReceiveAttribute = require( 'osgShadow/ShadowReceiveAttribute' );
-var ShadowSettings = require( 'osgShadow/ShadowSettings' );
-var ShadowTechnique = require( 'osgShadow/ShadowTechnique' );
-var ShadowTexture = require( 'osgShadow/ShadowTexture' );
-var ShadowedScene = require( 'osgShadow/ShadowedScene' );
-
-
-var osgShadow = {};
-
-osgShadow.ShadowCastAttribute = ShadowCastAttribute;
-osgShadow.ShadowCastCompiler = ShadowCastCompiler;
-osgShadow.ShadowReceiveAttribute = ShadowReceiveAttribute;
-osgShadow.ShadowCasterVisitor = ShadowCasterVisitor;
-osgShadow.ShadowFrustumIntersection = ShadowFrustumIntersection;
-osgShadow.ShadowMap = ShadowMap;
-osgShadow.ShadowedScene = ShadowedScene;
-osgShadow.ShadowSettings = ShadowSettings;
-osgShadow.ShadowCastShaderGenerator = ShadowCastShaderGenerator;
-osgShadow.ShadowTechnique = ShadowTechnique;
-osgShadow.ShadowTexture = ShadowTexture;
-
-
-module.exports = osgShadow;
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaderLib.js b/app/static/app/js/vendor/osgjs/osgShadow/shaderLib.js
deleted file mode 100644
index 0a1cdff1..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaderLib.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-var shadowsCastFrag = require( 'osgShadow/shaders/shadowsCastFrag.glsl' );
-var shadowsReceive = require( 'osgShadow/shaders/shadowsReceive.glsl' );
-var shadowsReceiveMain = require( 'osgShadow/shaders/shadowsReceiveMain.glsl' );
-var shadowLinearSoft = require( 'osgShadow/shaders/shadowLinearSoft.glsl' );
-var pcf = require( 'osgShadow/shaders/pcf.glsl' );
-var bandPCF = require( 'osgShadow/shaders/bandPCF.glsl' );
-var tapPCF = require( 'osgShadow/shaders/tapPCF.glsl' );
-var hash = require( 'osgShadow/shaders/hash.glsl' );
-var arrayPoisson = require( 'osgShadow/shaders/arrayPoisson.glsl' );
-var poissonPCF = require( 'osgShadow/shaders/poissonPCF.glsl' );
-var esm = require( 'osgShadow/shaders/esm.glsl' );
-var vsm = require( 'osgShadow/shaders/vsm.glsl' );
-var evsm = require( 'osgShadow/shaders/evsm.glsl' );
-
-module.exports = {
- 'shadowsCastFrag.glsl': shadowsCastFrag,
- 'shadowsReceive.glsl': shadowsReceive,
- 'shadowsReceiveMain.glsl': shadowsReceiveMain,
- 'shadowLinearSoft.glsl': shadowLinearSoft,
- 'pcf.glsl': pcf,
- 'bandPCF.glsl': bandPCF,
- 'tapPCF.glsl': tapPCF,
- 'hash.glsl': hash,
- 'arrayPoisson.glsl': arrayPoisson,
- 'poissonPCF.glsl': poissonPCF,
- 'esm.glsl': esm,
- 'vsm.glsl': vsm,
- 'evsm.glsl': evsm
-};
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/arrayPoisson.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/arrayPoisson.glsl
deleted file mode 100644
index b8c19176..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/arrayPoisson.glsl
+++ /dev/null
@@ -1,66 +0,0 @@
-vec2 poissonDisk[64];
-
-poissonDisk[0] = vec2(-0.613392, 0.617481);
-poissonDisk[1] = vec2(0.170019, -0.040254);
-poissonDisk[2] = vec2(-0.299417, 0.791925);
-poissonDisk[3] = vec2(0.645680, 0.493210);
-poissonDisk[4] = vec2(-0.651784, 0.717887);
-poissonDisk[5] = vec2(0.421003, 0.027070);
-poissonDisk[6] = vec2(-0.817194, -0.271096);
-poissonDisk[7] = vec2(-0.705374, -0.668203);
-poissonDisk[8] = vec2(0.977050, -0.108615);
-poissonDisk[9] = vec2(0.063326, 0.142369);
-poissonDisk[10] = vec2(0.203528, 0.214331);
-poissonDisk[11] = vec2(-0.667531, 0.326090);
-poissonDisk[12] = vec2(-0.098422, -0.295755);
-poissonDisk[13] = vec2(-0.885922, 0.215369);
-poissonDisk[14] = vec2(0.566637, 0.605213);
-poissonDisk[15] = vec2(0.039766, -0.396100);
-poissonDisk[16] = vec2(0.751946, 0.453352);
-poissonDisk[17] = vec2(0.078707, -0.715323);
-poissonDisk[18] = vec2(-0.075838, -0.529344);
-poissonDisk[19] = vec2(0.724479, -0.580798);
-poissonDisk[20] = vec2(0.222999, -0.215125);
-poissonDisk[21] = vec2(-0.467574, -0.405438);
-poissonDisk[22] = vec2(-0.248268, -0.814753);
-poissonDisk[23] = vec2(0.354411, -0.887570);
-poissonDisk[24] = vec2(0.175817, 0.382366);
-poissonDisk[25] = vec2(0.487472, -0.063082);
-poissonDisk[26] = vec2(-0.084078, 0.898312);
-poissonDisk[27] = vec2(0.488876, -0.783441);
-poissonDisk[28] = vec2(0.470016, 0.217933);
-poissonDisk[29] = vec2(-0.696890, -0.549791);
-poissonDisk[30] = vec2(-0.149693, 0.605762);
-poissonDisk[31] = vec2(0.034211, 0.979980);
-poissonDisk[32] = vec2(0.503098, -0.308878);
-poissonDisk[33] = vec2(-0.016205, -0.872921);
-poissonDisk[34] = vec2(0.385784, -0.393902);
-poissonDisk[35] = vec2(-0.146886, -0.859249);
-poissonDisk[36] = vec2(0.643361, 0.164098);
-poissonDisk[37] = vec2(0.634388, -0.049471);
-poissonDisk[38] = vec2(-0.688894, 0.007843);
-poissonDisk[39] = vec2(0.464034, -0.188818);
-poissonDisk[40] = vec2(-0.440840, 0.137486);
-poissonDisk[41] = vec2(0.364483, 0.511704);
-poissonDisk[42] = vec2(0.034028, 0.325968);
-poissonDisk[43] = vec2(0.099094, -0.308023);
-poissonDisk[44] = vec2(0.693960, -0.366253);
-poissonDisk[45] = vec2(0.678884, -0.204688);
-poissonDisk[46] = vec2(0.001801, 0.780328);
-poissonDisk[47] = vec2(0.145177, -0.898984);
-poissonDisk[48] = vec2(0.062655, -0.611866);
-poissonDisk[49] = vec2(0.315226, -0.604297);
-poissonDisk[50] = vec2(-0.780145, 0.486251);
-poissonDisk[51] = vec2(-0.371868, 0.882138);
-poissonDisk[52] = vec2(0.200476, 0.494430);
-poissonDisk[53] = vec2(-0.494552, -0.711051);
-poissonDisk[54] = vec2(0.612476, 0.705252);
-poissonDisk[55] = vec2(-0.578845, -0.768792);
-poissonDisk[56] = vec2(-0.772454, -0.090976);
-poissonDisk[57] = vec2(0.504440, 0.372295);
-poissonDisk[58] = vec2(0.155736, 0.065157);
-poissonDisk[59] = vec2(0.391522, 0.849605);
-poissonDisk[60] = vec2(-0.620106, -0.328104);
-poissonDisk[61] = vec2(0.789239, -0.419965);
-poissonDisk[62] = vec2(-0.545396, 0.538133);
-poissonDisk[63] = vec2(-0.178564, -0.596057);
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/bandPCF.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/bandPCF.glsl
deleted file mode 100644
index 884f8073..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/bandPCF.glsl
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-float getShadowPCF(const in sampler2D tex, const in vec4 size, const in vec2 uv, const in float shadowZ, const in vec2 biasPCF) {
-
- float shadowed = 0.0;
-
- #define TSF(off1, off2) getSingleFloatFromTex( tex, uv.xy + vec2(off1, off2) + biasPCF )
-
- float dx0 = -size.z;
- float dy0 = -size.w;
- float dx1 = size.z;
- float dy1 = size.w;
-
- // fastest but gives banding
-#if defined(_PCFx4)
-
- vec4 sV;
-
- // vector ops faster alu
- sV.x = TSF( dx0, dy0 );
- sV.y = TSF( dx1, dy0 );
- sV.z = TSF( dx1, dy0 );
- sV.w = TSF( dx1, dy1 );
- sV = vec4(lessThan(vec4(shadowZ), sV ));
- shadowed = dot(sV, vec4(0.25));
-
- // here still didn't querying the real shadow at uv.
- // This could be a single func checking for branching
- // like before going to x9, x16 or anything
- // or even complex "blurring"
- if (shadowed != 0.0) // we're on an edge
- {
- shadowed += step(shadowZ, TSF(0.0, 0.0));
- shadowed *= 0.5;
- }
-
-#elif defined(_PCFx9)
-
-
- mat3 kern;
- mat3 depthKernel;
-
-
- depthKernel[0][0] = TSF( dx0, dy0 );
- depthKernel[0][1] = TSF( dx0, 0.0 );
- depthKernel[0][2] = TSF( dx0, dy1 );
- depthKernel[1][0] = TSF( 0.0, dy0 );
- depthKernel[1][1] = TSF( 0.0, 0.0 );
- depthKernel[1][2] = TSF( 0.0, dy1 );
- depthKernel[2][0] = TSF( dx1, dy0 );
- depthKernel[2][1] = TSF( dx1, 0.0 );
- depthKernel[2][2] = TSF( dx1, dy1 );
-
- // using 4 vector ops to save ALU
- // filter is done post dept/shadow compare
- vec3 shadowZ3 = vec3( shadowZ );
- kern[0] = vec3(lessThan(shadowZ3, depthKernel[0] ));
- kern[0] *= vec3(0.25);
-
- kern[1] = vec3(lessThan(shadowZ3, depthKernel[1] ));
- kern[1] *= vec3(0.25);
-
- kern[2] = vec3(lessThan(shadowZ3, depthKernel[2] ));
- kern[2] *= vec3(0.25);
-
- vec2 fractCoord = 1.0 - fract( uv.xy );
-
- kern[0] = mix( kern[1], kern[0], fractCoord.x );
- kern[1] = mix( kern[2], kern[1], fractCoord.x );
-
- vec4 sV;
- sV.x = mix( kern[0][1], kern[0][0], fractCoord.y );
- sV.y = mix( kern[0][2], kern[0][1], fractCoord.y );
- sV.z = mix( kern[1][1], kern[1][0], fractCoord.y );
- sV.w = mix( kern[1][2], kern[1][1], fractCoord.x );
-
- shadowed = dot( sV, vec4( 1.0 ) );
-
-#elif defined(_PCFx16)
-
- float dx2 = -2.0 * size.z;
- float dy2 = -2.0 * size.w;
- float dx3 = 2.0 * size.z;
- float dy3 = 2.0 * size.w;
-
- shadowed += step(shadowZ , TSF(dx2, dy2));
- shadowed += step(shadowZ , TSF(dx0, dy2));
- shadowed += step(shadowZ , TSF(dx1, dy2));
- shadowed += step(shadowZ , TSF(dx3, dy2));
-
- shadowed += step(shadowZ , TSF(dx2, dy0));
- shadowed += step(shadowZ , TSF(dx0, dy0));
- shadowed += step(shadowZ , TSF(dx1, dy0));
- shadowed += step(shadowZ , TSF(dx3, dy0));
-
- shadowed += step(shadowZ , TSF(dx2, dy1));
- shadowed += step(shadowZ , TSF(dx0, dy1));
- shadowed += step(shadowZ , TSF(dx1, dy1));
- shadowed += step(shadowZ , TSF(dx3, dy1));
-
- shadowed += step(shadowZ , TSF(dx2, dy3));
- shadowed += step(shadowZ , TSF(dx0, dy3));
- shadowed += step(shadowZ , TSF(dx1, dy3));
- shadowed += step(shadowZ , TSF(dx3, dy3));
-
- shadowed = shadowed / 16.0;
-#endif // pcfx16
- return shadowed;
-
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/esm.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/esm.glsl
deleted file mode 100644
index 2133f2fc..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/esm.glsl
+++ /dev/null
@@ -1,50 +0,0 @@
-////////////////////////////////////////////////
-// ESM
-float fetchESM(const in sampler2D tex, const in vec4 shadowMapSize, const in vec2 shadowUV, const in float shadowZ, const in float exponent0, const in float exponent1) {
-
-
-#if defined(_FLOATTEX) && (!defined(_FLOATLINEAR))
- // emulate bilinear filtering (not needed if webgm/GPU support filtering FP32/FP16 textures)
- vec2 unnormalized = shadowUV * shadowMapSize.xy;
- vec2 fractional = fract(unnormalized);
- unnormalized = floor(unnormalized);
-
- vec4 occluder4;
- occluder4.x = getSingleFloatFromTex(tex, (unnormalized + vec2( -0.5, 0.5 ))* shadowMapSize.zw );
- occluder4.y = getSingleFloatFromTex(tex, (unnormalized + vec2( 0.5, 0.5 ))* shadowMapSize.zw );
- occluder4.z = getSingleFloatFromTex(tex, (unnormalized + vec2( 0.5, -0.5 ))* shadowMapSize.zw );
- occluder4.w = getSingleFloatFromTex(tex, (unnormalized + vec2( -0.5, -0.5 ))* shadowMapSize.zw );
-
- float occluder = (occluder4.w + (occluder4.x - occluder4.w) * fractional.y);
- occluder = occluder + ((occluder4.z + (occluder4.y - occluder4.z) * fractional.y) - occluder)*fractional.x;
-
-#else
- float occluder = getSingleFloatFromTex(tex, shadowUV);
-#endif
-
-
- // we're on an edge
- float depthScale = exponent1;
- float over_darkening_factor = exponent0;
- float receiver = depthScale * ( shadowZ);
- return 1.0 - clamp(over_darkening_factor*(occluder*exp(receiver)), 0.0, 1.0);
-}
-
-
-float computeShadow(const in bool lighted,
- const in sampler2D tex,
- const in vec4 shadowMapSize,
- const in mat4 shadowProjectionMatrix,
- const in mat4 shadowViewMatrix,
- const in vec4 depthRange,
- const in float N_Dot_L,
- const in vec3 vertexWorld,
- const in float bias,
- const in float exponent0,
- const in float exponent1
- )
-{
- #pragma include "shadowsReceiveMain.glsl" "_ESM"
-}
-
-// end ESM
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/evsm.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/evsm.glsl
deleted file mode 100644
index dc4af7de..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/evsm.glsl
+++ /dev/null
@@ -1,32 +0,0 @@
-// EVSM
-
-#pragma include "vsm.glsl"
-
-// Convert depth to EVSM coefficients
-// Input depth should be in [0, 1]
-vec2 warpDepth(const in float depth, const in vec2 exponents)
-{
- float pos = exp( exponents.x * depth);
- float neg = -exp(-exponents.y * depth);
- return vec2(pos, neg);
-}
-
-
-float computeShadow(const in bool lighted,
- const in sampler2D tex,
- const in vec4 shadowMapSize,
- const in mat4 shadowProjectionMatrix,
- const in mat4 shadowViewMatrix,
- const in vec4 depthRange,
- const in float N_Dot_L,
- const in vec3 vertexWorld,
- const in float bias,
- const in float epsilonVSM,
- const in float exponent0,
- const in float exponent1
- )
-{
- #pragma include "shadowsReceiveMain.glsl" "_EVSM"
-}
-
-// _EVSM
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/hash.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/hash.glsl
deleted file mode 100644
index d6fdf586..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/hash.glsl
+++ /dev/null
@@ -1,62 +0,0 @@
-//// hash glsl
-
-// Dave Hoskins: hash without sin
-//https://www.shadertoy.com/view/4djSRW
-#define MOD2 vec2(443.8975,397.2973)
-//----------------------------------------------------------------------------------------
-// 1 out, 1 in...
-//note: normalized uniform random, [0;1[
-float hash11(const in float p)
-{
- vec2 p2 = fract(vec2(p) * MOD2);
- p2 += dot(p2.yx, p2.xy+19.19);
- return fract(p2.x * p2.y);
-}
-//note: normalized uniform random, [0;1[
-// 2 out, 1 in...
-float hash21(const in vec2 p)
-{
- vec2 p2 = fract(p * MOD2);
- p2 += dot(p2.yx, p2.xy+19.19);
- return fract(p2.x * p2.y);
-}
-
-
-// Based on Morgan McGuire @morgan3d
-// https://www.shadertoy.com/view/4dS3Wd
-// using Sin
-// 1 out, 1 in...
-float hashSin11( const in float n )
-{
- return fract(sin(n)*43758.5453);
-}
-
-//note: normalized uniform random, [0;1[
-// 2 out, 1 in...
-float hashSin21( const in vec2 n ) {
- return fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);
-}
-
-// note: [-1;1]
-// iq: https://www.shadertoy.com/view/Xsl3Dl
-// note: value noise
-// 2 out, 2 in...
-vec2 hashSin22( const in vec2 n )
-{
- return fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* vec2(43758.5453,35458.5734));
-}
-// 3 out, 3 in...
-vec3 hashSin33( in vec3 p )
-{
- p = vec3( dot(p,vec3(127.1,311.7, 74.7)),
- dot(p,vec3(269.5,183.3,246.1)),
- dot(p,vec3(113.5,271.9,124.6)));
- return fract(sin(p)*43758.5453123);
-}
-
-// Returns a random number based on a vec3 and an int.
-float hashSin41(const in vec4 seed){
- return fract(sin(dot(seed, vec4(12.9898,78.233,45.164,94.673)) * 43758.5453));
-}
-
-/////// end hash
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/pcf.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/pcf.glsl
deleted file mode 100644
index 3e211803..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/pcf.glsl
+++ /dev/null
@@ -1,21 +0,0 @@
-
-#pragma include "bandPCF.glsl" "_BAND_PCF"
-#pragma include "poissonPCF.glsl" "_POISSON_PCF"
-#pragma include "tapPCF.glsl" "_TAP_PCF"
-
-float computeShadow(const in bool lighted,
- const in sampler2D tex,
- const in vec4 shadowMapSize,
- const in mat4 shadowProjectionMatrix,
- const in mat4 shadowViewMatrix,
- const in vec4 depthRange,
- const in float N_Dot_L,
- const in vec3 vertexWorld,
- const in float bias
- )
-{
- #pragma include "shadowsReceiveMain.glsl" "_PCF" "_NONE"
-
-
-
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/poissonArray.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/poissonArray.glsl
deleted file mode 100644
index 155ec800..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/poissonArray.glsl
+++ /dev/null
@@ -1,66 +0,0 @@
-
- vec2 poissonDisk[64];
- poissonDisk[0] = vec2(-0.613392, 0.617481);
- poissonDisk[1] = vec2(0.170019, -0.040254);
- poissonDisk[2] = vec2(-0.299417, 0.791925);
- poissonDisk[3] = vec2(0.645680, 0.493210);
- poissonDisk[4] = vec2(-0.651784, 0.717887);
- poissonDisk[5] = vec2(0.421003, 0.027070);
- poissonDisk[6] = vec2(-0.817194, -0.271096);
- poissonDisk[7] = vec2(-0.705374, -0.668203);
- poissonDisk[8] = vec2(0.977050, -0.108615);
- poissonDisk[9] = vec2(0.063326, 0.142369);
- poissonDisk[10] = vec2(0.203528, 0.214331);
- poissonDisk[11] = vec2(-0.667531, 0.326090);
- poissonDisk[12] = vec2(-0.098422, -0.295755);
- poissonDisk[13] = vec2(-0.885922, 0.215369);
- poissonDisk[14] = vec2(0.566637, 0.605213);
- poissonDisk[15] = vec2(0.039766, -0.396100);
- poissonDisk[16] = vec2(0.751946, 0.453352);
- poissonDisk[17] = vec2(0.078707, -0.715323);
- poissonDisk[18] = vec2(-0.075838, -0.529344);
- poissonDisk[19] = vec2(0.724479, -0.580798);
- poissonDisk[20] = vec2(0.222999, -0.215125);
- poissonDisk[21] = vec2(-0.467574, -0.405438);
- poissonDisk[22] = vec2(-0.248268, -0.814753);
- poissonDisk[23] = vec2(0.354411, -0.887570);
- poissonDisk[24] = vec2(0.175817, 0.382366);
- poissonDisk[25] = vec2(0.487472, -0.063082);
- poissonDisk[26] = vec2(-0.084078, 0.898312);
- poissonDisk[27] = vec2(0.488876, -0.783441);
- poissonDisk[28] = vec2(0.470016, 0.217933);
- poissonDisk[29] = vec2(-0.696890, -0.549791);
- poissonDisk[30] = vec2(-0.149693, 0.605762);
- poissonDisk[31] = vec2(0.034211, 0.979980);
- poissonDisk[32] = vec2(0.503098, -0.308878);
- poissonDisk[33] = vec2(-0.016205, -0.872921);
- poissonDisk[34] = vec2(0.385784, -0.393902);
- poissonDisk[35] = vec2(-0.146886, -0.859249);
- poissonDisk[36] = vec2(0.643361, 0.164098);
- poissonDisk[37] = vec2(0.634388, -0.049471);
- poissonDisk[38] = vec2(-0.688894, 0.007843);
- poissonDisk[39] = vec2(0.464034, -0.188818);
- poissonDisk[40] = vec2(-0.440840, 0.137486);
- poissonDisk[41] = vec2(0.364483, 0.511704);
- poissonDisk[42] = vec2(0.034028, 0.325968);
- poissonDisk[43] = vec2(0.099094, -0.308023);
- poissonDisk[44] = vec2(0.693960, -0.366253);
- poissonDisk[45] = vec2(0.678884, -0.204688);
- poissonDisk[46] = vec2(0.001801, 0.780328);
- poissonDisk[47] = vec2(0.145177, -0.898984);
- poissonDisk[48] = vec2(0.062655, -0.611866);
- poissonDisk[49] = vec2(0.315226, -0.604297);
- poissonDisk[50] = vec2(-0.780145, 0.486251);
- poissonDisk[51] = vec2(-0.371868, 0.882138);
- poissonDisk[52] = vec2(0.200476, 0.494430);
- poissonDisk[53] = vec2(-0.494552, -0.711051);
- poissonDisk[54] = vec2(0.612476, 0.705252);
- poissonDisk[55] = vec2(-0.578845, -0.768792);
- poissonDisk[56] = vec2(-0.772454, -0.090976);
- poissonDisk[57] = vec2(0.504440, 0.372295);
- poissonDisk[58] = vec2(0.155736, 0.065157);
- poissonDisk[59] = vec2(0.391522, 0.849605);
- poissonDisk[60] = vec2(-0.620106, -0.328104);
- poissonDisk[61] = vec2(0.789239, -0.419965);
- poissonDisk[62] = vec2(-0.545396, 0.538133);
- poissonDisk[63] = vec2(-0.178564, -0.596057);
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/poissonPCF.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/poissonPCF.glsl
deleted file mode 100644
index 584c1346..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/poissonPCF.glsl
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-#pragma include "shadowLinearSoft.glsl"
-
-#pragma include "hash.glsl"
-
-float getShadowPCF(const in sampler2D tex, const in vec4 size, const in vec2 uv, const in float shadowZ, const in vec2 biasPCF) {
-
- vec2 o = size.zw;
- float s = 0.0;
-
-// Not Good, as it needs the lerp things
-#pragma include "arrayPoisson.glsl"
-
- int idx = 0;
-
- // Not Good, as it needs the lerp things
-#define TSF_BASE(p, m) texture2DShadowLerp(tex, size, uv + m*poissonDisk[p]*o + biasPCF, shadowZ)
-
-// fixed pattern in the shadow, no noise
-#define TSF_FIXED(i) TSF_BASE(i, 1.0)
-
- // rand using screenpos: No banding,"moves" camera
-#define TSF_SCREEN(i) TSF_BASE(i, hashSin22( float(i)*gl_FragCoord.xy ))
-
-//rand using worl proj +depth as world psace xyez
-#define TSF_SPACE(i) TSF_BASE(i, hashSin41(vec4(uv.xy, shadowZ, float(i))))
-
-#define TSF(k) TSF_SPACE(k)
-
-
- s += TSF(1);
- s += TSF(2);
- s += TSF(3);
- s += TSF(4);
-
-#ifdef _PCFx4
- const float kernSize = 4.;
-#else
- s += TSF(5);
- s += TSF(6);
- s += TSF(7);
- s += TSF(8);
-#ifdef _PCFx9
- const float kernSize = 8.;
-#else
- s += TSF(9);
- s += TSF(10);
- s += TSF(11);
- s += TSF(12);
- s += TSF(13);
- s += TSF(14);
- s += TSF(15);
- s += TSF(16);
-#ifdef _PCFx16
- const float kernSize = 16.;
-#else
- s += TSF(17);
- s += TSF(18);
- s += TSF(19);
- s += TSF(20);
- s += TSF(21);
- s += TSF(22);
- s += TSF(23);
- s += TSF(24);
- s += TSF(25);
-#ifdef _PCFx25
- const float kernSize = 25.;
-#else
- s += TSF(26);
- s += TSF(27);
- s += TSF(28);
- s += TSF(29);
- s += TSF(30);
- s += TSF(31);
- s += TSF(32);
-#ifdef _PCFx32
- const float kernSize = 32.;
-#endif // 32
-#endif // 25
-#endif // 16
-#endif // 8
-#endif // 4
-
- s /= kernSize;
- return s;
-}
-// end poisson
-#undef TSF
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowLinearSoft.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowLinearSoft.glsl
deleted file mode 100644
index 85fb0d3b..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowLinearSoft.glsl
+++ /dev/null
@@ -1,32 +0,0 @@
-
-// simulation of texture2Dshadow glsl call on HW
-// http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/
-float texture2DCompare(const in sampler2D depths, const in vec2 uv, const in float compare){
-
- float depth = getSingleFloatFromTex(depths, uv);
- return step(compare, depth);
-
-}
-
-// simulates linear fetch like texture2d shadow
-float texture2DShadowLerp(const in sampler2D depths, const in vec4 size, const in vec2 uv, const in float compare){
-
-#if defined(_FAKE_PCF)
- // CHEAT: it's wrong, but 4x faster
- // wronb because http://www.eng.utah.edu/~cs5610/handouts/reeves87.pdf p2
- return texture2DCompare(depths, uv, compare);
-#else
- vec2 f = fract(uv*size.xy+0.5);
- vec2 centroidUV = floor(uv*size.xy+0.5)*size.zw;
-
- float lb = texture2DCompare(depths, centroidUV+size.zw*vec2(0.0, 0.0), compare);
- float lt = texture2DCompare(depths, centroidUV+size.zw*vec2(0.0, 1.0), compare);
- float rb = texture2DCompare(depths, centroidUV+size.zw*vec2(1.0, 0.0), compare);
- float rt = texture2DCompare(depths, centroidUV+size.zw*vec2(1.0, 1.0), compare);
- float a = mix(lb, lt, f.y);
- float b = mix(rb, rt, f.y);
- float c = mix(a, b, f.x);
- return c;
-#endif
-
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsCastFrag.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsCastFrag.glsl
deleted file mode 100644
index b119081a..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsCastFrag.glsl
+++ /dev/null
@@ -1,66 +0,0 @@
-
-#pragma include "colorEncode.glsl"
-
-// see shadowSettings.js header for shadow algo param explanations
-
-#ifdef _EVSM
-// Convert depth to EVSM coefficients
-// Input depth should be in [0, 1]
-vec2 warpDepth(const in float depth, const in vec2 exponents) {
- float pos = exp( exponents.x * depth);
- float neg = -exp(-exponents.y * depth);
- return vec2(pos, neg);
-}
-
-// Convert depth value to EVSM representation
-vec4 shadowDepthToEVSM(const in float depth, const in float expo0, const in float expo1) {
- vec2 warpedDepth = warpDepth(depth, vec2(expo0, expo1));
- return vec4(warpedDepth.xy, warpedDepth.xy * warpedDepth.xy);
-}
-#endif // _EVSM
-
-
-#if defined(_NONE) || defined(_PCF)
-vec4 computeShadowDepth(const in vec4 fragEye,
- const in vec4 shadowRange)
-#else
-vec4 computeShadowDepth(const in vec4 fragEye,
- const in vec4 shadowRange,
- const in float expo0,
- const in float expo1)
-#endif
-{
- // distance to camera
- float depth = -fragEye.z * fragEye.w;
- // most precision near 0, make sure we are near 0 and in [0,1]
- depth = (depth - shadowRange.x ) * shadowRange.w;
-
- vec4 outputFrag;
-
-#if defined (_FLOATTEX) && defined(_PCF)
- outputFrag = vec4(depth, 0.0, 0.0, 1.0);
-#elif defined (_FLOATTEX) && defined(_ESM)
- float depthScale = expo1;
- depth = exp(-depth * depthScale);
- outputFrag = vec4(depth, 0.0, 0.0, 1.0);
-#elif defined (_FLOATTEX) && defined(_VSM)
- outputFrag = vec4(depth, depth * depth, 0.0, 1.0);
-#elif defined (_FLOATTEX) && defined(_EVSM)
- outputFrag = shadowDepthToEVSM(depth, expo0, expo1);
-#elif defined (_FLOATTEX) // && defined(_NONE)
- outputFrag = vec4(depth, 0.0, 0.0, 1.0);
-#elif defined(_PCF)
- outputFrag = encodeFloatRGBA(depth);
-#elif defined(_ESM)
- float depthScale = expo1;
- depthScale = exp(-depth * depthScale);
- outputFrag = encodeFloatRGBA(depthScale);
-#elif defined(_VSM)
- outputFrag = encodeHalfFloatRGBA(vec2(depth, depth* depth));
-#else // NONE
- outputFrag = encodeFloatRGBA(depth);
-
-#endif
-
- return outputFrag;
-}
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsReceive.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsReceive.glsl
deleted file mode 100644
index e551457c..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsReceive.glsl
+++ /dev/null
@@ -1,36 +0,0 @@
-//begin shadows
-
-#pragma include "colorEncode.glsl"
-
-// see shadowSettings.js header for shadow algo param explanations
-
-// end Float codec
-float getSingleFloatFromTex(const in sampler2D depths, const in vec2 uv){
-#ifndef _FLOATTEX
- return decodeFloatRGBA(texture2D(depths, uv));
-#else
- return texture2D(depths, uv).x;
-#endif
-}
-
-vec2 getDoubleFloatFromTex(const in sampler2D depths, const in vec2 uv){
-#ifndef _FLOATTEX
- return decodeHalfFloatRGBA(texture2D(depths, uv));
-#else
- return texture2D(depths, uv).xy;
-#endif
-}
-
-vec4 getQuadFloatFromTex(const in sampler2D depths, const in vec2 uv){
- return texture2D(depths, uv).xyzw;
-}
-// end Float codec
-
-
-#pragma include "vsm.glsl" "_VSM"
-
-#pragma include "evsm.glsl" "_EVSM"
-
-#pragma include "esm.glsl" "_ESM"
-
-#pragma include "pcf.glsl" "_NONE" "_PCF"
\ No newline at end of file
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsReceiveMain.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsReceiveMain.glsl
deleted file mode 100644
index a8016c23..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/shadowsReceiveMain.glsl
+++ /dev/null
@@ -1,140 +0,0 @@
-
-// 0 for early out
-bool earlyOut = false;
-
-// Calculate shadow amount
-float shadow = 1.0;
-
-if(!lighted) {
- shadow = 0.0;
- earlyOut = true;
-}
-
-if (depthRange.x == depthRange.y) {
- earlyOut = true;
-}
-
-vec4 shadowVertexEye;
-float shadowReceiverZ = 0.0;
-vec4 shadowVertexProjected;
-vec2 shadowUV;
-
-if(!earlyOut) {
-
- shadowVertexEye= shadowViewMatrix * vec4(vertexWorld, 1.0);
- shadowReceiverZ= - shadowVertexEye.z;
- shadowVertexProjected = shadowProjectionMatrix * shadowVertexEye;
-
- if (shadowVertexProjected.w < 0.0) {
- earlyOut = true; // notably behind camera
- }
-
- if (!earlyOut) {
- shadowUV.xy = shadowVertexProjected.xy / shadowVertexProjected.w;
- shadowUV.xy = shadowUV.xy * 0.5 + 0.5;// mad like
-
- if(any(bvec4 ( shadowUV.x > 1., shadowUV.x < 0., shadowUV.y > 1., shadowUV.y < 0.))) {
- earlyOut = true;// limits of light frustum
- }
-
- // most precision near 0, make sure we are near 0 and in [0,1]
- shadowReceiverZ = (shadowReceiverZ - depthRange.x)* depthRange.w;
-
- if(shadowReceiverZ < 0.0) {
- earlyOut = true; // notably behind camera
- }
-
- }
-
-}
-
-
-#if defined( _PCF )
-
-// pcf pbias to add on offset
-vec2 shadowBiasPCF = vec2(0.);
-
-#ifdef GL_OES_standard_derivatives
-
-shadowBiasPCF.x = clamp(dFdx(shadowReceiverZ)* shadowMapSize.z, -1.0, 1.0 );
-shadowBiasPCF.y = clamp(dFdy(shadowReceiverZ)* shadowMapSize.w, -1.0, 1.0 );
-
-#endif
-#endif
-
-// now that derivatives is done
-// and we don't access any mipmapped/texgrad texture
-// we can early out
-// see http://teknicool.tumblr.com/post/77263472964/glsl-dynamic-branching-and-texture-samplers
-if (earlyOut) return shadow;
-
-// depth bias: fighting shadow acne (depth imprecsion z-fighting)
-float shadowBias = 0.0;
-// cosTheta is dot( n, l ), clamped between 0 and 1
-//float shadowBias = 0.005*tan(acos(N_Dot_L));
-// same but 4 cycles instead of 15
-shadowBias += 0.05 * sqrt( 1. - N_Dot_L*N_Dot_L) / clamp(N_Dot_L, 0.0005, 1.0);
-
-//That makes sure that plane perpendicular to light doesn't flicker due to
-//selfshadowing and 1 = dot(Normal, Light) using a min bias
-shadowBias = clamp(shadowBias, 0.00005, bias);
-
-// shadowZ must be clamped to [0,1]
-// otherwise it's not comparable to
-// shadow caster depth map
-// which is clamped to [0,1]
-// Not doing that makes ALL shadowReceiver > 1.0 black
-// because they ALL becomes behind any point in Caster depth map
-shadowReceiverZ = clamp(shadowReceiverZ, 0., 1. - shadowBias);
-
-shadowReceiverZ -= shadowBias;
-
-// Now computes Shadow
-
-
-#ifdef _NONE
-
-float shadowDepth = getSingleFloatFromTex(tex, shadowUV.xy);
-// shadowReceiverZ : receiver depth in light view
-// shadowDepth : caster depth in light view
-// receiver is shadowed if its depth is superior to the caster
-shadow = ( shadowReceiverZ > shadowDepth ) ? 0.0 : 1.0;
-
-#elif defined( _PCF )
-
-
-shadow = getShadowPCF(tex, shadowMapSize, shadowUV, shadowReceiverZ, shadowBiasPCF);
-
-#elif defined( _ESM )
-
-shadow = fetchESM(tex, shadowMapSize, shadowUV, shadowReceiverZ, exponent0, exponent1);
-
-#elif defined( _VSM )
-
-vec2 moments = getDoubleFloatFromTex(tex, shadowUV.xy);
-shadow = chebyshevUpperBound(moments, shadowReceiverZ, epsilonVSM);
-
-#elif defined( _EVSM )
-
-vec4 occluder = getQuadFloatFromTex(tex, shadowUV.xy);
-vec2 exponents = vec2(exponent0, exponent1);
-vec2 warpedDepth = warpDepth(shadowReceiverZ, exponents);
-
-float derivationEVSM = epsilonVSM;
-// Derivative of warping at depth
-vec2 depthScale = derivationEVSM * exponents * warpedDepth;
-vec2 minVariance = depthScale * depthScale;
-
-float epsilonEVSM = -epsilonVSM;
-
-// Compute the upper bounds of the visibility function both for x and y
-float posContrib = chebyshevUpperBound(occluder.xz, -warpedDepth.x, minVariance.x);
-float negContrib = chebyshevUpperBound(occluder.yw, warpedDepth.y, minVariance.y);
-
-shadow = min(posContrib, negContrib);
-
-#endif
-
-
-return shadow;
-
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/tapPCF.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/tapPCF.glsl
deleted file mode 100644
index 7bcc6840..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/tapPCF.glsl
+++ /dev/null
@@ -1,88 +0,0 @@
-
-#pragma include "noise.glsl" "_ROTATE_OFFSET"
-
-#pragma include "shadowLinearSoft.glsl"
-
-float getShadowPCF(const in sampler2D depths, const in vec4 size, const in vec2 uv, const in float compare, const in vec2 biasPCF)
-{
-
- float res = 0.0;
-
-#if defined(_ROTATE_OFFSET)
- res += texture2DShadowLerp(depths, size, uv + size.zw*(noise2D(uv*gl_FragCoord.xy)*2.0 - 1.0) + biasPCF, compare);
-#else
- res += texture2DShadowLerp(depths, size, uv + biasPCF, compare);
-#endif
-
-
-#if defined(_PCFx1)
-
-#else
-
- float dx0 = -size.z;
- float dy0 = -size.w;
- float dx1 = size.z;
- float dy1 = size.w;
-
-#define TSF(o1,o2) texture2DShadowLerp(depths, size, uv + vec2(o1, o2) + biasPCF, compare)
-
- res += TSF(dx0, dx0);
- res += TSF(dx0, .0);
- res += TSF(dx0, dx1);
-
-#if defined(_PCFx4)
-
- res /=4.0;
-
-#elif defined(_PCFx9)
- res += TSF(.0, dx0);
- res += TSF(.0, dx1);
-
- res += TSF(dx1, dx0);
- res += TSF(dx1, .0);
- res += TSF(dx1, dx1);
-
-
- res /=9.0;
-
-#elif defined(_PCFx25)
-
- float dx02 = -2.0*size.z;
- float dy02 = -2.0*size.w;
- float dx2 = 2.0*size.z;
- float dy2 = 2.0*size.w;
-
- // complete row above
- res += TSF(dx0, dx02);
- res += TSF(dx0, dx2);
-
- res += TSF(.0, dx02);
- res += TSF(.0, dx2);
-
- res += TSF(dx1, dx02);
- res += TSF(dx1, dx2);
-
- // two new col
- res += TSF(dx02, dx02);
- res += TSF(dx02, dx0);
- res += TSF(dx02, .0);
- res += TSF(dx02, dx1);
- res += TSF(dx02, dx2);
-
- res += TSF(dx2, dx02);
- res += TSF(dx2, dx0);
- res += TSF(dx2, .0);
- res += TSF(dx2, dx1);
- res += TSF(dx2, dx2);
-
-
- res/=25.0;
-
-#endif
-
-#undef TSF
-
-#endif
- return res;
-}
-/////// end Tap
diff --git a/app/static/app/js/vendor/osgjs/osgShadow/shaders/vsm.glsl b/app/static/app/js/vendor/osgjs/osgShadow/shaders/vsm.glsl
deleted file mode 100644
index 1031c0cd..00000000
--- a/app/static/app/js/vendor/osgjs/osgShadow/shaders/vsm.glsl
+++ /dev/null
@@ -1,60 +0,0 @@
-//////VSM
-//http://en.wikipedia.org/wiki/Chebyshev%27s_inequality
-float chebychevInequality (const in vec2 moments, const in float t)
-{
- // No shadow if depth of fragment is in front
- if ( t <= moments.x )
- return 1.0;
-
- // Calculate variance, which is actually the amount of
- // error due to precision loss from fp32 to RG/BA
- // (moment1 / moment2)
- float variance = moments.y - (moments.x * moments.x);
- variance = max(variance, 0.02);
-
- // Calculate the upper bound
- float d = t - moments.x;
- return variance / (variance + d * d);
-}
-
-// http://http.developer.nvidia.com/GPUGems3/gpugems3_ch08.html
-float chebyshevUpperBound(const in vec2 moments, const in float mean, const in float minVariance)
-{
- float d = mean - moments.x;
- if ( d <= 0.0 )
- return 1.0;
- // Compute variance
- float variance = moments.y - (moments.x * moments.x);
- variance = max(variance, minVariance);
-
- // Compute probabilistic upper bound
- //p represent an upper bound on the visibility percentage of the receiver. This value //attempts to estimate how much of the distribution of occluders at the surface location is //beyond the surface's distance from the light. If it is 0, then there is no probability //that the fragment is partially lit, so it will be fully in shadow. If it is a value in the //[0, 1] range, it represent the penumbrae value of the shadow edge.
- float p = smoothstep(mean, mean, moments.x);
-
- // Remove the [0, Amount] tail and linearly rescale (Amount, 1].
- /// light bleeding when shadows overlap.
-
- float pMax = smoothstep(0.2, 1.0, variance / (variance + d*d));
- // One-tailed chebyshev
- return clamp(max(p, pMax), 0.0, 1.0);
-}
-
-// might be included for EVSM
-#ifdef _VSM
-float computeShadow(const in bool lighted,
- const in sampler2D tex,
- const in vec4 shadowMapSize,
- const in mat4 shadowProjectionMatrix,
- const in mat4 shadowViewMatrix,
- const in vec4 depthRange,
- const in float N_Dot_L,
- const in vec3 vertexWorld,
- const in float bias,
- const in float epsilonVSM
- )
-{
-#pragma include "shadowsReceiveMain.glsl" "_VSM"
-}
-#endif // _VSM
-
-// end VSM
diff --git a/app/static/app/js/vendor/osgjs/osgText/Text.js b/app/static/app/js/vendor/osgjs/osgText/Text.js
deleted file mode 100644
index ec4fb3e3..00000000
--- a/app/static/app/js/vendor/osgjs/osgText/Text.js
+++ /dev/null
@@ -1,410 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var AutoTransform = require( 'osg/AutoTransform' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var Shape = require( 'osg/shape' );
-var Texture = require( 'osg/Texture' );
-var BlendFunc = require( 'osg/BlendFunc' );
-var quat = require( 'osg/glMatrix' ).quat;
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Node = require( 'osg/Node' );
-/**
- * @class Text: Text 2D using a Canvas2D as a texture for a textured quad.
- * Notes: The OSGjs Text has been implemented like OSG osgText::Text as much as possible. However there are some
- * things that should be noted:
- * - This Text is far more simple than OSG ones, it only supports basic functionality.
- * - In contrast to OSG, Text inherits from AutoTransform in osgjs.
- * - Supported fonts are not the same in HTML than in OSG/C++.
- * - Vertical layout is not supported right now.
- * - BaseLine alignments are not supported, instead they are converted to supported ones if parsing a osgjs file.
- * - Set the color in the range [ 0 - 1 ], as if you were working with OSG.
- * - Texts are generated as a canvas 2D texture sticked in a quad. The size of the texture is the next power of two of the current size of the
- * text so the bigger is your characterSize, the more memory it will consume.
- */
-var Text = function ( text ) {
- AutoTransform.call( this );
- // create a canvas element
- this._canvas = document.createElement( 'canvas' );
- this._context = this._canvas.getContext( '2d' );
- this._matrixTransform = new MatrixTransform();
- this.addChild( this._matrixTransform );
- this._text = '';
- if ( text !== undefined ) this._text = text;
- this._font = 'monospace';
- // Vec4 value to load/return
- this._color = vec4.fromValues( 0.0, 0.0, 0.0, 1.0 );
- // This determines the text color, it can take a hex value or rgba value (e.g. rgba(255,0,0,0.5))
- this._fillStyle = 'rgba( 0, 0, 0, 1 )';
- // This determines the alignment of text, e.g. left, center, right
- this._context.textAlign = 'center';
- this._textX = undefined;
- // This determines the baseline of the text, e.g. top, middle, bottom
- this._context.baseLine = 'middle';
- this._textY = undefined;
- // Size of the textured quad in meters.
- this._characterSize = 1;
- this._characterSizeMode = Text.OBJECT_COORDS;
- // Font resolution
- this._fontSize = 32;
- this._geometry = undefined;
- this._autoRotateToScreen = false;
- this._position = vec3.create();
- this._layout = Text.LEFT_TO_RIGHT;
- this._alignment = Text.CENTER_CENTER;
- // NPOT textures
- this._forcePowerOfTwo = false;
- // Lazy initialization
- this._texture = new Texture();
- this.drawText();
- this._dirty = false;
-
- // We need to keep track of modelView Matrix
- this._previousModelView = mat4.create();
-};
-
-// CharacterSizeMode
-Text.OBJECT_COORDS = 0;
-Text.SCREEN_COORDS = 1;
-Text.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT = 2;
-
-// Layout enum
-Text.LEFT_TO_RIGHT = 'ltr';
-Text.RIGHT_TO_LEFT = 'rtl';
-
-// Alignment enum
-Text.LEFT_TOP = 0;
-Text.LEFT_CENTER = 1;
-Text.LEFT_BOTTOM = 2;
-
-Text.CENTER_TOP = 3;
-Text.CENTER_CENTER = 4;
-Text.CENTER_BOTTOM = 5;
-
-Text.RIGHT_TOP = 6;
-Text.RIGHT_CENTER = 7;
-Text.RIGHT_BOTTOM = 8;
-
-/** @lends Text.prototype */
-Text.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( AutoTransform.prototype, {
-
- drawText: function () {
- if ( this._geometry !== undefined ) {
- this._matrixTransform.removeChild( this._geometry );
- // The text could be dynamic, so we need to remove GL objects
- this._geometry.releaseGLObjects();
- }
- if ( !this._text ) return;
- this.setTextProperties();
- this._canvas.width = this._context.measureText( this._text ).width;
- this._canvas.height = this._fontSize * 2;
- // For devices not supporting NPOT textures
- if ( this._forcePowerOfTwo ) {
- this._canvas.width = this._nextPowerOfTwo( this._canvas.width );
- this._canvas.height = this._nextPowerOfTwo( this._canvas.height );
- }
- // We need to set the text properties again, as the canvas size cold change.
- this.setTextProperties();
- this._context.clearRect( 0, 0, this._canvas.width, this._canvas.height );
- this._context.fillText( this._text, this._textX, this._textY );
- // Right now we set the pivot point to center, to assure the bounding box is correct when rendering billboards.
- // TODO: Possibility to set different pivot point so we can have missing alignments.
- var aspectRatio = this._canvas.width / this._canvas.height;
- var quadWidth = this._characterSize * aspectRatio;
- this._geometry = Shape.createTexturedQuadGeometry( -quadWidth / 2, -this._characterSize / 2, 0, quadWidth, 0, 0, 0, this._characterSize, 0 );
- // create a texture to attach the canvas2D
- this._texture.setTextureSize( this._canvas.width, this._canvas.height );
- this._texture.setMinFilter( 'LINEAR' );
- this._texture.setMagFilter( 'LINEAR' );
- this._texture.setImage( this._canvas );
- // Transparency stuff
- var stateset = this._geometry.getOrCreateStateSet();
- stateset.setTextureAttributeAndModes( 0, this._texture );
- stateset.setRenderingHint( 'TRANSPARENT_BIN' );
- stateset.setAttributeAndModes( new BlendFunc( BlendFunc.ONE, BlendFunc.ONE_MINUS_SRC_ALPHA ) );
- this._matrixTransform.addChild( this._geometry );
- this.dirtyBound();
- },
-
- setText: function ( text ) {
- this._text = text;
- // Canvas size could change so we need to make it dirty.
- this._dirty = true;
- },
-
- getText: function () {
- return this._text;
- },
-
- setFont: function ( font ) {
- this._font = font;
- this._dirty = true;
- },
-
- setColor: function ( color ) {
- this._color = color;
- // Convert color to html range
- this._fillStyle = 'rgba(' + Math.round( color[ 0 ] * 255 ) + ',' + Math.round( color[ 1 ] * 255 ) + ',' + Math.round( color[ 2 ] * 255 ) + ',' + color[ 3 ] + ')';
- this._context.fillStyle = this._fillStyle;
- // Canvas size does not change so we don't need to redo the quad.
- this._context.fillText( this._text, this._textX, this._textY );
- },
-
- getColor: function () {
- return this._color;
- },
-
- setCharacterSize: function ( size ) {
- this._characterSize = size;
- if ( this._characterSizeMode !== Text.OBJECT_COORDS ) {
- mat4.fromScaling( this._matrixTransform.getMatrix(), [ this._characterSize, this._characterSize, this._characterSize ] );
- if ( this._characterSizeMode === Text.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT )
- this.setMaximumScale( this._characterSize );
- }
- this._dirty = true;
- },
-
- getCharacterSize: function () {
- return this._characterSize;
- },
-
- setCharacterSizeMode: function ( mode ) {
- this._characterSizeMode = mode;
- if ( this._characterSizeMode !== Text.OBJECT_COORDS ) {
- mat4.fromScaling( this._matrixTransform.getMatrix(), [ this._characterSize, this._characterSize, this._characterSize ] );
- this.setAutoScaleToScreen( true );
- this.setMaximumScale( Number.MAX_VALUE );
- if ( this._characterSizeMode === Text.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT )
- this.setMaximumScale( this._characterSize );
- } else {
- this._matrixTransform.setMatrix( mat4.create() );
- this.setAutoScaleToScreen( false );
- }
- this._dirty = true;
- },
-
- getCharacterSizeMode: function () {
- return this._characterSizeMode;
- },
-
- setFontResolution: function ( resolution ) {
- this._fontSize = resolution;
- this._dirty = true;
- },
-
- getFontResolution: function () {
- return this._fontSize;
- },
-
- setPosition: function ( position ) {
- this._position = position;
- mat4.fromTranslation( this.getMatrix(), position );
- },
-
- getPosition: function () {
- return this._position;
- },
-
- setTextProperties: function () {
- this._context.fillStyle = this._fillStyle;
- this._setAlignmentValues( this._alignment );
- this._context.font = this._fontSize + 'px ' + this._font;
- this._context.direction = this._layout;
- },
-
- setAutoRotateToScreen: function ( value ) {
- AutoTransform.prototype.setAutoRotateToScreen.call( this, value );
- this._dirty = true;
- },
-
- getAutoRotateToScreen: function () {
- return this._autoRotateToScreen;
- },
-
- setLayout: function ( layout ) {
- if ( typeof layout === 'string' ) {
- this._layout = Text[ layout ];
- } else {
- this._layout = layout;
- }
- this._dirty = true;
- },
- getLayout: function () {
- return this._layout;
- },
- setAlignment: function ( alignment ) {
- if ( typeof alignment === 'string' ) {
- this._alignment = Text[ alignment ];
- } else {
- this._alignment = alignment;
- }
- this._dirty = true;
- },
- getAlignment: function () {
- return this._alignment;
- },
-
- accept: ( function () {
-
- return function ( visitor ) {
- if ( this._dirty ) {
- this.drawText();
- this._dirty = false;
- }
- if ( visitor.getVisitorType() === NodeVisitor.CULL_VISITOR ) {
-
- var width = visitor.getViewport().width();
- var height = visitor.getViewport().height();
- var projMat = visitor.getCurrentProjectionMatrix();
- var modelViewMat = visitor.getCurrentModelViewMatrix();
- var position = this._position;
- var doUpdate = this._firstTimeToInitEyePoint;
-
- if ( !this._firstTimeToInitEyePoint ) {
- if ( !mat4.exactEquals( modelViewMat, this._previousModelView ) ) {
- doUpdate = true;
- } else if ( width !== this._previousWidth || height !== this._previousHeight ) {
- doUpdate = true;
- } else if ( !mat4.exactEquals( projMat, this._previousProjection ) ) {
- doUpdate = true;
- } else if ( !vec3.exactEquals( position, this._previousPosition ) ) {
- doUpdate = true;
- }
- }
- this._firstTimeToInitEyePoint = false;
- if ( doUpdate ) {
- if ( this._autoScaleToScreen ) {
- var viewport = visitor.getViewport();
- var psvector = this.computePixelSizeVector( viewport, projMat, modelViewMat );
- var v = vec4.fromValues( this._position[ 0 ], this._position[ 1 ], this._position[ 2 ], 1.0 );
- var pixelSize = vec4.dot( v, psvector );
- pixelSize = 0.48 / pixelSize;
- var size = 1.0 / pixelSize;
- if ( this._autoScaleTransitionWidthRatio > 0.0 ) {
- var c, b, a;
- if ( this._minimumScale > 0.0 ) {
- var j = this._minimumScale;
- var i = ( this._maximumScale < Number.MAX_VALUE ) ?
- this._minimumScale + ( this._maximumScale - this._minimumScale ) * this._autoScaleTransitionWidthRatio :
- this._minimumScale * ( 1.0 + this._autoScaleTransitionWidthRatio );
- c = 1.0 / ( 4.0 * ( i - j ) );
- b = 1.0 - 2.0 * c * i;
- a = j + b * b / ( 4.0 * c );
- var k = -b / ( 2.0 * c );
- if ( size < k ) size = this._minimumScale;
- else if ( size < i ) size = a + b * size + c * ( size * size );
- }
- if ( this._maximumScale < Number.MAX_VALUE ) {
- var n = this._maximumScale;
- var m = ( this._minimumScale > 0.0 ) ?
- this._maximumScale + ( this._minimumScale - this._maximumScale ) * this._autoScaleTransitionWidthRatio :
- this._maximumScale * ( 1.0 - this._autoScaleTransitionWidthRatio );
- c = 1.0 / ( 4.0 * ( m - n ) );
- b = 1.0 - 2.0 * c * m;
- a = n + b * b / ( 4.0 * c );
- var p = -b / ( 2.0 * c );
-
- if ( size > p ) size = this._maximumScale;
- else if ( size > m ) size = a + b * size + c * ( size * size );
- }
- }
- this.setScale( size );
- }
- if ( this._autoRotateToScreen ) {
- var rotation = quat.create();
- var modelView = visitor.getCurrentModelViewMatrix();
- mat4.getRotation( rotation, modelView );
- this.setRotation( quat.invert( rotation, rotation ) );
- }
- this._previousWidth = width;
- this._previousHeight = height;
- vec3.copy( this._previousPosition, position );
- mat4.copy( this._previousProjection, projMat );
- mat4.copy( this._previousModelView, modelViewMat );
- }
- }
-
- Node.prototype.accept.call( this, visitor );
- };
- } )(),
- _setAlignmentValues: function ( alignment ) {
- // Convert the OSG Api to js API
- switch ( alignment ) {
- case Text.LEFT_TOP:
- this._context.textAlign = 'left';
- this._textX = 0;
- this._context.textBaseline = 'top';
- this._textY = 0;
- break;
- case Text.LEFT_CENTER:
- this._context.textAlign = 'left';
- this._textX = 0;
- this._context.textBaseline = 'middle';
- this._textY = this._canvas.height / 2;
- break;
- case Text.LEFT_BOTTOM:
- this._context.textAlign = 'left';
- this._textX = 0;
- this._context.textBaseline = 'bottom';
- this._textY = this._canvas.height;
- break;
- case Text.CENTER_TOP:
- this._context.textAlign = 'center';
- this._textX = this._canvas.width / 2;
- this._context.textBaseline = 'top';
- this._textY = 0;
- break;
- case Text.CENTER_CENTER:
- this._context.textAlign = 'center';
- this._textX = this._canvas.width / 2;
- this._context.textBaseline = 'middle';
- this._textY = this._canvas.height / 2;
- break;
- case Text.CENTER_BOTTOM:
- this._context.textAlign = 'center';
- this._textX = this._canvas.width / 2;
- this._context.textBaseline = 'bottom';
- this._textY = this._canvas.height;
- break;
- case Text.RIGHT_TOP:
- this._context.textAlign = 'right';
- this._textX = this._canvas.width;
- this._context.textBaseline = 'top';
- this._textY = 0;
- break;
- case Text.RIGHT_CENTER:
- this._context.textAlign = 'right';
- this._textX = this._canvas.width;
- this._context.textBaseline = 'middle';
- this._textY = this._canvas.height / 2;
- break;
- case Text.RIGHT_BOTTOM:
- this._context.textAlign = 'right';
- this._textX = this._canvas.width;
- this._context.textBaseline = 'bottom';
- this._textY = this._canvas.height;
- break;
- }
- },
- setForcePowerOfTwo: function ( value ) {
- this._forcePowerOfTwo = value;
- },
- getForcePowerOfTwo: function () {
- return this._forcePowerOfTwo;
- },
- _nextPowerOfTwo: function ( value ) {
- var v = value;
- v--;
- v |= v >> 1;
- v |= v >> 2;
- v |= v >> 4;
- v |= v >> 8;
- v |= v >> 16;
- v++;
- return v;
- }
-} ), 'osgText', 'Text' );
-
-module.exports = Text;
diff --git a/app/static/app/js/vendor/osgjs/osgText/osgText.js b/app/static/app/js/vendor/osgjs/osgText/osgText.js
deleted file mode 100644
index eafac292..00000000
--- a/app/static/app/js/vendor/osgjs/osgText/osgText.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-var Text = require( 'osgText/Text' );
-
-var osgText = {};
-osgText.Text = Text;
-
-module.exports = osgText;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/Composer.js b/app/static/app/js/vendor/osgjs/osgUtil/Composer.js
deleted file mode 100644
index 316f574c..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/Composer.js
+++ /dev/null
@@ -1,1599 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var MACROUTILS = require( 'osg/Utils' );
-var Node = require( 'osg/Node' );
-var CullFace = require( 'osg/CullFace' );
-var Depth = require( 'osg/Depth' );
-var Texture = require( 'osg/Texture' );
-var Camera = require( 'osg/Camera' );
-var FrameBufferObject = require( 'osg/FrameBufferObject' );
-var Viewport = require( 'osg/Viewport' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Uniform = require( 'osg/Uniform' );
-var StateSet = require( 'osg/StateSet' );
-var Program = require( 'osg/Program' );
-var Shader = require( 'osg/Shader' );
-var Shape = require( 'osg/shape' );
-var TransformEnums = require( 'osg/transformEnums' );
-var vec2 = require( 'osg/glMatrix' ).vec2;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-
-/*
- Composer is an helper to create post fx. The idea is to push one or more textures into a pipe of shader filter.
-
- how to use it:
-
- // example how to blur a texture and render it to screen
- var myTexture; // imagine it's your texture you want to process
- var composer = new Composer();
- composer.addPass(new Composer.Filter.InputTexture(myTexture));
- composer.addPass(new Composer.Filter.HBlur(5));
- composer.addPass(new Composer.Filter.VBlur(5));
- composer.renderToScreen(1200, 900);
- composer.build(); // if you dont build manually it will be done in the scenegraph while upading
- rootnode.addChild(composer);
-
- // now you can imagine to some process and use the result as input texture for a geometry
- var myTexture; // imagine it's your texture you want to process
- var myResultTexture = new Texture(); // imagine it's your texture you want to process
- myResultTexture.setTextureSize(1200,900);
- var composer = new Composer();
- composer.addPass(new Composer.Filter.InputTexture(myTexture));
- composer.addPass(new Composer.Filter.HBlur(5));
- composer.addPass(new Composer.Filter.VBlur(5), resultTexture);
-
- myGeometry.getStateSet().setTextureAttributeAndModes(0, resultTexture);
- rootnode.addChild(composer);
-
- */
-
-var Composer = function () {
- Node.call( this );
- this._stack = [];
- this._renderToScreen = false;
- this._dirty = false;
-
- this._textureRTT = [];
- this._cameraRTT = [];
-
- var UpdateCallback = function () {
-
- };
- UpdateCallback.prototype = {
- update: function ( node /*, nv */ ) {
- if ( node.isDirty() ) {
- node.build();
- }
- return true;
- }
- };
- this.addUpdateCallback( new UpdateCallback() );
- // disable unecessarry drawing/states/check
- this.getOrCreateStateSet().setAttributeAndModes( new Depth( 'DISABLE' ) );
- this.getOrCreateStateSet().setAttributeAndModes( new CullFace( 'BACK' ) );
-};
-
-Composer.prototype = MACROUTILS.objectInherit( Node.prototype, {
- dirty: function () {
- for ( var i = 0, l = this._stack.length; i < l; i++ ) {
- this._stack[ i ].filter.dirty();
- }
- },
-
- // addPass support different signature
- // addPass(filter) -> the filter will be done on a texture of the same size than the previous pass
- // addPass(filter, textureWidth, textureHeight) -> the filter will be done on a texture width and height
- // addPass(filter, texture) -> the filter will be done on the giver texture using its width and height
- addPass: function ( filter, arg0, arg1 ) {
-
- var newPass = {};
- newPass.filter = filter;
- // when arg0 is a texture
- // arg1 is the target, can be TEXTURE_2D ( by default ) or
- // a cubemape's face like TEXTURE_CUBE_MAP_POSITIVE_X, ...
- if ( arg0 instanceof Texture ) {
- newPass.texture = arg0;
- newPass.textureTarget = arg1 || Texture.TEXTURE_2D;
- } else if ( arg0 !== undefined && arg1 !== undefined ) {
- newPass.width = Math.floor( arg0 );
- newPass.height = Math.floor( arg1 );
- }
-
- this._stack.push( newPass );
- return newPass.filter;
- },
- renderToScreen: function ( w, h ) {
- this._renderToScreen = true;
- this._renderToScreenWidth = w;
- this._renderToScreenHeight = h;
- },
- getResultTexture: function () {
- return this._resultTexture;
- },
- isDirty: function () {
- for ( var i = 0, l = this._stack.length; i < l; i++ ) {
- if ( this._stack[ i ].filter.isDirty() ) {
- return true;
- }
- }
- return false;
- },
-
- /*develblock:start*/
- // debug only check for specific bad condition:
- // in webgl 1.0 you cannot read and write on the same texture
- // so you shouldn't bind a FOB texture as input and output
- debugCheckRttNotReadWrite: function ( textureResult, stateSet ) {
-
- for ( var k = 0, lt = stateSet.getNumTextureAttributeLists(); k < lt; k++ ) {
- var textureBinded = stateSet.getTextureAttribute( k, 'Texture' );
- Notify.assert( textureResult !== textureBinded, 'Composer: write/read at the same time on a texture is undefined behavior' );
-
- }
- },
- /*develblock:end*/
-
- build: function () {
-
- var self = this;
-
- // keep some references
- // TODO: use for reuse/cache/invalidation
- self._textureRTT = [];
- self._cameraRTT = [];
-
-
- this.removeChildren();
- var lastTextureResult;
-
- this._stack.forEach( function ( element, i, array ) {
-
- // update filter internal due to user change on filter
- if ( element.filter.isDirty() ) {
- element.filter.build();
- }
-
- // this filter need a special setup that composer build cannot do
- if ( element.filter.interConnectFilters ) {
- lastTextureResult = element.filter.interConnectFilters( self, i, array );
- // goto next filter directly
- return;
- }
-
- var stateSet = element.filter.getStateSet();
- var w, h;
-
- // compute filter render texture size
- if ( element.texture !== undefined ) {
-
- w = element.texture.getWidth();
- h = element.texture.getHeight();
-
- } else if ( element.width !== undefined && element.height !== undefined ) {
-
- w = element.width;
- h = element.height;
-
- } else {
-
- // get width from Texture0
- var inputTexture = stateSet.getTextureAttribute( 0, 'Texture' );
- if ( inputTexture === undefined ) {
- Notify.warn( 'Composer can\'t find any information to setup texture output size' );
- } else {
- w = inputTexture.getWidth();
- h = inputTexture.getHeight();
- }
- }
-
- // is it the last filter and we want to render to screen ?
- var lastFilterRenderToScreen = ( i === array.length - 1 &&
- self._renderToScreen === true );
-
- // check if we have something to do
- // else we will just translate stateset to the next filter
- // this part exist to manage the Composer.Filter.InputTexture that setup the first texture unit
- if ( !lastFilterRenderToScreen ) {
- if ( stateSet.getAttribute( 'Program' ) === undefined ) {
- array[ i + 1 ].filter.getStateSet().setTextureAttributeAndModes( 0, stateSet.getTextureAttribute( 0, 'Texture' ) );
- return;
- }
- }
-
- // build the filter into a Camera and a StateSet
- var camera = new Camera();
- self._cameraRTT.push( camera );
- camera.setStateSet( stateSet );
-
-
- var textureResult;
- // check if we want to render on screen
- if ( lastFilterRenderToScreen === true ) {
- w = self._renderToScreenWidth;
- h = self._renderToScreenHeight;
- } else {
- // Or in a offscreen Framebuffer
- camera.setRenderOrder( Camera.PRE_RENDER, 0 );
- textureResult = element.texture;
- var textureTarget = element.textureTarget;
- // if no user provided render target texture, create one
- if ( textureResult === undefined ) {
- textureResult = new Texture();
- textureResult.setName( 'composer Rtt ' + element.filter.getFragmentName() );
- textureResult.setTextureSize( w, h );
- textureTarget = Texture.TEXTURE_2D;
- self._textureRTT.push( textureResult );
- }
- // Attach the render texture target as FBO
- // Note: node depth attachment because we're in 2D
- camera.attachTexture( FrameBufferObject.COLOR_ATTACHMENT0, textureResult, textureTarget );
- }
-
- var vp = new Viewport( 0, 0, w, h );
- camera.setReferenceFrame( TransformEnums.ABSOLUTE_RF );
- camera.setViewport( vp );
-
- // FIXME: not really useful, but osgjs keep pushing projection matrix
- // and maybe some old code still use it
- mat4.ortho( camera.getProjectionMatrix(), 0, 1, 0, 1, -5, 5 );
-
- var quad = Shape.createTexturedFullScreenFakeQuadGeometry();
-
- if ( element.filter.buildGeometry )
- quad = element.filter.buildGeometry( quad );
-
- quad.setName( 'composer layer' );
-
- // if rendering into texture framebuffer
- if ( textureResult ) {
-
- /*develblock:start*/
- self.debugCheckRttNotReadWrite( textureResult, stateSet );
- /*develblock:end*/
-
- // assign the result texture to the next stateset
- if ( i + 1 < array.length ) {
- array[ i + 1 ].filter.getStateSet().setTextureAttributeAndModes( 0, textureResult );
- }
-
- }
- lastTextureResult = textureResult;
-
-
- camera.addChild( quad );
- element.filter.getStateSet().addUniform( Uniform.createFloat2( vec2.fromValues( w, h ), 'RenderSize' ) );
-
- // Optimization, no need to clear,
- // unless we know we'll have transparent parts
- // which is a special case rather than the default
- camera.setClearMask( 0 );
-
- camera.setName( element.filter.getFragmentName() || 'Composer Pass' + i );
- // add to composer
- self.addChild( camera );
- } );
- // reference to the resulting texture
- // undefined if rendering directly to screen
- this._resultTexture = lastTextureResult;
- }
-} );
-
-Composer.Filter = function () {
- this._stateSet = new StateSet();
- this._dirty = true;
- this._fragmentName = 'FilterOSGJS';
- this._vertexName = '';
-};
-
-Composer.Filter.prototype = {
- setFragmentName: function ( fname ) {
- this._fragmentName = fname;
- },
- getFragmentName: function () {
- return this._fragmentName;
- },
- setVertexName: function ( vname ) {
- this._vertexName = vname;
- },
- getVertexName: function () {
- return this._vertexName;
- },
- getDefineFragmentName: function () {
- return '\n#define SHADER_NAME ' + this._fragmentName + '\n';
- },
- getDefineVertexName: function () {
- return '\n#define SHADER_NAME ' + ( this._vertexName || this._fragmentName ) + '\n';
- },
- getStateSet: function () {
- return this._stateSet;
- },
- getOrCreateStateSet: function () {
- return this._stateSet;
- },
- dirty: function () {
- this._dirty = true;
- },
- isDirty: function () {
- return this._dirty;
- }
-};
-
-// default means you do use the special optimized full screen triangle
-// dubbed fakeFullscreenQuad
-// no need of modelView, projection, nor texcoord
-Composer.Filter.defaultVertexShader = [
- 'attribute vec3 Vertex;',
- 'varying vec2 vTexCoord0;',
- 'void main(void) {',
- ' gl_Position = vec4(Vertex*2.0 - 1.0,1.0);',
- ' vTexCoord0 = Vertex.xy;',
- '}',
- ''
-].join( '\n' );
-Composer.Filter.defaultFragmentShaderHeader = [
- '#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n#endif',
- 'varying vec2 vTexCoord0;',
- 'uniform vec2 RenderSize;',
- 'uniform sampler2D Texture0;',
- ''
-].join( '\n' );
-
-Composer.Filter.shaderUtils = [
- 'vec4 packFloatTo4x8(in float v) {',
- 'vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;',
- 'enc = fract(enc);',
- 'enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);',
- 'return enc;',
- '}',
-
- ' ',
- 'vec4 pack2FloatTo4x8(in vec2 val) {',
- ' const vec2 bitSh = vec2(256.0, 1.0);',
- ' const vec2 bitMsk = vec2(0.0, 1.0/256.0);',
- ' vec2 res1 = fract(val.x * bitSh);',
- ' res1 -= res1.xx * bitMsk;',
- ' vec2 res2 = fract(val.y * bitSh);',
- ' res2 -= res2.xx * bitMsk;',
- ' return vec4(res1.x,res1.y,res2.x,res2.y);',
- '}',
- ' ',
- 'float unpack4x8ToFloat( vec4 rgba ) {',
- ' return dot( rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) );',
- '}',
- ' ',
- 'vec2 unpack4x8To2Float(in vec4 val) {',
- ' const vec2 unshift = vec2(1.0/256.0, 1.0);',
- ' return vec2(dot(val.xy, unshift), dot(val.zw, unshift));',
- '}',
-
- 'vec2 encodeNormal (vec3 n)',
- '{',
- ' float f = sqrt(8.0*n.z+8.0);',
- ' return n.xy / f + 0.5;',
- '}',
-
- 'vec3 decodeNormal (vec2 enc)',
- '{',
- ' vec2 fenc = enc*4.0-2.0;',
- ' float f = dot(fenc,fenc);',
- ' float g = sqrt(1.0-f/4.0);',
- ' vec3 n;',
- ' n.xy = fenc*g;',
- ' n.z = 1.0-f/2.0;',
- ' return n;',
- '}',
- ''
-].join( '\n' );
-
-Composer.Filter.Helper = {
- pascalCache: [
- [ 1 ]
- ],
- getOrCreatePascalCoefficients: function ( kernelSize ) {
- kernelSize = kernelSize === undefined ? 5 : Math.min( kernelSize, 128 );
- var cache = Composer.Filter.Helper.pascalCache;
- if ( cache[ kernelSize ] )
- return cache[ kernelSize ];
- for ( var j = cache.length - 1; j < kernelSize; j++ ) {
- var currentRow = cache[ j ];
- var currentRowSize = currentRow.length;
-
- var nextRow = new Array( currentRowSize );
- nextRow[ 0 ] = 1.0;
- nextRow[ currentRowSize ] = 1.0;
-
- // unnormalized pascal
- var sum = j === cache.length - 1 ? Math.pow( 2, j ) : 1.0;
- for ( var p = 0; p < currentRowSize - 1; p++ )
- nextRow[ p + 1 ] = ( currentRow[ p ] + currentRow[ p + 1 ] ) * sum;
- // normalized array
- sum = Math.pow( 2, j + 1 );
- for ( var k = 0; k < currentRowSize + 1; k++ )
- nextRow[ k ] /= sum;
- cache.push( nextRow );
- }
- return cache[ kernelSize ];
- }
-};
-
-Composer.Filter.Custom = function ( fragmentShader, uniforms ) {
- Composer.Filter.call( this );
- this._fragmentShader = fragmentShader;
- this._uniforms = uniforms;
- this._vertexShader = Composer.Filter.defaultVertexShader;
-};
-
-Composer.Filter.Custom.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- setFragmentShader: function ( f ) {
- this._fragmentShader = f;
- },
- setVertexShader: function ( v ) {
- this._vertexShader = v;
- },
- autoBindFragmentUniformStateSet: function ( stateSet, fragmentShader, uniforms ) {
-
- var unitIndex = 0;
-
- // TODO: check if not a better place Utils
- // and reuse (we already do this in shader)
- // At least DEFINE the regexp somewhere somehow
- var r = fragmentShader.match( /uniform\s+\w+\s+\w+/g );
- if ( !r ) return;
-
- for ( var i = 0, l = r.length; i < l; i++ ) {
-
- var match = r[ i ].match( /uniform\s+(\w+)\s+(\w+)/ );
- var uniformType = match[ 1 ];
- var uniformName = match[ 2 ];
- var uniform;
-
- if ( !uniforms[ uniformName ] ) continue;
-
- var uniformValue = uniforms[ uniformName ];
-
- if ( uniformType.search( 'sampler' ) !== -1 ) {
-
- // STRONG IMPLICIT LINKING HERE:
- // Texture Unit Linked directly to declaration order in fragment Shader
- stateSet.setTextureAttributeAndModes( unitIndex, uniformValue );
- uniform = Uniform.createInt1( unitIndex, uniformName );
- unitIndex++;
- stateSet.addUniform( uniform );
-
- } else {
-
- if ( Uniform.isUniform( uniformValue ) ) {
- uniform = uniformValue;
- } else {
- uniform = Uniform[ uniformType ]( uniforms[ uniformName ], uniformName );
- }
- stateSet.addUniform( uniform );
-
- }
-
- }
- },
- build: function () {
-
- this._program = new Program(
- new Shader( Shader.VERTEX_SHADER, this._vertexShader + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, this._fragmentShader + this.getDefineFragmentName() ) );
-
- if ( this._uniforms ) {
- this.autoBindFragmentUniformStateSet( this._stateSet, this._fragmentShader, this._uniforms );
- }
- this._stateSet.setAttributeAndModes( this._program );
- this._dirty = false;
-
- }
-} );
-
-
-// filter that switch its render target and its input at each frame
-// allowing to get input for last frame render.
-Composer.Filter.PingPong = function ( cameraRtt0, rtt0, cameraRtt1, rtt1, fragmentShader, uniforms ) {
- Composer.Filter.Custom.apply( this, [ fragmentShader, uniforms ] );
-
- this._cameraRtt0 = cameraRtt0;
- this._rtt0 = rtt0;
-
- this._cameraRtt1 = cameraRtt1;
- this._rtt1 = rtt1;
-
- this._fragmentName = 'PingPong';
-};
-
-Composer.Filter.PingPong.prototype = MACROUTILS.objectInherit( Composer.Filter.Custom.prototype, {
-
- // Constraints:
- // - Next Filter: texture unit 0 === rtt0 && texture unit 1 === rtt1
- // - Previous Filter: the output of the previous filter if any
- // will be binded to texture unit 0 of both camera stateset
- interConnectFilters: function ( composer, i, array ) {
-
- var filterStateSet = this.getStateSet();
-
- var st0 = this._cameraRtt0.getOrCreateStateSet();
- var st1 = this._cameraRtt1.getOrCreateStateSet();
-
- // copy filter program and uniforms on the 2 cameras
- st0.setAttributeAndModes( this._program );
- st1.setAttributeAndModes( this._program );
-
- // PingPong filter is a peculiar Filter where user provides the Camera
- // instead of compose::build creating them, and allowing user to provide
- // them in the ctor
- // To make sure we don't forget any uniform
- // we make sure to get uniform from the filter itself and the uniform
- // from the parameters
- var k, l, keys, unif, uniforms = this.getStateSet().getUniformList();
- if ( uniforms ) {
- keys = window.Object.keys( uniforms );
- for ( k = 0, l = keys.length; k < l; k++ ) {
- unif = uniforms[ keys[ k ] ].getUniform();
- st0.addUniform( unif );
- st1.addUniform( unif );
- }
- }
-
- uniforms = this._uniforms;
- if ( uniforms ) {
- keys = window.Object.keys( uniforms );
- for ( k = 0, l = keys.length; k < l; k++ ) {
- unif = uniforms[ keys[ k ] ];
- st0.addUniform( unif );
- st1.addUniform( unif );
- }
- }
-
-
- var uniformTU0 = Uniform.createInt1( 0, 'Texture0' );
- var uniformTU1 = Uniform.createInt1( 1, 'Texture1' );
-
- st0.addUniform( uniformTU0 );
- st0.addUniform( uniformTU1 );
-
- st1.addUniform( uniformTU0 );
- st1.addUniform( uniformTU1 );
-
- // copy input on both camera
- // Composer::Build set the last render into the current filter stateset texture unit 0
- // we copy that into each camera as Texture unit 0
- var inputTexture = filterStateSet.getTextureAttribute( 0, 'Texture' );
- st0.setTextureAttributeAndModes( 0, inputTexture );
- st1.setTextureAttributeAndModes( 0, inputTexture );
-
- st0.setTextureAttributeAndModes( 1, this._rtt1 );
- st1.setTextureAttributeAndModes( 1, this._rtt0 );
-
- // if not the last filter
- // bind both result to next filter
- // rtt0 to texture unit 0
- // rtt0 to texture unit 1
- if ( i !== array.length - 1 ) {
-
- // just translate stateset to the next filter
- var nextSt = array[ i + 1 ].filter.getStateSet();
-
- nextSt.setTextureAttributeAndModes( 0, this._rtt0 );
- nextSt.setTextureAttributeAndModes( 1, this._rtt1 );
-
- nextSt.addUniform( uniformTU0 );
- nextSt.addUniform( uniformTU1 );
-
- }
-
- var quad = Shape.createTexturedFullScreenFakeQuadGeometry();
-
- if ( this.buildGeometry )
- quad = this.buildGeometry( quad );
-
- quad.setName( 'composer layer' );
-
- this._cameraRtt0.addChild( quad );
- this._cameraRtt1.addChild( quad );
-
- composer.addChild( this._cameraRtt0 );
- composer.addChild( this._cameraRtt1 );
-
- composer._textureRTT.push( this._rtt0 );
- composer._textureRTT.push( this._rtt1 );
-
- composer._cameraRTT.push( this._cameraRtt0 );
- composer._cameraRTT.push( this._cameraRtt1 );
-
- // hide one of the two pass, as we will render only one each frame
- this._cameraRtt1.setNodeMask( 0x0 );
-
- // last texture result, only one possible so the first will do
- return this._rtt0;
-
- },
-
- // PingPong
- switch: function () {
-
- var nodeMask0 = this._cameraRtt0.getNodeMask();
- var nodeMask1 = this._cameraRtt1.getNodeMask();
-
- this._cameraRtt0.setNodeMask( nodeMask1 );
- this._cameraRtt1.setNodeMask( nodeMask0 );
-
- }
-
-} );
-
-Composer.Filter.AverageHBlur = function ( nbSamplesOpt, linear, unpack, pack ) {
- Composer.Filter.call( this );
- this._linear = linear !== false;
- this.setBlurSize( nbSamplesOpt !== undefined ? nbSamplesOpt : 5 );
- this._unpack = unpack;
- this._pack = pack;
- this._pixelSize = 1.0;
- this._fragmentName = 'AverageHBlur' + this._nbSamples;
-};
-
-Composer.Filter.AverageHBlur.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- setBlurSize: function ( nbSamples ) {
- if ( nbSamples % 2 !== 1 ) {
- nbSamples += 1;
- }
- this._nbSamples = nbSamples;
- this.dirty();
- },
- setPixelSize: function ( value ) {
- this._pixelSize = value;
- this.dirty();
- },
-
- getUVOffset: function ( value ) {
- return 'vec2(float(' + value + ')/RenderSize[0], 0.0);';
- },
- getShaderBlurKernel: function () {
- var nbSamples = this._nbSamples;
-
-
- var kernel = [];
-
- kernel.push( ' pixel = unpack(Texture0, vTexCoord0 );' );
- kernel.push( ' if (pixel.w == 0.0) { gl_FragColor = pixel; return; }' );
- kernel.push( ' vec2 offset;' );
- var i;
- var numTexBlurStep = Math.floor( nbSamples / 2 );
- if ( numTexBlurStep % 2 !== 0 ) {
- nbSamples += 1;
- numTexBlurStep = Math.floor( nbSamples / 2 );
- }
- var numFinalSample = numTexBlurStep * 2.0 + 1.0;
- var weight = 1.0 / numFinalSample;
- if ( !this._linear ) {
- for ( i = 0; i < numTexBlurStep; i++ ) {
- kernel.push( ' offset = ' + this.getUVOffset( ( i + 1 ) * this._pixelSize ) );
- kernel.push( ' pixel += unpack(Texture0, vTexCoord0 + offset);' );
- kernel.push( ' pixel += unpack(Texture0, vTexCoord0 - offset);' );
- }
- kernel.push( ' pixel *= float(' + weight + ');' );
-
- //console.log( 'N: Sum = ' + ( weight + numTexBlurStep * weight * 2 ) );
- //console.log( 'N: nbSample = ' + nbSamples + ' texBlurStep= ' + numTexBlurStep + ' finalSample= ' + numFinalSample );
- //console.log( 'N: w = ' + weight );
-
- } else {
- // using bilinear HW to divide texfetch by 2
- var offset, offsetIdx;
- var idx = 1;
- var weightTwo = ( 1.0 - weight ) / ( numTexBlurStep * 2.0 );
- // first pixel not same weight as others
- kernel.push( ' pixel *= float(' + weight + ');' );
- kernel.push( ' vec4 pixelLin = vec4(0.0);' );
-
- for ( i = 0; i < numTexBlurStep; i += 2 ) {
-
- offsetIdx = idx + 0.5; // ((i*weight + (i+1)*weight)/(weight+weight)) === (2i + 1) / 2 = i + 0.5
- idx += 2;
- offset = this.getUVOffset( offsetIdx * this._pixelSize );
-
- kernel.push( ' offset = ' + offset );
-
- kernel.push( ' pixelLin += unpack(Texture0, vTexCoord0 + offset);' );
- kernel.push( ' pixelLin += unpack(Texture0, vTexCoord0 - offset);' );
- }
- kernel.push( ' pixel += pixelLin * float(' + weightTwo * 2 + ');' );
-
- //console.log( 'L: Sum = ' + ( weight + numTexBlurStep * weightTwo * 2 ) );
- //console.log( 'L: nbSample = ' + nbSamples + ' texBlurStep= ' + numTexBlurStep + ' finalSample= ' + numFinalSample );
- //console.log( 'N: w = ' + weight + ' numTexBlurStep ' + numTexBlurStep + ' * w2 = ' + weightTwo );
-
- }
- return kernel;
- },
- build: function () {
-
- var tex = this._stateSet.getTextureAttribute( 0, 'Texture' );
- if ( tex && this._linear ) {
- tex.setMinFilter( 'LINEAR' );
- tex.setMagFilter( 'LINEAR' );
- } else {
- this._linear = false;
- }
-
- //var nbSamples = this._nbSamples;
- var vtx = Composer.Filter.defaultVertexShader;
- var fgt = [
- Composer.Filter.defaultFragmentShaderHeader,
- 'uniform float width;',
-
- this._unpack || 'vec4 unpack(const in sampler2D tex, const in vec2 uv) { return texture2D(tex, uv); }',
- this._pack || 'vec4 pack(vec4 pix) { return pix; }',
-
- 'void main (void)',
- '{',
- ' vec4 pixel;',
- this.getShaderBlurKernel().join( '\n' ),
- ' gl_FragColor = pack(pixel);',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vtx + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fgt + this.getDefineFragmentName() ) );
-
- if ( this._stateSet.getUniform( 'Texture0' ) === undefined ) {
- this._stateSet.addUniform( Uniform.createInt1( 0, 'Texture0' ) );
- }
-
-
- this._stateSet.setAttributeAndModes( program );
- this._dirty = false;
- }
-} );
-
-
-Composer.Filter.AverageVBlur = function ( nbSamplesOpt, linear, unpack, pack ) {
- Composer.Filter.AverageHBlur.call( this, nbSamplesOpt, linear, unpack, pack );
- this._fragmentName = 'AverageVBlur' + this._nbSamples;
-};
-Composer.Filter.AverageVBlur.prototype = MACROUTILS.objectInherit( Composer.Filter.AverageHBlur.prototype, {
- getUVOffset: function ( value ) {
- return 'vec2(0.0, float(' + value + ')/RenderSize[1]);';
- }
-} );
-
-Composer.Filter.BilateralHBlur = function ( options, unpack, pack ) {
- Composer.Filter.call( this );
-
- if ( options === undefined ) {
- options = {};
- }
-
- var nbSamplesOpt = options.nbSamples;
- var depthTexture = options.depthTexture;
- var radius = options.radius;
-
- this.setBlurSize( nbSamplesOpt !== undefined ? nbSamplesOpt : 5 );
- this._depthTexture = depthTexture;
- this._radius = Uniform.createFloat( 1.0, 'radius' );
- this._pixelSize = Uniform.createFloat( 1.0, 'pixelSize' );
- this.setRadius( radius );
-
- this._unpack = unpack;
- this._pack = pack;
- this._fragmentName = 'BilateralHBlur' + this._nbSamples;
-};
-
-Composer.Filter.BilateralHBlur.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- setBlurSize: function ( nbSamples ) {
- if ( nbSamples % 2 !== 1 ) {
- nbSamples += 1;
- }
- //Notify.log('BlurSize ' + nbSamples);
- this._nbSamples = nbSamples;
- this.dirty();
- },
- setPixelSize: function ( value ) {
- this._pixelSize.setFloat( value );
- },
- setRadius: function ( radius ) {
- this._radius.setFloat( radius ); // *2.0;
- },
- getUVOffset: function ( value ) {
- return 'vec2(0.0, float(' + value + ') * pixelSize )/RenderSize[1];';
- },
- getShaderBlurKernel: function () {
- var nbSamples = this._nbSamples;
- var kernel = [];
- kernel.push( ' pixel = unpack(Texture0, vTexCoord0 );' );
- kernel.push( ' if (pixel.w <= 0.0001) { gl_FragColor = vec4(1.0); return; }' );
- kernel.push( ' vec2 offset, tmpUV;' );
- kernel.push( ' depth = getDepthValue(unpack(Texture1, vTexCoord0 ));' );
- for ( var i = 1; i < Math.ceil( nbSamples / 2 ); i++ ) {
- kernel.push( ' offset = ' + this.getUVOffset( i ) );
-
- kernel.push( ' tmpUV = vTexCoord0 + offset;' );
- kernel.push( ' tmpDepth = getDepthValue(unpack(Texture1, tmpUV ));' );
- kernel.push( ' if ( abs(depth-tmpDepth) < radius) {' );
- kernel.push( ' pixel += unpack(Texture0, tmpUV);' );
- kernel.push( ' nbHits += 1.0;' );
- kernel.push( ' }' );
-
- kernel.push( ' tmpUV = vTexCoord0 - offset;' );
- kernel.push( ' tmpDepth = getDepthValue(unpack(Texture1, tmpUV ));' );
- kernel.push( ' if ( abs(depth-tmpDepth) < radius) {' );
- kernel.push( ' pixel += unpack(Texture0, tmpUV);' );
- kernel.push( ' nbHits += 1.0;' );
- kernel.push( ' }' );
- }
- kernel.push( ' pixel /= nbHits;' );
- return kernel;
- },
- build: function () {
- //var nbSamples = this._nbSamples;
- var vtx = Composer.Filter.defaultVertexShader;
- var fgt = [
- Composer.Filter.defaultFragmentShaderHeader,
- 'uniform sampler2D Texture1;',
- 'uniform float width;',
- 'uniform mat4 projection;',
- 'uniform float radius;',
- 'uniform float pixelSize;',
-
- this._unpack || 'vec4 unpack(const in sampler2D tex, const in vec2 uv) { return texture2D(tex, uv); }',
- this._pack || 'vec4 pack(vec4 pix) { return pix; }',
-
- 'float znear,zfar,zrange;',
- '',
- Composer.Filter.shaderUtils,
- '',
- 'float getDepthValue(vec4 v) {',
- ' float depth = unpack4x8ToFloat(v);',
- ' depth = depth*zrange+znear;',
- ' return -depth;',
- '}',
-
- 'void main (void)',
- '{',
- ' vec4 pixel;',
- ' float depth, tmpDepth;',
- ' znear = projection[3][2] / (projection[2][2]-1.0);',
- ' zfar = projection[3][2] / (projection[2][2]+1.0);',
- ' zrange = zfar-znear;',
- ' float nbHits = 1.0;',
-
- this.getShaderBlurKernel().join( '\n' ),
- ' gl_FragColor = pack(pixel);',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vtx + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fgt + this.getDefineFragmentName() ) );
-
- if ( this._stateSet.getUniform( 'Texture0' ) === undefined ) {
- this._stateSet.addUniform( Uniform.createInt1( 0, 'Texture0' ) );
- }
- if ( this._stateSet.getUniform( 'Texture1' ) === undefined ) {
- this._stateSet.addUniform( Uniform.createInt1( 1, 'Texture1' ) );
- }
- this._stateSet.addUniform( this._radius );
- this._stateSet.addUniform( this._pixelSize );
- this._stateSet.setTextureAttributeAndModes( 1, this._depthTexture );
- this._stateSet.setAttributeAndModes( program );
- this._dirty = false;
- }
-} );
-
-Composer.Filter.BilateralVBlur = function ( options, unpack, pack ) {
- Composer.Filter.BilateralHBlur.call( this, options, unpack, pack );
- this._fragmentName = 'BilateralVBlur' + this._nbSamples;
-};
-
-Composer.Filter.BilateralVBlur.prototype = MACROUTILS.objectInherit( Composer.Filter.BilateralHBlur.prototype, {
- getUVOffset: function ( value ) {
- return 'vec2(float(' + value + ')*pixelSize/RenderSize[0],0.0);';
- }
-} );
-
-// InputTexture is a fake filter to setup the first texture
-// in the composer pipeline
-Composer.Filter.InputTexture = function ( texture ) {
- Composer.Filter.call( this );
- this._stateSet.setTextureAttributeAndModes( 0, texture );
- this._fragmentName = 'InputTexture';
-};
-Composer.Filter.InputTexture.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- build: function () {
- this._dirty = false;
- }
-} );
-
-// Operate a Gaussian horizontal blur
-Composer.Filter.HBlur = function ( nbSamplesOpt, linear, unpack, pack ) {
- Composer.Filter.call( this );
- this._linear = linear !== false;
- this.setBlurSize( nbSamplesOpt !== undefined ? nbSamplesOpt : 5 );
- this._unpack = unpack;
- this._pack = pack;
- this._fragmentName = 'HBlur' + this._nbSamples;
-};
-
-Composer.Filter.HBlur.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- setBlurSize: function ( nbSamples ) {
- if ( nbSamples % 2 !== 0 ) {
- nbSamples += 1;
- }
- this._nbSamples = nbSamples;
- this.dirty();
- },
- getUVOffset: function ( value ) {
- // TODO: could compute that in JS and remove 1 div per kernel step
- return 'vec2(float(' + value + ')/ RenderSize[0], 0.0) ;';
- },
- build: function () {
- var nbSamples = this._nbSamples;
-
- // TODO: get rendersize from that and precompute
- // offset when possible
- var tex = this._stateSet.getTextureAttribute( 0, 'Texture' );
- if ( tex && this._linear ) {
- tex.setMinFilter( 'LINEAR' );
- tex.setMagFilter( 'LINEAR' );
- } else {
- this._linear = false;
- }
-
- var vtx = Composer.Filter.defaultVertexShader;
-
-
- // http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
- // outermost are near 0, so unless float buffer...
- // at samples = 6 already it's 1/32 = 0.03
- // so we lessen texFetch (allow higher kernel size with less texfetch)
- var weightMin = 0.005 / nbSamples;
- var coeffIdx = nbSamples;
- var weights = Composer.Filter.Helper.getOrCreatePascalCoefficients( coeffIdx );
- var start = Math.floor( coeffIdx / 2.0 );
-
- var kernel = [];
- kernel.push( ' pixel = float(' + weights[ start ] + ')*unpack(Texture0, vTexCoord0 ).rgb;' );
-
- kernel.push( ' vec2 offset;' );
- var idx, i, weight, offset, offsetIdx;
- if ( !this._linear ) {
- idx = 1;
- for ( i = start + 1; i < nbSamples; i++ ) {
- weight = weights[ i ];
-
- if ( weight < weightMin ) break;
-
- offsetIdx = idx++;
- offset = this.getUVOffset( offsetIdx );
-
- kernel.push( ' offset = ' + offset );
- kernel.push( ' pixel += ' + weight + '* unpack(Texture0, (vTexCoord0.xy + offset.xy)).rgb;' );
- kernel.push( ' pixel += ' + weight + '* unpack(Texture0, (vTexCoord0.xy - offset.xy)).rgb;' );
- }
- } else {
-
- // using bilinear HW to divide texfetch by 2
- // http://www.rastergrid.com/blog/wp-content/uploads/2010/09/equation.png
- idx = 1;
- for ( i = start + 1; i < nbSamples; i += 2 ) {
- var weightT1 = weights[ i ];
- var weightT2 = weights[ i + 1 ];
-
- weight = weightT1 + weightT2;
-
- if ( weight < weightMin ) break;
-
- var offsetT1 = idx;
- var offsetT2 = idx + 1;
- idx += 2;
-
- offsetIdx = ( offsetT1 * weightT1 + offsetT2 * weightT2 ) / weight;
- offset = this.getUVOffset( offsetIdx );
-
- kernel.push( ' offset = ' + offset );
- kernel.push( ' pixel += ' + weight + '* unpack(Texture0, (vTexCoord0.xy + offset.xy)).rgb;' );
- kernel.push( ' pixel += ' + weight + '* unpack(Texture0, (vTexCoord0.xy - offset.xy)).rgb;' );
- }
- }
- var fgt = [
- Composer.Filter.defaultFragmentShaderHeader,
- 'uniform float width;',
-
- this._unpack || 'vec4 unpack(const in sampler2D tex, const in vec2 uv) { return texture2D(tex, uv); }',
- this._pack || 'vec4 pack(vec4 pix) { return pix; }',
-
- 'void main (void)',
- '{',
- ' vec3 pixel;',
- kernel.join( '\n' ),
- ' gl_FragColor = pack(vec4(pixel, 1.0));',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vtx + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fgt + this.getDefineFragmentName() ) );
-
- if ( this._stateSet.getUniform( 'Texture0' ) === undefined ) {
- this._stateSet.addUniform( Uniform.createInt1( 0, 'Texture0' ) );
- }
- this._stateSet.setAttributeAndModes( program );
- this._dirty = false;
- }
-} );
-
-// Operate a Gaussian vertical blur
-Composer.Filter.VBlur = function ( nbSamplesOpt, linear, unpack, pack ) {
- Composer.Filter.HBlur.call( this, nbSamplesOpt, linear, unpack, pack );
- this._fragmentName = 'VBlur' + this._nbSamples;
-};
-
-Composer.Filter.VBlur.prototype = MACROUTILS.objectInherit( Composer.Filter.HBlur.prototype, {
- getUVOffset: function ( value ) {
- return 'vec2(0.0, float(' + value + ')/RenderSize[1]) ;';
- }
-} );
-
-// Sobel filter
-// http://en.wikipedia.org/wiki/Sobel_operator
-Composer.Filter.SobelFilter = function () {
- Composer.Filter.call( this );
- this._color = Uniform.createFloat3( vec3.fromValues( 1.0, 1.0, 1.0 ), 'color' );
- this._factor = Uniform.createFloat( 1.0, 'factor' );
- this._fragmentName = 'SobelFilter';
-};
-
-Composer.Filter.SobelFilter.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- setColor: function ( color ) {
- this._color.setVec3( color );
- },
- setFactor: function ( f ) {
- this._factor.setFloat( f );
- },
- build: function () {
- var stateSet = this._stateSet;
- var vtx = Composer.Filter.defaultVertexShader;
- var fgt = [
- '',
- Composer.Filter.defaultFragmentShaderHeader,
- 'uniform vec3 color;',
- 'uniform float factor;',
- 'void main (void)',
- '{',
- ' float fac0 = 2.0;',
- ' float fac1 = 1.0;',
- ' float offsetx = 1.0/RenderSize[0];',
- ' float offsety = 1.0/RenderSize[1];',
- ' vec4 texel0 = texture2D(Texture0, vTexCoord0 + vec2(offsetx, offsety));',
- ' vec4 texel1 = texture2D(Texture0, vTexCoord0 + vec2(offsetx, 0.0));',
- ' vec4 texel2 = texture2D(Texture0, vTexCoord0 + vec2(offsetx, -offsety));',
- ' vec4 texel3 = texture2D(Texture0, vTexCoord0 + vec2(0.0, -offsety));',
- ' vec4 texel4 = texture2D(Texture0, vTexCoord0 + vec2(-offsetx, -offsety));',
- ' vec4 texel5 = texture2D(Texture0, vTexCoord0 + vec2(-offsetx, 0.0));',
- ' vec4 texel6 = texture2D(Texture0, vTexCoord0 + vec2(-offsetx, offsety));',
- ' vec4 texel7 = texture2D(Texture0, vTexCoord0 + vec2(0.0, offsety));',
- ' vec4 rowx = -fac0*texel5 + fac0*texel1 + -fac1*texel6 + fac1*texel0 + -fac1*texel4 + fac1*texel2;',
- ' vec4 rowy = -fac0*texel3 + fac0*texel7 + -fac1*texel4 + fac1*texel6 + -fac1*texel2 + fac1*texel0;',
- ' float mag = sqrt(dot(rowy,rowy)+dot(rowx,rowx));',
- ' if (mag < 1.0/255.0) discard;',
- ' mag *= factor;',
- ' mag = min(1.0, mag);',
- ' gl_FragColor = vec4(color*mag,mag);',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vtx + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fgt + this.getDefineFragmentName() ) );
-
- stateSet.setAttributeAndModes( program );
- stateSet.addUniform( this._color );
- stateSet.addUniform( this._factor );
- stateSet.addUniform( Uniform.createInt1( 0, 'Texture0' ) );
- this._dirty = false;
- }
-} );
-
-Composer.Filter.BlendMix = function () {
- Composer.Filter.call( this );
- var texture0, texture1, mixValue;
- var unit0 = 0;
- var unit1 = 1;
- var stateSet = this._stateSet;
- if ( arguments.length === 3 ) {
- texture0 = arguments[ 0 ];
- texture1 = arguments[ 1 ];
- mixValue = arguments[ 2 ];
- unit0 = 1;
- unit1 = 2;
- stateSet.setTextureAttributeAndModes( unit0, texture0 );
- } else if ( arguments.length === 2 ) {
- texture1 = arguments[ 0 ];
- mixValue = arguments[ 1 ];
- } else if ( arguments.length === 1 ) {
- texture1 = arguments[ 0 ];
- mixValue = 0.5;
- }
- stateSet.setTextureAttributeAndModes( unit1, texture1 );
- stateSet.addUniform( Uniform.createInt1( unit0, 'Texture0' ) );
- stateSet.addUniform( Uniform.createInt1( unit1, 'Texture1' ) );
- this._mixValueUniform = Uniform.createFloat1( mixValue, 'MixValue' );
- stateSet.addUniform( this._mixValueUniform );
- this._fragmentName = 'BlendMix';
-};
-
-Composer.Filter.BlendMix.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- getBlendFactorUniform: function () {
- return this._mixValueUniform;
- },
-
- build: function () {
- var stateSet = this._stateSet;
- var vtx = Composer.Filter.defaultVertexShader;
- var fgt = [
- '',
- Composer.Filter.defaultFragmentShaderHeader,
- 'uniform sampler2D Texture1;',
- 'uniform float MixValue;',
-
- 'void main (void)',
- '{',
- ' gl_FragColor = mix(texture2D(Texture0,vTexCoord0), texture2D(Texture1,vTexCoord0),MixValue);',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vtx + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fgt + this.getDefineFragmentName() ) );
-
- stateSet.setAttributeAndModes( program );
- this._dirty = false;
- }
-} );
-
-
-Composer.Filter.BlendMultiply = function () {
- Composer.Filter.call( this );
- var stateSet = this._stateSet;
- var texture0, texture1;
- var unit0 = 0;
- var unit1 = 1;
- if ( arguments.length === 2 ) {
- texture0 = arguments[ 0 ];
- texture1 = arguments[ 1 ];
- unit0 = 1;
- unit0 = 2;
- stateSet.setTextureAttributeAndModes( unit0, texture0 );
- } else if ( arguments.length === 1 ) {
- texture1 = arguments[ 0 ];
- }
- stateSet.setTextureAttributeAndModes( unit1, texture1 );
- stateSet.addUniform( Uniform.createInt1( unit0, 'Texture0' ) );
- stateSet.addUniform( Uniform.createInt1( unit1, 'Texture1' ) );
- this._fragmentName = 'BlendMultiply';
-};
-
-Composer.Filter.BlendMultiply.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
- build: function () {
- var vtx = Composer.Filter.defaultVertexShader;
- var fgt = [
- '',
- Composer.Filter.defaultFragmentShaderHeader,
- 'uniform sampler2D Texture1;',
- 'uniform float MixValue;',
-
- 'void main (void)',
- '{',
- ' gl_FragColor = texture2D(Texture0,vTexCoord0)*texture2D(Texture1,vTexCoord0);',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vtx + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fgt + this.getDefineFragmentName() ) );
-
- this._stateSet.setAttributeAndModes( program );
- this._dirty = false;
- }
-} );
-
-Composer.Filter.SSAO = function ( options ) {
- Composer.Filter.call( this );
-
- var stateSet = this._stateSet;
- var nbSamples = 16;
- var radius = 0.05;
- if ( options !== undefined ) {
- if ( options.nbSamples !== undefined )
- nbSamples = options.nbSamples;
-
- if ( options.radius !== undefined )
- radius = options.radius;
- var textureNormal = options.normal;
- var texturePosition = options.position;
- var w = textureNormal.getWidth();
- var h = textureNormal.getHeight();
- this._size = vec2.fromValues( w, h );
-
- stateSet.setTextureAttributeAndModes( 0, textureNormal );
- stateSet.setTextureAttributeAndModes( 1, texturePosition );
- }
-
- this._radius = radius;
- this._nbSamples = nbSamples;
- this._noiseTextureSize = 16;
- this._sceneRadius = 2.0;
-
- stateSet.addUniform( Uniform.createFloat1( 1.0, 'Power' ) );
- stateSet.addUniform( Uniform.createFloat1( radius, 'Radius' ) );
- stateSet.addUniform( Uniform.createInt1( 0, 'Texture0' ) );
- stateSet.addUniform( Uniform.createInt1( 1, 'Texture1' ) );
- stateSet.addUniform( Uniform.createInt1( 2, 'Texture2' ) );
- stateSet.addUniform( Uniform.createFloat1( 0.1, 'AngleLimit' ) );
-
- this.initNoise();
- this._fragmentName = 'SSAO';
-};
-
-Composer.Filter.SSAO.prototype = MACROUTILS.objectInherit( Composer.Filter.prototype, {
-
- initNoise: function () {
- var sizeNoise = this._noiseTextureSize;
- var noise = new Array( sizeNoise * sizeNoise * 3 );
- ( function ( array ) {
- var n = vec2.fromValues( 0.0, 0.0 );
- for ( var i = 0; i < sizeNoise * sizeNoise; i++ ) {
- n[ 0 ] = 2.0 * ( Math.random() - 0.5 );
- n[ 1 ] = 2.0 * ( Math.random() - 0.5 );
-
- vec2.normalize( n, n );
- array[ i * 3 + 0 ] = 255 * ( n[ 0 ] * 0.5 + 0.5 );
- array[ i * 3 + 1 ] = 255 * ( n[ 1 ] * 0.5 + 0.5 );
- array[ i * 3 + 2 ] = 255 * 0.5;
- }
- } )( noise );
-
- var noiseTexture = new Texture();
- noiseTexture.setWrapS( 'REPEAT' );
- noiseTexture.setWrapT( 'REPEAT' );
- noiseTexture.setMinFilter( 'NEAREST' );
- noiseTexture.setMagFilter( 'NEAREST' );
-
- noiseTexture.setTextureSize( sizeNoise, sizeNoise );
- noiseTexture.setImage( new Uint8Array( noise ), 'RGB' );
- this._noiseTexture = noiseTexture;
- },
- setSceneRadius: function ( value ) {
- this._sceneRadius = value;
- this.dirty();
- },
- setAngleLimit: function ( value ) {
- var uniform = this._stateSet.getUniform( 'AngleLimit' );
- uniform.setFloat( value );
- },
- setNbSamples: function ( value ) {
- if ( value === this._nbSamples ) {
- return;
- }
- this._nbSamples = Math.floor( value );
- this.dirty();
- },
- setRadius: function ( value ) {
- var uniform = this._stateSet.getUniform( 'Radius' );
- uniform.setFloat( value );
- },
- setPower: function ( value ) {
- var uniform = this._stateSet.getUniform( 'Power' );
- uniform.setFloat( value );
- },
- build: function () {
- var stateSet = this._stateSet;
- var nbSamples = this._nbSamples;
- var kernel = new Array( nbSamples * 4 );
- ( function ( array ) {
- var v = vec3.create();
- for ( var i = 0; i < nbSamples; i++ ) {
- v[ 0 ] = 2.0 * ( Math.random() - 0.5 );
- v[ 1 ] = 2.0 * ( Math.random() - 0.5 );
- v[ 2 ] = Math.random();
-
- vec3.normalize( v, v );
- var scale = Math.max( i / nbSamples, 0.1 );
- scale = 0.1 + ( 1.0 - 0.1 ) * ( scale * scale );
- array[ i * 3 + 0 ] = v[ 0 ];
- array[ i * 3 + 1 ] = v[ 1 ];
- array[ i * 3 + 2 ] = v[ 2 ];
- array[ i * 3 + 3 ] = scale;
- }
- } )( kernel );
-
-
- stateSet.setTextureAttributeAndModes( 2, this._noiseTexture );
- var uniform = stateSet.getUniform( 'noiseSampling' );
- if ( uniform === undefined ) {
- uniform = Uniform.createFloat2( vec2.fromValues( this._size[ 0 ] / this._noiseTextureSize, this._size[ 1 ] / this._noiseTextureSize ), 'noiseSampling' );
- stateSet.addUniform( uniform );
- } else {
- uniform.setVec2( vec2.fromValues( this._size[ 0 ] / this._noiseTextureSize, this._size[ 1 ] / this._noiseTextureSize ) );
- }
- var vertexShader = [
- '',
- 'attribute vec3 Vertex;',
- 'attribute vec2 TexCoord0;',
- 'varying vec2 vTexCoord0;',
- 'uniform mat4 uModelViewMatrix;',
- 'uniform mat4 uProjectionMatrix;',
- 'void main(void) {',
- ' gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0);',
- ' vTexCoord0 = TexCoord0;',
- '}',
- ''
- ].join( '\n' );
-
- var kernelglsl = [];
- for ( var i = 0; i < nbSamples; i++ ) {
- kernelglsl.push( 'kernel[' + i + '] = vec4(' + kernel[ i * 3 ] + ',' + kernel[ i * 3 + 1 ] + ', ' + kernel[ i * 3 + 2 ] + ', ' + kernel[ i * 3 + 3 ] + ');' );
- }
- kernelglsl = kernelglsl.join( '\n' );
-
- //var ssaoRadiusMin = this._sceneRadius * 0.002;
- //var ssaoRadiusMax = this._sceneRadius * 0.05;
- //var ssaoRadiusStep = ( ssaoRadiusMax - ssaoRadiusMin ) / 200.0;
-
- var fragmentShader = [
- '',
- Composer.Filter.defaultFragmentShaderHeader,
- 'uniform sampler2D Texture1;',
- 'uniform sampler2D Texture2;',
- 'uniform mat4 projection;',
- 'uniform vec2 noiseSampling;',
- 'uniform float Power;', //'+ '{ 'min': 0.1, 'max': 16.0, 'step': 0.1, 'value': 1.0 }',
- 'uniform float Radius;', //'+ '{ 'min': ' + ssaoRadiusMin +', 'max': ' + ssaoRadiusMax + ', 'step': '+ ssaoRadiusStep + ', 'value': 0.01 }',
- 'uniform float AngleLimit;',
- '#define NB_SAMPLES ' + this._nbSamples,
- 'float depth;',
- 'vec3 normal;',
- 'vec4 position;',
- 'vec4 kernel[' + nbSamples + '];',
-
-
- 'mat3 computeBasis()',
- '{',
- ' vec2 uvrand = vTexCoord0*noiseSampling;',
- ' vec3 rvec = texture2D(Texture2, uvrand*2.0).xyz*2.0-vec3(1.0);',
- ' vec3 tangent = normalize(rvec - normal * dot(rvec, normal));',
- ' vec3 bitangent = cross(normal, tangent);',
- ' mat3 tbn = mat3(tangent, bitangent, normal);',
- ' return tbn;',
- '}',
-
- 'void main (void)',
- '{',
- kernelglsl,
- ' position = texture2D(Texture1, vTexCoord0);',
- ' vec4 p = texture2D(Texture0, vTexCoord0);',
- ' depth = p.w;',
- ' normal = vec3(p);',
- ' if ( position.w == 0.0) {',
- ' gl_FragColor = vec4(1.0,1.0,1.0,0.0);',
- ' return;',
- ' }',
- '',
- ' mat3 tbn = computeBasis();',
- ' float occlusion = 0.0;',
- ' for (int i = 0; i < NB_SAMPLES; i++) {',
- ' vec3 vecKernel = vec3(kernel[i]);',
- ' vecKernel[2] = max(AngleLimit,vecKernel[2]);',
- ' vec3 sample = tbn * vecKernel;',
- ' vec3 dir = sample;',
- ' float w = dot(dir, normal);',
- ' float dist = 1.0-kernel[i].w;',
- ' w *= dist*dist*Power;',
- ' sample = dir * float(Radius) + position.xyz;',
-
- ' vec4 offset = projection * vec4(sample,1.0);',
- ' offset.xy /= offset.w;',
- ' offset.xy = offset.xy * 0.5 + 0.5;',
-
- ' float sample_depth = texture2D(Texture1, offset.xy).z;',
- ' float range_check = abs(sample.z - sample_depth) < float(Radius) ? 1.0 : 0.0;',
- ' occlusion += (sample_depth > sample.z ? 1.0 : 0.0) * range_check*w;',
-
- ' }',
- ' occlusion = 1.0 - (occlusion / float(NB_SAMPLES));',
- ' gl_FragColor = vec4(vec3(occlusion),1.0);',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vertexShader + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentShader + this.getDefineFragmentName() ) );
-
- stateSet.setAttributeAndModes( program );
- this._dirty = false;
- }
-} );
-
-Composer.Filter.SSAO8 = function ( options ) {
- Composer.Filter.SSAO.call( this, options );
- this._fragmentName = 'SSAO8';
-};
-
-Composer.Filter.SSAO8.prototype = MACROUTILS.objectInherit( Composer.Filter.SSAO.prototype, {
- buildGeometry: function ( quad ) {
- quad.getAttributes().TexCoord1 = this._texCoord1;
- return quad;
- },
- build: function () {
- var stateSet = this._stateSet;
- var nbSamples = this._nbSamples;
- var kernel = new Array( nbSamples * 4 );
- //var angleLimit = this._angleLimit;
- ( function ( array ) {
- var v = vec3.create();
- for ( var i = 0; i < nbSamples; i++ ) {
- v[ 0 ] = 2.0 * ( Math.random() - 0.5 );
- v[ 1 ] = 2.0 * ( Math.random() - 0.5 );
- v[ 2 ] = Math.random();
-
- vec3.normalize( v, v );
- var scale = Math.max( i / nbSamples, 0.1 );
- scale = 0.1 + ( 1.0 - 0.1 ) * ( scale * scale );
- array[ i * 3 + 0 ] = v[ 0 ];
- array[ i * 3 + 1 ] = v[ 1 ];
- array[ i * 3 + 2 ] = v[ 2 ];
- array[ i * 3 + 3 ] = scale;
- }
- } )( kernel );
-
- //var sizeNoise = this._noiseTextureSize;
- stateSet.setTextureAttributeAndModes( 2, this._noiseTexture );
- var uniform = stateSet.getUniform( 'noiseSampling' );
- if ( uniform === undefined ) {
- uniform = Uniform.createFloat2( vec2.fromValues( this._size[ 0 ] / this._noiseTextureSize, this._size[ 1 ] / this._noiseTextureSize ), 'noiseSampling' );
- stateSet.addUniform( uniform );
- } else {
- uniform.setVec2( vec2.fromValues( this._size[ 0 ] / this._noiseTextureSize, this._size[ 1 ] / this._noiseTextureSize ) );
- }
- var vertexShader = [
- '',
- 'attribute vec3 Vertex;',
- 'attribute vec2 TexCoord0;',
- 'attribute vec3 TexCoord1;',
- 'varying vec2 vTexCoord0;',
- 'varying vec3 vTexCoord1;',
- 'uniform mat4 uModelViewMatrix;',
- 'uniform mat4 uProjectionMatrix;',
- 'void main(void) {',
- ' gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0);',
- ' vTexCoord0 = TexCoord0;',
- ' vTexCoord1 = TexCoord1;',
- '}',
- ''
- ].join( '\n' );
-
- var kernelglsl = [];
- for ( var i = 0; i < nbSamples; i++ ) {
- kernelglsl.push( 'kernel[' + i + '] = vec4(' + kernel[ i * 3 ] + ',' + kernel[ i * 3 + 1 ] + ', ' + kernel[ i * 3 + 2 ] + ', ' + kernel[ i * 3 + 3 ] + ');' );
- }
- kernelglsl = kernelglsl.join( '\n' );
-
- //var ssaoRadiusMin = this._sceneRadius * 0.002;
- //var ssaoRadiusMax = this._sceneRadius * 0.05;
- //var ssaoRadiusStep = ( ssaoRadiusMax - ssaoRadiusMin ) / 200.0;
-
- var fragmentShader = [
- '',
- Composer.Filter.defaultFragmentShaderHeader,
- 'varying vec3 vTexCoord1;',
- 'uniform sampler2D Texture1;',
- 'uniform sampler2D Texture2;',
- 'uniform mat4 projection;',
- 'uniform vec2 noiseSampling;',
- 'uniform float Power;', //'+ '{ 'min': 0.1, 'max': 16.0, 'step': 0.1, 'value': 1.0 }',
- 'uniform float Radius;', //'+ '{ 'min': ' + ssaoRadiusMin +', 'max': ' + ssaoRadiusMax + ', 'step': '+ ssaoRadiusStep + ', 'value': 0.01 }',
- 'uniform float AngleLimit;',
- '#define NB_SAMPLES ' + this._nbSamples,
- 'float depth;',
- 'float znear, zfar, zrange;',
- 'vec3 normal;',
- 'vec3 position;',
- 'vec4 kernel[' + nbSamples + '];',
-
- Composer.Filter.shaderUtils,
-
- 'mat3 computeBasis()',
- '{',
- ' vec2 uvrand = vTexCoord0*noiseSampling;',
- ' //uvrand = rand(gl_FragCoord.xy);',
- ' vec3 rvec = texture2D(Texture2, uvrand*2.0).xyz*2.0-vec3(1.0);',
- ' //vec3 rvec = normalize(vec3(uvrand,0.0));',
- ' vec3 tangent = normalize(rvec - normal * dot(rvec, normal));',
- ' vec3 bitangent = cross(normal, tangent);',
- ' mat3 tbn = mat3(tangent, bitangent, normal);',
- ' return tbn;',
- '}',
-
- 'float getDepthValue(vec4 v) {',
- ' float depth = unpack4x8ToFloat(v);',
- ' depth = depth*zrange+znear;',
- ' //depth = depth*zrange;',
- ' return -depth;',
- '}',
-
- 'void main (void)',
- '{',
- kernelglsl,
- ' vec4 p = texture2D(Texture0, vTexCoord0);',
- ' if (dot(p,p) < 0.001) { ',
- ' gl_FragColor = vec4(1.0,1.0,1.0,0.0);',
- ' return;',
- ' }',
- ' znear = projection[3][2] / (projection[2][2]-1.0);',
- ' zfar = projection[3][2] / (projection[2][2]+1.0);',
- ' zrange = zfar-znear;',
- ' depth = getDepthValue(texture2D(Texture1, vTexCoord0));',
- //B = (A - znear)/(zfar-znear);',
- //B = A/(zfar-znear) - znear/(zfar-znear);',
- //B+ znear/(zfar-znear) = A/(zfar-znear) ;',
- //(zfar-znear)*(B+ znear/(zfar-znear)) = A ;',
- //(zfar-znear)*B+ znear = A ;',
-
- ' if ( -depth < znear) {',
- ' gl_FragColor = vec4(1.0,1.0,1.0,0.0);',
- ' return;',
- ' }',
-
- ' normal = decodeNormal(unpack4x8To2Float(p));',
-
- ' position = -vTexCoord1*depth;',
- ' position.z = -position.z;',
-
- '',
- ' mat3 tbn = computeBasis();',
- ' float occlusion = 0.0;',
- ' for (int i = 0; i < NB_SAMPLES; i++) {',
- ' vec3 vecKernel = vec3(kernel[i]);',
- ' vecKernel[2] = max(AngleLimit,vecKernel[2]);',
- ' vec3 sample = tbn * vec3(vecKernel);',
- ' vec3 dir = sample;',
- ' float w = dot(dir, normal);',
- ' float dist = 1.0-kernel[i].w;',
- ' w *= dist*dist*Power;',
- ' sample = dir * float(Radius) + position.xyz;',
-
- ' vec4 offset = projection * vec4(sample,1.0);',
- ' offset.xy /= offset.w;',
- ' offset.xy = offset.xy * 0.5 + 0.5;',
-
- ' float sample_depth = getDepthValue(texture2D(Texture1, offset.xy));',
- ' float range_check = abs(sample.z - sample_depth) < float(Radius) ? 1.0 : 0.0;',
- ' occlusion += (sample_depth > sample.z ? 1.0 : 0.0) * range_check*w;',
-
- ' }',
- ' occlusion = 1.0 - (occlusion / float(NB_SAMPLES));',
- ' gl_FragColor = vec4(vec3(occlusion),1.0);',
- '}',
- ''
- ].join( '\n' );
-
- var program = new Program(
- new Shader( Shader.VERTEX_SHADER, vertexShader + this.getDefineVertexName() ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentShader + this.getDefineFragmentName() ) );
-
- stateSet.setAttributeAndModes( program );
- this._dirty = false;
- }
-} );
-
-module.exports = Composer;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGeometryVisitor.js b/app/static/app/js/vendor/osgjs/osgUtil/DisplayGeometryVisitor.js
deleted file mode 100644
index 9a8c30db..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGeometryVisitor.js
+++ /dev/null
@@ -1,225 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Geometry = require( 'osg/Geometry' );
-var RigGeometry = require( 'osgAnimation/RigGeometry' );
-var Uniform = require( 'osg/Uniform' );
-var StateSet = require( 'osg/StateSet' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var ShaderGenerator = require( 'osgShader/ShaderGenerator' );
-var Compiler = require( 'osgShader/Compiler' );
-var BufferArray = require( 'osg/BufferArray' );
-var DrawArrays = require( 'osg/DrawArrays' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var Depth = require( 'osg/Depth' );
-
-
-////////////////////////
-// COMPILER DEBUG GEOMETRY
-////////////////////////
-var CompilerColorGeometry = function () {
- Compiler.apply( this, arguments );
-};
-
-CompilerColorGeometry.prototype = MACROUTILS.objectInherit( Compiler.prototype, {
- getFragmentShaderName: function () {
- return 'CompilerDebugGeometry';
- },
- initTextureAttributes: function () {},
- createFragmentShaderGraph: function () {
- var frag = this.getNode( 'glFragColor' );
-
- this.getNode( 'SetAlpha' ).inputs( {
- color: this.getOrCreateUniform( 'vec3', 'uColorDebug' ),
- alpha: this.createVariable( 'float' ).setValue( '1.0' )
- } ).outputs( {
- color: frag
- } );
-
- return [ frag ];
- }
-} );
-
-var ShaderGeneratorCompilerColorGeometry = function () {
- ShaderGenerator.apply( this, arguments );
- this.setShaderCompiler( CompilerColorGeometry );
-};
-ShaderGeneratorCompilerColorGeometry.prototype = ShaderGenerator.prototype;
-
-
-////////////////////////
-// COMPILER SKINNING DEBUG
-////////////////////////
-var CompilerColorSkinning = function () {
- Compiler.apply( this, arguments );
-};
-
-CompilerColorSkinning.prototype = MACROUTILS.objectInherit( Compiler.prototype, {
- getFragmentShaderName: function () {
- return 'CompilerDebugSkinning';
- },
- initTextureAttributes: function () {},
- createFragmentShaderGraph: function () {
- var frag = this.getNode( 'glFragColor' );
-
- this.getNode( 'SetAlpha' ).inputs( {
- color: this.getOrCreateVarying( 'vec3', 'vBonesColor' ),
- alpha: this.createVariable( 'float' ).setValue( '1.0' )
- } ).outputs( {
- color: frag
- } );
-
- return [ frag ];
- },
- declareVertexVaryings: function ( roots ) {
- var color = this.getOrCreateVarying( 'vec3', 'vBonesColor' );
- this.getNode( 'SetFromNode' ).inputs( this.getOrCreateAttribute( 'vec3', 'BonesColor' ) ).outputs( color );
- return Compiler.prototype.declareVertexVaryings.call( this, roots );
- }
-} );
-
-var ShaderGeneratorCompilerColorSkinning = function () {
- ShaderGenerator.apply( this, arguments );
- this.setShaderCompiler( CompilerColorSkinning );
-};
-ShaderGeneratorCompilerColorSkinning.prototype = ShaderGenerator.prototype;
-
-///////////////////////////
-// DISPLAY GEOMETRY VISITOR
-///////////////////////////
-
-var GeometryColorDebugVisitor = function () {
- NodeVisitor.call( this );
- this._debugColor = true;
- this._debugSkinning = false;
-
- this._stCenter = new StateSet(); // state set of center crosses
- this._stCenter.setShaderGeneratorName( 'debugGeometry' );
-};
-
-GeometryColorDebugVisitor.CompilerColorGeometry = CompilerColorGeometry;
-GeometryColorDebugVisitor.ShaderGeneratorCompilerColorGeometry = ShaderGeneratorCompilerColorGeometry;
-
-GeometryColorDebugVisitor.CompilerSkinningGeometry = CompilerColorSkinning;
-GeometryColorDebugVisitor.ShaderGeneratorCompilerColorSkinning = ShaderGeneratorCompilerColorSkinning;
-
-GeometryColorDebugVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- setGeometryDebug: function ( node ) {
- this._stCenter.setAttributeAndModes( new Depth( Depth.ALWAYS ) );
- this._debugColor = true;
- this._debugSkinning = false;
- this.apply( node );
- },
- setSkinningDebug: function ( node ) {
- this._stCenter.setAttributeAndModes( new Depth( Depth.NEVER ) );
- this._debugColor = false;
- this._debugSkinning = true;
- this.apply( node );
- },
- disableDebug: function ( node ) {
- this._stCenter.setAttributeAndModes( new Depth( Depth.NEVER ) );
- this._debugColor = false;
- this._debugSkinning = false;
- this.apply( node );
- },
- apply: function ( node ) {
- if ( node._isNormalDebug || node._isCenterDebug )
- return;
-
- if ( node instanceof Geometry ) {
-
- if ( this._debugColor || ( this._debugSkinning && node instanceof RigGeometry ) ) {
-
- if ( node._originalStateSet === undefined )
- node._originalStateSet = node.getStateSet() || null;
-
- var st = new StateSet();
- node.setStateSet( st );
-
- if ( this._debugSkinning ) {
- st.setShaderGeneratorName( 'debugSkinning' );
-
- // a bone can be shared between several rigs so we use the instanceID to get unique color
- var vList = node.getVertexAttributeList();
- if ( !vList.BonesColor ) {
- var eltBones = vList.Bones.getElements();
- var eltWeights = vList.Weights.getElements();
-
- var bones = node._rigTransformImplementation._bones;
- var nbBones = eltBones.length / 4;
-
- var bonesColor = new Float32Array( nbBones * 3 );
-
- for ( var i = 0; i < nbBones; ++i ) {
- var idb = i * 4;
- var c0 = bones[ eltBones[ idb ] ].getOrCreateDebugColor();
- var c1 = bones[ eltBones[ idb + 1 ] ].getOrCreateDebugColor();
- var c2 = bones[ eltBones[ idb + 2 ] ].getOrCreateDebugColor();
- var c3 = bones[ eltBones[ idb + 3 ] ].getOrCreateDebugColor();
-
- var w0 = eltWeights[ idb ];
- var w1 = eltWeights[ idb + 1 ];
- var w2 = eltWeights[ idb + 2 ];
- var w3 = eltWeights[ idb + 3 ];
-
- var idc = i * 3;
- bonesColor[ idc ] = w0 * c0[ 0 ] + w1 * c1[ 0 ] + w2 * c2[ 0 ] + w3 * c3[ 0 ];
- bonesColor[ idc + 1 ] = w0 * c0[ 1 ] + w1 * c1[ 1 ] + w2 * c2[ 1 ] + w3 * c3[ 1 ];
- bonesColor[ idc + 2 ] = w0 * c0[ 2 ] + w1 * c1[ 2 ] + w2 * c2[ 2 ] + w3 * c3[ 2 ];
- }
-
- vList.BonesColor = new BufferArray( BufferArray.ARRAY_BUFFER, bonesColor, 3 );
- }
-
- } else {
-
- var color = vec3.fromValues( Math.random(), Math.random(), Math.random() );
- st.addUniform( Uniform.createFloat3( color, 'uColorDebug' ) );
- st.setShaderGeneratorName( 'debugGeometry' );
-
- // draw crosses
- var bb = node.getBound();
-
- var verts = new Float32Array( 18 );
- var off = bb.radius() * 0.1;
- verts[ 0 ] = off;
- verts[ 3 ] = -off;
-
- verts[ 7 ] = off;
- verts[ 10 ] = -off;
-
- verts[ 14 ] = off;
- verts[ 17 ] = -off;
-
- var geo = new Geometry();
- geo.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, verts, 3 );
- var primitive = new DrawArrays( PrimitiveSet.LINES, 0, 6 );
- geo.getPrimitives().push( primitive );
-
- var mt = new MatrixTransform();
- var center = bb.center();
- mt.getMatrix()[ 12 ] = center[ 0 ];
- mt.getMatrix()[ 13 ] = center[ 1 ];
- mt.getMatrix()[ 14 ] = center[ 2 ];
-
- mt.addChild( geo );
- this.nodePath[ this.nodePath.length - 2 ].addChild( mt );
- color = vec3.fromValues( color[ 0 ] * 0.8, color[ 1 ] * 0.8, color[ 2 ] * 0.8 );
- geo.getOrCreateStateSet().addUniform( Uniform.createFloat3( color, 'uColorDebug' ) );
- mt.setStateSet( this._stCenter );
-
- mt._isCenterDebug = true;
- }
-
- } else if ( node._originalStateSet !== undefined ) {
- node.setStateSet( node._originalStateSet || undefined );
- }
-
- }
-
- this.traverse( node );
- }
-} );
-
-module.exports = GeometryColorDebugVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraph.js b/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraph.js
deleted file mode 100644
index 9d72a3f3..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraph.js
+++ /dev/null
@@ -1,293 +0,0 @@
-'use strict';
-
-var DisplayGraphRenderer = require( 'osgUtil/DisplayGraphRenderer' );
-var DisplayGraphNode = require( 'osgUtil/DisplayGraphNode' );
-var Notify = require( 'osg/notify' );
-
-var $;
-
-var init$ = function () {
- try {
- $ = require( 'jquery' );
- } catch ( e ) {
- Notify.warn( 'You will not be able to use osgUtil.DisplayGraph until you add jQuery in your page' );
- }
-};
-
-// Simple tooltips implementation
-var SimpleTooltips = function ( options ) {
-
- this.options = options;
- var css = document.createElement( 'style' );
- css.type = 'text/css';
- css.innerHTML = [
- '.osgDebugSimpleTooltip {',
- 'display: none;',
- 'position: absolute;',
- 'margin-left: 10px;',
- 'border-radius: 4px;',
- 'padding: 10px;',
- 'background: rgba(0,0,0,.9);',
- 'color: #ffffff;',
- '}',
- '.osgDebugSimpleTooltip:before {',
- 'content: ',
- ';',
- 'position: absolute;',
- 'left: -10px;',
- 'top: 8px;',
- 'border: 10px solid transparent;',
- 'border-width: 10px 10px 10px 0;',
- 'border-right-color: rgba(0,0,0,.9);',
- '}'
- ].join( '\n' );
- document.getElementsByTagName( 'head' )[ 0 ].appendChild( css );
-
- this.el = document.createElement( 'div' );
- this.el.className = 'osgDebugSimpleTooltip';
- document.body.appendChild( this.el );
- var nodes = document.querySelectorAll( this.options.selector );
- for ( var i = 0; i < nodes.length; i++ ) {
- nodes[ i ].addEventListener( 'mouseover', this.showTooltip.bind( this ), false );
- nodes[ i ].addEventListener( 'mouseout', this.hideTooltip.bind( this ), false );
- }
-};
-SimpleTooltips.prototype = {
- showTooltip: function ( e ) {
- if ( !$ ) return;
-
- var target = e.currentTarget;
- this.el.innerHTML = target.getAttribute( 'title' );
- this.el.style.display = 'block';
- this.el.style.left = $( target ).position().left + $( target ).get( 0 ).getBoundingClientRect().width + 'px';
- this.el.style.top = $( target ).position().top + 'px';
- },
- hideTooltip: function () {
- this.el.style.display = 'none';
- }
-};
-
-var DisplayGraph = function () {
-
- init$();
- if ( !$ ) return;
-
- // indexed with instanceID, references nodes, stateSet, sourceGeometry...
- // referenced with strings !
- this._selectables = new window.Map();
-
- this._graphNode = new DisplayGraphNode( this._selectables );
- this._graphRender = new DisplayGraphRenderer( this._selectables );
-
- this._displayNode = true;
- this._displayRenderer = false;
-
- // callback when selecting a node
- this._cbSelect = undefined;
-
- this._focusedElement = 'graph';
- this._idToDomElement = new window.Map();
-
- this._$svg = $( '' );
- $( 'body' ).append( this._$svg );
-
- this._css = '.node {text-align: center;cursor: pointer;}.node rect {stroke: #FFF;}.edgePath path {stroke: #FFF;fill: none;}table {text-align: right;}svg {position: absolute;left: 0px;top: 0px;}.osgDebugButton {position: absolute;left: 15px;top: 15px;z-index: 5;border: 0;background: #65a9d7;background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7));background: -webkit-linear-gradient(top, #3e779d, #65a9d7);background: -moz-linear-gradient(top, #3e779d, #65a9d7);background: -ms-linear-gradient(top, #3e779d, #65a9d7);background: -o-linear-gradient(top, #3e779d, #65a9d7);padding: 5px 10px;-webkit-border-radius: 7px;-moz-border-radius: 7px;border-radius: 7px;-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;box-shadow: rgba(0,0,0,1) 0 1px 0;text-shadow: rgba(0,0,0,.4) 0 1px 0;color: white;font-size: 15px;font-family: Helvetica, Arial, Sans-Serif;text-decoration: none;vertical-align: middle;}.osgDebugButton:hover {border-top-color: #28597a;background: #28597a;color: #ccc;}.osgDebugButton:active {border-top-color: #1b435e;background: #1b435e;}.osgDebugSimpleTooltip .osgDebugName {font-weight: bold;color: #60b1fc;margin: 0;}.osgDebugSimpleTooltip .osgDebugDescription {margin: 0;}';
-};
-
-DisplayGraph.instance = function () {
- if ( !DisplayGraph._instance )
- DisplayGraph._instance = new DisplayGraph();
- return DisplayGraph._instance;
-};
-
-DisplayGraph.prototype = {
- getColorFromClassName: DisplayGraphNode.prototype.getColorFromClassName,
-
- setCallbackSelect: function ( cb ) {
- this._cbSelect = cb;
- },
-
- reset: function () {
- if ( !$ ) return;
-
- this._selectables.clear();
- this._$svg.empty();
- this._focusedElement = 'scene';
- $( '.osgDebugButton' ).hide();
- },
-
- setDisplayGraphRenderer: function ( bool ) {
- this._displayRenderer = bool;
- },
-
- createRenderGraph: function ( renderStage ) {
- // called by renderer
- this._graphRender.createGraph( renderStage );
- this.displayGraph();
- },
-
- createGraph: function ( root ) {
- if ( !$ ) return;
- this.reset();
-
- this._displayNode = !!root;
- if ( root ) {
- this._graphNode.createGraph( root );
- }
-
- // check if asynchronous is necessary
- if ( !this._displayRenderer ) {
- this.displayGraph();
- } else {
- // circular dependency
- require( 'osgViewer/Renderer' ).debugGraph = true;
- }
- },
-
- // Create and display a dagre d3 graph
- displayGraph: function () {
- if ( !$ ) return;
- if ( window.d3 && window.dagreD3 ) {
- this._createGraphApply();
- return;
- }
-
- var d3url = '//cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.min.js';
- var dagreurl = '//cdn.jsdelivr.net/dagre-d3/0.2.9/dagre-d3.min.js';
-
- var cb = this._createGraphApply.bind( this );
- $.getScript( d3url ).done( function () {
- $.getScript( dagreurl ).done( cb );
- } );
- },
-
- _createGraphApply: function () {
- var diGraph = new window.dagreD3.Digraph();
- if ( this._displayNode ) this._graphNode.generateNodeAndLink( diGraph );
- if ( this._displayRenderer ) this._graphRender.generateNodeAndLink( diGraph );
-
-
- // Add the style of the graph
- this.injectStyleElement();
- $( '.osgDebugButton' ).show();
-
- // Create the renderer
- var renderer = this.renderer = new window.dagreD3.Renderer();
-
- // Set up an SVG group so that we can translate the final graph.
- var svg = window.d3.select( this._$svg.get( 0 ) );
- var svgGroup = svg.append( 'g' );
-
- // Set initial zoom to 75%
- var initialScale = 0.75;
- var oldZoom = renderer.zoom();
- renderer.zoom( function ( g, argSVG ) {
- var zoom = oldZoom( g, argSVG );
-
- zoom.scale( initialScale ).event( argSVG );
- return zoom;
- } );
-
- // Simple function to style the tooltip for the given node.
- var styleTooltip = function ( instanceID, description ) {
- // instanceID is used by onNodeSelect to retrieve the node
- return '
' + instanceID + '
' + description + '
';
- };
-
- var idToDom = this._idToDomElement;
- // Override drawNodes to set up the hover.
- var oldDrawNodes = renderer.drawNodes();
- renderer.drawNodes( function ( g, argSVG ) {
- var svgNodes = oldDrawNodes( g, argSVG );
-
- // Set the title on each of the nodes and use tipsy to display the tooltip on hover
- svgNodes.attr( 'title', function ( d ) {
- idToDom.set( d, this );
- return styleTooltip( d, g.node( d ).description || '' );
- } );
-
- return svgNodes;
- } );
-
- // Run the renderer. This is what draws the final graph.
- renderer.run( diGraph, svgGroup );
-
- this.tooltip = new SimpleTooltips( {
- selector: '.node'
- } );
-
- // Do a console log of the node (or stateset) and save it in window.*
- $( '.node' ).click( this.onNodeSelect.bind( this ) );
- this.focusOnGraph();
- },
-
- selectNode: function ( node ) {
- var id = node.getInstanceID();
- var dom = this._idToDomElement.get( id );
- if ( dom )
- $( dom ).click();
- },
-
- onNodeSelect: function ( e ) {
- var target = e.currentTarget;
- var identifier = $( target.getAttribute( 'title' ) )[ 0 ].innerHTML;
- var selectables = this._selectables;
-
- // color the node back
- if ( this.lastNode ) {
- this.lastNode.style.fill = this.lastColor;
- }
-
- // non selectables nodes
- var elt = selectables.get( identifier );
- if ( !elt )
- return;
-
- this.lastNode = target.childNodes[ 0 ];
- this.lastColor = this.lastNode.style.fill;
- target.childNodes[ 0 ].style.fill = '#f00';
-
- window.activeNode = elt;
- Notify.info( 'window.activeNode is set with the node below !' );
- Notify.log( window.activeNode );
- Notify.log( '\n' );
-
- if ( this._cbSelect )
- this._cbSelect( elt );
- },
-
- focusOnScene: function () {
- $( '.osgDebugButton' ).text( 'Access to the graph' );
- this._$svg.css( 'zIndex', '-2' );
- this._focusedElement = 'scene';
- },
-
- focusOnGraph: function () {
- $( '.osgDebugButton' ).text( 'Access to the scene' );
- this._$svg.css( 'zIndex', '2' );
- $( '.osgDebugSimpleTooltip' ).css( 'zIndex', '3' );
- this._focusedElement = 'graph';
- },
-
- // Apply all the style
- injectStyleElement: function () {
- if ( this._cssInjected )
- return;
- this._cssInjected = true;
-
- $( 'body' ).append( '' );
- $( '.osgDebugButton' ).click( function () {
- if ( this._focusedElement === 'scene' )
- this.focusOnGraph();
- else
- this.focusOnScene();
- }.bind( this ) );
-
- var css = document.createElement( 'style' );
- css.type = 'text/css';
- css.innerHTML = this._css;
- document.getElementsByTagName( 'head' )[ 0 ].appendChild( css );
- }
-};
-
-module.exports = DisplayGraph;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraphNode.js b/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraphNode.js
deleted file mode 100644
index 5ef59297..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraphNode.js
+++ /dev/null
@@ -1,201 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var MorphGeometry = require( 'osgAnimation/MorphGeometry' );
-
-var DisplayGraphNode = function ( selectables ) {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_ALL_CHILDREN );
-
- this._selectables = selectables;
- this._nodeList = [];
- this._linkList = [];
-
- // don't reference twice same node
- this._uniqueNodes = new window.Set();
- this._uniqueEdges = new window.Set();
-};
-
-DisplayGraphNode.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- getColorFromClassName: function ( name ) {
- switch ( name ) {
- case 'ShadowedScene':
- return '#3D3D3D';
- case 'Camera':
- return '#AB7BCF';
- case 'RenderBin':
- return '#59778B';
- case 'LightSource':
- return '#53967D';
- case 'RenderStage':
- return '#DDCC55';
- case 'RenderLeaf':
- case 'Geometry':
- return '#FFCC55';
- case 'RigGeometry':
- return '#DD8800';
- case 'MorphGeometry':
- return '#AA5500';
- case 'MatrixTransform':
- return '#CE697E';
- case 'StateSet':
- return '#0099FF';
- case 'StateGraph':
- case 'Skeleton':
- return '#96999E';
- case 'Bone':
- return '#A9DEAA';
- case 'Node':
- return '#FFFFFF';
- default:
- return '#FF00AA';
- }
- },
-
- createGraph: function ( root ) {
- this.reset();
- root.accept( this );
- },
-
- reset: function () {
- this._nodeList.length = 0;
- this._linkList.length = 0;
- this._uniqueNodes.clear();
- this._uniqueEdges.clear();
- },
-
- apply: function ( node ) {
- if ( node._isNormalDebug )
- return;
-
- if ( !this._uniqueNodes.has( node.getInstanceID() ) ) {
- this._uniqueNodes.add( node.getInstanceID() );
- this._nodeList.push( node );
- }
-
- if ( this.nodePath.length >= 2 ) {
- var parentID = this.nodePath[ this.nodePath.length - 2 ].getInstanceID();
- var childID = node.getInstanceID();
- var key = parentID + '+' + childID;
- if ( !this._uniqueEdges.has( key ) ) {
- this._linkList.push( {
- parentNode: parentID,
- childrenNode: childID
- } );
- this._uniqueEdges.add( key );
- }
- }
-
- this.traverse( node );
- },
-
- // Create an array to display the matrix
- createMatrixGrid: function ( node, matrixArray ) {
-
- var nodeMatrix = '';
-
- nodeMatrix += '
' + this.createMatrixGrid( node, node.getMatrix() );
- }
-
- this._selectables.set( node.getInstanceID().toString(), node );
- g.addNode( node.getInstanceID(), {
- label: this.getLabel( node ),
- description: description,
- style: 'fill: ' + this.getColorFromClassName( node.className() ) + ';stroke-width: 0px;'
- } );
- },
-
- generateStateSet: function ( g, node ) {
- var stateSet = node.getStateSet();
- var stateSetID = stateSet.getInstanceID();
-
- var label = this.getLabel( stateSet );
- label += '\nNbTexture : ' + stateSet.getNumTextureAttributeLists();
-
- if ( !g.hasNode( stateSetID ) ) {
-
- this._selectables.set( stateSetID.toString(), stateSet );
- g.addNode( stateSetID, {
- label: label,
- style: 'fill: ' + this.getColorFromClassName( stateSet.className() ) + ';stroke-width: 0px;'
- } );
- }
-
- g.addEdge( null, node.getInstanceID(), stateSetID, {
- style: 'stroke: ' + this.getColorFromClassName( stateSet.className() ) + ';'
- } );
- },
-
- generateSourceGeometry: function ( g, node ) {
- var sourceGeom = node.getSourceGeometry();
- var sourceGeomID = sourceGeom.getInstanceID();
-
- this._selectables.set( sourceGeomID.toString(), sourceGeom );
- g.addNode( sourceGeomID, {
- label: this.getLabel( sourceGeom ),
- style: 'fill: ' + this.getColorFromClassName( sourceGeom.className() ) + ';stroke-width: 0px;'
- } );
-
- g.addEdge( null, node.getInstanceID(), sourceGeomID, {
- style: 'stroke: ' + this.getColorFromClassName( sourceGeom.className() ) + ';'
- } );
- },
-
- // Subfunction of createGraph, will iterate to create all the node and link in dagre
- generateNodeAndLink: function ( g ) {
-
- for ( var i = 0, ni = this._nodeList.length; i < ni; i++ ) {
- var node = this._nodeList[ i ];
-
- // node
- this.generateNode( g, node );
-
- // adds statesets node
- if ( node.getStateSet() ) {
- this.generateStateSet( g, node );
- }
-
- // adds source geometry node
- if ( node.getSourceGeometry && node.getSourceGeometry() instanceof MorphGeometry ) {
- this.generateSourceGeometry( g, node );
- }
- }
-
- for ( var j = 0, nj = this._linkList.length; j < nj; j++ ) {
- g.addEdge( null, this._linkList[ j ].parentNode, this._linkList[ j ].childrenNode );
- }
- }
-} );
-
-module.exports = DisplayGraphNode;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraphRenderer.js b/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraphRenderer.js
deleted file mode 100644
index e8a3bd16..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/DisplayGraphRenderer.js
+++ /dev/null
@@ -1,233 +0,0 @@
-'use strict';
-var DisplayGraphNode = require( 'osgUtil/DisplayGraphNode' );
-var RenderBin = require( 'osg/RenderBin' );
-
-var DisplayGraphRenderer = function ( selectables ) {
-
- this._selectables = selectables;
- this._nodeList = [];
- this._linkList = [];
-
- this._renderBinMap = new window.Map();
- this._renderBinStack = [];
-
- this._generatorID = 0;
- this._refID = 0; // invalide old _instanceID if we recreate the graph
-
- this._uniqueEdges = new window.Set();
-};
-
-DisplayGraphRenderer.prototype = {
- getColorFromClassName: DisplayGraphNode.prototype.getColorFromClassName,
-
- createGraph: function ( renderBin ) {
- this.reset();
- this.apply( renderBin );
- },
-
- reset: function () {
- this._renderBinMap.clear();
- this._renderBinStack.length = 0;
- this._generatorID = 0;
- this._refID++;
-
- this._nodeList.length = 0;
- this._linkList.length = 0;
-
- this._uniqueEdges.clear();
- },
-
- apply: function ( rb ) {
-
- var instanceID = rb.getInstanceID();
- if ( !this._renderBinMap.has( instanceID ) ) {
- this._renderBinMap.set( instanceID, rb );
- }
-
- this._renderBinStack.push( rb );
-
- // pre render stage if render stage node
- if ( rb.getPreRenderStageList ) {
- var preRenderList = rb.getPreRenderStageList();
- for ( var i = 0, ni = preRenderList.length; i < ni; ++i ) {
- this.apply( preRenderList[ i ].renderStage );
- }
- }
-
- // draw implementation
- // handle rs camera
- this.registerNode( rb );
-
- // post render stage if render stage node
- if ( rb.getPostRenderStageList ) {
- var postRenderList = rb.getPostRenderStageList();
- for ( var j = 0, nj = postRenderList.length; j < nj; ++j ) {
- this.apply( postRenderList[ j ].renderStage );
- }
- }
-
- this._renderBinStack.pop();
- },
-
- registerNode: function ( rb ) {
-
- var childID = rb.getInstanceID();
-
- this._nodeList.push( rb );
-
- // register bins
- var bins = rb._bins;
- var binKeys = window.Object.keys( bins );
- for ( var i = 0, ni = binKeys.length; i < ni; i++ ) {
- var bin = bins[ binKeys[ i ] ];
- this.apply( bin );
- }
-
- // register fine grained leafs
- if ( rb._leafs.length ) {
- for ( var j = 0, nj = rb._leafs.length; j < nj; j++ ) {
- this.createNodeAndSetID( childID, rb._leafs[ j ] );
- }
- }
-
- // register coarse grained leafs
- for ( var k = 0, nk = rb.stateGraphList.length; k < nk; k++ ) {
- var sg = rb.stateGraphList[ k ];
- this.createNodeAndSetID( childID, sg );
- var stateGraphID = sg._instanceID;
- for ( var l = 0, nl = sg.leafs.length; l < nl; l++ )
- this.createNodeAndSetID( stateGraphID, sg.leafs[ l ] );
- }
-
-
- // no parent no link
- if ( this._renderBinStack.length < 2 )
- return;
-
- var parentID = this._renderBinStack[ this._renderBinStack.length - 2 ].getInstanceID();
- this.createLink( parentID, childID );
- },
-
- createLink: function ( parent, child ) {
- var key = parent + '+' + child;
- if ( !this._uniqueEdges.has( key ) ) {
- this._linkList.push( {
- parentNode: parent,
- childrenNode: child
- } );
- this._uniqueEdges.add( key );
- }
- },
-
- createNodeAndSetID: function ( parentID, node ) {
-
- // register render leaf
- this._nodeList.push( node );
-
- // generate fake id < 0 because RenderLeaf does not inherit from Object
- if ( node._instanceID === undefined || ( node._instanceID < 0 && node._refID !== this._refID ) ) {
- node._instanceID = -1 - this._generatorID++;
- node._refID = this._refID;
- }
-
- this.createLink( parentID, node._instanceID );
- },
-
- generateRenderLeaf: function ( g, node ) {
-
- var instanceID = node._instanceID;
- var className = 'RenderLeaf';
- var geomName = node._geometry && node._geometry.getName() ? '\n' + node._geometry.getName() : 'Geometry';
-
- var label = className + ' ( ' + node._instanceID + ' )';
- label += '\n' + geomName + ' ( ' + node._geometry.getInstanceID() + ' )';
-
- this._selectables.set( instanceID.toString(), node );
- g.addNode( instanceID, {
- label: label,
- description: '',
- style: 'fill: ' + this.getColorFromClassName( className ) + ';stroke-width: 0px;'
- } );
- },
-
- generateStateGraph: function ( g, node ) {
-
- var instanceID = node._instanceID;
- var className = 'StateGraph';
- var label = className + ' ( ' + node._instanceID + ' )';
- label += '\n' + node.leafs.length + ' leafs';
-
- this._selectables.set( instanceID.toString(), node );
- g.addNode( instanceID, {
- label: label,
- description: '',
- style: 'fill: ' + this.getColorFromClassName( className ) + ';stroke-width: 0px;'
- } );
- },
-
- generateRenderStage: function ( g, node ) {
-
- var label = node.className() + ' ( ' + node._instanceID + ' )';
- if ( node.getName() ) label += '\n' + node.getName();
- label += '\nViewport ( ' + node.getViewport().width() + ' x ' + node.getViewport().height() + ' )';
-
- this._selectables.set( node.getInstanceID().toString(), node );
- g.addNode( node.getInstanceID(), {
- label: label,
- description: '',
- style: 'fill: ' + this.getColorFromClassName( node.className() ) + ';stroke-width: 0px;'
- } );
-
- },
-
- generateRenderBin: function ( g, rb ) {
-
- var label = rb.className() + ' ( ' + rb.getInstanceID() + ' )';
- if ( rb.getName() ) label += '\n' + rb.getName();
-
- var sortMode = '';
- if ( rb.getSortMode() === RenderBin.SORT_BACK_TO_FRONT )
- sortMode = 'SortMode: BackToFront';
-
- var description = 'BinNumber: ' + rb.getBinNumber() + '\n' + sortMode;
-
- this._selectables.set( rb.getInstanceID().toString(), rb );
- g.addNode( rb.getInstanceID(), {
- label: label,
- description: description,
- style: 'fill: ' + this.getColorFromClassName( rb.className() ) + ';stroke-width: 0px;'
- } );
-
- },
-
- // Subfunction of createGraph, will iterate to create all the node and link in dagre
- generateNodeAndLink: function ( g ) {
- for ( var i = 0, ni = this._nodeList.length; i < ni; i++ ) {
-
- var node = this._nodeList[ i ];
-
- // detect if RenderLeaf
- if ( node._geometry && node._depth !== undefined ) {
- this.generateRenderLeaf( g, node );
-
- } else if ( node.depth !== undefined && node.leafs && node.children ) {
- // it's StateGraph
- this.generateStateGraph( g, node );
-
- } else if ( node.className() === 'RenderStage' ) {
- this.generateRenderStage( g, node );
-
- } else {
- // it's a RenderBin
- this.generateRenderBin( g, node );
- }
-
- }
-
- for ( var j = 0, nj = this._linkList.length; j < nj; j++ ) {
- g.addEdge( null, this._linkList[ j ].parentNode, this._linkList[ j ].childrenNode );
- }
- }
-};
-
-module.exports = DisplayGraphRenderer;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/DisplayNormalVisitor.js b/app/static/app/js/vendor/osgjs/osgUtil/DisplayNormalVisitor.js
deleted file mode 100644
index a8c1bd54..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/DisplayNormalVisitor.js
+++ /dev/null
@@ -1,282 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var Geometry = require( 'osg/Geometry' );
-var BufferArray = require( 'osg/BufferArray' );
-var DrawArrays = require( 'osg/DrawArrays' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var StateSet = require( 'osg/StateSet' );
-var Uniform = require( 'osg/Uniform' );
-var Depth = require( 'osg/Depth' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var ShaderGenerator = require( 'osgShader/ShaderGenerator' );
-var Compiler = require( 'osgShader/Compiler' );
-var RigGeometry = require( 'osgAnimation/RigGeometry' );
-var MorphGeometry = require( 'osgAnimation/MorphGeometry' );
-var UpdateMorph = require( 'osgAnimation/UpdateMorph' );
-
-
-////////////////////////
-// COMPILER OFFSET NORMAL
-////////////////////////
-var CompilerOffsetNormal = function () {
- Compiler.apply( this, arguments );
-};
-
-CompilerOffsetNormal.prototype = MACROUTILS.objectInherit( Compiler.prototype, {
- getFragmentShaderName: function () {
- return 'CompilerOffsetNormal';
- },
- initTextureAttributes: function () {},
- createFragmentShaderGraph: function () {
- var frag = this.getNode( 'glFragColor' );
-
- this.getNode( 'SetAlpha' ).inputs( {
- color: this.getOrCreateUniform( 'vec3', 'uColorDebug' ),
- alpha: this.createVariable( 'float' ).setValue( '1.0' )
- } ).outputs( {
- color: frag
- } );
-
- return [ frag ];
- },
- getOffsetDirection: function () {
- return this.getOrCreateModelNormal();
- },
- getOrCreateModelVertex: function () {
- var vertexOffset = this.getVariable( 'vertexOffset' );
- if ( vertexOffset ) return vertexOffset;
-
- vertexOffset = this.createVariable( 'vec3', 'vertexOffset' );
-
- var str = '%out = %offset == 1.0 ? %vertex + normalize(%direction.xyz) * %scale: %vertex;';
- this.getNode( 'InlineCode' ).code( str ).inputs( {
- offset: this.getOrCreateAttribute( 'float', 'Offset' ),
- direction: this.getOffsetDirection(),
- vertex: Compiler.prototype.getOrCreateModelVertex.call( this ),
- scale: this.getOrCreateUniform( 'float', 'uScale' )
- } ).outputs( {
- out: vertexOffset
- } );
-
- return vertexOffset;
- },
- getOrCreateViewVertex: function () {
- var out = this._variables.FragEyeVector;
- if ( out && !out.isEmpty() ) return out;
- out = this._varyings.FragEyeVector || this.createVariable( 'vec4', 'FragEyeVector' );
-
- this.getNode( 'MatrixMultPosition' ).inputs( {
- matrix: this.getOrCreateUniform( 'mat4', 'uViewMatrix' ),
- vec: this.getOrCreateModelVertex()
- } ).outputs( {
- vec: out
- } );
-
- return out;
- }
-} );
-
-var ShaderGeneratorCompilerOffsetNormal = function () {
- ShaderGenerator.apply( this, arguments );
- this.setShaderCompiler( CompilerOffsetNormal );
-};
-ShaderGeneratorCompilerOffsetNormal.prototype = ShaderGenerator.prototype;
-
-////////////////////////
-// COMPILER OFFSET TANGENT
-////////////////////////
-var CompilerOffsetTangent = function () {
- CompilerOffsetNormal.apply( this, arguments );
-};
-
-CompilerOffsetTangent.prototype = MACROUTILS.objectInherit( CompilerOffsetNormal.prototype, {
- getFragmentShaderName: function () {
- return 'CompilerOffsetTangent';
- },
- getOffsetDirection: function () {
- return this.getOrCreateModelTangent();
- }
-} );
-
-var ShaderGeneratorCompilerOffsetTangent = function () {
- ShaderGenerator.apply( this, arguments );
- this.setShaderCompiler( CompilerOffsetTangent );
-};
-ShaderGeneratorCompilerOffsetTangent.prototype = ShaderGenerator.prototype;
-
-////////////////////////
-// DISPLAY NORMAL VISITOR
-////////////////////////
-
-var DisplayNormalVisitor = function () {
- NodeVisitor.call( this );
-
- this._unifScale = Uniform.createFloat( 1.0, 'uScale' );
-
- var ns = this._normalStateSet = new StateSet();
- ns.addUniform( Uniform.createFloat3( vec3.fromValues( 1.0, 0.0, 0.0 ), 'uColorDebug' ) );
- ns.addUniform( this._unifScale );
- ns.setAttributeAndModes( new Depth( Depth.NEVER ) );
- ns.setShaderGeneratorName( 'debugNormal' );
-
- var ts = this._tangentStateSet = new StateSet();
- ts.addUniform( Uniform.createFloat3( vec3.fromValues( 0.0, 1.0, 0.0 ), 'uColorDebug' ) );
- ts.addUniform( this._unifScale );
- ts.setAttributeAndModes( new Depth( Depth.NEVER ) );
- ts.setShaderGeneratorName( 'debugTangent' );
-};
-
-DisplayNormalVisitor.CompilerOffsetNormal = CompilerOffsetNormal;
-DisplayNormalVisitor.CompilerOffsetTangent = CompilerOffsetTangent;
-DisplayNormalVisitor.ShaderGeneratorCompilerOffsetNormal = ShaderGeneratorCompilerOffsetNormal;
-DisplayNormalVisitor.ShaderGeneratorCompilerOffsetTangent = ShaderGeneratorCompilerOffsetTangent;
-
-DisplayNormalVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- setScale: function ( scale ) {
- this._unifScale.setFloat( scale );
- },
- setTangentVisibility: function ( bool ) {
- this._tangentStateSet.setAttributeAndModes( new Depth( bool ? Depth.LESS : Depth.NEVER ) );
- },
- setNormalVisibility: function ( bool ) {
- this._normalStateSet.setAttributeAndModes( new Depth( bool ? Depth.LESS : Depth.NEVER ) );
- },
- apply: function ( node ) {
- var list = node.getUpdateCallbackList();
- // dirty the UpdateMorph so that they detect the normal/tangent geometry and update the target/weights correctly
- for ( var i = 0, nbCB = list.length; i < nbCB; ++i ) {
- if ( list[ i ] instanceof UpdateMorph ) {
- list[ i ]._isInitialized = false;
- }
- }
-
- if ( node._isVisitedNormalDebug )
- return;
-
- node._isVisitedNormalDebug = true;
-
- if ( node instanceof Geometry === false )
- return this.traverse( node );
-
- this._createDebugGeom( node, 'Normal', this._normalStateSet );
- this._createDebugGeom( node, 'Tangent', this._tangentStateSet );
- },
- _createDoubleOffsetArray: function ( nbVertices ) {
- // 0 means original vertex pos
- // 1 means offseted vertex
- var elts = new Float32Array( nbVertices * 2 );
- for ( var i = 0; i < nbVertices; ++i ) {
- elts[ i * 2 ] = 1.0;
- }
- return new BufferArray( BufferArray.ARRAY_BUFFER, elts, 1 );
- },
- _createDoubledBufferArray: function ( bufferArray ) {
- // in case of morphs
- if ( bufferArray.getInitialBufferArray )
- bufferArray = bufferArray.getInitialBufferArray();
-
- var itemSize = bufferArray.getItemSize();
- var elements = bufferArray.getElements();
- var nbElements = elements.length / itemSize;
-
- var ctor = elements.constructor;
- var elementsDouble = new ctor( elements.length * 2 );
- for ( var i = 0; i < nbElements; ++i ) {
- var iSize = i * itemSize;
- var iSize2 = iSize * 2;
-
- for ( var j = 0; j < itemSize; ++j ) {
- elementsDouble[ iSize2 + j ] = elementsDouble[ iSize2 + j + itemSize ] = elements[ iSize + j ];
- }
- }
-
- return new BufferArray( BufferArray.ARRAY_BUFFER, elementsDouble, itemSize );
- },
- _addMorphTargets: function ( originMorph, morph, vecName ) {
- var targets = morph.getMorphTargets();
- morph.setName( originMorph.getName() ); // for the UpdateMorph
-
- var originTargets = originMorph.getMorphTargets();
- for ( var i = 0, nbTarget = originTargets.length; i < nbTarget; ++i ) {
- var origTarget = originTargets[ i ];
- var origAttrs = origTarget.getVertexAttributeList();
-
- var newTarget = new Geometry();
- newTarget.setName( origTarget.getName() ); // for the UpdateMorph
- var newAttrs = newTarget.getVertexAttributeList();
-
- newAttrs.Vertex = this._createDoubledBufferArray( origAttrs.Vertex );
- if ( origAttrs[ vecName ] ) newAttrs[ vecName ] = this._createDoubledBufferArray( origAttrs[ vecName ] );
-
- targets.push( newTarget );
- }
-
- morph.mergeChildrenVertexAttributeList();
- return morph;
- },
- _createDebugGeom: function ( node, vecName, stateSet ) {
- var attrs = node.getAttributes();
- var dispVec = attrs[ vecName ];
- if ( !dispVec )
- return;
-
- var vertices = attrs.Vertex;
- if ( !vertices )
- return;
-
- var originMorph;
- if ( node instanceof MorphGeometry ) originMorph = node;
- else if ( node.getSourceGeometry && node.getSourceGeometry() instanceof MorphGeometry ) originMorph = node.getSourceGeometry();
-
- var nbVertices = vertices.getElements().length / vertices.getItemSize();
-
- // vertex and normals
- var source = originMorph ? new MorphGeometry() : new Geometry();
- source.getAttributes().Vertex = this._createDoubledBufferArray( vertices );
- source.getAttributes().Offset = this._createDoubleOffsetArray( nbVertices );
- source.getAttributes()[ vecName ] = this._createDoubledBufferArray( dispVec );
-
- // primitive
- source.getPrimitives().push( new DrawArrays( PrimitiveSet.LINES, 0, nbVertices * 2 ) );
-
- if ( originMorph )
- this._addMorphTargets( originMorph, source, vecName );
-
- var geom;
- if ( node instanceof RigGeometry ) {
-
- var rig = new RigGeometry();
- rig.setSourceGeometry( source );
-
- rig.getVertexAttributeList().Bones = this._createDoubledBufferArray( attrs.Bones );
- rig.getVertexAttributeList().Weights = this._createDoubledBufferArray( attrs.Weights );
-
- // we can simply share the rig-animated stateSet attributes
- // (unlike morph, the stateSet and update animation doesn't operate at per vertex level)
- rig._rigTransformImplementation = node._rigTransformImplementation;
- rig._stateSetAnimation = node._stateSetAnimation;
-
- rig.mergeChildrenData();
- geom = rig;
-
- } else {
- geom = source;
- }
-
-
- // add geom to the graph
- var parents = node.getParents();
- var nbParents = parents.length;
- geom._isVisitedNormalDebug = true;
- geom._isNormalDebug = true;
- geom.setStateSet( stateSet );
- for ( var i = 0; i < nbParents; ++i )
- parents[ i ].addChild( geom );
-
- return geom;
- }
-} );
-
-
-module.exports = DisplayNormalVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/IntersectionVisitor.js b/app/static/app/js/vendor/osgjs/osgUtil/IntersectionVisitor.js
deleted file mode 100644
index 5887864a..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/IntersectionVisitor.js
+++ /dev/null
@@ -1,198 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var MatrixMemoryPool = require( 'osg/MatrixMemoryPool' );
-var TransformEnums = require( 'osg/transformEnums' );
-
-
-var IntersectionVisitor = function () {
- NodeVisitor.call( this );
- // We could need to use a stack of intersectors in case we want
- // to use several intersectors. Right now we use only one.
- this._intersector = undefined;
- this._projectionStack = [ mat4.IDENTITY ];
- this._modelStack = [ mat4.IDENTITY ];
- this._viewStack = [ mat4.IDENTITY ];
- this._windowStack = [ mat4.IDENTITY ];
-
- this.reset();
-};
-
-IntersectionVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- reset: function () {
- IntersectionVisitor._reservedMatrixStack.reset();
- },
- setIntersector: function ( intersector ) {
- this._intersector = intersector;
- },
- getIntersector: function () {
- return this._intersector;
- },
- // Model matrix
- pushModelMatrix: function ( matrix ) {
- this._modelStack.push( matrix );
- },
- getModelMatrix: function () {
- return ( this._modelStack.length ) ? this._modelStack[ this._modelStack.length - 1 ] : undefined;
-
- },
- popModelMatrix: function () {
- return this._modelStack.pop();
- },
- // View Matrix
- pushViewMatrix: function ( matrix ) {
- this._viewStack.push( matrix );
-
- },
- getViewMatrix: function () {
- return ( this._viewStack.length ) ? this._viewStack[ this._viewStack.length - 1 ] : undefined;
-
- },
- popViewMatrix: function () {
- return this._viewStack.pop();
- },
- // Projection Matrix
- pushProjectionMatrix: function ( matrix ) {
- this._projectionStack.push( matrix );
- },
- getProjectionMatrix: function () {
- return ( this._projectionStack.length ) ? this._projectionStack[ this._projectionStack.length - 1 ] : undefined;
-
- },
- popProjectionMatrix: function () {
- return this._projectionStack.pop();
- },
- // Window Matrix
- pushWindowMatrix: function ( matrix ) {
- this._windowStack.push( matrix );
- },
- pushWindowMatrixUsingViewport: function ( viewport ) {
- this._windowStack.push( viewport.computeWindowMatrix( IntersectionVisitor._reservedMatrixStack.get() ) );
- },
- getWindowMatrix: function () {
- return ( this._windowStack.length ) ? this._windowStack[ this._windowStack.length - 1 ] : undefined;
- },
- popWindowMatrix: function () {
- return this._windowStack.pop();
- },
- getTransformation: ( function () {
- // We should move this to the intersector when we need to use different coordinate frames
- // Now we only support WINDOW coordinate frame
-
- // /!\ 64 bit precision because the picking is jittery otherwise
- // It's probably caused by one of the camera matrix that has too big/small values
- // but currently it's the ony fix we have
- var mat = mat4.create64();
-
- return function () {
- mat4.copy( mat, this.getWindowMatrix() || mat4.IDENTITY );
- mat4.mul( mat, mat, this.getProjectionMatrix() || mat4.IDENTITY );
- mat4.mul( mat, mat, this.getViewMatrix() || mat4.IDENTITY );
- mat4.mul( mat, mat, this.getModelMatrix() || mat4.IDENTITY );
-
- return mat;
- };
- } )(),
-
- enter: function ( node ) {
- // Call to each intersector
- return this._intersector.enter( node );
- },
-
- apply: function ( node ) {
- // Here we need to decide which apply method to use
- if ( node.getViewMatrix ) {
- // It's a Camera
- this.applyCamera( node );
- } else {
- if ( node.getMatrix ) {
- // It's a Transform Node
- this.applyTransform( node );
- } else {
- // It's a leaf or an intermediate node
- this.applyNode( node );
- }
- }
- },
-
- applyCamera: function ( camera ) {
- // We use an absolute reference frame for simplicity
- var vp = camera.getViewport();
- if ( vp !== undefined ) {
- this.pushWindowMatrixUsingViewport( vp );
- }
-
- var projection, view, model;
- if ( camera.getReferenceFrame() === TransformEnums.RELATIVE_RF && this.getViewMatrix() && this.getProjectionMatrix() ) {
- // relative
- projection = mat4.mul( IntersectionVisitor._reservedMatrixStack.get(), this.getProjectionMatrix(), camera.getProjectionMatrix() );
- view = this.getViewMatrix();
- model = mat4.mul( IntersectionVisitor._reservedMatrixStack.get(), this.getModelMatrix(), camera.getViewMatrix() );
- } else {
- // absolute
- projection = camera.getProjectionMatrix();
- view = camera.getViewMatrix();
- model = mat4.identity( IntersectionVisitor._reservedMatrixStack.get() );
- }
-
- this.pushProjectionMatrix( projection );
- this.pushViewMatrix( view );
- this.pushModelMatrix( model );
-
- // TODO maybe we should do something like OSG for the transformation given
- // to the intersector (having a stack)
- this._intersector.setCurrentTransformation( this.getTransformation() );
- this.traverse( camera );
-
- this.popModelMatrix();
- this.popViewMatrix();
- this.popProjectionMatrix();
- if ( vp !== undefined ) {
- this.popWindowMatrix();
- }
- this._intersector.setCurrentTransformation( this.getTransformation() );
- },
-
- applyNode: function ( node ) {
- if ( !this.enter( node ) ) return;
- if ( node.primitives ) {
- this._intersector.intersect( this, node );
- // If it is a leaf (it has primitives) we can safely return
- return;
- }
- if ( node.traverse ) {
- this.traverse( node );
- }
- },
-
- applyTransform: function ( node ) {
- // Now only use PROJECTION coordinate frame
- if ( !this.enter( node ) ) return;
- // Accumulate Transform
- if ( node.getReferenceFrame() === TransformEnums.ABSOLUTE_RF ) {
- var matrix = IntersectionVisitor._reservedMatrixStack.get();
- this.pushViewMatrix( mat4.identity( matrix ) );
- this.pushModelMatrix( node.getMatrix() );
- } else if ( this._modelStack.length > 0 ) {
- var m = mat4.copy( IntersectionVisitor._reservedMatrixStack.get(), this.getModelMatrix() );
- mat4.mul( m, m, node.getMatrix() );
- this.pushModelMatrix( m );
- } else {
- this.pushModelMatrix( node.getMatrix() );
- }
-
- // TODO see above
- this._intersector.setCurrentTransformation( this.getTransformation() );
- this.traverse( node );
-
- this.popModelMatrix();
- if ( node.getReferenceFrame() === TransformEnums.ABSOLUTE_RF )
- this.popViewMatrix();
- this._intersector.setCurrentTransformation( this.getTransformation() );
- }
-} );
-
-IntersectionVisitor._reservedMatrixStack = new MatrixMemoryPool();
-
-module.exports = IntersectionVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/LineSegmentIntersector.js b/app/static/app/js/vendor/osgjs/osgUtil/LineSegmentIntersector.js
deleted file mode 100644
index d262ec12..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/LineSegmentIntersector.js
+++ /dev/null
@@ -1,126 +0,0 @@
-'use strict';
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var TriangleIntersector = require( 'osgUtil/TriangleIntersector' );
-
-
-var LineSegmentIntersector = function () {
- this._start = vec3.create();
- this._end = vec3.create();
- this._iStart = vec3.create();
- this._iEnd = vec3.create();
- this._intersections = [];
-};
-
-LineSegmentIntersector.prototype = {
- set: function ( start, end ) {
- vec3.copy( this._start, start );
- vec3.copy( this._iStart, start );
- vec3.copy( this._end, end );
- vec3.copy( this._iEnd, end );
- },
- setStart: function ( start ) {
- vec3.copy( this._start, start );
- vec3.copy( this._iStart, start );
- },
- setEnd: function ( end ) {
- vec3.copy( this._end, end );
- vec3.copy( this._iEnd, end );
- },
- reset: function () {
- // Clear the intersections vector
- this._intersections.length = 0;
- },
- enter: function ( node ) {
- // Not working if culling disabled ??
- return !node.isCullingActive() || this.intersects( node.getBound() );
- },
- // Intersection Segment/Sphere
- intersects: ( function () {
- var sm = vec3.create();
- var se = vec3.create();
- return function ( bsphere ) {
- // test for _start inside the bounding sphere
- if ( !bsphere.valid() ) return false;
- vec3.sub( sm, this._iStart, bsphere.center() );
- var c = vec3.sqrLen( sm ) - bsphere.radius2();
- if ( c <= 0.0 ) {
- return true;
- }
- // solve quadratic equation
- vec3.sub( se, this._iEnd, this._iStart );
- var a = vec3.sqrLen( se );
- var b = vec3.dot( sm, se ) * 2.0;
- var d = b * b - 4.0 * a * c;
- // no intersections if d<0
- if ( d < 0.0 ) {
- return false;
- }
- // compute two solutions of quadratic equation
- d = Math.sqrt( d );
- var div = 0.5 / a;
- var r1 = ( -b - d ) * div;
- var r2 = ( -b + d ) * div;
-
- // return false if both intersections are before the ray start
- if ( r1 <= 0.0 && r2 <= 0.0 ) {
- return false;
- }
-
- if ( r1 > 1.0 && r2 > 1.0 ) {
- return false;
- }
- return true;
- };
- } )(),
-
- intersect: ( function () {
-
- var ti = new TriangleIntersector();
-
- return function ( iv, node ) {
-
- var kdtree = node.getShape();
- if ( kdtree )
- return kdtree.intersectRay( this._iStart, this._iEnd, this._intersections, iv.nodePath );
-
- ti.reset();
- ti.setNodePath( iv.nodePath );
- ti.set( this._iStart, this._iEnd );
-
- // handle rig transformed vertices
- if ( node.computeTransformedVertices ) {
- var vList = node.getVertexAttributeList();
- var originVerts = vList.Vertex.getElements();
-
- // temporarily hook vertex buffer for the tri intersections
- // don't call setElements as it dirty some stuffs because of gl buffer
- vList.Vertex._elements = node.computeTransformedVertices();
- ti.apply( node );
- vList.Vertex._elements = originVerts;
- } else {
- ti.apply( node );
- }
-
- var trianglesIntersections = ti._intersections;
- var intersections = this._intersections;
- var l = trianglesIntersections.length;
- for ( var i = 0; i < l; i++ ) {
- intersections.push( trianglesIntersections[ i ] );
- }
-
- return l > 0;
- };
- } )(),
-
- getIntersections: function () {
- return this._intersections;
- },
- setCurrentTransformation: function ( matrix ) {
- mat4.invert( matrix, matrix );
- vec3.transformMat4( this._iStart, this._start, matrix );
- vec3.transformMat4( this._iEnd, this._end, matrix );
- }
-};
-
-module.exports = LineSegmentIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/NodeGizmo.js b/app/static/app/js/vendor/osgjs/osgUtil/NodeGizmo.js
deleted file mode 100644
index c1a43f1c..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/NodeGizmo.js
+++ /dev/null
@@ -1,1027 +0,0 @@
-'use strict';
-var Node = require( 'osg/Node' );
-var MatrixTransform = require( 'osg/MatrixTransform' );
-var Notify = require( 'osg/notify' );
-var Depth = require( 'osg/Depth' );
-var BlendFunc = require( 'osg/BlendFunc' );
-var CullFace = require( 'osg/CullFace' );
-var Uniform = require( 'osg/Uniform' );
-var vec2 = require( 'osg/glMatrix' ).vec2;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var quat = require( 'osg/glMatrix' ).quat;
-var IntersectionVisitor = require( 'osgUtil/IntersectionVisitor' );
-var LineSegmentIntersector = require( 'osgUtil/LineSegmentIntersector' );
-var GizmoGeometry = require( 'osgUtil/gizmoGeometry' );
-var TransformEnums = require( 'osg/transformEnums' );
-var MACROUTILS = require( 'osg/Utils' );
-
-
-var getCanvasCoord = function ( vec, e ) {
- vec[ 0 ] = e.offsetX === undefined ? e.layerX : e.offsetX;
- vec[ 1 ] = e.offsetY === undefined ? e.layerY : e.offsetY;
-};
-
-var HideCullCallback = function () {};
-HideCullCallback.prototype = {
- cull: function () {
- return false;
- }
-};
-
-var blendAttribute = new BlendFunc( BlendFunc.SRC_ALPHA, BlendFunc.ONE_MINUS_SRC_ALPHA );
-
-var LineCustomIntersector = function ( testPlane ) {
- this._testPlane = testPlane; // intersection plane or line
- this._inter = vec3.create(); // translate distance
- LineSegmentIntersector.call( this );
-};
-LineCustomIntersector.prototype = MACROUTILS.objectInherit( LineSegmentIntersector.prototype, {
- setTestPlane: function ( testPlane ) {
- this._testPlane = testPlane; // intersection plane or line
- },
- getTranslateDistance: function () {
- return this._inter;
- },
- enter: ( function () {
- var axis = vec3.create();
- var dir = vec3.create();
-
- return function ( node ) {
- if ( node._nbAxis === undefined )
- return true;
-
- vec3.init( axis );
- axis[ node._nbAxis ] = 1.0;
- if ( !this._testPlane ) {
- // intersection line line
- vec3.normalize( dir, vec3.sub( dir, this._iEnd, this._iStart ) );
-
- var a01 = -vec3.dot( dir, axis );
- var b0 = vec3.dot( this._iStart, dir );
- var det = Math.abs( 1.0 - a01 * a01 );
-
- var b1 = -vec3.dot( this._iStart, axis );
- vec3.init( this._inter );
- this._inter[ node._nbAxis ] = ( a01 * b0 - b1 ) / det;
- } else {
- // intersection line plane
- var dist1 = vec3.dot( this._iStart, axis );
- var dist2 = vec3.dot( this._iEnd, axis );
- // ray copplanar to triangle
- if ( dist1 === dist2 )
- return false;
- // intersection between ray and triangle
- var val = -dist1 / ( dist2 - dist1 );
- this._inter[ 0 ] = this._iStart[ 0 ] + ( this._iEnd[ 0 ] - this._iStart[ 0 ] ) * val;
- this._inter[ 1 ] = this._iStart[ 1 ] + ( this._iEnd[ 1 ] - this._iStart[ 1 ] ) * val;
- this._inter[ 2 ] = this._iStart[ 2 ] + ( this._iEnd[ 2 ] - this._iStart[ 2 ] ) * val;
- }
- return false;
- };
- } )(),
- intersect: function () {
- return false;
- }
-} );
-
-// The MT node can be detected as such because they
-// have a '_nbAxis' property on them (x=0, y=1, z=2)
-//
-// MatrixTransform _________________________________________
-// | | |
-// ____ Rotate Translate TranslatePlane
-// | / | \ / | \ / | \
-// MT MT MT MT MT MT MT MT MT MT
-// | \ | / \ | / \ | /
-// FullArc \|/ \|/ \|/
-// ____|_____ ___|________ ___|________
-// | | | | | |
-// DrawArc HideNode DrawArrow HideNode DrawPlane HideNode
-// | | |
-// PickArc PickArrow PickPlane
-//
-var NodeGizmo = function ( viewer ) {
- MatrixTransform.call( this );
-
- this._tmask = 1; // traversal mask when picking the scene
-
- // We can set this boolean to true if we want to insert a MatrixTransform just
- // before the picked geometry.
- // Otherwise, we simply select the first MatrixTransform with an 'editMask' property
- this._autoInsertMT = false;
-
- this._viewer = viewer;
- this._canvas = viewer.getGraphicContext().canvas;
- this._manipulator = viewer.getManipulator();
-
- this._rotateNode = new MatrixTransform();
- this._translateNode = new MatrixTransform();
- this._planeNode = new MatrixTransform();
-
- this._rotateInLocal = true; // local vs world space
- this._translateInLocal = true; // local vs world space
- this._showAngle = new MatrixTransform();
-
- //for realtime picking
- this._downCanvasCoord = vec2.create();
- this._hoverNode = null; // the hovered x/y/z MT node
- this._keepHoverColor = vec4.create();
-
- // for editing
- this._isEditing = false;
-
- this._editLineOrigin = vec3.create();
- this._editLineDirection = vec3.create();
- this._editOffset = vec3.create();
-
- // cached matrices when starting the editing operations
- this._editLocal = mat4.create();
- this._editWorldTrans = mat4.create();
- this._editWorldScaleRot = mat4.create();
- this._editInvWorldScaleRot = mat4.create();
-
- // red line, it can be useful as helpers too
- this._debugNode = new Node();
-
- this._lastDistToEye = 0.0; // see updateGizmo comment
-
- this._attachedNode = null;
- this.attachToGeometry( null );
-
- // Intersectors
- this._lsi = new LineCustomIntersector();
- this._origIntersect = vec3.create();
- this._dstIntersect = vec3.create();
- this._iv = new IntersectionVisitor();
- this._iv.setIntersector( this._lsi );
-
- this.init();
-};
-
-// picking masks
-NodeGizmo.NO_PICK = 1 << 0;
-
-NodeGizmo.PICK_ARC_X = 1 << 1;
-NodeGizmo.PICK_ARC_Y = 1 << 2;
-NodeGizmo.PICK_ARC_Z = 1 << 3;
-
-NodeGizmo.PICK_ARROW_X = 1 << 4;
-NodeGizmo.PICK_ARROW_Y = 1 << 5;
-NodeGizmo.PICK_ARROW_Z = 1 << 6;
-
-NodeGizmo.PICK_PLANE_X = 1 << 7;
-NodeGizmo.PICK_PLANE_Y = 1 << 8;
-NodeGizmo.PICK_PLANE_Z = 1 << 9;
-
-NodeGizmo.NO_FULL_CIRCLE = 1 << 10; // don't display the full non pickable circle (visual cue)
-
-NodeGizmo.PICK_ARC = NodeGizmo.PICK_ARC_X | NodeGizmo.PICK_ARC_Y | NodeGizmo.PICK_ARC_Z;
-NodeGizmo.PICK_ARROW = NodeGizmo.PICK_ARROW_X | NodeGizmo.PICK_ARROW_Y | NodeGizmo.PICK_ARROW_Z;
-NodeGizmo.PICK_PLANE = NodeGizmo.PICK_PLANE_X | NodeGizmo.PICK_PLANE_Y | NodeGizmo.PICK_PLANE_Z;
-
-NodeGizmo.PICK_GIZMO = NodeGizmo.PICK_ARC | NodeGizmo.PICK_ARROW | NodeGizmo.PICK_PLANE;
-
-NodeGizmo.prototype = MACROUTILS.objectInherit( MatrixTransform.prototype, {
-
- setRotateInLocal: function ( bool ) {
- this._rotateInLocal = bool;
- },
-
- setTranslateInLocal: function ( bool ) {
- this._translateInLocal = bool;
- },
-
- setTraversalMask: function ( tmask ) {
- this._tmask = tmask;
- },
-
- init: function () {
- this.getOrCreateStateSet().setAttributeAndModes( new Depth( Depth.DISABLE ) );
- this.getOrCreateStateSet().setAttributeAndModes( new CullFace( CullFace.DISABLE ) );
-
- var UpdateCallback = function () {};
- UpdateCallback.prototype = {
- update: this.updateGizmo.bind( this )
- };
- this.addUpdateCallback( new UpdateCallback() );
- this.addChild( this.initNodeTranslate() );
- this.addChild( this.initNodeTranslatePlane() );
- this.addChild( this.initNodeRotate() );
- if ( this._debugNode ) {
- this._debugNode.addChild( GizmoGeometry.createDebugLineGeometry() );
- this.addChild( this._debugNode );
- this._debugNode.setNodeMask( 0x0 );
- }
-
- var canvas = this._canvas;
- canvas.addEventListener( 'mousemove', this.onMouseMove.bind( this ) );
- canvas.addEventListener( 'mousedown', this.onMouseDown.bind( this ) );
- canvas.addEventListener( 'mouseup', this.onMouseUp.bind( this ) );
- canvas.addEventListener( 'mouseout', this.onMouseUp.bind( this ) );
- },
-
- attachToNodePath: function ( nodepath ) {
- var node;
- if ( nodepath ) {
- for ( var i = nodepath.length - 1; i >= 0; --i ) {
- var editMask = nodepath[ i ].editMask || 0;
- if ( editMask & NodeGizmo.PICK_GIZMO ) {
- node = nodepath[ i ];
- break;
- }
- }
- }
- if ( !node ) {
- this._attachedNode = null;
- this.setNodeMask( 0x0 );
- return;
- }
-
- this._attachedNode = node;
- this.updateGizmoMask();
- },
-
- attachToMatrixTransform: function ( node ) {
- if ( !node ) {
- this._attachedNode = null;
- this.setNodeMask( 0x0 );
- return;
- }
- if ( node.editMask === undefined )
- node.editMask = NodeGizmo.PICK_GIZMO;
-
- this._attachedNode = node;
- this.updateGizmoMask();
- },
-
- attachToGeometry: function ( argNode ) {
-
- var node = argNode;
-
- if ( !node ) {
- this._attachedNode = null;
- this.setNodeMask( 0x0 );
- return;
- }
-
- // insert MatrixTransform node before geometry node
- var pr = node.getParents();
- if ( pr[ 0 ].editMask === undefined ) {
- var imt = new MatrixTransform();
- while ( pr.length > 0 ) {
- pr[ 0 ].addChild( imt );
- pr[ 0 ].removeChild( node );
- }
- imt.addChild( node );
- imt.editMask = NodeGizmo.PICK_GIZMO;
- node = imt;
- } else {
- node = pr[ 0 ];
- }
-
- this._attachedNode = node;
- this.updateGizmoMask();
- },
-
- updateGizmoMask: function () {
- if ( !this._attachedNode ) {
- this.setNodeMask( 0x0 );
- return;
- }
-
- var mask = this._attachedNode.editMask;
-
- this.setNodeMask( mask & NodeGizmo.PICK_GIZMO ? NodeGizmo.NO_PICK : 0x0 );
-
- this._translateNode.setNodeMask( mask & NodeGizmo.PICK_ARROW ? NodeGizmo.PICK_ARROW : 0x0 );
- this._rotateNode.setNodeMask( mask & NodeGizmo.PICK_ARC ? NodeGizmo.PICK_ARC : 0x0 );
- this._planeNode.setNodeMask( mask & NodeGizmo.PICK_PLANE ? NodeGizmo.PICK_PLANE : 0x0 );
-
- var transChildren = this._translateNode.getChildren();
- transChildren[ 0 ].setNodeMask( mask & NodeGizmo.PICK_ARROW_X ? NodeGizmo.PICK_ARROW_X : 0x0 );
- transChildren[ 1 ].setNodeMask( mask & NodeGizmo.PICK_ARROW_Y ? NodeGizmo.PICK_ARROW_Y : 0x0 );
- transChildren[ 2 ].setNodeMask( mask & NodeGizmo.PICK_ARROW_Z ? NodeGizmo.PICK_ARROW_Z : 0x0 );
-
- // children 0 is full arc
- var rotChildren = this._rotateNode.getChildren();
- rotChildren[ 0 ].setNodeMask( mask & NodeGizmo.NO_FULL_CIRCLE ? 0x0 : NodeGizmo.NO_PICK );
- rotChildren[ 1 ].setNodeMask( mask & NodeGizmo.PICK_ARC_X ? NodeGizmo.PICK_ARC_X : 0x0 );
- rotChildren[ 2 ].setNodeMask( mask & NodeGizmo.PICK_ARC_Y ? NodeGizmo.PICK_ARC_Y : 0x0 );
- rotChildren[ 3 ].setNodeMask( mask & NodeGizmo.PICK_ARC_Z ? NodeGizmo.PICK_ARC_Z : 0x0 );
-
- var planeChildren = this._planeNode.getChildren();
- planeChildren[ 0 ].setNodeMask( mask & NodeGizmo.PICK_PLANE_X ? NodeGizmo.PICK_PLANE_X : 0x0 );
- planeChildren[ 1 ].setNodeMask( mask & NodeGizmo.PICK_PLANE_Y ? NodeGizmo.PICK_PLANE_Y : 0x0 );
- planeChildren[ 2 ].setNodeMask( mask & NodeGizmo.PICK_PLANE_Z ? NodeGizmo.PICK_PLANE_Z : 0x0 );
- },
-
- onNodeHovered: ( function () {
- var hoverColor = vec4.fromValues( 1.0, 1.0, 0.0, 1.0 );
-
- return function ( hit ) {
-
- if ( this._hoverNode )
- this._hoverNode.getStateSet().getUniform( 'uColor' ).setFloat4( this._keepHoverColor );
- if ( !hit ) {
- this._hoverNode = null;
- return;
- }
-
- // stop at the first X/Y/Z matrix node
- var np = hit.nodepath;
- var i = np.length - 1;
- var node = np[ i ];
- while ( node._nbAxis === undefined ) {
- if ( i === 0 )
- return;
- node = np[ --i ];
- }
-
- var unif = node.getStateSet().getUniform( 'uColor' );
- this._hoverNode = node;
- vec4.copy( this._keepHoverColor, unif.getInternalArray() );
- unif.setFloat4( hoverColor );
- };
- } )(),
-
- initNodeRotate: function () {
- var drawArcXYZ = GizmoGeometry.createTorusGeometry( 1.0, 0.01, 6, 64, Math.PI * 2 );
- var drawArc = GizmoGeometry.createTorusGeometry( 1.0, 0.01, 6, 64, Math.PI );
- var pickArc = GizmoGeometry.createTorusGeometry( 1.0, 0.1, 6, 64, Math.PI );
-
- var mtXYZ = new MatrixTransform();
- var mtX = new MatrixTransform();
- var mtY = new MatrixTransform();
- var mtZ = new MatrixTransform();
- mtX._nbAxis = 0;
- mtY._nbAxis = 1;
- mtZ._nbAxis = 2;
-
- var hideNode = new Node();
- hideNode.setCullCallback( new HideCullCallback() );
- hideNode.addChild( pickArc );
-
- // set masks
- drawArcXYZ.setNodeMask( NodeGizmo.NO_PICK );
- drawArc.setNodeMask( NodeGizmo.NO_PICK );
- mtX.setNodeMask( NodeGizmo.PICK_ARC_X );
- mtY.setNodeMask( NodeGizmo.PICK_ARC_Y );
- mtZ.setNodeMask( NodeGizmo.PICK_ARC_Z );
-
- mtXYZ.addChild( drawArcXYZ );
- mtX.addChild( drawArc );
- mtY.addChild( drawArc );
- mtZ.addChild( drawArc );
-
- mtX.addChild( hideNode );
- mtY.addChild( hideNode );
- mtZ.addChild( hideNode );
-
- mtXYZ.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 0.2, 0.2, 0.2, 1.0 ), 'uColor' ) );
- mtX.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 1.0, 0.0, 0.0, 1.0 ), 'uColor' ) );
- mtY.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 0.0, 1.0, 0.0, 1.0 ), 'uColor' ) );
- mtZ.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 0.0, 0.0, 1.0, 1.0 ), 'uColor' ) );
-
- var showAngle = this._showAngle;
- showAngle.getOrCreateStateSet().setAttributeAndModes( blendAttribute );
- showAngle.setNodeMask( 0x0 );
- showAngle.getOrCreateStateSet().addUniform( Uniform.createFloat3( vec3.fromValues( 1.0, 0.0, 0.0 ), 'uBase' ) );
- showAngle.getOrCreateStateSet().addUniform( Uniform.createFloat( 0.0, 'uAngle' ) );
- showAngle.addChild( GizmoGeometry.createQuadCircleGeometry() );
-
- var rotate = this._rotateNode;
- rotate.setNodeMask( NodeGizmo.PICK_ARC );
- rotate.addChild( mtXYZ );
- rotate.addChild( mtX );
- rotate.addChild( mtY );
- rotate.addChild( mtZ );
- rotate.addChild( showAngle );
- return rotate;
- },
-
- initNodeTranslate: function () {
- var aHeight = 1.5;
- var aConeHeight = 0.3;
- var pickStart = 0.5; // offset (because of the picking plane)
- var pickHeight = ( aHeight - pickStart + aConeHeight ) * 1.1;
-
- // cone arrow
- var mtCone = new MatrixTransform();
- mat4.fromTranslation( mtCone.getMatrix(), vec3.fromValues( 0.0, 0.0, aHeight + aConeHeight * 0.5 ) );
- mtCone.addChild( GizmoGeometry.createCylinderGeometry( 0.0, 0.07, aConeHeight, 32, 1, true, true ) );
- // arrow base
- var mtArrow = new MatrixTransform();
- mat4.fromTranslation( mtArrow.getMatrix(), vec3.fromValues( 0.0, 0.0, aHeight * 0.5 ) );
- mtArrow.addChild( GizmoGeometry.createCylinderGeometry( 0.01, 0.01, aHeight, 32, 1, true, true ) );
- // draw arrow
- var drawArrow = new Node();
- drawArrow.addChild( mtArrow );
- drawArrow.addChild( mtCone );
-
- var pickArrow = GizmoGeometry.createCylinderGeometry( 0.1, 0.1, pickHeight, 32, 1, true, true );
-
- var mtX = new MatrixTransform();
- var mtY = new MatrixTransform();
- var mtZ = new MatrixTransform();
- mtX._nbAxis = 0;
- mtY._nbAxis = 1;
- mtZ._nbAxis = 2;
-
- mat4.fromRotation( mtX.getMatrix(), Math.PI * 0.5, vec3.fromValues( 0.0, 1.0, 0.0 ) );
- mat4.fromRotation( mtY.getMatrix(), -Math.PI * 0.5, vec3.fromValues( 1.0, 0.0, 0.0 ) );
-
- var hideNode = new MatrixTransform();
- hideNode.setCullCallback( new HideCullCallback() );
- mat4.fromTranslation( hideNode.getMatrix(), vec3.fromValues( 0.0, 0.0, pickStart + pickHeight * 0.5 ) );
- hideNode.addChild( pickArrow );
-
- // set masks
- drawArrow.setNodeMask( NodeGizmo.NO_PICK );
- mtX.setNodeMask( NodeGizmo.PICK_ARROW_X );
- mtY.setNodeMask( NodeGizmo.PICK_ARROW_Y );
- mtZ.setNodeMask( NodeGizmo.PICK_ARROW_Z );
-
- mtX.addChild( drawArrow );
- mtY.addChild( drawArrow );
- mtZ.addChild( drawArrow );
-
- mtX.addChild( hideNode );
- mtY.addChild( hideNode );
- mtZ.addChild( hideNode );
-
- mtX.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 1.0, 0.0, 0.0, 1.0 ), 'uColor' ) );
- mtY.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 0.0, 1.0, 0.0, 1.0 ), 'uColor' ) );
- mtZ.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 0.0, 0.0, 1.0, 1.0 ), 'uColor' ) );
-
- var translate = this._translateNode;
- translate.setNodeMask( NodeGizmo.PICK_ARROW );
- translate.addChild( mtX );
- translate.addChild( mtY );
- translate.addChild( mtZ );
- return translate;
- },
-
- initNodeTranslatePlane: function () {
- var mtPlane = new MatrixTransform();
- mat4.fromTranslation( mtPlane.getMatrix(), vec3.fromValues( 0.5, 0.5, 0.0 ) );
- mat4.mul( mtPlane.getMatrix(), mat4.fromScaling( mat4.create(), vec3.fromValues( 0.5, 0.5, 1.0 ) ), mtPlane.getMatrix() );
- mtPlane.addChild( GizmoGeometry.createPlaneGeometry() );
-
- var mtX = new MatrixTransform();
- var mtY = new MatrixTransform();
- var mtZ = new MatrixTransform();
- mtX._nbAxis = 0;
- mtY._nbAxis = 1;
- mtZ._nbAxis = 2;
-
- mat4.fromRotation( mtX.getMatrix(), -Math.PI * 0.5, vec3.fromValues( 0.0, 1.0, 0.0 ) );
- mat4.fromRotation( mtY.getMatrix(), Math.PI * 0.5, vec3.fromValues( 1.0, 0.0, 0.0 ) );
-
- // set masks
- mtX.setNodeMask( NodeGizmo.PICK_PLANE_X );
- mtY.setNodeMask( NodeGizmo.PICK_PLANE_Y );
- mtZ.setNodeMask( NodeGizmo.PICK_PLANE_Z );
-
- mtX.addChild( mtPlane );
- mtY.addChild( mtPlane );
- mtZ.addChild( mtPlane );
-
- mtX.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 1.0, 0.0, 0.0, 0.3 ), 'uColor' ) );
- mtY.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 0.0, 1.0, 0.0, 0.3 ), 'uColor' ) );
- mtZ.getOrCreateStateSet().addUniform( Uniform.createFloat4( vec4.fromValues( 0.0, 0.0, 1.0, 0.3 ), 'uColor' ) );
-
- var plane = this._planeNode;
- plane.setNodeMask( NodeGizmo.PICK_PLANE );
- plane.getOrCreateStateSet().setAttributeAndModes( blendAttribute );
- plane.addChild( mtX );
- plane.addChild( mtY );
- plane.addChild( mtZ );
- return plane;
- },
-
- updateArcRotation: ( function () {
- var qTmp = quat.create();
- var quatx = quat.setAxisAngle( quat.create(), [ 0.0, 1.0, 0.0 ], -Math.PI * 0.5 );
- var quaty = quat.setAxisAngle( quat.create(), [ 1.0, 0.0, 0.0 ], -Math.PI * 0.5 );
- return function ( eye ) {
- var rotateNode = this._rotateNode;
- var arcs = rotateNode.getChildren();
- // eye arc
- qTmp[ 0 ] = -eye[ 1 ];
- qTmp[ 1 ] = eye[ 0 ];
- qTmp[ 2 ] = 0.0;
- qTmp[ 3 ] = 1.0 + eye[ 2 ];
- quat.normalize( qTmp, qTmp );
- mat4.fromQuat( arcs[ 0 ].getMatrix(), qTmp );
- // x arc
- quat.setAxisAngle( qTmp, [ 1.0, 0.0, 0.0 ], Math.atan2( eye[ 2 ], eye[ 1 ] ) );
- quat.mul( qTmp, qTmp, quatx );
- mat4.fromQuat( arcs[ 1 ].getMatrix(), qTmp );
- // y arc
- quat.setAxisAngle( qTmp, [ 0.0, 1.0, 0.0 ], Math.atan2( -eye[ 0 ], -eye[ 2 ] ) );
- quat.mul( qTmp, qTmp, quaty );
- mat4.fromQuat( arcs[ 2 ].getMatrix(), qTmp );
- // z arc
- quat.setAxisAngle( qTmp, [ 0.0, 0.0, 1.0 ], Math.atan2( -eye[ 0 ], eye[ 1 ] ) );
- mat4.fromQuat( arcs[ 3 ].getMatrix(), qTmp );
-
- arcs[ 1 ].dirtyBound();
- arcs[ 2 ].dirtyBound();
- arcs[ 3 ].dirtyBound();
- };
- } )(),
-
- getTransformType: function ( node ) {
- var n = node;
- while ( n.getParents().length > 0 ) {
- if ( n.referenceFrame !== undefined && n.referenceFrame === TransformEnums.ABSOLUTE_RF )
- return TransformEnums.ABSOLUTE_RF;
- n = n.getParents()[ 0 ];
- }
- return TransformEnums.RELATIVE_RF;
- },
-
- updateGizmo: ( function () {
- var eye = vec3.create();
- var trVec = vec3.create();
- var tmpVec = vec3.create();
-
- var temp = mat4.create();
- var trWorld = mat4.create();
- var invScale = mat4.create();
- var scGiz = mat4.create();
-
- return function () {
- if ( !this._attachedNode )
- return;
- var ttype = this.getTransformType( this._attachedNode );
- this.setReferenceFrame( ttype );
- this.setCullingActive( ttype === TransformEnums.RELATIVE_RF );
- var worldMat = this._attachedNode.getWorldMatrices()[ 0 ];
-
- // world trans
- mat4.getTranslation( trVec, worldMat );
- mat4.fromTranslation( trWorld, trVec );
-
- // normalize gizmo size
- var scaleFactor = 3.0;
- if ( ttype === TransformEnums.ABSOLUTE_RF ) {
- eye[ 0 ] = eye[ 1 ] = eye[ 2 ] = 0.0;
- tmpVec[ 0 ] = tmpVec[ 1 ] = tmpVec[ 2 ] = 1.0;
- } else {
- // normalize gizmo size relative to screen size
- var proj = this._viewer.getCamera().getProjectionMatrix();
- var scaleFov = this._canvas.clientWidth * 0.023 * proj[ 0 ];
- this._manipulator.getEyePosition( eye );
- // while we are editing we don't normalize the gizmo
- // it gives a better depth feedback, especially if we are editing a geometry that has
- // a constant screen size (for example an icon)
- this._lastDistToEye = this._isEditing ? this._lastDistToEye : vec3.distance( trVec, eye );
- scaleFactor *= this._lastDistToEye / scaleFov;
- }
- mat4.fromScaling( scGiz, [ scaleFactor, scaleFactor, scaleFactor ] );
-
- // gizmo node
- mat4.mul( this.getMatrix(), trWorld, scGiz );
-
- vec3.sub( eye, eye, trVec );
- vec3.normalize( eye, eye );
-
- // rotate node
- if ( this._rotateInLocal || this._translateInLocal ) {
- // world scale
- mat4.getScale( tmpVec, worldMat );
- mat4.fromScaling( invScale, tmpVec );
- mat4.invert( invScale, invScale );
-
- mat4.mul( temp, worldMat, invScale );
- temp[ 12 ] = temp[ 13 ] = temp[ 14 ] = 0.0;
-
- if ( this._translateInLocal ) {
- mat4.copy( this._translateNode.getMatrix(), temp );
- mat4.copy( this._planeNode.getMatrix(), temp );
- }
-
- if ( this._rotateInLocal ) {
- mat4.copy( this._rotateNode.getMatrix(), temp );
- mat4.invert( temp, temp );
- vec3.transformMat4( eye, eye, temp );
- }
- } else {
- mat4.identity( this._rotateNode.getMatrix() );
- }
-
- this.updateArcRotation( eye );
-
- this._rotateNode.dirtyBound();
- this._translateNode.dirtyBound();
- this._planeNode.dirtyBound();
-
- if ( this._isEditing )
- mat4.copy( this._showAngle.getMatrix(), this._hoverNode.getMatrix() );
- };
- } )(),
-
- computeNearestIntersection: ( function () {
- var sortByRatio = function ( a, b ) {
- return a.ratio - b.ratio;
- };
- var coord = vec2.create();
-
- return function ( e, tmask ) {
- getCanvasCoord( coord, e );
-
- // canvas to webgl coord
- var viewer = this._viewer;
- var canvas = this._canvas;
- var x = coord[ 0 ] * ( viewer._canvasWidth / canvas.clientWidth );
- var y = ( canvas.clientHeight - coord[ 1 ] ) * ( viewer._canvasHeight / canvas.clientHeight );
-
- var hits = this._viewer.computeIntersections( x, y, tmask );
-
- if ( hits.length === 0 )
- return undefined;
-
- hits.sort( sortByRatio );
- return hits[ 0 ];
- };
- } )(),
-
- setOnlyGizmoPicking: function () {
- // enable picking only for the gizmo
- this._viewer.getCamera().addChild( this );
- this._viewer.getSceneData().setNodeMask( 0x0 );
- this.setNodeMask( ~0x0 );
- },
-
- setOnlyScenePicking: function () {
- this._viewer.getCamera().removeChild( this );
- this._viewer.getSceneData().setNodeMask( ~0x0 );
- this.setNodeMask( NodeGizmo.NO_PICK );
- },
-
- pickGizmo: function ( e, tmask ) {
- this.setOnlyGizmoPicking();
- var hit = this.computeNearestIntersection( e, tmask );
- this.setOnlyScenePicking();
- return hit;
- },
-
- getCanvasPositionFromWorldPoint: ( function () {
- var mat = mat4.create();
-
- return function ( worldPoint, out ) {
- var cam = this._viewer.getCamera();
-
- var screenPoint = out;
- if ( !out ) {
- Notify.warn( 'deprecated, use out argument for result ' );
- screenPoint = vec3.create();
- }
-
- if ( cam.getViewport() ) {
- cam.getViewport().computeWindowMatrix( mat );
- } else {
- mat4.identity( mat );
- }
-
- mat4.mul( mat, mat, cam.getProjectionMatrix() );
- if ( this.getReferenceFrame() === TransformEnums.RELATIVE_RF )
- mat4.mul( mat, mat, cam.getViewMatrix() );
-
- vec3.transformMat4( screenPoint, worldPoint, mat );
-
- // canvas to webgl coord
- var viewer = this._viewer;
- var canvas = this._canvas;
- screenPoint[ 0 ] = screenPoint[ 0 ] / ( viewer._canvasWidth / canvas.clientWidth );
- screenPoint[ 1 ] = canvas.clientHeight - screenPoint[ 1 ] / ( viewer._canvasHeight / canvas.clientHeight );
- return screenPoint;
- };
- } )(),
-
- onMouseDown: function ( e ) {
- getCanvasCoord( this._downCanvasCoord, e );
- if ( !this._hoverNode || !this._attachedNode )
- return;
- this._viewer._eventProxy.StandardMouseKeyboard._enable = false;
-
- this.saveEditMatrices();
- var nm = this._hoverNode.getParents()[ 0 ].getNodeMask();
- this._isEditing = true;
-
- if ( nm & NodeGizmo.PICK_ARC ) {
- this._translateNode.setNodeMask( 0x0 );
- this._planeNode.setNodeMask( 0x0 );
- this.startRotateEdit( e );
- } else if ( nm & NodeGizmo.PICK_ARROW ) {
- this._rotateNode.setNodeMask( 0x0 );
- this._planeNode.setNodeMask( 0x0 );
- this.startTranslateEdit( e );
- } else if ( nm & NodeGizmo.PICK_PLANE ) {
- this._rotateNode.setNodeMask( 0x0 );
- this._translateNode.setNodeMask( 0x0 );
- this.startPlaneEdit( e );
- }
- },
-
- saveEditMatrices: function () {
- mat4.copy( this._editLocal, this._attachedNode.getMatrix() );
- // save the world translation
- var wm = this._attachedNode.getWorldMatrices()[ 0 ];
- mat4.fromTranslation( this._editWorldTrans, vec3.fromValues( wm[ 12 ], wm[ 13 ], wm[ 14 ] ) );
- // save the inv of world rotation + scale
- mat4.copy( this._editWorldScaleRot, wm );
- // removes translation
- this._editWorldScaleRot[ 12 ] = this._editWorldScaleRot[ 13 ] = this._editWorldScaleRot[ 14 ] = 0.0;
- mat4.invert( this._editInvWorldScaleRot, this._editWorldScaleRot );
- },
-
- startRotateEdit: function ( e ) {
- var gizmoMat = this._rotateNode.getWorldMatrices()[ 0 ];
-
- // center of gizmo on screen
- var projCenter = vec3.create();
- vec3.transformMat4( projCenter, projCenter, gizmoMat );
- this.getCanvasPositionFromWorldPoint( projCenter, projCenter );
-
- // pick rotate gizmo
- var hit = this.pickGizmo( e, this._hoverNode.getNodeMask() | NodeGizmo.PICK_ARC );
- if ( !hit ) return;
-
- // compute tangent direction
- var sign = this._hoverNode._nbAxis === 0 ? -1.0 : 1.0;
- var tang = vec3.create();
- tang[ 0 ] = sign * hit.point[ 1 ];
- tang[ 1 ] = -sign * hit.point[ 0 ];
- tang[ 2 ] = hit.point[ 2 ];
-
- // project tangent on screen
- var projArc = vec3.create();
- vec3.transformMat4( projArc, tang, this._hoverNode.getMatrix() );
- vec3.transformMat4( projArc, projArc, gizmoMat );
- this.getCanvasPositionFromWorldPoint( projArc, projArc );
-
- var dir = this._editLineDirection;
- vec2.sub( dir, projArc, projCenter );
- vec2.normalize( dir, dir );
-
- // show angle
- this._showAngle.setNodeMask( NodeGizmo.NO_PICK );
- hit.point[ 2 ] = 0.0;
- var stateAngle = this._showAngle.getStateSet();
- stateAngle.getUniform( 'uAngle' ).setFloat( 0.0 );
- stateAngle.getUniform( 'uBase' ).setVec3( vec3.normalize( hit.point, hit.point ) );
-
- getCanvasCoord( this._editLineOrigin, e );
- },
-
- startTranslateEdit: function ( e ) {
- var origin = this._editLineOrigin;
- var dir = this._editLineDirection;
-
- // 3d origin (center of gizmo)
- var gizmoMat = this._translateNode.getWorldMatrices()[ 0 ];
- mat4.getTranslation( origin, gizmoMat );
-
- // 3d direction
- vec3.init( dir );
- dir[ this._hoverNode._nbAxis ] = 1.0;
- if ( this._translateInLocal ) {
- vec3.transformMat4( dir, dir, this._editWorldScaleRot );
- vec3.normalize( dir, dir );
- }
- vec3.add( dir, origin, dir );
-
- // project on canvas
- this.getCanvasPositionFromWorldPoint( origin, origin );
- this.getCanvasPositionFromWorldPoint( dir, dir );
-
- vec2.sub( dir, dir, origin );
- vec2.normalize( dir, dir );
-
- var offset = this._editOffset;
- getCanvasCoord( offset, e );
- vec2.sub( offset, offset, origin );
- },
-
- startPlaneEdit: function ( e ) {
- var origin = this._editLineOrigin; // just used to determine the 2d offset
-
- // 3d origin (center of gizmo)
- var gizmoMat = this._planeNode.getWorldMatrices()[ 0 ];
- mat4.getTranslation( origin, gizmoMat );
-
- // project on canvas
- this.getCanvasPositionFromWorldPoint( origin, origin );
-
- var offset = this._editOffset;
- getCanvasCoord( offset, e );
- vec2.sub( offset, offset, origin );
- },
-
- drawLineCanvasDebug: function ( x1, y1, x2, y2 ) {
- this._debugNode.setNodeMask( NodeGizmo.NO_PICK );
- var buffer = this._debugNode.getChildren()[ 0 ].getAttributes().Vertex;
- buffer.getElements()[ 0 ] = ( ( x1 / this._canvas.clientWidth ) * 2 ) - 1.0;
- buffer.getElements()[ 1 ] = ( ( ( this._canvas.clientHeight - y1 ) / this._canvas.clientHeight ) ) * 2 - 1.0;
- buffer.getElements()[ 2 ] = ( ( x2 / this._canvas.clientWidth ) * 2 ) - 1.0;
- buffer.getElements()[ 3 ] = ( ( ( this._canvas.clientHeight - y2 ) / this._canvas.clientHeight ) ) * 2 - 1.0;
- buffer.dirty();
- },
-
- pickAndSelect: function ( e ) {
- this.setNodeMask( 0x0 );
- var hit = this.computeNearestIntersection( e, this._tmask );
- if ( this._autoInsertMT )
- this.attachToGeometry( hit ? hit.nodepath[ hit.nodepath.length - 1 ] : hit );
- else
- this.attachToNodePath( hit ? hit.nodepath : hit );
- },
-
- onMouseUp: function ( e ) {
- var smk = this._viewer._eventProxy.StandardMouseKeyboard;
- if ( smk._enable === false ) {
- smk._enable = true;
- this._viewer._eventProxy.StandardMouseKeyboard.mouseup( e );
- }
- if ( this._debugNode )
- this._debugNode.setNodeMask( 0x0 );
-
- var v = vec2.create();
- getCanvasCoord( v, e );
- if ( vec2.distance( v, this._downCanvasCoord ) === 0.0 )
- this.pickAndSelect( e );
-
- this._showAngle.setNodeMask( 0x0 );
- this._isEditing = false;
- if ( !this._hoverNode )
- return;
- this.updateGizmoMask();
- },
-
- onMouseMove: function ( e ) {
- if ( !this._attachedNode )
- return;
- var hit;
- if ( this._isEditing === false ) {
- hit = this.pickGizmo( e, NodeGizmo.PICK_GIZMO );
- this.onNodeHovered( hit );
- return;
- }
-
- if ( !this._hoverNode )
- return;
-
- var par = this._hoverNode.getParents()[ 0 ];
- if ( par === this._rotateNode )
- this.updateRotateEdit( e );
- else if ( par === this._translateNode )
- this.updateTranslateEdit( e );
- else if ( par === this._planeNode )
- this.updatePlaneEdit( e );
- },
-
- updateRotateEdit: ( function () {
- var mrot = mat4.create();
- var vec = vec2.create();
- var right = vec3.fromValues( 1.0, 0.0, 0.0 );
- var upy = vec3.fromValues( 0.0, 1.0, 0.0 );
- var upz = vec3.fromValues( 0.0, 0.0, 1.0 );
- return function ( e ) {
-
- var origin = this._editLineOrigin;
- var dir = this._editLineDirection;
-
- getCanvasCoord( vec, e );
- vec2.sub( vec, vec, origin );
- var dist = vec2.dot( vec, dir );
-
- if ( this._debugNode )
- this.drawLineCanvasDebug( origin[ 0 ], origin[ 1 ], origin[ 0 ] + dir[ 0 ] * dist, origin[ 1 ] + dir[ 1 ] * dist );
-
- var angle = 7 * dist / Math.min( this._canvas.clientWidth, this._canvas.clientHeight );
- angle %= ( Math.PI * 2 );
- var nbAxis = this._hoverNode._nbAxis;
- if ( nbAxis === 0 )
- mat4.fromRotation( mrot, -angle, right );
- else if ( nbAxis === 1 )
- mat4.fromRotation( mrot, -angle, upy );
- else if ( nbAxis === 2 )
- mat4.fromRotation( mrot, -angle, upz );
-
- this._showAngle.getOrCreateStateSet().getUniform( 'uAngle' ).setFloat( nbAxis === 0 ? -angle : angle );
-
- if ( !this._rotateInLocal ) {
- mat4.mul( mrot, this._editInvWorldScaleRot, mrot );
- mat4.mul( mrot, mrot, this._editWorldScaleRot );
- }
-
- mat4.mul( this._attachedNode.getMatrix(), this._editLocal, mrot );
-
- this._attachedNode.dirtyBound();
- };
- } )(),
-
- updateTranslateEdit: ( function () {
- var vec = vec2.create();
- var tra = vec3.create();
-
- return function ( e ) {
-
- var origin = this._editLineOrigin;
- var dir = this._editLineDirection;
-
- getCanvasCoord( vec, e );
- vec2.sub( vec, vec, origin );
- vec2.sub( vec, vec, this._editOffset );
-
- var dist = vec2.dot( vec, dir );
- vec[ 0 ] = origin[ 0 ] + dir[ 0 ] * dist;
- vec[ 1 ] = origin[ 1 ] + dir[ 1 ] * dist;
-
- if ( this._debugNode )
- this.drawLineCanvasDebug( origin[ 0 ], origin[ 1 ], vec[ 0 ], vec[ 1 ] );
-
- // canvas to webgl coord
- var viewer = this._viewer;
- var canvas = this._canvas;
- var coordx = vec[ 0 ] * ( viewer._canvasWidth / canvas.clientWidth );
- var coordy = ( canvas.clientHeight - vec[ 1 ] ) * ( viewer._canvasHeight / canvas.clientHeight );
-
- // project 2D point on the 3d line
- this._lsi.reset();
- this._lsi.setTestPlane( false );
- this._lsi.set( vec3.set( this._origIntersect, coordx, coordy, 0.0 ),
- vec3.set( this._dstIntersect, coordx, coordy, 1.0 ) );
- this._iv.reset();
- this._iv.setTraversalMask( this._hoverNode.getNodeMask() );
-
- mat4.copy( this.getMatrix(), this._editWorldTrans );
-
- this.setOnlyGizmoPicking();
- this._viewer._camera.accept( this._iv );
- this.setOnlyScenePicking();
-
- if ( !this._translateInLocal ) {
- vec3.transformMat4( tra, this._lsi.getTranslateDistance(), this._editInvWorldScaleRot );
- } else {
- mat4.getScale( tra, this._editInvWorldScaleRot );
-
- var inter = this._lsi.getTranslateDistance();
- vec3.mul( tra, tra, inter );
- }
-
- mat4.translate( this._attachedNode.getMatrix(), this._editLocal, tra );
-
- this._attachedNode.dirtyBound();
- };
- } )(),
-
- updatePlaneEdit: ( function () {
- var vec = vec2.create();
- var tra = vec3.create();
-
- return function ( e ) {
- getCanvasCoord( vec, e );
- vec2.sub( vec, vec, this._editOffset );
-
- // canvas to webgl coord
- var viewer = this._viewer;
- var canvas = this._canvas;
- var coordx = vec[ 0 ] * ( viewer._canvasWidth / canvas.clientWidth );
- var coordy = ( canvas.clientHeight - vec[ 1 ] ) * ( viewer._canvasHeight / canvas.clientHeight );
-
- // project 2D point on the 3d plane
- this._lsi.reset();
- this._lsi.setTestPlane( true );
- this._lsi.set( vec3.set( this._origIntersect, coordx, coordy, 0.0 ),
- vec3.set( this._dstIntersect, coordx, coordy, 1.0 ) );
- this._iv.reset();
- this._iv.setTraversalMask( this._hoverNode.getNodeMask() );
-
- mat4.copy( this.getMatrix(), this._editWorldTrans );
-
- this.setOnlyGizmoPicking();
- this._viewer._camera.accept( this._iv );
- this.setOnlyScenePicking();
-
- if ( !this._translateInLocal ) {
- vec3.transformMat4( tra, this._lsi.getTranslateDistance(), this._editInvWorldScaleRot );
- } else {
- mat4.getScale( tra, this._editInvWorldScaleRot );
- var inter = this._lsi.getTranslateDistance();
- vec3.mul( tra, tra, inter );
- }
-
- mat4.translate( this._attachedNode.getMatrix(), this._editLocal, tra );
-
- this._attachedNode.dirtyBound();
- };
- } )()
-
-} );
-
-module.exports = NodeGizmo;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/ParameterVisitor.js b/app/static/app/js/vendor/osgjs/osgUtil/ParameterVisitor.js
deleted file mode 100644
index 75a7e88e..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/ParameterVisitor.js
+++ /dev/null
@@ -1,421 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Notify = require( 'osg/notify' );
-var Uniform = require( 'osg/Uniform' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-
-var ArraySlider = function ( params ) {
- if ( params !== undefined ) {
- if ( params.object !== undefined && params.field !== undefined ) {
- this.createInternalSlider( params );
- }
- this._uniform = this.createInternalSliderUniform( params );
- }
-};
-
-ArraySlider.prototype = {
- setTargetHTML: function ( target ) {
- this.parent = target;
- },
- addToDom: function ( content ) {
- var mydiv = document.createElement( 'div' );
- mydiv.innerHTML = content;
- this.parent.appendChild( mydiv );
- },
-
- getValue: function ( name ) {
- if ( window.localStorage ) {
- var value = window.localStorage.getItem( name );
- return value;
- }
- return null;
- },
- setValue: function ( name, value ) {
- if ( window.localStorage ) {
- window.localStorage.setItem( name, value );
- }
- },
- createHTMLSlider: function ( param, value, nameIndex, cbnameIndex ) {
- var input = '
NAME [ MIN - MAX ]
';
- var min = param.min;
- var max = param.max;
- var step = param.step;
- var name = nameIndex;
- var cbname = cbnameIndex;
- var onchange = cbname + '(this.value)';
- input = input.replace( /MIN/g, min );
- input = input.replace( /MAX/g, ( max + step ) );
- input = input.replace( 'STEP', step );
- input = input.replace( 'VALUE', value );
- input = input.replace( /NAME/g, name );
- input = input.replace( /UPDATE/g, cbname );
- input = input.replace( 'ONCHANGE', onchange );
- return input;
- },
-
- createUniformFunction: function ( param, name, index, uniform, cbnameIndex ) {
- var self = this;
- return ( function () {
- var cname = name;
- var cindex = index;
- var cuniform = uniform;
- var id = cbnameIndex;
- var func = function ( value ) {
- cuniform.get()[ cindex ] = value;
- cuniform.dirty();
- Notify.debug( cname + ' value ' + value );
- document.getElementById( cbnameIndex ).innerHTML = Number( value ).toFixed( 4 );
- self.setValue( id, value );
- if ( param.onchange !== undefined ) {
- param.onchange( cuniform.get() );
- }
- // store the value to localstorage
- };
- return func;
- } )();
- },
-
- createFunction: function ( param, name, index, object, field, cbnameIndex ) {
- var self = this;
- return ( function () {
- var cname = name;
- //var cindex = index;
- var cfield = field;
- var id = cbnameIndex;
- var obj = object;
- var func = function ( value ) {
- if ( typeof ( value ) === 'string' ) {
- value = parseFloat( value );
- }
-
- if ( typeof ( object[ cfield ] ) === 'number' ) {
- obj[ cfield ] = value;
- } else {
- obj[ cfield ][ index ] = value;
- }
- Notify.debug( cname + ' value ' + value );
- document.getElementById( cbnameIndex ).innerHTML = Number( value ).toFixed( 4 );
- self.setValue( id, value );
- if ( param.onchange !== undefined ) {
- param.onchange( obj[ cfield ] );
- }
-
- // store the value to localstorage
- };
- return func;
- } )();
- },
-
- getCallbackName: function ( name, prgId ) {
- return 'change_' + prgId + '_' + name;
- },
-
- copyDefaultValue: function ( param ) {
- var uvalue = param.value;
- if ( Array.isArray( param.value ) ) {
- uvalue = param.value.slice();
- } else {
- uvalue = [ uvalue ];
- }
- return uvalue;
- },
-
- createInternalSliderUniform: function ( param ) {
- var uvalue = param.value;
- var uniform = param.uniform;
- if ( uniform === undefined ) {
- var type = param.type;
- type = type.charAt( 0 ).toUpperCase() + type.slice( 1 );
- uniform = Uniform[ 'create' + type ]( uvalue, param.name );
- }
-
- var cbname = this.getCallbackName( param.name, param.id );
- var dim = uvalue.length;
- for ( var i = 0; i < dim; i++ ) {
-
- var istring = i.toString();
- var nameIndex = param.name + istring;
- var cbnameIndex = cbname + istring;
-
- // default value
- var value = uvalue[ i ];
-
- // read local storage value if it exist
- var readValue = this.getValue( cbnameIndex );
- if ( readValue !== null ) {
- value = readValue;
- } else if ( param.uniform && param.uniform.get()[ i ] !== undefined ) {
- // read value from original uniform
- value = param.uniform.get()[ i ];
- }
-
- var dom = this.createHTMLSlider( param, value, nameIndex, cbnameIndex );
- this.addToDom( dom );
- window[ cbnameIndex ] = this.createUniformFunction( param, nameIndex, i, uniform, cbnameIndex );
- Notify.log( nameIndex + ' ' + value );
- window[ cbnameIndex ]( value );
- }
- this.uniform = uniform;
- return uniform;
- },
-
- createInternalSlider: function ( param ) {
- var uvalue = param.value;
- var name = param.name;
- var id = param.id;
- var dim = uvalue.length;
- var cbname = this.getCallbackName( name, id );
- var object = param.object;
- var field = param.field;
- for ( var i = 0; i < dim; i++ ) {
-
- var istring = i.toString();
- var nameIndex = name + istring;
- var cbnameIndex = cbname + istring;
-
- // default value
- var value = uvalue[ i ];
-
- // read local storage value if it exist
- var readValue = this.getValue( cbnameIndex );
- if ( readValue !== null ) {
- value = readValue;
- } else {
- if ( typeof object[ field ] === 'number' ) {
- value = object[ field ];
- } else {
- value = object[ field ][ i ];
- }
- }
-
- var dom = this.createHTMLSlider( param, value, nameIndex, cbnameIndex );
- this.addToDom( dom );
- window[ cbnameIndex ] = this.createFunction( param, nameIndex, i, object, field, cbnameIndex );
- Notify.log( nameIndex + ' ' + value );
- window[ cbnameIndex ]( value );
- }
- },
-
- createSlider: function ( param ) {
- if ( param.html !== undefined ) {
- this.setTargetHTML( param.html );
- }
- if ( param.id === undefined ) {
- param.id = param.name;
- }
- param.value = this.copyDefaultValue( param );
- if ( param.type !== undefined ) {
- return this.createInternalSliderUniform( param );
- } else {
- if ( param.object === undefined ) {
- param.object = {
- 'data': param.value
- };
- param.field = 'data';
- }
- return this.createInternalSlider( param );
- }
- }
-};
-
-
-var ParameterVisitor = function () {
- NodeVisitor.call( this );
-
- this.arraySlider = new ArraySlider();
- this.setTargetHTML( document.body );
-};
-
-ParameterVisitor.createSlider = function ( param ) {
- ( new ArraySlider() ).createSlider( param );
-};
-
-ParameterVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
-
- setTargetHTML: function ( html ) {
- this.targetHTML = html;
- this.arraySlider.setTargetHTML( this.targetHTML );
- },
-
- getUniformList: function ( str, map ) {
-
- //var txt='uniform float Power; // { min: 0.1, max: 2.0, step: 0.1, value: [0,0,0] }';
-
- var re1 = '(uniform)'; // Word 1
- var re2 = '.*?'; // Non-greedy match on filler
- var re3 = '((?:[a-z][a-z]+))'; // Word 2
- var re4 = '.*?'; // Non-greedy match on filler
- var re5 = '((?:[a-z][a-z]+))'; // Word 3
- var re6 = '.*?'; // Non-greedy match on filler
- var re7 = '.'; // Uninteresting: c
- var re8 = '.*?'; // Non-greedy match on filler
- var re9 = '.'; // Uninteresting: c
- var re10 = '.*?'; // Non-greedy match on filler
- var re11 = '(.)'; // Any Single Character 1
- var re12 = '(.)'; // Any Single Character 2
- var re13 = '.*?'; // Non-greedy match on filler
- var re14 = '(\\{.*?\\})'; // Curly Braces 1
-
- var p = new RegExp( re1 + re2 + re3 + re4 + re5 + re6 + re7 + re8 + re9 + re10 + re11 + re12 + re13 + re14, [ 'g' ] );
- var r = str.match( p );
- var list = map;
-
- var createGetter = function ( value ) {
- return function () {
- return value;
- };
- };
-
- if ( r !== null ) {
- var re = new RegExp( re1 + re2 + re3 + re4 + re5 + re6 + re7 + re8 + re9 + re10 + re11 + re12 + re13 + re14, [ 'i' ] );
- for ( var i = 0, l = r.length; i < l; i++ ) {
- var result = r[ i ].match( re );
- //var result = p.exec(str);
- if ( result !== null ) {
- //var word1 = result[ 1 ];
- var type = result[ 2 ];
- var name = result[ 3 ];
- //var c1 = result[ 4 ];
- //var c2 = result[ 5 ];
- var json = result[ 6 ];
-
- var param = JSON.parse( json );
- param.type = type;
- param.name = name;
- var value = param.value;
- param.value = createGetter( value );
- list[ name ] = param;
- }
- }
- }
- return list;
- },
-
- getUniformFromStateSet: function ( stateSet, uniformMap ) {
- var maps = stateSet.getUniformList();
- if ( !maps ) {
- return;
- }
- var keys = window.Object.keys( uniformMap );
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- var k = keys[ i ];
- // get the first one found in the tree
- if ( maps[ k ] !== undefined && uniformMap[ k ].uniform === undefined ) {
- uniformMap[ k ].uniform = maps[ k ].object;
- }
- }
- },
-
- findExistingUniform: function ( node, uniformMap ) {
- var BackVisitor = function () {
- NodeVisitor.call( this, NodeVisitor.TRAVERSE_PARENTS );
- };
- BackVisitor.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
- setUniformMap: function ( map ) {
- this.uniformMap = map;
- },
- apply: function ( node ) {
- var stateSet = node.getStateSet();
- if ( stateSet ) {
- ParameterVisitor.prototype.getUniformFromStateSet( stateSet, this.uniformMap );
- }
- this.traverse( node );
- }
- } );
- var visitor = new BackVisitor();
- visitor.setUniformMap( uniformMap );
- node.accept( visitor );
- },
-
- applyProgram: function ( node, stateset ) {
- var program = stateset.getAttribute( 'Program' );
- var programName = program.getName();
- //var string = program.getVertexShader().getText();
- var uniformMap = {};
- this.getUniformList( program.getVertexShader().getText(), uniformMap );
- this.getUniformList( program.getFragmentShader().getText(), uniformMap );
-
- var i = 0;
-
- var keys = window.Object.keys( uniformMap );
-
- if ( programName === undefined ) {
- var hashCode = function ( str ) {
- var hash = 0;
- var chara = 0;
- if ( str.length === 0 ) {
- return hash;
- }
- for ( i = 0; i < str.length; i++ ) {
- chara = str.charCodeAt( i );
- /*jshint bitwise: false */
- hash = ( ( hash << 5 ) - hash ) + chara;
- hash = hash & hash; // Convert to 32bit integer
- /*jshint bitwise: true */
- }
- if ( hash < 0 ) {
- hash = -hash;
- }
- return hash;
- };
- var str = keys.join( '' );
- programName = hashCode( str ).toString();
- }
-
- this.findExistingUniform( node, uniformMap );
-
- var addedSlider = false;
- for ( i = 0; i < keys.length; i++ ) {
- var k = keys[ i ];
- var entry = uniformMap[ k ];
- var type = entry.type;
- var name = entry.name;
- entry.id = programName;
- var uniform = this.arraySlider.createSlider( entry );
- if ( false ) {
- uniform = this.arraySlider.createSlider( {
- name: name,
- type: type,
- id: programName,
- uniform: entry.uniform
- } );
- }
- if ( entry.uniform === undefined && uniform ) {
- stateset.addUniform( uniform );
- }
- addedSlider = true;
- }
-
- // add a separator
- if ( addedSlider ) {
- var mydiv = document.createElement( 'div' );
- mydiv.innerHTML = '
';
- this.targetHTML.appendChild( mydiv );
- }
-
- Notify.log( uniformMap );
- },
-
-
- applyStateSet: function ( node, stateset ) {
- if ( stateset.getAttribute( 'Program' ) !== undefined ) {
- this.applyProgram( node, stateset );
- }
- },
-
- apply: function ( node ) {
- var element = this.targetHTML;
- if ( element === undefined || element === null ) {
- return;
- }
-
- var st = node.getStateSet();
- if ( st !== undefined ) {
- this.applyStateSet( node, st );
- }
-
- this.traverse( node );
- }
-} );
-
-module.exports = ParameterVisitor;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/PolytopeIntersector.js b/app/static/app/js/vendor/osgjs/osgUtil/PolytopeIntersector.js
deleted file mode 100644
index 99abceca..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/PolytopeIntersector.js
+++ /dev/null
@@ -1,166 +0,0 @@
-'use strict';
-var PolytopePrimitiveIntersector = require( 'osgUtil/PolytopePrimitiveIntersector' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-/** Concrete class for implementing polytope intersections with the scene graph.
- * To be used in conjunction with IntersectionVisitor. */
-var PolytopeIntersector = function () {
- this._intersections = [];
- this._index = 0;
- this._polytope = [];
- this._iPolytope = [];
- this._referencePlane = vec4.create();
- this._iReferencePlane = vec4.create();
- this._intersectionLimit = PolytopeIntersector.NO_LIMIT;
- this._dimensionMask = PolytopeIntersector.AllDims;
-};
-
-
-PolytopeIntersector.NO_LIMIT = 0;
-PolytopeIntersector.LIMIT_ONE_PER_DRAWABLE = 1;
-PolytopeIntersector.LIMIT_ONE = 2;
-
-
-PolytopeIntersector.DimZero = ( 1 << 0 );
-PolytopeIntersector.DimOne = ( 1 << 1 );
-PolytopeIntersector.DimTwo = ( 1 << 2 );
-PolytopeIntersector.AllDims = ( PolytopeIntersector.DimZero | PolytopeIntersector.DimOne | PolytopeIntersector.DimTwo );
-
-
-var transformVec4PostMult = function ( out, p, m ) {
- var x = p[ 0 ];
- var y = p[ 1 ];
- var z = p[ 2 ];
- var w = p[ 3 ];
-
- out[ 0 ] = m[ 0 ] * x + m[ 1 ] * y + m[ 2 ] * z + m[ 3 ] * w;
- out[ 1 ] = m[ 4 ] * x + m[ 5 ] * y + m[ 6 ] * z + m[ 7 ] * w;
- out[ 2 ] = m[ 8 ] * x + m[ 9 ] * y + m[ 10 ] * z + m[ 11 ] * w;
- out[ 3 ] = m[ 12 ] * x + m[ 13 ] * y + m[ 14 ] * z + m[ 15 ] * w;
-};
-
-PolytopeIntersector.prototype = {
-
- setPolytope: function ( polytope ) {
- this._polytope = polytope;
- this._referencePlane[ 0 ] = polytope[ polytope.length - 1 ][ 0 ];
- this._referencePlane[ 1 ] = polytope[ polytope.length - 1 ][ 1 ];
- this._referencePlane[ 2 ] = polytope[ polytope.length - 1 ][ 2 ];
- this._referencePlane[ 3 ] = polytope[ polytope.length - 1 ][ 3 ];
- // TODO initialize _iPolytope or _iReferencePlane in case there is no transform in the graph?
- // same as setCurrentTransformation with matrix identity
- },
-
- setPolytopeFromWindowCoordinates: function ( xMin, yMin, xMax, yMax ) {
- // Note: last polytope value depends on the Coordinate frame
- // Now we are only supporting WINDOW coordinate frame, so must change this if we decide to support
- // other types of Coordinate Frame
- this.setPolytope( [
- vec4.fromValues( 1.0, 0.0, 0.0, -xMin ),
- vec4.fromValues( -1.0, 0.0, 0.0, xMax ),
- vec4.fromValues( 0.0, 1.0, 0.0, -yMin ),
- vec4.fromValues( 0.0, -1.0, 0.0, yMax ),
- vec4.fromValues( 0.0, 0.0, 1.0, 0.0 )
- ] );
- },
-
- /** Set the dimension mask.
- * As polytope-triangle and polytope-quad intersections are expensive to compute
- * it is possible to turn them off by calling setDimensionMask( DimZero | DimOne )
- */
- setDimensionMask: function ( mask ) {
- this._dimensionMask = mask;
- },
-
- reset: function () {
- // Clear the intersections vector
- this._intersections.length = 0;
- },
-
- enter: function ( node ) {
- if ( this.reachedLimit() ) return false;
- return ( this.intersects( node.getBound() ) );
- },
-
- reachedLimit: function () {
- return this._intersectionLimit === PolytopeIntersector.LIMIT_ONE && this._intersections.length > 0;
- },
-
- // Intersection Polytope/Sphere
- intersects: ( function () {
- var position = vec3.create();
- return function ( bsphere ) {
- if ( !bsphere.valid() ) return false;
- var pos = bsphere.center();
- var d;
- vec3.copy( position, pos );
- var radius = -bsphere.radius();
- for ( var i = 0, j = this._iPolytope.length; i < j; i++ ) {
- d = this._iPolytope[ i ][ 0 ] * position[ 0 ] + this._iPolytope[ i ][ 1 ] * position[ 1 ] + this._iPolytope[ i ][ 2 ] * position[ 2 ] + this._iPolytope[ i ][ 3 ];
- if ( d <= radius ) {
- return false;
- }
- }
- return true;
- };
- } )(),
-
- // Intersection Polytope/Geometry
- intersect: function ( iv, node ) {
- if ( this.reachedLimit() ) return false;
- var ppi = new PolytopePrimitiveIntersector();
- ppi.setNodePath( iv.nodePath );
- ppi.set( this._iPolytope, this._iReferencePlane );
- ppi.setLimitOneIntersection( this._intersectionLimit === PolytopeIntersector.LIMIT_ONE_PER_DRAWABLE || this._intersectionLimit === PolytopeIntersector.LIMIT_ONE );
- ppi.setDimensionMask( this._dimensionMask );
- ppi.apply( node );
- var l = ppi._intersections.length;
- if ( l > 0 ) {
- // Intersection/s exists
- for ( var i = 0; i < l; i++ ) {
- this._intersections.push( ppi._intersections[ i ] );
- }
- return true;
- }
- // No intersection found
- return false;
- },
-
- getIntersections: function () {
- return this._intersections;
- },
-
- setIntersectionLimit: function ( limit ) {
- this._intersectionLimit = limit;
- },
-
- setCurrentTransformation: function ( matrix ) {
- // Transform the polytope and the referencePlane to the current Model local coordinate frame
- var inv;
- var iplane = vec4.create();
- for ( var i = 0, j = this._polytope.length; i < j; i++ ) {
- var plane = this._polytope[ i ];
- // PostMult
- transformVec4PostMult( iplane, plane, matrix );
- // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.
- inv = 1.0 / Math.sqrt( iplane[ 0 ] * iplane[ 0 ] + iplane[ 1 ] * iplane[ 1 ] + iplane[ 2 ] * iplane[ 2 ] );
- iplane[ 0 ] *= inv;
- iplane[ 1 ] *= inv;
- iplane[ 2 ] *= inv;
- iplane[ 3 ] *= inv;
- this._iPolytope[ i ] = vec4.clone( iplane );
- }
- //Post Mult
- transformVec4PostMult( this._iReferencePlane, this._referencePlane, matrix );
-
- // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.
- inv = 1.0 / Math.sqrt( this._iReferencePlane[ 0 ] * this._iReferencePlane[ 0 ] + this._iReferencePlane[ 1 ] * this._iReferencePlane[ 1 ] + this._iReferencePlane[ 2 ] * this._iReferencePlane[ 2 ] );
- this._iReferencePlane[ 0 ] *= inv;
- this._iReferencePlane[ 1 ] *= inv;
- this._iReferencePlane[ 2 ] *= inv;
- this._iReferencePlane[ 3 ] *= inv;
- }
-};
-
-module.exports = PolytopeIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/PolytopePrimitiveIntersector.js b/app/static/app/js/vendor/osgjs/osgUtil/PolytopePrimitiveIntersector.js
deleted file mode 100644
index 6632b166..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/PolytopePrimitiveIntersector.js
+++ /dev/null
@@ -1,425 +0,0 @@
-'use strict';
-var osgMath = require( 'osg/math' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var PrimitiveFunctor = require( 'osg/PrimitiveFunctor' );
-
-
-var PolytopeIntersection = function ( index, candidates, candidatesMasks, referencePlane, nodePath ) {
- this._index = index - 1; ///< primitive index
- this._distance = 0; ///< distance from reference plane
- this._maxDistance = -1; ///< maximum distance of intersection points from reference plane
- this._numPoints = 0;
- this._points = [];
- this._maxNumIntersections = 6;
- this._center = vec3.create();
- for ( var i = 0, j = candidates.length; i < j; i++ ) {
- if ( candidatesMasks[ i ] === 0 ) continue;
- this._points[ this._numPoints++ ] = vec3.clone( candidates[ i ] );
- vec3.add( this._center, this._center, candidates[ i ] );
- var distance = referencePlane[ 0 ] * candidates[ i ][ 0 ] + referencePlane[ 1 ] * candidates[ i ][ 1 ] + referencePlane[ 2 ] * candidates[ i ][ 2 ] + referencePlane[ 3 ];
- if ( distance > this._maxDistance ) this._maxDistance = distance;
- if ( this._numPoints === this._maxNumIntesections ) break;
- }
- vec3.scale( this._center, this._center, 1 / this._numPoints );
- this._distance = referencePlane[ 0 ] * this._center[ 0 ] + referencePlane[ 1 ] * this._center[ 1 ] + referencePlane[ 2 ] * this._center[ 2 ] + referencePlane[ 3 ];
- this.nodePath = nodePath;
-};
-
-var PlanesLine = function ( planeMask, pos, dir ) {
- this._planeMask = planeMask;
- this._pos = pos;
- this._dir = dir;
-};
-var PolytopePrimitiveIntersector = function () {
- this._intersections = [];
- this._nodePath = [];
- this._index = 0;
- this._referencePlane = [];
- this._planes = []; ///< active planes extracted from polytope
- this._lines = []; ///< all intersection lines of two polytope planes
- this._candidates = [];
- this._candidatesMasks = [];
- this._lines = [];
- this._planesMask = 0;
- this._limitOneIntersection = false;
- this._dimensionMask = undefined;
-};
-
-PolytopePrimitiveIntersector.prototype = {
-
- setNodePath: function ( np ) {
- this._nodePath = np;
- },
-
- set: function ( polytope, referencePlane ) {
- this._planes = polytope;
- this._referencePlane = referencePlane;
- this._planesMask = 0;
- this._lines.length = 0;
- for ( var i = 0; i < this._planes.length; i++ ) {
- this._planesMask = ( this._planesMask << 1 ) | 1;
- }
- },
-
- setDimensionMask: function ( mask ) {
- this._dimensionMask = mask;
- },
-
- apply: function ( node ) {
- if ( !node.getAttributes().Vertex ) {
- return;
- }
- var vertices = node.getAttributes().Vertex.getElements();
- var self = this;
- // The callback must be defined as a closure
- /* jshint asi: true */
- var cb = function () {
- return {
- operatorPoint: function ( v ) {
- self.intersectPoint( v );
- },
- operatorLine: function ( v1, v2 ) {
- self.intersectLine( v1, v2 );
- },
- operatorTriangle: function ( v1, v2, v3 ) {
- self.intersectTriangle( v1, v2, v3 );
- }
- }
- };
- var pf = new PrimitiveFunctor( node, cb, vertices );
- pf.apply();
- },
-
-
- checkCandidatePoints: function ( insideMask ) {
- var selectorMask = 0x1;
- var numCands = this._candidates.length;
- for ( var i = 0, j = this._planes.length; i < j && numCands > 0; ++i, selectorMask <<= 1 ) {
- if ( insideMask & selectorMask ) continue;
- for ( var c = 0; c < this._candidates.length; ++c ) {
- if ( this._candidatesMasks[ c ] === 0 ) continue;
- if ( selectorMask & this._candidatesMasks[ c ] ) continue;
- if ( this.distance( this._planes[ i ], this._candidates[ c ] ) < 0.0 ) {
- this._candidatesMasks[ c ] = 0;
- --numCands;
- if ( numCands === 0 ) return 0;
- }
- }
- }
- return numCands;
- },
-
- intersectPoint: ( function () {
- var hit = vec3.create();
- return function ( v ) {
- this._index++;
- if ( ( this._dimensionMask & ( 1 << 0 ) ) === 0 ) return;
- if ( this._limitOneIntersection && this._intersections.length > 0 ) return;
- var d;
-
- for ( var i = 0, j = this._planes.length; i < j; ++i ) {
- d = this.distance( this._planes[ i ], v );
- if ( d < 0.0 ) {
- // point is outside the polytope
- return;
- }
- }
- this._candidates = [];
- this._candidatesMasks = [];
- // Intersection found: Copy the value and push it
- vec3.copy( hit, v );
- this._candidates.push( hit );
- this._candidatesMasks.push( this._planesMask );
- this._intersections.push( new PolytopeIntersection( this._index, this._candidates, this._candidatesMasks, this._referencePlane, this._nodePath.slice( 0 ) ) );
- };
- } )(),
-
-
- intersectLine: ( function () {
-
- var hit = vec3.create();
- return function ( v1, v2 ) {
- this._index++;
- if ( ( this._dimensionMask & ( 1 << 1 ) ) === 0 ) return;
- if ( this._limitOneIntersection && this._intersections.length > 0 ) return;
- var v1Inside = true;
- var v2Inside = true;
- var selectorMask = 0x1;
- var insideMask = 0x0;
- this._candidates = [];
- this._candidatesMasks = [];
- var d1, d2, d1IsNegative, d2IsNegative;
- for ( var i = 0, j = this._planes.length; i < j; ++i, selectorMask <<= 1 ) {
- d1 = this.distance( this._planes[ i ], v1 );
- d2 = this.distance( this._planes[ i ], v2 );
- d1IsNegative = ( d1 < 0.0 );
- d2IsNegative = ( d2 < 0.0 );
- if ( d1IsNegative && d2IsNegative ) return; // line outside
- if ( !d1IsNegative && !d2IsNegative ) {
- // completly inside this plane
- insideMask |= selectorMask;
- continue;
- }
- if ( d1IsNegative ) v1Inside = false;
- if ( d2IsNegative ) v2Inside = false;
- if ( d1 === 0.0 ) {
- vec3.copy( hit, v1 );
- this._candidates.push( hit );
- this._candidatesMasks.push( selectorMask );
- } else if ( d2 === 0.0 ) {
- vec3.copy( hit, v2 );
- this._candidates.push( hit );
- this._candidatesMasks.push( selectorMask );
- } else if ( d1IsNegative && !d2IsNegative ) {
- //v1-(v2-v1)*(d1/(-d1+d2))) )
- vec3.sub( hit, v2, v1 );
- vec3.scale( hit, hit, d1 / ( -d1 + d2 ) );
- vec3.sub( hit, v1, hit );
- this._candidates.push( hit );
- this._candidatesMasks.push( selectorMask );
- } else if ( !d1IsNegative && d2IsNegative ) {
- //(v1+(v2-v1)*(d1/(d1-d2)))
- vec3.sub( hit, v2, v1 );
-
- vec3.scaleAndAdd( hit, v1, hit, d1 / ( d1 - d2 ) );
-
- this._candidates.push( hit );
- this._candidatesMasks.push( selectorMask );
- }
- }
-
- if ( insideMask === this._planesMask ) {
- this._candidates.push( vec3.clone( v1 ) );
- this._candidatesMasks.push( this._planesMask );
- this._candidates.push( vec3.clone( v2 ) );
- this._candidatesMasks.push( this._planesMask );
- this._intersections.push( new PolytopeIntersection( this._index, this._candidates, this._candidatesMasks, this._referencePlane, this._nodePath.slice( 0 ) ) );
- return;
- }
-
- var numCands = this.checkCandidatePoints( insideMask );
- if ( numCands > 0 ) {
- if ( v1Inside ) {
- this._candidatesMasks.push( this._planesMask );
- this._candidates.push( vec3.clone( v1 ) );
- }
- if ( v2Inside ) {
- this._candidatesMasks.push( this._planesMask );
- this._candidates.push( vec3.clone( v2 ) );
- }
- this._intersections.push( new PolytopeIntersection( this._index, this._candidates, this._candidatesMasks, this._referencePlane, this._nodePath.slice( 0 ) ) );
- }
- };
- } )(),
-
- intersectTriangle: ( function () {
-
- var tmpHit = vec3.create();
- // Only needed for special case, should we move it to a new function?
- var e1 = vec3.create();
- var e2 = vec3.create();
- var point = vec3.create();
- var p = vec3.create();
- var s = vec3.create();
- var q = vec3.create();
- return function ( v1, v2, v3 ) {
- this._index++;
- if ( ( this._dimensionMask & ( 1 << 2 ) ) === 0 ) return;
- if ( this._limitOneIntersection && this._intersections.length > 0 ) return;
- var selectorMask = 0x1;
- var insideMask = 0x0;
- this._candidates = [];
- this._candidatesMasks = [];
- var d1, d2, d3, d1IsNegative, d2IsNegative, d3IsNegative;
- for ( var i = 0, j = this._planes.length; i < j; ++i, selectorMask <<= 1 ) {
- d1 = this.distance( this._planes[ i ], v1 );
- d2 = this.distance( this._planes[ i ], v2 );
- d3 = this.distance( this._planes[ i ], v3 );
- d1IsNegative = ( d1 < 0.0 );
- d2IsNegative = ( d2 < 0.0 );
- d3IsNegative = ( d3 < 0.0 );
-
- if ( d1IsNegative && d2IsNegative && d3IsNegative ) return; // Triangle outside
- if ( !d1IsNegative && !d2IsNegative && !d3IsNegative ) {
- // completly inside this plane
- insideMask |= selectorMask;
- continue;
- }
- // edge v1-v2 intersects
- if ( d1 === 0.0 ) {
- vec3.copy( tmpHit, v1 );
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- } else if ( d2 === 0.0 ) {
- vec3.copy( tmpHit, v2 );
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- } else if ( d1IsNegative && !d2IsNegative ) {
- //v1-(v2-v1)*(d1/(-d1+d2))) )
- vec3.sub( tmpHit, v2, v1 );
- vec3.scale( tmpHit, tmpHit, d1 / ( -d1 + d2 ) );
- vec3.sub( tmpHit, v1, tmpHit );
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- } else if ( !d1IsNegative && d2IsNegative ) {
- //(v1+(v2-v1)*(d1/(d1-d2)))
- vec3.sub( tmpHit, v2, v1 );
-
- vec3.scaleAndAdd( tmpHit, v1, tmpHit, d1 / ( d1 - d2 ) );
-
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- }
- // edge v1-v3 intersects
- if ( d3 === 0.0 ) {
- vec3.copy( tmpHit, v3 );
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- } else if ( d1IsNegative && !d3IsNegative ) {
- // v1-(v3-v1)*(d1/(-d1+d3))
- vec3.sub( tmpHit, v3, v1 );
- vec3.scale( tmpHit, tmpHit, d1 / ( -d1 + d3 ) );
- vec3.sub( tmpHit, v1, tmpHit );
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- } else if ( !d1IsNegative && d3IsNegative ) {
- // v1+(v3-v1)*(d1/(d1-d3))
- vec3.sub( tmpHit, v3, v1 );
-
- vec3.scaleAndAdd( tmpHit, v1, tmpHit, d1 / ( d1 - d3 ) );
-
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- }
- // edge v2-v3 intersects
- if ( d2IsNegative && !d3IsNegative ) {
- // v2-(v3-v2)*(d2/(-d2+d3))
- vec3.sub( tmpHit, v3, v2 );
- vec3.scale( tmpHit, tmpHit, d2 / ( -d2 + d3 ) );
- vec3.sub( tmpHit, v2, tmpHit );
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- } else if ( !d2IsNegative && d3IsNegative ) {
- //v2+(v3-v2)*(d2/(d2-d3))
- vec3.sub( tmpHit, v3, v2 );
-
- vec3.scaleAndAdd( tmpHit, v2, tmpHit, d2 / ( d2 - d3 ) );
-
- this._candidates.push( vec3.clone( tmpHit ) );
- this._candidatesMasks.push( selectorMask );
- }
- }
- if ( insideMask === this._planesMask ) {
- // triangle lies inside of all planes
- this._candidates.push( vec3.clone( v1 ) );
- this._candidatesMasks.push( this._planesMask );
- this._candidates.push( vec3.clone( v2 ) );
- this._candidatesMasks.push( this._planesMask );
- this._candidates.push( vec3.clone( v3 ) );
- this._candidatesMasks.push( this._planesMask );
- this._intersections.push( new PolytopeIntersection( this._index, this._candidates, this._candidatesMasks, this._referencePlane, this._nodePath.slice( 0 ) ) );
- return;
- }
- var numCands = this.checkCandidatePoints( insideMask );
- if ( numCands > 0 ) {
- this._intersections.push( new PolytopeIntersection( this._index, this._candidates, this._candidatesMasks, this._referencePlane, this._nodePath.slice( 0 ) ) );
- return;
- }
- // handle case where the polytope goes through the triangle
- // without containing any point of it
- // Probably it can be moved to other function and do the relevant closures.
-
- var lines = this.getPolytopeLines();
- this._candidates = [];
- this._candidatesMasks = [];
- // check all polytope lines against the triangle
- // use algorithm from "Real-time rendering" (second edition) pp.580
- //var e1= vec3.create();
- //var e2= vec3.create();
-
- vec3.sub( e1, v2, v1 );
- vec3.sub( e2, v3, v1 );
- for ( i = 0; i < lines.length; ++i ) {
- //var point = vec3.create();
- //var p = vec3.create();
- vec3.cross( p, lines[ i ]._dir, e2 );
- var a = vec3.dot( e1, p );
- if ( Math.abs( a ) < 1E-6 ) continue;
- var f = 1.0 / a;
- //var s = vec3.create();
- vec3.sub( s, lines[ i ]._pos, v1 );
- var u = f * ( vec3.dot( s, p ) );
- if ( u < 0.0 || u > 1.0 ) continue;
- //var q = vec3.create();
- vec3.cross( q, s, e1 );
- var v = f * ( vec3.dot( lines[ i ]._dir, q ) );
- if ( v < 0.0 || u + v > 1.0 ) continue;
- var t = f * ( vec3.dot( e2, q ) );
-
- vec3.scaleAndAdd( point, lines[ i ]._pos, lines[ i ]._dir, t );
-
- this._candidates.push( vec3.copy( vec3.create(), point ) );
- this._candidatesMasks.push( lines[ i ]._planeMask );
- }
- numCands = this.checkCandidatePoints( insideMask );
- if ( numCands > 0 ) {
- this._intersections.push( new PolytopeIntersection( this._index, this._candidates, this._candidatesMasks, this._referencePlane, this._nodePath.slice( 0 ) ) );
- return;
- }
- };
- } )(),
-
- getPolytopeLines: ( function () {
- var lineDirection = vec3.create();
- var searchDirection = vec3.create();
- var normal1 = vec3.create();
- var point1 = vec3.create();
- var normal2 = vec3.create();
- var linePoint = vec3.create();
- var epsilon = 1E-6;
- return function () {
- if ( this._lines.length > 0 ) return this._lines; // Polytope lines already calculated
- var selectorMask = 0x1;
- for ( var i = 0, j = this._planes.length; i < j; i++, selectorMask <<= 1 ) {
- vec3.copy( normal1, this.getNormal( this._planes[ i ] ) );
- vec3.scale( point1, normal1, -this._planes[ i ][ 3 ] ); // canonical point on plane[ i ]
- var subSelectorMask = ( selectorMask << 1 );
- for ( var jt = i + 1, k = this._planes.length; jt < k; ++jt, subSelectorMask <<= 1 ) {
- vec3.copy( normal2, this.getNormal( this._planes[ jt ] ) );
- if ( Math.abs( vec3.dot( normal1, normal2 ) ) > ( 1.0 - epsilon ) ) continue;
- vec3.cross( lineDirection, normal1, normal2 );
- vec3.cross( searchDirection, lineDirection, normal1 );
- //-plane2.distance(point1)/(searchDirection*normal2);
- var searchDist = -this.distance( this._planes[ jt ], point1 ) / vec3.dot( searchDirection, normal2 );
- if ( osgMath.isNaN( searchDist ) ) continue;
-
- vec3.scaleAndAdd( linePoint, point1, searchDirection, searchDist );
-
- this._lines.push( new PlanesLine( selectorMask | subSelectorMask, vec3.clone( linePoint ), vec3.clone( lineDirection ) ) );
- }
- }
- return this._lines;
- };
- } )(),
-
- setLimitOneIntersection: function ( limit ) {
- this._limitOneIntersection = limit;
- },
-
- distance: function ( plane, v ) {
- var d = plane[ 0 ] * v[ 0 ] + plane[ 1 ] * v[ 1 ] + plane[ 2 ] * v[ 2 ] + plane[ 3 ];
- return d;
- },
-
- getNormal: ( function () {
- var normal = vec3.create();
- return function ( plane ) {
- normal[ 0 ] = plane[ 0 ];
- normal[ 1 ] = plane[ 1 ];
- normal[ 2 ] = plane[ 2 ];
- return normal;
- };
- } )()
-};
-
-module.exports = PolytopePrimitiveIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/SphereIntersector.js b/app/static/app/js/vendor/osgjs/osgUtil/SphereIntersector.js
deleted file mode 100644
index bd91ad7a..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/SphereIntersector.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict';
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var TriangleSphereIntersector = require( 'osgUtil/TriangleSphereIntersector' );
-
-
-var SphereIntersector = function () {
- this._center = vec3.create();
- this._iCenter = vec3.create();
- this._radius = 1.0;
- this._iRadius = 1.0;
- this._intersections = [];
-};
-
-SphereIntersector.prototype = {
- set: function ( center, radius ) {
- // we copy iCenter and iRadius in case setCurrentTransformation is never called
- vec3.copy( this._center, center );
- vec3.copy( this._iCenter, center );
- this._radius = this._iRadius = radius;
- this.reset();
- },
- setCenter: function ( center ) {
- vec3.copy( this._center, center );
- vec3.copy( this._iCenter, center );
- },
- setRadius: function ( radius ) {
- this._radius = this._iRadius = radius;
- },
- reset: function () {
- // Clear the intersections vector
- this._intersections.length = 0;
- },
- enter: function ( node ) {
- // Not working if culling disabled ??
- return !node.isCullingActive() || this.intersects( node.getBound() );
- },
- // Intersection Sphere/Sphere
- intersects: function ( bsphere ) {
- if ( !bsphere.valid() ) return false;
- var r = this._iRadius + bsphere.radius();
- return vec3.sqrDist( bsphere.center(), this._iCenter ) <= r * r;
- },
-
- intersect: ( function () {
-
- var ti = new TriangleSphereIntersector();
-
- return function ( iv, node ) {
-
- var kdtree = node.getShape();
- if ( kdtree )
- return kdtree.intersectSphere( this._iCenter, this._iRadius, this._intersections, iv.nodePath );
-
- ti.reset();
- ti.setNodePath( iv.nodePath );
- ti.set( this._iCenter, this._iRadius );
-
- // handle rig transformed vertices
- if ( node.computeTransformedVertices ) {
- var vList = node.getVertexAttributeList();
- var originVerts = vList.Vertex.getElements();
-
- // temporarily hook vertex buffer for the tri intersections
- // don't call setElements as it dirty some stuffs because of gl buffer
- vList.Vertex._elements = node.computeTransformedVertices();
- ti.apply( node );
- vList.Vertex._elements = originVerts;
- } else {
- ti.apply( node );
- }
-
- var l = ti._intersections.length;
- for ( var i = 0; i < l; i++ ) {
- this._intersections.push( ti._intersections[ i ] );
- }
-
- return l > 0;
- };
- } )(),
-
- getIntersections: function () {
- return this._intersections;
- },
-
- setCurrentTransformation: ( function () {
- var tmp = vec3.create();
-
- return function ( matrix ) {
- mat4.invert( matrix, matrix );
- vec3.transformMat4( this._iCenter, this._center, matrix );
- this._iRadius = this._radius * mat4.getScale( tmp, matrix )[ 0 ];
- };
- } )()
-};
-
-module.exports = SphereIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/TangentSpaceGenerator.js b/app/static/app/js/vendor/osgjs/osgUtil/TangentSpaceGenerator.js
deleted file mode 100644
index fbed0912..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/TangentSpaceGenerator.js
+++ /dev/null
@@ -1,272 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var BufferArray = require( 'osg/BufferArray' );
-var Geometry = require( 'osg/Geometry' );
-var NodeVisitor = require( 'osg/NodeVisitor' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-
-
-var osg = MACROUTILS;
-
-var TangentSpaceGenerator = function () {
- NodeVisitor.call( this );
- this._T = undefined;
- this._B = undefined;
- this._N = undefined;
- this._texCoordUnit = 0;
-};
-
-TangentSpaceGenerator.prototype = MACROUTILS.objectInherit( NodeVisitor.prototype, {
-
- apply: function ( node ) {
-
- if ( node.getTypeID() === Geometry.getTypeID() )
- this.generate( node, this._texCoordUnit );
- else
- this.traverse( node );
-
- },
-
- setTexCoordUnit: function ( texCoordUnit ) {
- this._texCoordUnit = texCoordUnit;
- },
-
- computePrimitiveSet: function ( geometry, primitiveSet ) {
-
- // no indices -> exit
- if ( !primitiveSet.getIndices )
- return;
-
- var numIndices = primitiveSet.getNumIndices();
-
- var vx = geometry.getAttributes().Vertex;
- var nx = geometry.getAttributes().Normal;
- var tx = geometry.getAttributes()[ 'TexCoord' + this._texCoordUnit ];
-
- var i;
-
- if ( primitiveSet.getMode() === PrimitiveSet.TRIANGLES ) {
-
- for ( i = 0; i < numIndices; i += 3 ) {
- this.compute( primitiveSet, vx, nx, tx, i, i + 1, i + 2 );
- }
-
- } else if ( primitiveSet.getMode() === PrimitiveSet.TRIANGLE_STRIP ) {
-
- for ( i = 0; i < numIndices - 2; ++i ) {
- if ( ( i % 2 ) === 0 ) {
- this.compute( primitiveSet, vx, nx, tx, i, i + 1, i + 2 );
- } else {
- this.compute( primitiveSet, vx, nx, tx, i + 1, i, i + 2 );
- }
- }
- }
-
- },
-
- generate: function ( geometry, texCoordUnit ) {
-
- this._texCoordUnit = texCoordUnit;
-
- if ( this._texCoordUnit === undefined )
- this._texCoordUnit = 0;
-
- var size = geometry.getAttributes().Vertex.getElements().length;
- this._T = new osg.Float32Array( size );
- this._B = new osg.Float32Array( size );
- this._N = new osg.Float32Array( size );
-
- geometry.getPrimitiveSetList().forEach( function ( primitiveSet ) {
-
- this.computePrimitiveSet( geometry, primitiveSet );
-
- }, this );
-
- var nbElements = size / 3;
- var tangents = new osg.Float32Array( nbElements * 4 );
-
- var tmp0 = vec3.create();
- var tmp1 = vec3.create();
- var t3 = vec3.create();
-
- for ( var i = 0; i < nbElements; i++ ) {
- var t = this._T.subarray( i * 3, i * 3 + 3 );
- var n = this._N.subarray( i * 3, i * 3 + 3 );
- var b = this._B.subarray( i * 3, i * 3 + 3 );
-
- vec3.normalize( n, n );
-
- // Gram-Schmidt orthogonalize
- // vec3 t3 = (t - n * (n * t));
- // t3.normalize();
- // finalTangent = Vec4(t3, 0.0);
- // Calculate handedness
- // finalTangent[3] = (((n ^ t) * b) < 0.0) ? -1.0 : 1.0;
- // The bitangent vector B is then given by B = (N × T) · Tw
-
- var nt = vec3.dot( n, t );
- vec3.scale( tmp1, n, nt );
- vec3.sub( tmp0, t, tmp1 );
- vec3.normalize( t3, tmp0 );
-
- vec3.cross( tmp0, n, t );
- var sign = vec3.dot( tmp0, b );
- sign = sign < 0.0 ? -1.0 : 0.0;
-
- // TODO perf : cache index var id = i * 4;
- tangents[ i * 4 ] = t3[ 0 ];
- tangents[ i * 4 + 1 ] = t3[ 1 ];
- tangents[ i * 4 + 2 ] = t3[ 2 ];
- tangents[ i * 4 + 3 ] = sign;
- }
-
- geometry.getAttributes().Normal.setElements( this._N );
- geometry.getAttributes().Tangent = new BufferArray( 'ARRAY_BUFFER', tangents, 4 );
-
- },
-
- compute: function ( primitiveSet, vx, nx, tx, ia, ib, ic ) {
-
- var i0 = primitiveSet.index( ia );
- var i1 = primitiveSet.index( ib );
- var i2 = primitiveSet.index( ic );
-
- // TODO perf : cache xx.getElements() but more importantly
- // subarray call have very high overhead, it's super useful
- // when you call it a few times for big array chunk, but for
- // small array extraction (each vertex) it's better to use a temporary
- // pre allocated array and simply fill it
- // then, you'll have to write in the big arrays at the end
- var P1 = vx.getElements().subarray( i0 * 3, i0 * 3 + 3 );
- var P2 = vx.getElements().subarray( i1 * 3, i1 * 3 + 3 );
- var P3 = vx.getElements().subarray( i2 * 3, i2 * 3 + 3 );
-
- var N1 = nx.getElements().subarray( i0 * 3, i0 * 3 + 3 );
- var N2 = nx.getElements().subarray( i1 * 3, i1 * 3 + 3 );
- var N3 = nx.getElements().subarray( i2 * 3, i2 * 3 + 3 );
-
- var uv1 = tx.getElements().subarray( i0 * 2, i0 * 2 + 2 );
- var uv2 = tx.getElements().subarray( i1 * 2, i1 * 2 + 2 );
- var uv3 = tx.getElements().subarray( i2 * 2, i2 * 2 + 2 );
-
- var vz, vy;
- // TODO perf : use temporary vec
- var V = vec3.create();
-
- var B1 = vec3.create();
- var B2 = vec3.create();
- var B3 = vec3.create();
-
- var T1 = vec3.create();
- var T2 = vec3.create();
- var T3 = vec3.create();
-
- var v1 = vec3.create();
- var v2 = vec3.create();
-
-
- vec3.set( v1, P2[ 0 ] - P1[ 0 ], uv2[ 0 ] - uv1[ 0 ], uv2[ 1 ] - uv1[ 1 ] );
- vec3.set( v2, P3[ 0 ] - P1[ 0 ], uv3[ 0 ] - uv1[ 0 ], uv3[ 1 ] - uv1[ 1 ] );
-
- vec3.cross( V, v1, v2 );
-
- if ( V[ 0 ] !== 0.0 ) {
- vec3.normalize( V, V );
- vy = -V[ 1 ] / V[ 0 ];
- vz = -V[ 2 ] / V[ 0 ];
- T1[ 0 ] += vy;
- B1[ 0 ] += vz;
- T2[ 0 ] += vy;
- B2[ 0 ] += vz;
- T3[ 0 ] += vy;
- B3[ 0 ] += vz;
- }
-
-
- vec3.set( v1, P2[ 1 ] - P1[ 1 ], uv2[ 0 ] - uv1[ 0 ], uv2[ 1 ] - uv1[ 1 ] );
- vec3.set( v2, P3[ 1 ] - P1[ 1 ], uv3[ 0 ] - uv1[ 0 ], uv3[ 1 ] - uv1[ 1 ] );
-
- vec3.cross( V, v1, v2 );
-
- if ( V[ 0 ] !== 0.0 ) {
- vec3.normalize( V, V );
- vy = -V[ 1 ] / V[ 0 ];
- vz = -V[ 2 ] / V[ 0 ];
- T1[ 1 ] += vy;
- B1[ 1 ] += vz;
- T2[ 1 ] += vy;
- B2[ 1 ] += vz;
- T3[ 1 ] += vy;
- B3[ 1 ] += vz;
- }
-
-
- vec3.set( v1, P2[ 2 ] - P1[ 2 ], uv2[ 0 ] - uv1[ 0 ], uv2[ 1 ] - uv1[ 1 ] );
- vec3.set( v2, P3[ 2 ] - P1[ 2 ], uv3[ 0 ] - uv1[ 0 ], uv3[ 1 ] - uv1[ 1 ] );
-
- vec3.cross( V, v1, v2 );
-
- if ( V[ 0 ] !== 0.0 ) {
- vec3.normalize( V, V );
- vy = -V[ 1 ] / V[ 0 ];
- vz = -V[ 2 ] / V[ 0 ];
- T1[ 2 ] += vy;
- B1[ 2 ] += vz;
- T2[ 2 ] += vy;
- B2[ 2 ] += vz;
- T3[ 2 ] += vy;
- B3[ 2 ] += vz;
- }
-
- var tempVec = vec3.create();
- var tempVec2 = vec3.create();
-
- var Tdst, Bdst, Ndst;
-
- vec3.cross( tempVec, N1, T1 );
- vec3.cross( tempVec2, tempVec, N1 );
- Tdst = this._T.subarray( i0 * 3, i0 * 3 + 3 );
- vec3.add( Tdst, tempVec2, Tdst );
-
- vec3.cross( tempVec, B1, N1 );
- vec3.cross( tempVec2, N1, tempVec );
- Bdst = this._B.subarray( i0 * 3, i0 * 3 + 3 );
- vec3.add( Bdst, tempVec2, Bdst );
-
-
- vec3.cross( tempVec, N2, T2 );
- vec3.cross( tempVec2, tempVec, N2 );
- Tdst = this._T.subarray( i1 * 3, i1 * 3 + 3 );
- vec3.add( Tdst, tempVec2, Tdst );
-
- vec3.cross( tempVec, B2, N2 );
- vec3.cross( tempVec2, N2, tempVec );
- Bdst = this._B.subarray( i1 * 3, i1 * 3 + 3 );
- vec3.add( Bdst, tempVec2, Bdst );
-
-
- vec3.cross( tempVec, N3, T3 );
- vec3.cross( tempVec2, tempVec, N3 );
- Tdst = this._T.subarray( i2 * 3, i2 * 3 + 3 );
- vec3.add( Tdst, tempVec2, Tdst );
-
- vec3.cross( tempVec, B3, N3 );
- vec3.cross( tempVec2, N3, tempVec );
- Bdst = this._B.subarray( i2 * 3, i2 * 3 + 3 );
- vec3.add( Bdst, tempVec2, Bdst );
-
-
- Ndst = this._N.subarray( i0 * 3, i0 * 3 + 3 );
- vec3.add( Ndst, N1, Ndst );
-
- Ndst = this._N.subarray( i1 * 3, i1 * 3 + 3 );
- vec3.add( Ndst, N2, Ndst );
-
- Ndst = this._N.subarray( i2 * 3, i2 * 3 + 3 );
- vec3.add( Ndst, N3, Ndst );
- }
-
-} );
-
-module.exports = TangentSpaceGenerator;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/TriangleIntersector.js b/app/static/app/js/vendor/osgjs/osgUtil/TriangleIntersector.js
deleted file mode 100644
index 4c6fb8e1..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/TriangleIntersector.js
+++ /dev/null
@@ -1,173 +0,0 @@
-'use strict';
-
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var TriangleIndexFunctor = require( 'osg/TriangleIndexFunctor' );
-var Notify = require( 'osg/notify' );
-var ComputeMatrixFromNodePath = require( 'osg/computeMatrixFromNodePath' );
-
-var TriangleIntersection = function ( normal, i1, i2, i3, r1, r2, r3 ) {
- this.normal = normal;
-
- this.i1 = i1;
- this.i2 = i2;
- this.i3 = i3;
-
- this.r1 = r1;
- this.r2 = r2;
- this.r3 = r3;
-};
-
-var TriangleIntersector = function () {
-
- if ( arguments && arguments.length ) {
- Notify.warn( 'using ctor as initialiser is deprecated, use set(start, end)' );
- }
-
- this._intersections = [];
- this._nodePath = [];
- this._dir = vec3.create();
-};
-
-TriangleIntersector.prototype = {
- reset: function () {
- this._intersections.length = 0;
- },
- setNodePath: function ( np ) {
- this._nodePath = np;
- },
- set: function ( start, end ) {
- this._start = start;
- this._end = end;
- this._dir = vec3.sub( this._dir, end, start );
- this._length = vec3.length( this._dir );
- this._invLength = 1.0 / this._length;
- vec3.scale( this._dir, this._dir, this._invLength );
- },
-
- apply: ( function () {
-
- var v1 = vec3.create();
- var v2 = vec3.create();
- var v3 = vec3.create();
- var tif = new TriangleIndexFunctor();
-
- return function ( node ) {
-
- if ( !node.getAttributes().Vertex ) {
- return;
- }
- var vertices = node.getAttributes().Vertex.getElements();
- var self = this;
-
- var cb = function ( i1, i2, i3 ) {
-
- if ( i1 === i2 || i1 === i3 || i2 === i3 )
- return;
-
- var j = i1 * 3;
- v1[ 0 ] = vertices[ j ];
- v1[ 1 ] = vertices[ j + 1 ];
- v1[ 2 ] = vertices[ j + 2 ];
-
- j = i2 * 3;
- v2[ 0 ] = vertices[ j ];
- v2[ 1 ] = vertices[ j + 1 ];
- v2[ 2 ] = vertices[ j + 2 ];
-
- j = i3 * 3;
- v3[ 0 ] = vertices[ j ];
- v3[ 1 ] = vertices[ j + 1 ];
- v3[ 2 ] = vertices[ j + 2 ];
-
- self.intersect( v1, v2, v3, i1, i2, i3 );
- };
- tif.init( node, cb );
- tif.apply();
-
- };
- } )(),
-
- isBackFace: ( function () {
-
- var mat = mat4.create();
-
- return function ( det, nodepath ) {
- mat4.identity( mat );
- // http://gamedev.stackexchange.com/questions/54505/negative-scale-in-matrix-4x4
- // https://en.wikipedia.org/wiki/Determinant#Orientation_of_a_basis
- // you can't exactly extract scale of a matrix but the determinant will tell you
- // if the orientation is preserved
- ComputeMatrixFromNodePath.computeLocalToWorld( nodepath, true, mat );
- var detMat = mat4.determinant( mat );
- return detMat * det < 0.0;
- };
-
- } )(),
-
- intersect: ( function () {
-
- var normal = vec3.create();
- var e2 = vec3.create();
- var e1 = vec3.create();
- var tvec = vec3.create();
- var pvec = vec3.create();
- var qvec = vec3.create();
- var epsilon = 1E-20;
-
- return function ( v0, v1, v2, i0, i1, i2 ) {
-
- var d = this._dir;
-
- vec3.sub( e2, v2, v0 );
- vec3.sub( e1, v1, v0 );
- vec3.cross( pvec, d, e2 );
-
- var det = vec3.dot( pvec, e1 );
- if ( det > -epsilon && det < epsilon )
- return;
- var invDet = 1.0 / det;
-
- vec3.sub( tvec, this._start, v0 );
-
- var u = vec3.dot( pvec, tvec ) * invDet;
- if ( u < 0.0 || u > 1.0 )
- return;
-
- vec3.cross( qvec, tvec, e1 );
-
- var v = vec3.dot( qvec, d ) * invDet;
- if ( v < 0.0 || ( u + v ) > 1.0 )
- return;
-
- var t = vec3.dot( qvec, e2 ) * invDet;
-
- if ( t < epsilon || t > this._length ) //no intersection
- return;
-
- var r0 = 1.0 - u - v;
- var r1 = u;
- var r2 = v;
- var r = t * this._invLength;
-
- var interX = v0[ 0 ] * r0 + v1[ 0 ] * r1 + v2[ 0 ] * r2;
- var interY = v0[ 1 ] * r0 + v1[ 1 ] * r1 + v2[ 1 ] * r2;
- var interZ = v0[ 2 ] * r0 + v1[ 2 ] * r1 + v2[ 2 ] * r2;
-
- vec3.cross( normal, e1, e2 );
- vec3.normalize( normal, normal );
-
- // GC TriangleIntersection & Point
- this._intersections.push( {
- ratio: r,
- backface: this.isBackFace( det, this._nodePath ),
- nodepath: this._nodePath.slice( 0 ), // Note: If you are computing intersections from a viewer the first node is the camera of the viewer
- TriangleIntersection: new TriangleIntersection( vec3.clone( normal ), i0, i1, i2, r0, r1, r2 ),
- point: vec3.fromValues( interX, interY, interZ )
- } );
- this.hit = true;
- };
- } )()
-};
-
-module.exports = TriangleIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/TriangleSphereIntersector.js b/app/static/app/js/vendor/osgjs/osgUtil/TriangleSphereIntersector.js
deleted file mode 100644
index 6d1576c8..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/TriangleSphereIntersector.js
+++ /dev/null
@@ -1,242 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var TriangleIntersector = require( 'osgUtil/TriangleIntersector' );
-var Notify = require( 'osg/notify' );
-
-var TriangleIntersection = function ( normal, i1, i2, i3 ) {
- this.normal = normal;
-
- this.i1 = i1;
- this.i2 = i2;
- this.i3 = i3;
-};
-
-var TriangleSphereIntersector = function () {
- TriangleIntersector.apply( this, arguments );
-
- if ( arguments && arguments.length ) {
- Notify.warn( 'using ctor as initialiser is deprecated, use set(center, radius)' );
- }
-};
-
-TriangleSphereIntersector.prototype = MACROUTILS.objectInherit( TriangleIntersector.prototype, {
- set: function ( center, radius ) {
- this._center = center;
- this._radius = radius;
- },
-
- //
- // \2|
- // \|
- // \
- // 3 |\ 1
- // |0\
- // __|__\___
- // 4 | 5 \ 6
- //
- // from http://www.geometrictools.com/Source/Distance3D.html#PointPlanar
- // js : https://github.com/stephomi/sculptgl/blob/master/src/math3d/Geometry.js#L89
- intersect: ( function () {
- var edge1 = vec3.create();
- var edge2 = vec3.create();
- var diff = vec3.create();
- return function ( v1, v2, v3, i1, i2, i3 ) {
-
- // sphere is a 'volume' here (so if the triangle is inside the ball it will intersects)
-
- vec3.sub( edge1, v2, v1 );
- vec3.sub( edge2, v3, v1 );
- var a00 = vec3.sqrLen( edge1 );
- var a01 = vec3.dot( edge1, edge2 );
- var a11 = vec3.sqrLen( edge2 );
-
- vec3.sub( diff, v1, this._center );
- var b0 = vec3.dot( diff, edge1 );
- var b1 = vec3.dot( diff, edge2 );
- var c = vec3.sqrLen( diff );
- var det = Math.abs( a00 * a11 - a01 * a01 );
- if ( det < 1e-10 )
- return;
-
- var s = a01 * b1 - a11 * b0;
- var t = a01 * b0 - a00 * b1;
- var sqrDistance;
- var zone = 4;
-
- if ( s + t <= det ) {
- if ( s < 0.0 ) {
- if ( t < 0.0 ) { // region 4
- zone = 4;
- if ( b0 < 0.0 ) {
- t = 0.0;
- if ( -b0 >= a00 ) {
- s = 1.0;
- sqrDistance = a00 + 2.0 * b0 + c;
- } else {
- s = -b0 / a00;
- sqrDistance = b0 * s + c;
- }
- } else {
- s = 0.0;
- if ( b1 >= 0.0 ) {
- t = 0.0;
- sqrDistance = c;
- } else if ( -b1 >= a11 ) {
- t = 1.0;
- sqrDistance = a11 + 2.0 * b1 + c;
- } else {
- t = -b1 / a11;
- sqrDistance = b1 * t + c;
- }
- }
- } else { // region 3
- zone = 3;
- s = 0.0;
- if ( b1 >= 0.0 ) {
- t = 0.0;
- sqrDistance = c;
- } else if ( -b1 >= a11 ) {
- t = 1.0;
- sqrDistance = a11 + 2.0 * b1 + c;
- } else {
- t = -b1 / a11;
- sqrDistance = b1 * t + c;
- }
- }
- } else if ( t < 0.0 ) { // region 5
- zone = 5;
- t = 0.0;
- if ( b0 >= 0.0 ) {
- s = 0.0;
- sqrDistance = c;
- } else if ( -b0 >= a00 ) {
- s = 1.0;
- sqrDistance = a00 + 2.0 * b0 + c;
- } else {
- s = -b0 / a00;
- sqrDistance = b0 * s + c;
- }
- } else { // region 0
- zone = 0;
- // minimum at interior point
- var invDet = 1.0 / det;
- s *= invDet;
- t *= invDet;
- sqrDistance = s * ( a00 * s + a01 * t + 2.0 * b0 ) + t * ( a01 * s + a11 * t + 2.0 * b1 ) + c;
- }
- } else {
- var tmp0, tmp1, numer, denom;
-
- if ( s < 0.0 ) { // region 2
- zone = 2;
- tmp0 = a01 + b0;
- tmp1 = a11 + b1;
- if ( tmp1 > tmp0 ) {
- numer = tmp1 - tmp0;
- denom = a00 - 2.0 * a01 + a11;
- if ( numer >= denom ) {
- s = 1.0;
- t = 0.0;
- sqrDistance = a00 + 2.0 * b0 + c;
- } else {
- s = numer / denom;
- t = 1.0 - s;
- sqrDistance = s * ( a00 * s + a01 * t + 2.0 * b0 ) + t * ( a01 * s + a11 * t + 2.0 * b1 ) + c;
- }
- } else {
- s = 0.0;
- if ( tmp1 <= 0.0 ) {
- t = 1.0;
- sqrDistance = a11 + 2.0 * b1 + c;
- } else if ( b1 >= 0.0 ) {
- t = 0.0;
- sqrDistance = c;
- } else {
- t = -b1 / a11;
- sqrDistance = b1 * t + c;
- }
- }
- } else if ( t < 0.0 ) { // region 6
- zone = 6;
- tmp0 = a01 + b1;
- tmp1 = a00 + b0;
- if ( tmp1 > tmp0 ) {
- numer = tmp1 - tmp0;
- denom = a00 - 2.0 * a01 + a11;
- if ( numer >= denom ) {
- t = 1.0;
- s = 0.0;
- sqrDistance = a11 + 2.0 * b1 + c;
- } else {
- t = numer / denom;
- s = 1.0 - t;
- sqrDistance = s * ( a00 * s + a01 * t + 2.0 * b0 ) + t * ( a01 * s + a11 * t + 2.0 * b1 ) + c;
- }
- } else {
- t = 0.0;
- if ( tmp1 <= 0.0 ) {
- s = 1.0;
- sqrDistance = a00 + 2.0 * b0 + c;
- } else if ( b0 >= 0.0 ) {
- s = 0.0;
- sqrDistance = c;
- } else {
- s = -b0 / a00;
- sqrDistance = b0 * s + c;
- }
- }
- } else { // region 1
- zone = 1;
- numer = a11 + b1 - a01 - b0;
- if ( numer <= 0.0 ) {
- s = 0.0;
- t = 1.0;
- sqrDistance = a11 + 2.0 * b1 + c;
- } else {
- denom = a00 - 2.0 * a01 + a11;
- if ( numer >= denom ) {
- s = 1.0;
- t = 0.0;
- sqrDistance = a00 + 2.0 * b0 + c;
- } else {
- s = numer / denom;
- t = 1.0 - s;
- sqrDistance = s * ( a00 * s + a01 * t + 2.0 * b0 ) + t * ( a01 * s + a11 * t + 2.0 * b1 ) + c;
- }
- }
- }
- }
-
- // Account for numerical round-off error.
- if ( sqrDistance < 0.0 )
- sqrDistance = 0.0;
-
- if ( sqrDistance > ( this._radius * this._radius ) )
- return;
-
- var closest = vec3.create();
- if ( closest ) {
- closest[ 0 ] = v1[ 0 ] + s * edge1[ 0 ] + t * edge2[ 0 ];
- closest[ 1 ] = v1[ 1 ] + s * edge1[ 1 ] + t * edge2[ 1 ];
- closest[ 2 ] = v1[ 2 ] + s * edge1[ 2 ] + t * edge2[ 2 ];
- }
-
- var normal = vec3.create();
- vec3.cross( normal, edge1, edge2 );
- vec3.normalize( normal, normal );
-
- // TODO: gc TriangleIntersection, closest, normal ? (stack pool)
- this._intersections.push( {
- ratio: Math.sqrt( sqrDistance ),
- nodepath: this._nodePath.slice( 0 ),
- TriangleIntersection: new TriangleIntersection( normal, i1, i2, i3 ),
- point: closest,
- zone: zone
- } );
- this.hit = true;
- };
- } )()
-} );
-
-module.exports = TriangleSphereIntersector;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/WebVR.js b/app/static/app/js/vendor/osgjs/osgUtil/WebVR.js
deleted file mode 100644
index 05003bab..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/WebVR.js
+++ /dev/null
@@ -1,146 +0,0 @@
-'use strict';
-var Camera = require( 'osg/Camera' );
-var FrameBufferObject = require( 'osg/FrameBufferObject' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Node = require( 'osg/Node' );
-var Program = require( 'osg/Program' );
-var Shader = require( 'osg/Shader' );
-var Shape = require( 'osg/shape' );
-var Texture = require( 'osg/Texture' );
-var Transform = require( 'osg/Transform' );
-var Uniform = require( 'osg/Uniform' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var Viewport = require( 'osg/Viewport' );
-var Composer = require( 'osgUtil/Composer' );
-
-
-var UpdateRttCameraCallback = function ( rootView, offsetView ) {
- this._rootView = rootView;
- this._offsetView = offsetView;
-};
-
-UpdateRttCameraCallback.prototype = {
- update: function ( node /*, nv */ ) {
- var nodeView = node.getViewMatrix();
- mat4.mul( nodeView, this._offsetView, this._rootView );
- return true;
- }
-};
-
-var createTexture = function ( size ) {
- var texture = new Texture();
- texture.setTextureSize( size.width, size.height );
- texture.setMinFilter( 'LINEAR' );
- texture.setMagFilter( 'LINEAR' );
- return texture;
-};
-
-var getAssembleShader = function () {
-
- var fragmentShader = [
- '#ifdef GL_ES',
- ' precision highp float;',
- '#endif',
- 'varying vec2 vTexCoord0;',
- 'uniform sampler2D TextureLeft;',
- 'uniform sampler2D TextureRight;',
-
- 'void main() {',
- ' if (vTexCoord0.x < 0.5)',
- ' gl_FragColor = texture2D(TextureLeft, vec2(vTexCoord0.x * 2.0, vTexCoord0.y));',
- ' else',
- ' gl_FragColor = texture2D(TextureRight, vec2(vTexCoord0.x * 2.0 - 1.0, vTexCoord0.y));',
- '}',
- ].join( '\n' );
-
- return new Program(
- new Shader( Shader.VERTEX_SHADER, Composer.Filter.defaultVertexShader ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentShader )
- );
-};
-
-// This camera will render both textures on the canvas in a single pass
-var createCameraCanvas = function ( leftEyeTexture, rightEyeTexture, viewport ) {
-
- var orthoCamera = new Camera();
- orthoCamera.setViewport( viewport );
- orthoCamera.setRenderOrder( Camera.NESTED_RENDER, 0 );
- orthoCamera.setReferenceFrame( Transform.ABSOLUTE_RF );
- mat4.ortho( orthoCamera.getProjectionMatrix(), 0.0, 1.0, 0.0, 1.0, -5.0, 5.0 );
-
- var stateSet = orthoCamera.getOrCreateStateSet();
- stateSet.addUniform( Uniform.createInt( 0, 'TextureLeft' ) );
- stateSet.addUniform( Uniform.createInt( 1, 'TextureRight' ) );
- stateSet.setTextureAttributeAndModes( 0, leftEyeTexture );
- stateSet.setTextureAttributeAndModes( 1, rightEyeTexture );
- stateSet.setAttributeAndModes( getAssembleShader() );
-
- orthoCamera.addChild( Shape.createTexturedFullScreenFakeQuadGeometry() );
-
- return orthoCamera;
-};
-
-// This camera will render the scene on a texture for an eye
-var createCameraRtt = function ( texture, projection ) {
- var camera = new Camera();
- camera.setName( 'rtt camera' );
- camera.setViewport( new Viewport( 0.0, 0.0, texture.getWidth(), texture.getHeight() ) );
- camera.setProjectionMatrix( projection );
- camera.setClearColor( vec4.fromValues( 0.3, 0.3, 0.3, 0.0 ) );
- camera.setRenderOrder( Camera.POST_RENDER, 0 );
- camera.attachTexture( FrameBufferObject.COLOR_ATTACHMENT0, texture );
- camera.attachRenderBuffer( FrameBufferObject.DEPTH_ATTACHMENT, FrameBufferObject.DEPTH_COMPONENT16 );
- camera.setReferenceFrame( Transform.ABSOLUTE_RF );
- return camera;
-};
-
-var WebVR = {};
-
-WebVR.createScene = function ( viewer, rttScene, HMDdevice, rootOverride, worldFactorOverride ) {
-
- var root = rootOverride || new Node();
- var worldFactor = worldFactorOverride !== undefined ? worldFactorOverride : 1.0;
-
- var left = HMDdevice.getEyeParameters( 'left' );
- var right = HMDdevice.getEyeParameters( 'right' );
-
- var frameData = new window.VRFrameData();
- HMDdevice.getFrameData( frameData );
-
- // Compute projections and view matrices for both eyes
- var viewLeft = mat4.fromTranslation( mat4.create(), vec3.fromValues( -worldFactor * left.offset[ 0 ], left.offset[ 1 ], left.offset[ 2 ] ) );
- var viewRight = mat4.fromTranslation( mat4.create(), vec3.fromValues( -worldFactor * right.offset[ 0 ], right.offset[ 1 ], right.offset[ 2 ] ) );
-
- // Each eye is rendered on a texture whose width is half of the final combined texture
- var eyeTextureSize = {
- width: Math.max( left.renderWidth, right.renderWidth ),
- height: Math.max( left.renderHeight, right.renderHeight )
- };
-
- var leftEyeTexture = createTexture( eyeTextureSize );
- var rightEyeTexture = createTexture( eyeTextureSize );
-
- // Setup the render cameras for both eyes
- var camRttLeft = createCameraRtt( leftEyeTexture, frameData.leftProjectionMatrix );
- var camRttRight = createCameraRtt( rightEyeTexture, frameData.rightProjectionMatrix );
-
- // The viewMatrix of each eye is updated with the current viewer's camera viewMatrix
- var rootViewMatrix = viewer.getCamera().getViewMatrix();
- camRttLeft.addUpdateCallback( new UpdateRttCameraCallback( rootViewMatrix, viewLeft ) );
- camRttRight.addUpdateCallback( new UpdateRttCameraCallback( rootViewMatrix, viewRight ) );
-
- // Render both textures on the canvas, using the viewer's camera viewport to render on the fullscreen canvas
- var camCanvas = createCameraCanvas( leftEyeTexture, rightEyeTexture, viewer.getCamera().getViewport() );
-
- camRttLeft.addChild( rttScene );
- camRttRight.addChild( rttScene );
-
- root.addChild( camRttLeft );
- root.addChild( camRttRight );
- root.addChild( camCanvas );
-
- return root;
-};
-
-module.exports = WebVR;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/WebVRCustom.js b/app/static/app/js/vendor/osgjs/osgUtil/WebVRCustom.js
deleted file mode 100644
index 0fbae8a0..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/WebVRCustom.js
+++ /dev/null
@@ -1,291 +0,0 @@
-'use strict';
-var Camera = require( 'osg/Camera' );
-var FrameBufferObject = require( 'osg/FrameBufferObject' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Node = require( 'osg/Node' );
-var Program = require( 'osg/Program' );
-var Shader = require( 'osg/Shader' );
-var Shape = require( 'osg/shape' );
-var Texture = require( 'osg/Texture' );
-var Transform = require( 'osg/Transform' );
-var Uniform = require( 'osg/Uniform' );
-var vec2 = require( 'osg/glMatrix' ).vec2;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var Viewport = require( 'osg/Viewport' );
-var Composer = require( 'osgUtil/Composer' );
-
-
-var WebVRCustom = {};
-
-// no smart resize, we just recreate everything
-var UpdateRecreateOnResize = function ( viewer, rttScene, hmdConfig, root, canvas ) {
- this._viewer = viewer;
- this._rttScene = rttScene;
- this._hmdConfig = hmdConfig;
- this._root = root;
- this._canvas = canvas;
- this._width = canvas.width;
- this._height = canvas.height;
-};
-
-UpdateRecreateOnResize.prototype = {
- update: function () {
- var canvas = this._canvas;
- var width = canvas.width;
- var height = canvas.height;
-
- if ( width !== this._width || height !== this._height ) {
- this._root.removeChildren();
-
- var hmdConfig = this._hmdConfig;
- if ( hmdConfig && hmdConfig.isCardboard ) {
- hmdConfig.hResolution = width;
- hmdConfig.vResolution = height;
- }
- this._width = width;
- this._height = height;
-
- WebVRCustom.createScene( this._viewer, this._rttScene, hmdConfig, this._root );
- }
- return true;
- }
-};
-
-var UpdateOffsetCamera = function ( rootView, offsetView ) {
- this._rootView = rootView;
- this._offsetView = offsetView;
-};
-
-UpdateOffsetCamera.prototype = {
- update: function ( node ) {
- var nodeView = node.getViewMatrix();
- mat4.mul( nodeView, this._offsetView, this._rootView );
- return true;
- }
-};
-
-var setupWebVR = function ( worldFactor, HMD, webVRUniforms, webVRMatrices ) {
-
- var aspect = HMD.hResolution / ( 2.0 * HMD.vResolution );
- var r = -1.0 - ( 4.0 * ( HMD.hScreenSize * 0.25 - HMD.lensSeparationDistance * 0.5 ) / HMD.hScreenSize );
- var distScale = ( HMD.distortionK[ 0 ] + HMD.distortionK[ 1 ] * Math.pow( r, 2 ) + HMD.distortionK[ 2 ] * Math.pow( r, 4 ) + HMD.distortionK[ 3 ] * Math.pow( r, 6 ) );
- var fov = ( 180.0 / Math.PI ) * 2.0 * Math.atan2( HMD.vScreenSize * distScale, 2.0 * HMD.eyeToScreenDistance );
-
- var proj = mat4.perspective( mat4.create(), Math.PI / 180 * fov, aspect, 0.3, 10000.0 );
-
- var hOffset = 4.0 * ( HMD.hScreenSize * 0.25 - HMD.interpupillaryDistance * 0.5 ) / HMD.hScreenSize;
- var lensShift = 4.0 * ( HMD.hScreenSize * 0.25 - HMD.lensSeparationDistance * 0.5 ) / HMD.hScreenSize;
-
- var leftMat = mat4.create();
- var rightMat = mat4.create();
- webVRMatrices.projectionLeft = mat4.mul( leftMat, mat4.fromTranslation( leftMat, vec3.fromValues( hOffset, 0.0, 0.0 ) ), proj );
- webVRMatrices.projectionRight = mat4.mul( rightMat, mat4.fromTranslation( rightMat, vec3.fromValues( -hOffset, 0.0, 0.0 ) ), proj );
- webVRMatrices.viewLeft = mat4.fromTranslation( mat4.create(), vec3.fromValues( worldFactor * HMD.interpupillaryDistance * 0.5, 0.0, 0.0 ) );
- webVRMatrices.viewRight = mat4.fromTranslation( mat4.create(), vec3.fromValues( -worldFactor * HMD.interpupillaryDistance * 0.5, 0.0, 0.0 ) );
-
- webVRUniforms.lensCenterLeft = vec2.fromValues( lensShift, 0.0 );
- webVRUniforms.lensCenterRight = vec2.fromValues( -lensShift, 0.0 );
- webVRUniforms.hmdWarpParam = HMD.distortionK;
- webVRUniforms.chromAbParam = HMD.chromaAbParameter;
- webVRUniforms.scaleIn = vec2.fromValues( 1.0, 1.0 / aspect );
- webVRUniforms.scale = vec2.fromValues( 1.0 / distScale, 1.0 * aspect / distScale );
-};
-
-var getWebVRShader = function () {
-
- var fragmentshader = [
- '',
- '#ifdef GL_ES',
- 'precision highp float;',
- '#endif',
-
- 'uniform vec2 uScale;',
- 'uniform vec2 uScaleIn;',
- 'uniform vec2 uLensCenter;',
- 'uniform vec4 uHmdWarpParam;',
- 'uniform vec4 uChromAbParam;',
- 'uniform sampler2D Texture0;',
-
- 'varying vec2 vTexCoord0;',
-
- // from http://paradise.untergrund.net/tmp/demoshit/examples/js/effects/OculusRiftEffect.js
- 'void main(void) {',
- ' vec2 uv = (vTexCoord0 * 2.0) - 1.0;', // range from [0,1] to [-1,1]
- ' vec2 theta = (uv - uLensCenter) * uScaleIn;',
- ' float rSq = theta.x * theta.x + theta.y * theta.y;',
- ' vec2 rvector = theta * (uHmdWarpParam.x + uHmdWarpParam.y * rSq + uHmdWarpParam.z * rSq * rSq + uHmdWarpParam.w * rSq * rSq * rSq);',
- ' vec2 rBlue = rvector * (uChromAbParam.z + uChromAbParam.w * rSq);',
- ' vec2 tcBlue = (uLensCenter + uScale * rBlue);',
- ' tcBlue = (tcBlue + 1.0) * 0.5;', // range from [-1,1] to [0,1]
- ' if (any(bvec2(clamp(tcBlue, vec2(0.0, 0.0), vec2(1.0, 1.0)) - tcBlue))) {',
- ' gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);',
- ' return;',
- ' }',
- ' vec2 tcGreen = uLensCenter + uScale * rvector;',
- ' tcGreen = (tcGreen + 1.0) * 0.5;', // range from [-1,1] to [0,1]
- ' vec2 rRed = rvector * (uChromAbParam.x + uChromAbParam.y * rSq);',
- ' vec2 tcRed = uLensCenter + uScale * rRed;',
- ' tcRed = (tcRed + 1.0) * 0.5;', // range from [-1,1] to [0,1]
- ' gl_FragColor = vec4(texture2D(Texture0, tcRed).r, texture2D(Texture0, tcGreen).g, texture2D(Texture0, tcBlue).b, 1);',
- '}',
- ''
- ].join( '\n' );
-
- return new Program(
- new Shader( Shader.VERTEX_SHADER, Composer.Filter.defaultVertexShader ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentshader ) );
-};
-
-var createTextureRtt = function ( rttSize ) {
- var rttTexture = new Texture();
- rttTexture.setTextureSize( rttSize[ 0 ], rttSize[ 1 ] );
- rttTexture.setMinFilter( 'LINEAR' );
- rttTexture.setMagFilter( 'LINEAR' );
- return rttTexture;
-};
-
-var createOrthoRtt = function ( left, viewportSize, canvasSize, cardboard, texture, webVRUniforms ) {
- var orthoCamera = new Camera();
- var vw = viewportSize[ 0 ];
- var vh = viewportSize[ 1 ];
- var cw = canvasSize[ 0 ];
- var ch = canvasSize[ 1 ];
- if ( cardboard === true ) {
- if ( left )
- orthoCamera.setViewport( new Viewport( 0.0, 0.0, cw / 2.0, ch ) );
- else
- orthoCamera.setViewport( new Viewport( cw / 2.0, 0.0, cw / 2.0, ch ) );
- } else {
- if ( left )
- orthoCamera.setViewport( new Viewport( 0.5 * cw - vw, 0.5 * ( ch - vh ), vw, vh ) );
- else
- orthoCamera.setViewport( new Viewport( 0.5 * cw, 0.5 * ( ch - vh ), vw, vh ) );
- }
- mat4.ortho( orthoCamera.getProjectionMatrix(), -0.5, 0.5, -0.5, 0.5, -5, 5 );
- orthoCamera.setRenderOrder( Camera.NESTED_RENDER, 0 );
- orthoCamera.setReferenceFrame( Transform.ABSOLUTE_RF );
-
- var stateSet = orthoCamera.getOrCreateStateSet();
- stateSet.setTextureAttributeAndModes( 0, texture );
- stateSet.setAttributeAndModes( getWebVRShader() );
- stateSet.addUniform( Uniform.createFloat2( webVRUniforms.scale, 'uScale' ) );
- stateSet.addUniform( Uniform.createFloat2( webVRUniforms.scaleIn, 'uScaleIn' ) );
- stateSet.addUniform( Uniform.createFloat2( left ? webVRUniforms.lensCenterLeft : webVRUniforms.lensCenterRight, 'uLensCenter' ) );
- stateSet.addUniform( Uniform.createFloat4( webVRUniforms.hmdWarpParam, 'uHmdWarpParam' ) );
- stateSet.addUniform( Uniform.createFloat4( webVRUniforms.chromAbParam, 'uChromAbParam' ) );
-
- return orthoCamera;
-};
-
-var createCameraRtt = function ( texture, projMatrix ) {
- var camera = new Camera();
- camera.setName( 'rtt camera' );
- camera.setViewport( new Viewport( 0, 0, texture.getWidth(), texture.getHeight() ) );
- camera.setProjectionMatrix( projMatrix );
- camera.setClearColor( vec4.fromValues( 0.3, 0.3, 0.3, 0.0 ) );
- camera.setRenderOrder( Camera.POST_RENDER, 0 );
- camera.attachTexture( FrameBufferObject.COLOR_ATTACHMENT0, texture );
- camera.attachRenderBuffer( FrameBufferObject.DEPTH_ATTACHMENT, FrameBufferObject.DEPTH_COMPONENT16 );
- camera.setReferenceFrame( Transform.ABSOLUTE_RF );
- return camera;
-};
-
-WebVRCustom.createScene = function ( viewer, rttScene, HMDconfig, rootOverride, worldFactorOverride ) {
- var HMD = WebVRCustom.getDefaultConfig( HMDconfig );
- var rttSize = vec2.fromValues( HMD.hResolution * 0.5, HMD.vResolution );
- var viewportSize = vec2.fromValues( HMD.hResolution * 0.5, HMD.vResolution );
- var vp = viewer.getCamera().getViewport();
- var canvasSize = vec2.fromValues( vp.width(), vp.height() );
-
- var canvas = viewer.getGraphicContext().canvas;
- if ( HMD.isCardboard ) {
- canvasSize[ 0 ] = canvas.width;
- canvasSize[ 1 ] = canvas.height;
- }
-
- var worldFactor = worldFactorOverride !== undefined ? worldFactorOverride : 1.0;
- var webVRUniforms = {};
- var webVRMatrices = {};
- setupWebVR( worldFactor, HMD, webVRUniforms, webVRMatrices );
-
- var rootViewMatrix = viewer.getCamera().getViewMatrix();
-
- var root = rootOverride || new Node();
- root.addUpdateCallback( new UpdateRecreateOnResize( viewer, rttScene, HMDconfig, root, canvas ) );
-
- var rttTextureLeft = createTextureRtt( rttSize );
- var rttCamLeft = createCameraRtt( rttTextureLeft, webVRMatrices.projectionLeft );
- var orthoCameraLeft = createOrthoRtt( true, viewportSize, canvasSize, HMD.isCardboard, rttTextureLeft, webVRUniforms );
- rttCamLeft.addUpdateCallback( new UpdateOffsetCamera( rootViewMatrix, webVRMatrices.viewLeft ) );
-
- var rttTextureRight = createTextureRtt( rttSize );
- var rttCamRight = createCameraRtt( rttTextureRight, webVRMatrices.projectionRight );
- var orthoCameraRight = createOrthoRtt( false, viewportSize, canvasSize, HMD.isCardboard, rttTextureRight, webVRUniforms );
- rttCamRight.addUpdateCallback( new UpdateOffsetCamera( rootViewMatrix, webVRMatrices.viewRight ) );
-
- rttCamLeft.addChild( rttScene );
- rttCamRight.addChild( rttScene );
-
- orthoCameraLeft.addChild( Shape.createTexturedFullScreenFakeQuadGeometry() );
- orthoCameraRight.addChild( Shape.createTexturedFullScreenFakeQuadGeometry() );
-
- root.addChild( rttCamLeft );
- root.addChild( rttCamRight );
-
-
- root.addChild( orthoCameraLeft );
- root.addChild( orthoCameraRight );
-
- return root;
-};
-
-WebVRCustom.getDefaultConfig = function ( hmdConfig ) {
- // FOV: 103.506416
- // vScreenCenter: 0.03645
-
- // Oculus Rift DK2
- var hmd = {
- hResolution: 1920,
- vResolution: 1080,
- hScreenSize: 0.1296,
- vScreenSize: 0.0729,
- interpupillaryDistance: 0.064,
- lensSeparationDistance: 0.0635,
- eyeToScreenDistance: 0.04,
- distortionK: vec4.fromValues( 1.0, 0.22, 0.13, 0.02 ),
- chromaAbParameter: vec4.fromValues( 0.996, -0.004, 1.014, 0.0 ),
- isCardboard: false
- };
-
- if ( hmdConfig === 2 || hmdConfig === undefined )
- return hmd;
-
- if ( hmdConfig === 1 ) {
- // Oculus Rift DK1
- hmd.hResolution = 1280;
- hmd.vResolution = 800;
- hmd.hScreenSize = 0.14976;
- hmd.vScreenSize = 0.0936;
- hmd.lensSeparationDistance = 0.064;
- hmd.eyeToScreenDistance = 0.041;
- hmd.distortionK = vec4.fromValues( 1.0, 0.22, 0.24, 0.0 );
- return hmd;
- }
-
- // custom param
- if ( hmdConfig.hResolution !== undefined ) hmd.hResolution = hmdConfig.hResolution;
- if ( hmdConfig.vResolution !== undefined ) hmd.vResolution = hmdConfig.vResolution;
- if ( hmdConfig.hScreenSize !== undefined ) hmd.hScreenSize = hmdConfig.hScreenSize;
- if ( hmdConfig.vScreenSize !== undefined ) hmd.vScreenSize = hmdConfig.vScreenSize;
- if ( hmdConfig.interpupillaryDistance !== undefined ) hmd.interpupillaryDistance = hmdConfig.interpupillaryDistance;
- if ( hmdConfig.lensSeparationDistance !== undefined ) hmd.lensSeparationDistance = hmdConfig.lensSeparationDistance;
- if ( hmdConfig.eyeToScreenDistance !== undefined ) hmd.eyeToScreenDistance = hmdConfig.eyeToScreenDistance;
- if ( hmdConfig.distortionK !== undefined ) hmd.distortionK = hmdConfig.distortionK;
- if ( hmdConfig.chromaAbParameter !== undefined ) hmd.chromaAbParameter = hmdConfig.chromaAbParameter;
- if ( hmdConfig.isCardboard !== undefined ) hmd.isCardboard = hmdConfig.isCardboard;
-
- return hmd;
-};
-
-module.exports = WebVRCustom;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/debug.js b/app/static/app/js/vendor/osgjs/osgUtil/debug.js
deleted file mode 100644
index 61135200..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/debug.js
+++ /dev/null
@@ -1,91 +0,0 @@
-'use strict';
-var Shape = require( 'osg/shape' );
-
-/*
- * Given a Camera, update a wireframe representation of its
- * view frustum from a projection and depthrange
- * @param Geomtry g frustum geometry
- * @param Matrix proj Projection
- * @param Vec2 dR depthRange (optional, only if proj is infinite)
- */
-var updateFrustum = function ( proj, dR ) {
-
- var near, far;
- if ( !dR ) {
-
- // Get near and far from the Projection matrix.
- near = proj[ 14 ] / ( proj[ 10 ] - 1.0 );
- far = proj[ 14 ] / ( 1.0 + proj[ 10 ] );
-
- } else {
- near = dR[ 0 ];
- far = dR[ 1 ];
- }
-
- // Get the sides of the near plane.
- var nLeft = near * ( proj[ 8 ] - 1.0 ) / proj[ 0 ];
- var nRight = near * ( 1.0 + proj[ 8 ] ) / proj[ 0 ];
- var nTop = near * ( 1.0 + proj[ 9 ] ) / proj[ 5 ];
- var nBottom = near * ( proj[ 9 ] - 1.0 ) / proj[ 5 ];
-
- // Get the sides of the far plane.
- var fLeft = far * ( proj[ 8 ] - 1.0 ) / proj[ 0 ];
- var fRight = far * ( 1.0 + proj[ 8 ] ) / proj[ 0 ];
- var fTop = far * ( 1.0 + proj[ 9 ] ) / proj[ 5 ];
- var fBottom = far * ( proj[ 9 ] - 1.0 ) / proj[ 5 ];
-
- var vBuff = this.getAttributes().Vertex;
- var v = vBuff.getElements();
-
- // eight corners of the near and far planes.
- v[ 0 ] = nLeft;
- v[ 1 ] = nBottom;
- v[ 2 ] = -near;
-
- v[ 3 ] = nRight;
- v[ 4 ] = nBottom;
- v[ 5 ] = -near;
-
-
- v[ 6 ] = nRight;
- v[ 7 ] = nTop;
- v[ 8 ] = -near;
-
- v[ 9 ] = nLeft;
- v[ 10 ] = nTop;
- v[ 11 ] = -near;
-
- v[ 12 ] = fLeft;
- v[ 13 ] = fBottom;
- v[ 14 ] = -far;
-
- v[ 15 ] = fRight;
- v[ 16 ] = fBottom;
- v[ 17 ] = -far;
-
- v[ 18 ] = fRight;
- v[ 19 ] = fTop;
- v[ 20 ] = -far;
-
- v[ 21 ] = fLeft;
- v[ 22 ] = fTop;
- v[ 23 ] = -far;
-
- vBuff.dirty();
-
-};
-/*
- * Given a Camera, create a wireframe representation
- * of its view frustum
- */
-var createDebugFrustrumGeometry = function () {
-
- var g = Shape.createBoundingBoxGeometry();
- g.updateGeometry = updateFrustum;
- return g;
-
-};
-
-module.exports = {
- createDebugFrustumGeometry: createDebugFrustrumGeometry
-};
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/gizmoGeometry.js b/app/static/app/js/vendor/osgjs/osgUtil/gizmoGeometry.js
deleted file mode 100644
index 434eaaf6..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/gizmoGeometry.js
+++ /dev/null
@@ -1,327 +0,0 @@
-'use strict';
-var BufferArray = require( 'osg/BufferArray' );
-var Geometry = require( 'osg/Geometry' );
-var PrimitiveSet = require( 'osg/primitiveSet' );
-var DrawArrays = require( 'osg/DrawArrays' );
-var DrawElements = require( 'osg/DrawElements' );
-var Program = require( 'osg/Program' );
-var Shader = require( 'osg/Shader' );
-
-
-var glPrecision = [ '#ifdef GL_ES',
- 'precision highp float;',
- '#endif'
-].join( '\n' );
-
-var program;
-var getOrCreateShader = function () {
- if ( program )
- return program;
- var shaderName = '#define SHADER_NAME GizmoLine3D';
- var vertexshader = [
- glPrecision,
- 'attribute vec3 Vertex;',
- 'uniform mat4 uModelViewMatrix;',
- 'uniform mat4 uProjectionMatrix;',
- shaderName,
- '',
- 'void main(void) {',
- ' gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);',
- '}'
- ].join( '\n' );
-
- var fragmentshader = [
- glPrecision,
- 'uniform vec4 uColor;',
- shaderName,
- '',
- 'void main(void) {',
- ' gl_FragColor = uColor;',
- '}'
- ].join( '\n' );
-
- program = new Program( new Shader( Shader.VERTEX_SHADER, vertexshader ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentshader ) );
- return program;
-};
-
-var program2D;
-var getOrCreateShader2D = function () {
- if ( program2D )
- return program2D;
- var shaderName = '#define SHADER_NAME GizmoLine2D';
- var vertexshader = [
- glPrecision,
- 'attribute vec2 Vertex;',
- shaderName,
- '',
- 'void main(void) {',
- ' gl_Position = vec4(Vertex, 0.0, 1.0);',
- '}'
- ].join( '\n' );
-
- var fragmentshader = [
- glPrecision,
- shaderName,
- '',
- 'void main(void) {',
- ' gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);',
- '}'
- ].join( '\n' );
-
- program2D = new Program( new Shader( Shader.VERTEX_SHADER, vertexshader ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentshader ) );
- return program2D;
-};
-
-var programQC;
-var getOrCreateShaderQuadCircle = function () {
- if ( programQC )
- return programQC;
- var shaderName = '#define SHADER_NAME GizmoQuadCircle';
- var vertexshader = [
- glPrecision,
- 'attribute vec3 Vertex;',
- 'uniform mat4 uModelViewMatrix;',
- 'uniform mat4 uProjectionMatrix;',
- 'varying vec3 vViewVertex;',
- shaderName,
- '',
- 'void main(void) {',
- ' vViewVertex = Vertex;',
- ' gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);',
- '}'
- ].join( '\n' );
-
- var fragmentshader = [
- glPrecision,
- 'uniform float uAngle;',
- 'uniform vec3 uBase;',
- 'varying vec3 vViewVertex;',
- 'const float PI = 3.14159265358979323846264;',
- 'const float PI2 = PI * 2.0;',
- shaderName,
- '',
- 'void main(void) {',
- ' if(length(vViewVertex) > 0.5)',
- ' discard;',
- ' vec3 vn = normalize(vViewVertex);',
- ' float angle = atan(uBase.y * vn.x - uBase.x * vn.y, dot(uBase, vn));',
- ' if(angle > 0.0) {',
- ' if(uAngle >= 0.0 && angle > uAngle) discard;',
- ' if(uAngle < -PI && angle < uAngle + PI2) discard;',
- ' if(uAngle < 0.0 && uAngle > -PI) discard;',
- ' }',
- ' if(angle < 0.0) {',
- ' if(uAngle <= 0.0 && angle < uAngle) discard;',
- ' if(uAngle > PI && angle > uAngle - PI2) discard;',
- ' if(uAngle > 0.0 && uAngle < PI) discard;',
- ' }',
- ' gl_FragColor = vec4(1.0, 1.0, 0.0, 0.5);',
- '}'
- ].join( '\n' );
-
- programQC = new Program( new Shader( Shader.VERTEX_SHADER, vertexshader ),
- new Shader( Shader.FRAGMENT_SHADER, fragmentshader ) );
- return programQC;
-};
-
-var createDebugLineGeometry = function () {
- var g = new Geometry();
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, new Float32Array( 4 ), 2 );
- var primitive = new DrawArrays( PrimitiveSet.LINES, 0, 2 );
- g.getPrimitives().push( primitive );
- g.getOrCreateStateSet().setAttributeAndModes( getOrCreateShader2D() );
- return g;
-};
-
-var createTorusGeometry = function ( argRadiusOut, argRadiusWidth, argNbRadial, argNbTubular, argArc ) {
- var radiusOut = argRadiusOut !== undefined ? argRadiusOut : 1.0;
- var radiusWidth = argRadiusWidth !== undefined ? argRadiusWidth : 0.2;
- var nbRadial = argNbRadial !== undefined ? argNbRadial : 6;
- var nbTubular = argNbTubular !== undefined ? argNbTubular : 64;
- var arc = argArc !== undefined ? argArc : Math.PI * 2;
-
- var nbVertices = ( nbRadial + 1 ) * ( nbTubular + 1 );
- var nbTriangles = nbRadial * nbTubular * 2;
- var g = new Geometry();
- var vertices = new Float32Array( nbVertices * 3 );
- var indices = new Uint16Array( nbTriangles * 3 );
- arc = arc || Math.PI * 2;
- var id = 0;
- var k = 0;
- var i = 0;
- var j = 0;
- for ( j = 0; j <= nbRadial; ++j ) {
- for ( i = 0; i <= nbTubular; ++i ) {
- var u = i / nbTubular * arc;
- var v = j / nbRadial * Math.PI * 2;
- k = id * 3;
- vertices[ k ] = ( radiusOut + radiusWidth * Math.cos( v ) ) * Math.cos( u );
- vertices[ k + 1 ] = ( radiusOut + radiusWidth * Math.cos( v ) ) * Math.sin( u );
- vertices[ k + 2 ] = radiusWidth * Math.sin( v );
- id++;
- }
- }
- id = 0;
- for ( j = 1; j <= nbRadial; ++j ) {
- for ( i = 1; i <= nbTubular; ++i ) {
- k = id * 6;
- indices[ k ] = ( nbTubular + 1 ) * j + i - 1;
- indices[ k + 1 ] = indices[ k + 3 ] = ( nbTubular + 1 ) * ( j - 1 ) + i - 1;
- indices[ k + 2 ] = indices[ k + 5 ] = ( nbTubular + 1 ) * j + i;
- indices[ k + 4 ] = ( nbTubular + 1 ) * ( j - 1 ) + i;
- id++;
- }
- }
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertices, 3 );
- g.getOrCreateStateSet().setAttributeAndModes( getOrCreateShader() );
- g.getPrimitives().push( new DrawElements( PrimitiveSet.TRIANGLES, new BufferArray( BufferArray.ELEMENT_ARRAY_BUFFER, indices, 1 ) ) );
- return g;
-};
-
-var createCylinderGeometry = function ( argRadiusTop, argRadiusBottom, argHeight, argRadialSegments, argHeightSegments, argTopCap, argLowCap ) {
- var radiusTop = argRadiusTop !== undefined ? argRadiusTop : 1.0;
- var radiusBottom = argRadiusBottom !== undefined ? argRadiusBottom : 1.0;
- var height = argHeight !== undefined ? argHeight : 5.0;
- var radialSegments = argRadialSegments !== undefined ? argRadialSegments : 32;
- var heightSegments = argHeightSegments !== undefined ? argHeightSegments : 1;
- var topCap = argTopCap !== undefined ? argTopCap : true;
- var lowCap = argLowCap !== undefined ? argLowCap : true;
-
- topCap = topCap && radiusTop > 0.0;
- lowCap = lowCap && radiusBottom > 0.0;
- var heightHalf = height * 0.5;
-
- var nbVertices = ( heightSegments + 1 ) * ( radialSegments + 1 );
- var nbTriangles = heightSegments * radialSegments * 2;
- if ( topCap ) {
- nbVertices += 1;
- nbTriangles += radialSegments;
- }
- if ( lowCap ) {
- nbVertices += 1;
- nbTriangles += radialSegments;
- }
- var g = new Geometry();
- var vertices = new Float32Array( nbVertices * 3 );
- var indices = new Uint16Array( nbTriangles * 3 );
-
- var id = 0;
- var k = 0;
- var i = 0;
- var j = 0;
- for ( i = 0; i <= heightSegments; i++ ) {
- var v = i / heightSegments;
- var radius = v * ( radiusBottom - radiusTop ) + radiusTop;
- for ( j = 0; j <= radialSegments; j++ ) {
- var u = j / radialSegments;
- k = id * 3;
- vertices[ k ] = radius * Math.sin( u * Math.PI * 2 );
- vertices[ k + 1 ] = radius * Math.cos( u * Math.PI * 2 );
- vertices[ k + 2 ] = -v * height + heightHalf;
- id++;
- }
- }
-
- id = 0;
- for ( j = 0; j < radialSegments; j++ ) {
- for ( i = 0; i < heightSegments; i++ ) {
- k = id * 6;
- indices[ k ] = ( radialSegments + 1 ) * i + j;
- indices[ k + 1 ] = indices[ k + 3 ] = ( radialSegments + 1 ) * ( i + 1 ) + j;
- indices[ k + 2 ] = indices[ k + 5 ] = ( radialSegments + 1 ) * i + j + 1;
- indices[ k + 4 ] = ( radialSegments + 1 ) * ( i + 1 ) + j + 1;
- id++;
- }
- }
- id *= 2;
- var last;
- if ( topCap ) {
- last = ( lowCap ? vertices.length - 6 : vertices.length - 3 ) / 3;
- vertices[ last * 3 + 2 ] = heightHalf;
- for ( j = 0; j < radialSegments; j++ ) {
- k = id * 3;
- indices[ k ] = j;
- indices[ k + 1 ] = j + 1;
- indices[ k + 2 ] = last;
- id++;
- }
- }
-
- if ( lowCap ) {
- last = ( vertices.length - 3 ) / 3;
- vertices[ last * 3 + 2 ] = -heightHalf;
- var end = ( radialSegments + 1 ) * i;
- for ( j = 0; j < radialSegments; j++ ) {
- k = id * 3;
- indices[ k ] = end + j + 1;
- indices[ k + 1 ] = end + j;
- indices[ k + 2 ] = last;
- id++;
- }
- }
-
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertices, 3 );
- g.getOrCreateStateSet().setAttributeAndModes( getOrCreateShader() );
- g.getPrimitives().push( new DrawElements( PrimitiveSet.TRIANGLES, new BufferArray( BufferArray.ELEMENT_ARRAY_BUFFER, indices, 1 ) ) );
- return g;
-};
-
-var createCircleGeometry = function ( nbVertices, radius, argArc ) {
- var g = new Geometry();
- var vertices = new Float32Array( nbVertices * 3 );
- var arc = argArc || Math.PI * 2;
- for ( var i = 0; i < nbVertices; ++i ) {
- var j = i * 3;
- var segment = arc * i / nbVertices;
- vertices[ j ] = Math.cos( segment ) * radius;
- vertices[ j + 1 ] = Math.sin( segment ) * radius;
- }
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertices, 3 );
- var primitive = new DrawArrays( PrimitiveSet.LINE_STRIP, 0, nbVertices );
- g.getOrCreateStateSet().setAttributeAndModes( getOrCreateShader() );
- g.getPrimitives().push( primitive );
- return g;
-};
-
-var createPlaneGeometry = function ( width, height ) {
- var offx = width ? width * 0.5 : 0.5;
- var offy = height ? height * 0.5 : 0.5;
-
- var g = new Geometry();
- var vertices = new Float32Array( 12 );
- vertices[ 0 ] = -offx;
- vertices[ 1 ] = -offy;
-
- vertices[ 3 ] = offx;
- vertices[ 4 ] = -offy;
-
- vertices[ 6 ] = -offx;
- vertices[ 7 ] = offy;
-
- vertices[ 9 ] = offx;
- vertices[ 10 ] = offy;
-
- g.getAttributes().Vertex = new BufferArray( BufferArray.ARRAY_BUFFER, vertices, 3 );
- var primitive = new DrawArrays( PrimitiveSet.TRIANGLE_STRIP, 0, 4 );
- g.getOrCreateStateSet().setAttributeAndModes( getOrCreateShader() );
- g.getPrimitives().push( primitive );
- return g;
-};
-
-var createQuadCircleGeometry = function () {
- var g = createPlaneGeometry();
- g.getOrCreateStateSet().setAttributeAndModes( getOrCreateShaderQuadCircle() );
- return g;
-};
-
-var GizmoGeometry = {};
-GizmoGeometry.createCircleGeometry = createCircleGeometry;
-GizmoGeometry.createCylinderGeometry = createCylinderGeometry;
-GizmoGeometry.createTorusGeometry = createTorusGeometry;
-GizmoGeometry.createDebugLineGeometry = createDebugLineGeometry;
-GizmoGeometry.createPlaneGeometry = createPlaneGeometry;
-GizmoGeometry.createQuadCircleGeometry = createQuadCircleGeometry;
-
-module.exports = GizmoGeometry;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/osgPool.js b/app/static/app/js/vendor/osgjs/osgUtil/osgPool.js
deleted file mode 100644
index fb90b8b8..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/osgPool.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Authors:
- * Tuan.kuranes Jerome Etienne
- */
-
-'use strict';
-var osgPool = {};
-osgPool.memoryPools = {};
-
-/*
- * TODO: Add stats & reports for developper per application finer calibration (max, min, average)
- * TODO: Debug Mode: check if not putting object twice, etc.
- * USAGE: osg.memoryPools.stateGraph = new OsgObjectMemoryPool(osg.StateGraph).grow(50);
- */
-osgPool.OsgObjectMemoryPool = function ( ObjectClassName ) {
- return {
- _memPool: [],
- reset: function () {
- this._memPool = [];
- return this;
- },
- put: function ( obj ) {
- this._memPool.push( obj );
- },
- get: function () {
- if ( this._memPool.length > 0 ) {
- return this._memPool.pop();
- }
- this.grow();
- return this.get();
- },
- grow: function ( sizeAddParam ) {
- var sizeAdd;
- if ( sizeAddParam === undefined ) {
- sizeAdd = ( this._memPool.length > 0 ) ? this._memPool.length * 2 : 20;
- } else {
- sizeAdd = sizeAddParam;
- }
- var i = this._memPool.length;
- while ( i++ < sizeAdd ) this._memPool.push( new ObjectClassName() );
- return this;
- }
- };
-};
-
-/*
- * USAGE: osg.memoryPools.arrayPool = new OsgArrayMemoryPool();
- * mymatrix = osg.memoryPools.arrayPool.get(16);
- * // do use matrix, etc..
- * osg.memoryPools.arrayPool.put(mymatrix);
- */
-osgPool.OsgArrayMemoryPool = function () {
- return {
- _mempoolofPools: [],
- reset: function () {
- this._memPoolofPools = {};
- return this;
- },
- put: function ( obj ) {
- if ( !this._memPoolofPools[ obj.length ] )
- this._memPoolofPools[ obj.length ] = [];
- this._memPoolofPools[ obj.length ].push( obj );
- },
- get: function ( arraySize ) {
- if ( !this._memPoolofPools[ arraySize ] )
- this._memPoolofPools[ arraySize ] = [];
- else if ( this._memPoolofPools.length > 0 )
- return this._memPool.pop();
- this.grow( arraySize );
- return this.get();
- },
- grow: function ( arraySize, sizeAdd ) {
- if ( sizeAdd === undefined ) sizeAdd = ( this._memPool.length > 0 ) ? this._memPool.length * 2 : 5;
- var i = this._memPool.length;
- while ( i++ < sizeAdd ) this._memPool.push( new Array( arraySize ) );
- return this;
- }
- };
-};
-/*
- * USAGE: osg.memoryPools.OsgObjectMemoryStack = new OsgArrayMemoryStack(ctor);
- * For a stack of object that you reset each frame.
- */
-osgPool.OsgObjectMemoryStack = function ( ObjectClassName ) {
- return {
- _current: 0,
- _memPool: [ new ObjectClassName() ],
- reset: function () {
- this._current = 0;
- return this;
- },
- get: function () {
- var obj = this._memPool[ this._current++ ];
- if ( this._current >= this._memPool.length ) {
- this._memPool.push( new ObjectClassName() );
- }
- return obj;
- }
- };
-};
-
-module.exports = osgPool;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/osgUtil.js b/app/static/app/js/vendor/osgjs/osgUtil/osgUtil.js
deleted file mode 100644
index d3fa0961..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/osgUtil.js
+++ /dev/null
@@ -1,42 +0,0 @@
-'use strict';
-var Composer = require( 'osgUtil/Composer' );
-var debug = require( 'osgUtil/debug' );
-var DisplayNormalVisitor = require( 'osgUtil/DisplayNormalVisitor' );
-var DisplayGeometryVisitor = require( 'osgUtil/DisplayGeometryVisitor' );
-var DisplayGraph = require( 'osgUtil/DisplayGraph' );
-var IntersectionVisitor = require( 'osgUtil/IntersectionVisitor' );
-var LineSegmentIntersector = require( 'osgUtil/LineSegmentIntersector' );
-var MACROUTILS = require( 'osg/Utils' );
-var NodeGizmo = require( 'osgUtil/NodeGizmo' );
-var GizmoGeometry = require( 'osgUtil/gizmoGeometry' );
-var ParameterVisitor = require( 'osgUtil/ParameterVisitor' );
-var PolytopeIntersector = require( 'osgUtil/PolytopeIntersector' );
-var PolytopePrimitiveIntersector = require( 'osgUtil/PolytopePrimitiveIntersector' );
-var SphereIntersector = require( 'osgUtil/SphereIntersector' );
-var TangentSpaceGenerator = require( 'osgUtil/TangentSpaceGenerator' );
-var TriangleIntersect = require( 'osgUtil/TriangleIntersector' );
-var WebVRCustom = require( 'osgUtil/WebVRCustom' );
-var WebVR = require( 'osgUtil/WebVR' );
-
-
-var osgUtil = {};
-
-osgUtil.Composer = Composer;
-MACROUTILS.objectMix( osgUtil, debug );
-osgUtil.DisplayNormalVisitor = DisplayNormalVisitor;
-osgUtil.DisplayGeometryVisitor = DisplayGeometryVisitor;
-osgUtil.DisplayGraph = DisplayGraph;
-osgUtil.IntersectionVisitor = IntersectionVisitor;
-osgUtil.LineSegmentIntersector = LineSegmentIntersector;
-osgUtil.NodeGizmo = NodeGizmo;
-osgUtil.GizmoGeometry = GizmoGeometry;
-osgUtil.WebVRCustom = WebVRCustom;
-osgUtil.ParameterVisitor = ParameterVisitor;
-osgUtil.PolytopeIntersector = PolytopeIntersector;
-osgUtil.PolytopePrimitiveIntersector = PolytopePrimitiveIntersector;
-osgUtil.SphereIntersector = SphereIntersector;
-osgUtil.TangentSpaceGenerator = TangentSpaceGenerator;
-osgUtil.TriangleIntersect = TriangleIntersect;
-osgUtil.WebVR = WebVR;
-
-module.exports = osgUtil;
diff --git a/app/static/app/js/vendor/osgjs/osgUtil/webvr-1-1.js b/app/static/app/js/vendor/osgjs/osgUtil/webvr-1-1.js
deleted file mode 100644
index 7c4b1d34..00000000
--- a/app/static/app/js/vendor/osgjs/osgUtil/webvr-1-1.js
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Installs a shim that emulates functionality from the WebVR '1.1' spec if the
-// browser only exposes WebVR '1.0'.
-'use strict';
-
-var mat4 = require( 'osg/glMatrix' ).mat4;
-
-if ( 'getVRDisplays' in navigator ) {
-
- // A lot of Chrome builds to date don't have depthNear and depthFar, even
- // though they're in the WebVR 1.0 spec. They're more necessary in 1.1.
- if ( !( 'depthNear' in window.VRDisplay.prototype ) ) {
- window.VRDisplay.prototype.depthNear = 0.01;
- }
-
- if ( !( 'depthFar' in window.VRDisplay.prototype ) ) {
- window.VRDisplay.prototype.depthFar = 10000.0;
- }
-
- // If the browser has a WebVR implementation but does not include the 1.1
- // functionality patch it with JS.
- if ( !( 'VRFrameData' in window ) ) {
- window.VRFrameData = function () {
- this.leftProjectionMatrix = new Float32Array( 16 );
- this.leftViewMatrix = new Float32Array( 16 );
- this.rightProjectionMatrix = new Float32Array( 16 );
- this.rightViewMatrix = new Float32Array( 16 );
- this.pose = null;
- };
-
- window.VRDisplay.prototype.getFrameData = ( function () {
-
- var defaultOrientation = new Float32Array( [ 0, 0, 0, 1 ] );
- var defaultPosition = new Float32Array( [ 0, 0, 0 ] );
-
- function updateEyeMatrices( projection, view, pose, parameters, vrDisplay ) {
- mat4.perspectiveFromFieldOfView( projection, parameters.fieldOfView, vrDisplay.depthNear, vrDisplay.depthFar );
-
- var orientation = pose.orientation;
- var position = pose.position;
- if ( !orientation ) {
- orientation = defaultOrientation;
- }
- if ( !position ) {
- position = defaultPosition;
- }
-
- mat4.fromRotationTranslation( view, orientation, position );
- mat4.translate( view, view, parameters.offset );
- mat4.invert( view, view );
- }
-
- return function ( frameData ) {
- var pose = this.getPose();
- if ( !pose )
- return false;
-
- frameData.pose = pose;
- frameData.timestamp = pose.timestamp;
-
- updateEyeMatrices(
- frameData.leftProjectionMatrix, frameData.leftViewMatrix,
- pose, this.getEyeParameters( 'left' ), this );
- updateEyeMatrices(
- frameData.rightProjectionMatrix, frameData.rightViewMatrix,
- pose, this.getEyeParameters( 'right' ), this );
-
- return true;
- };
- } )();
- }
-}
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/Renderer.js b/app/static/app/js/vendor/osgjs/osgViewer/Renderer.js
deleted file mode 100644
index 1a530bf1..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/Renderer.js
+++ /dev/null
@@ -1,215 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var CullSettings = require( 'osg/CullSettings' );
-var CullVisitor = require( 'osg/CullVisitor' );
-var Object = require( 'osg/Object' );
-var RenderStage = require( 'osg/RenderStage' );
-var State = require( 'osg/State' );
-var StateGraph = require( 'osg/StateGraph' );
-var vec4 = require( 'osg/glMatrix' ).vec4;
-var osgShader = require( 'osgShader/osgShader' );
-var DisplayGraph = require( 'osgUtil/DisplayGraph' );
-
-
-var Renderer = function ( camera ) {
- Object.call( this );
-
- this._state = undefined;
- this._camera = camera;
- this._renderStage = undefined;
- this._stateGraph = undefined;
-
- this._frameStamp = undefined;
-
- this._previousCullsettings = new CullSettings();
-
- this.setDefaults();
-};
-
-Renderer.debugGraph = false;
-
-Renderer.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- setDefaults: function () {
-
- this._state = new State( new osgShader.ShaderGeneratorProxy() );
-
- this._cullVisitor = new CullVisitor();
- this._cullVisitor.setRenderer( this );
- this._stateGraph = new StateGraph();
-
- this.getCamera().setClearColor( vec4.create() );
- this.setRenderStage( new RenderStage() );
-
- var osg = require( 'osg/osg' );
- var stateSet = this.getCamera().getOrCreateStateSet();
- stateSet.setAttributeAndModes( new osg.Material() );
- stateSet.setAttributeAndModes( new osg.Depth() );
- stateSet.setAttributeAndModes( new osg.BlendFunc() );
- stateSet.setAttributeAndModes( new osg.CullFace() );
-
- },
-
- getCullVisitor: function () {
- return this._cullVisitor;
- },
-
- setCullVisitor: function ( cv ) {
- if ( cv && !cv.getRenderer() ) cv.setRenderer( this );
- this._cullVisitor = cv;
- },
-
- setRenderStage: function ( rs ) {
- this._renderStage = rs;
- },
-
- getCamera: function () {
- return this._camera;
- },
-
- setFrameStamp: function ( fs ) {
- this._frameStamp = fs;
- },
-
- getFrameStamp: function () {
- return this._frameStamp;
- },
-
- getState: function () {
- return this._state;
- },
-
- setState: function ( state ) {
- this._state = state;
- },
-
- setGraphicContext: function ( gc ) {
- this._state.setGraphicContext( gc );
- },
-
- getGraphicContext: function () {
- return this._state.getGraphicContext();
- },
-
- cullAndDraw: function () {
- this.cull();
- this.draw();
- },
-
- cull: function () {
-
- var camera = this.getCamera();
- var view = camera.getView();
-
- this._cullVisitor.setFrameStamp( this._frameStamp );
-
- // reset stats
- this._cullVisitor.resetStats();
-
- // this part of code should be called for each view
- // right now, we dont support multi view
- this._stateGraph.clean();
- this._renderStage.reset();
-
- this._cullVisitor.reset();
- this._cullVisitor.setStateGraph( this._stateGraph );
- this._cullVisitor.setRenderStage( this._renderStage );
-
- this._cullVisitor.pushStateSet( camera.getStateSet() );
-
- // save cullSettings
- this._previousCullsettings.reset();
- this._previousCullsettings.setCullSettings( this._cullVisitor );
- this._cullVisitor.setCullSettings( camera );
- if ( this._previousCullsettings.getSettingSourceOverrider() === this._cullVisitor && this._previousCullsettings.getEnableFrustumCulling() ) {
- this._cullVisitor.setEnableFrustumCulling( true );
- }
-
- // Push reference on the projection stack, it means that if compute near/far
- // is activated, it will update the projection matrix of the camera
- this._cullVisitor.pushCameraModelViewProjectionMatrix( camera, camera.getViewMatrix(), camera.getProjectionMatrix() );
-
- // update bound
- camera.getBound();
-
- var light = view.getLight();
- var View = require( 'osgViewer/View' );
-
- if ( light ) {
-
- switch ( view.getLightingMode() ) {
-
- case View.LightingMode.HEADLIGHT:
- this._cullVisitor.addPositionedAttribute( null, light );
- break;
-
- case View.LightingMode.SKY_LIGHT:
- this._cullVisitor.addPositionedAttribute( camera.getViewMatrix(), light );
- break;
-
- default:
- break;
- }
- }
-
- this._cullVisitor.pushViewport( camera.getViewport() );
-
-
- this._renderStage.setClearDepth( camera.getClearDepth() );
- this._renderStage.setClearColor( camera.getClearColor() );
- this._renderStage.setClearMask( camera.getClearMask() );
- this._renderStage.setViewport( camera.getViewport() );
-
- // pass de dbpager to the cullvisitor, so plod's can do the requests
- this._cullVisitor.setDatabaseRequestHandler( this._camera.getView().getDatabasePager() );
- // dont add camera on the stack just traverse it
- this._cullVisitor.handleCullCallbacksAndTraverse( camera );
-
- // fix projection matrix if camera has near/far auto compute
- this._cullVisitor.popCameraModelViewProjectionMatrix( camera );
-
- // Important notes about near/far
- // If you are using the picking on the main camera and
- // you use only children sub camera for RTT, your
- // main camera will keep +/-infinity for near/far because
- // the computation of near/far is done by camera and use Geometry
-
-
- // restore previous state of the camera
- this._cullVisitor.setCullSettings( this._previousCullsettings );
-
- this._cullVisitor.popViewport();
- this._cullVisitor.popStateSet();
-
- this._renderStage.sort();
-
- },
-
- draw: function () {
-
- var state = this.getState();
-
- // important because cache are used in cullvisitor
- state.resetCacheFrame();
-
- // reset stats counter
- state.resetStats();
-
- this._renderStage.setCamera( this._camera );
- this._renderStage.draw( state );
-
- if ( Renderer.debugGraph ) {
- DisplayGraph.instance().createRenderGraph( this._renderStage );
- Renderer.debugGraph = false;
- }
-
- this._renderStage.setCamera( undefined );
-
- state.applyDefault();
-
- }
-
-
-} ), 'osgViewer', 'Renderer' );
-
-module.exports = Renderer;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/Scene.js b/app/static/app/js/vendor/osgjs/osgViewer/Scene.js
deleted file mode 100644
index b0749ad9..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/Scene.js
+++ /dev/null
@@ -1,42 +0,0 @@
-'use strict';
-var MACROUTILS = require( 'osg/Utils' );
-var Object = require( 'osg/Object' );
-var DatabasePager = require( 'osgDB/DatabasePager' );
-
-
-var Scene = function () {
- Object.call( this );
- this._databasePager = new DatabasePager();
- this._sceneData = undefined;
-};
-
-Scene.prototype = MACROUTILS.objectLibraryClass( MACROUTILS.objectInherit( Object.prototype, {
-
- getSceneData: function () {
- return this._sceneData;
- },
-
- setSceneData: function ( node ) {
- this._sceneData = node;
- },
-
- setDatabasePager: function ( dbpager ) {
- this._databasePager = dbpager;
- },
-
- getDatabasePager: function () {
- return this._databasePager;
- },
-
- // database pager are not implemented yet here
- updateSceneGraph: function ( updateVisitor ) {
- if ( this._databasePager )
- this._databasePager.updateSceneGraph( updateVisitor.getFrameStamp() );
- if ( this._sceneData )
- this._sceneData.accept( updateVisitor );
- }
-
-
-} ), 'osgViewer', 'Scene' );
-
-module.exports = Scene;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/View.js b/app/static/app/js/vendor/osgjs/osgViewer/View.js
deleted file mode 100644
index f868c6f7..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/View.js
+++ /dev/null
@@ -1,336 +0,0 @@
-'use strict';
-var BufferArray = require( 'osg/BufferArray' );
-var Camera = require( 'osg/Camera' );
-var FrameStamp = require( 'osg/FrameStamp' );
-var FrameBufferObject = require( 'osg/FrameBufferObject' );
-var Light = require( 'osg/Light' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Texture = require( 'osg/Texture' );
-var Program = require( 'osg/Program' );
-var Shader = require( 'osg/Shader' );
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var Viewport = require( 'osg/Viewport' );
-var WebGLCaps = require( 'osg/WebGLCaps' );
-var IntersectionVisitor = require( 'osgUtil/IntersectionVisitor' );
-var LineSegmentIntersector = require( 'osgUtil/LineSegmentIntersector' );
-var Renderer = require( 'osgViewer/Renderer' );
-var Scene = require( 'osgViewer/Scene' );
-var DisplayGraph = require( 'osgUtil/DisplayGraph' );
-var Notify = require( 'osg/notify' );
-
-
-// View is normally inherited from osg/View. In osgjs we dont need it yet
-// this split, so everything is in osgViewer/View
-
-var View = function () {
-
- this._camera = new Camera();
- this._scene = new Scene();
- this._frameStamp = new FrameStamp();
- this._lightingMode = undefined;
- this._manipulator = undefined;
- this._canvasWidth = 0;
- this._canvasHeight = 0;
-
- this._requestContinousUpdate = true;
- this._requestRedraw = true;
-
- this.setLightingMode( View.LightingMode.HEADLIGHT );
- // assign a renderer to the camera
- var renderer = this.createRenderer( this.getCamera() );
- renderer.setFrameStamp( this._frameStamp );
- this.getCamera().setRenderer( renderer );
- this.getCamera().setView( this );
-
-};
-
-View.LightingMode = {
- NO_LIGHT: 0,
- HEADLIGHT: 1,
- SKY_LIGHT: 2
-};
-
-View.prototype = {
- requestRedraw: function () {
- this._requestRedraw = true;
- },
- requestContinuousUpdate: function ( bool ) {
- this._requestContinousUpdate = bool;
- },
- createRenderer: function ( camera ) {
- var render = new Renderer( camera );
- //camera->setStats(new osg::Stats("Camera"));
- return render;
- },
-
- setGraphicContext: function ( gc ) {
- this.getCamera().getRenderer().getState().setGraphicContext( gc );
- },
-
- getGraphicContext: function () {
- return this.getCamera().getRenderer().getState().getGraphicContext();
- },
-
-
- initWebGLCaps: function ( gl ) {
-
- WebGLCaps.instance( gl );
-
- },
-
- // check Each frame because HTML standard inconsistencies
- // - mobile full-screen, device orientation, etc
- // peculiarity of webgl canvas resizing here some details
- // http://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html
- // screen size
- // http://tripleodeon.com/2011/12/first-understand-your-screen/
- // touchy is touchy: many things to know
- // http://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html
- computeCanvasSize: ( function () {
- return function ( canvas ) {
-
- var clientWidth, clientHeight;
- clientWidth = canvas.clientWidth;
- clientHeight = canvas.clientHeight;
-
- if ( clientWidth < 1 ) clientWidth = 1;
- if ( clientHeight < 1 ) clientHeight = 1;
-
- var devicePixelRatio = this._devicePixelRatio;
-
- var widthPixel = Math.floor( clientWidth * devicePixelRatio );
- var heightPixel = Math.floor( clientHeight * devicePixelRatio );
-
- var hasChanged = false;
- if ( this._canvasWidth !== widthPixel ) {
- canvas.width = widthPixel;
- this._canvasWidth = widthPixel;
- hasChanged = true;
- }
-
- if ( this._canvasHeight !== heightPixel ) {
- canvas.height = heightPixel;
- this._canvasHeight = heightPixel;
- hasChanged = true;
- }
- return hasChanged;
- };
- } )(),
-
- getCanvasWidth: function () {
- return this._canvasWidth;
- },
-
- getCanvasHeight: function () {
- return this._canvasHeight;
- },
-
- getCanvasClientWidth: function () {
- return Math.ceil( this._canvasWidth / this._devicePixelRatio );
- },
-
- getCanvasClientHeight: function () {
- return Math.ceil( this._canvasHeight / this._devicePixelRatio );
- },
-
- getCanvasPixelRatio: function () {
- // in case of VR headset, it's probably not relevant anymore
- return this._devicePixelRatio;
- },
-
- setUpView: function ( canvas, options ) {
-
-
- var devicePixelRatio = window.devicePixelRatio || 1;
- var overrideDevicePixelRatio = options.getNumber( 'overrideDevicePixelRatio' );
- var maxDevicePixelRatio = options.getNumber( 'maxDevicePixelRatio' ) || -1;
-
- // override the pixel ratio, used to save pixel on mobile
- if ( typeof overrideDevicePixelRatio === 'number' ) {
- devicePixelRatio = overrideDevicePixelRatio;
- } else if ( maxDevicePixelRatio !== -1 ) {
- devicePixelRatio = Math.min( devicePixelRatio, maxDevicePixelRatio );
- }
- this._devicePixelRatio = devicePixelRatio;
-
- this.computeCanvasSize( canvas );
-
- var width = canvas.width;
- var height = canvas.height;
- var ratio = width / height;
-
- this._camera.setViewport( new Viewport( 0, 0, width, height ) );
-
- this._camera.setGraphicContext( this.getGraphicContext() );
- mat4.lookAt( this._camera.getViewMatrix(), vec3.fromValues( 0.0, 0.0, -10.0 ), vec3.create(), vec3.fromValues( 0.0, 1.0, 0.0 ) );
- mat4.perspective( this._camera.getProjectionMatrix(), Math.PI / 180 * 55, ratio, 1.0, 1000.0 );
-
-
-
- if ( options && options.enableFrustumCulling )
- this.getCamera().getRenderer().getCullVisitor().setEnableFrustumCulling( true );
-
-
- // add a function to refresh the graph from the console
- if ( options && options.debugGraph ) {
-
- var camera = this.getCamera();
- DisplayGraph.instance().refreshGraph = function () {
- var displayGraph = DisplayGraph.instance();
- displayGraph.setDisplayGraphRenderer( true );
- displayGraph.createGraph( camera );
- };
-
- Notify.log( 'to refresh the graphs type in the console:\nOSG.osgUtil.DisplayGraph.instance().refreshGraph()' );
-
- }
-
- },
-
- /**
- * X = 0 at the left
- * Y = 0 at the BOTTOM
- */
- computeIntersections: function ( x, y, traversalMask ) {
-
- /*jshint bitwise: false */
- if ( traversalMask === undefined ) {
- traversalMask = ~0;
- }
- /*jshint bitwise: true */
-
-
- if ( !this._lsi ) {
- this._lsi = new LineSegmentIntersector();
- } else {
- this._lsi.reset();
- }
-
- if ( !this._origIntersect ) {
- this._origIntersect = vec3.create();
- this._dstIntersect = vec3.create();
- }
-
- this._lsi.set( vec3.set( this._origIntersect, x, y, 0.0 ),
- vec3.set( this._dstIntersect, x, y, 1.0 ) );
-
-
- if ( !this._iv ) {
- this._iv = new IntersectionVisitor();
- this._iv.setIntersector( this._lsi );
- } else {
- this._iv.reset();
- }
- this._iv.setTraversalMask( traversalMask );
- this._camera.accept( this._iv );
-
- return this._lsi.getIntersections();
- },
-
- setFrameStamp: function ( frameStamp ) {
- this._frameStamp = frameStamp;
- },
-
- getFrameStamp: function () {
- return this._frameStamp;
- },
-
- setCamera: function ( camera ) {
- this._camera = camera;
- },
-
- getCamera: function () {
- return this._camera;
- },
-
- setSceneData: function ( node ) {
-
- if ( node === this._scene.getSceneData() )
- return;
-
- this._scene.setSceneData( node );
-
- this._camera.removeChildren();
- this._camera.addChild( node );
-
- },
-
- getSceneData: function () {
- return this._scene.getSceneData();
- },
-
- setDatabasePager: function ( dbpager ) {
- this._scene.setDatabasePager( dbpager );
- },
-
- getDatabasePager: function () {
- return this._scene.getDatabasePager();
- },
-
- getScene: function () {
- return this._scene;
- },
-
- getManipulator: function () {
- return this._manipulator;
- },
-
- setManipulator: function ( manipulator ) {
- this._manipulator = manipulator;
- },
-
- getLight: function () {
- return this._light;
- },
-
- setLight: function ( light ) {
- this._light = light;
- if ( this._lightingMode !== View.LightingMode.NO_LIGHT ) {
- this._scene.getOrCreateStateSet().setAttributeAndModes( this._light );
- }
- },
-
- getLightingMode: function () {
- return this._lightingMode;
- },
-
- setLightingMode: function ( lightingMode ) {
-
- if ( this._lightingMode !== lightingMode ) {
- this._lightingMode = lightingMode;
-
- if ( this._lightingMode !== View.LightingMode.NO_LIGHT ) {
-
- if ( !this._light ) this._light = new Light();
-
- } else {
- this._light = undefined;
- }
- }
- },
-
- // In OSG this call is done in SceneView
- flushDeletedGLObjects: function ( /*currentTime,*/ availableTime ) {
- // Flush all deleted OpenGL objects within the specified availableTime
- var gl = this.getGraphicContext();
- availableTime = BufferArray.flushDeletedGLBufferArrays( gl, availableTime );
- availableTime = Texture.getTextureManager( gl ).flushDeletedTextureObjects( gl, availableTime );
- availableTime = Program.flushDeletedGLPrograms( gl, availableTime );
- availableTime = Shader.flushDeletedGLShaders( gl, availableTime );
- availableTime = FrameBufferObject.flushDeletedGLFrameBuffers( gl, availableTime );
- availableTime = FrameBufferObject.flushDeletedGLRenderBuffers( gl, availableTime );
- },
-
- flushAllDeletedGLObjects: function () {
- // Flush all deleted OpenGL objects
- var gl = this.getGraphicContext();
- BufferArray.flushAllDeletedGLBufferArrays( gl );
- Texture.getTextureManager( gl ).flushAllDeletedTextureObjects( gl );
- Program.flushAllDeletedGLPrograms( gl );
- Shader.flushAllDeletedGLShaders( gl );
- FrameBufferObject.flushAllDeletedGLFrameBuffers( gl );
- FrameBufferObject.flushAllDeletedGLRenderBuffers( gl );
- }
-};
-
-module.exports = View;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/Viewer.js b/app/static/app/js/vendor/osgjs/osgViewer/Viewer.js
deleted file mode 100644
index 0c6b8439..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/Viewer.js
+++ /dev/null
@@ -1,697 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var mat4 = require( 'osg/glMatrix' ).mat4;
-var Options = require( 'osg/Options' );
-var P = require( 'bluebird' );
-var Timer = require( 'osg/Timer' );
-var TimerGPU = require( 'osg/TimerGPU' );
-var UpdateVisitor = require( 'osg/UpdateVisitor' );
-var MACROUTILS = require( 'osg/Utils' );
-var Texture = require( 'osg/Texture' );
-var OrbitManipulator = require( 'osgGA/OrbitManipulator' );
-var createStats = require( 'osgViewer/createStats' );
-var EventProxy = require( 'osgViewer/eventProxy/eventProxy' );
-var View = require( 'osgViewer/View' );
-var WebGLUtils = require( 'osgViewer/webgl-utils' );
-var WebGLDebugUtils = require( 'osgViewer/webgl-debug' );
-var requestFile = require( 'osgDB/requestFile' );
-
-
-var OptionsURL = ( function () {
- var options = {};
- ( function ( options ) {
- var vars = [],
- hash;
- if ( !window.location.search ) return;
-
- // slice(1) to remove leading '?'
- var hashes = window.location.search.slice( 1 ).split( '&' );
- for ( var i = 0; i < hashes.length; i++ ) {
- hash = hashes[ i ].split( '=' );
- var element = hash[ 0 ];
- vars.push( element );
- var result = hash[ 1 ];
- if ( result === undefined ) {
- result = '1';
- }
- options[ element ] = result;
- }
- } )( options );
-
- if ( options.log !== undefined ) {
- var level = options.log.toLowerCase();
-
- switch ( level ) {
- case 'debug':
- Notify.setNotifyLevel( Notify.DEBUG );
- break;
- case 'info':
- Notify.setNotifyLevel( Notify.INFO );
- break;
- case 'notice':
- Notify.setNotifyLevel( Notify.NOTICE );
- break;
- case 'warn':
- Notify.setNotifyLevel( Notify.WARN );
- break;
- case 'error':
- Notify.setNotifyLevel( Notify.ERROR );
- break;
- case 'html':
- ( function () {
- var logContent = [];
- var divLogger = document.createElement( 'div' );
- var codeElement = document.createElement( 'pre' );
- document.addEventListener( 'DOMContentLoaded', function () {
- document.body.appendChild( divLogger );
- divLogger.appendChild( codeElement );
- } );
- var logFunc = function ( str ) {
- logContent.unshift( str );
- codeElement.innerHTML = logContent.join( '\n' );
- };
- divLogger.style.overflow = 'hidden';
- divLogger.style.position = 'absolute';
- divLogger.style.zIndex = '10000';
- divLogger.style.height = '100%';
- divLogger.style.maxWidth = '600px';
- codeElement.style.overflow = 'scroll';
- codeElement.style.width = '105%';
- codeElement.style.height = '100%';
- codeElement.style.fontSize = '10px';
-
- [ 'log', 'error', 'warn', 'info', 'debug' ].forEach( function ( value ) {
- window.console[ value ] = logFunc;
- } );
- } )();
- break;
- }
- }
-
- return options;
-} )();
-
-
-var getGLSLOptimizer = function () {
-
- var deferOptimizeGLSL = P.defer();
- window.deferOptimizeGLSL = deferOptimizeGLSL;
-
- var mod = [
- ' var Module = {',
- ' preRun: [],',
- ' postRun: [ function () {',
- ' var func = Module.cwrap( "optimize_glsl", "string", [ "string", "number", "number" ] );',
- ' window.deferOptimizeGLSL.resolve( func );',
- ' } ],',
- ' print: function ( text ) {',
- ' Notify.debug( text );',
- ' },',
- ' printErr: function ( text ) {',
- ' Notify.debug( text );',
- ' },',
- ' setStatus: function ( text ) {',
- ' Notify.debug( text );',
- ' },',
- ' totalDependencies: 0,',
- ' monitorRunDependencies: function ( left ) {',
- ' this.totalDependencies = Math.max( this.totalDependencies, left );',
- ' Module.setStatus( left ? "GLSL optimizer preparing... (" + ( this.totalDependencies - left ) + "/" + this.totalDependencies + ")" : "All downloads complete." );',
- ' },',
- ' memoryInitializerPrefixURL: "https://raw.githubusercontent.com/zz85/glsl-optimizer/gh-pages/"',
- ' };'
- ].join( '\n' );
-
- Notify.log( 'try to load glsl optimizer' );
- var url = 'https://raw.githubusercontent.com/zz85/glsl-optimizer/gh-pages/glsl-optimizer.js';
- var promise = requestFile( url );
- promise.then( function ( script ) {
- /*jshint evil: true */
- eval( mod + script );
- /*jshint evil: false */
- } ).catch( function () {
- deferOptimizeGLSL.reject();
- } );
-
- return deferOptimizeGLSL.promise;
-};
-
-var Viewer = function ( canvas, userOptions, error ) {
- View.call( this );
-
- this._startTick = Timer.instance().tick();
- this._stats = undefined;
- this._done = false;
- this._runPromise = P.resolve();
-
- var options = this.initOptions( userOptions );
- var gl = this.initWebGLContext( canvas, options, error );
-
- if ( !gl )
- throw 'No WebGL implementation found';
-
- // this MACROUTILS.init(); should be removed and replace by something
- // more natural
- MACROUTILS.init();
-
- this.initDeviceEvents( options, canvas );
- this.initStats( options, canvas );
- this.initRun( options );
- this._updateVisitor = new UpdateVisitor();
-
- this.setUpView( gl.canvas, options );
-
- this._hmd = null;
- this._requestAnimationFrame = window.requestAnimationFrame.bind( window );
-
- this._contextLost = false;
-};
-
-
-Viewer.prototype = MACROUTILS.objectInherit( View.prototype, {
-
- initDeviceEvents: function ( options, canvas ) {
-
- // default argument for mouse binding
- var defaultMouseEventNode = options.mouseEventNode || canvas;
-
- var eventsBackend = options.EventBackend || {};
- if ( !options.EventBackend ) options.EventBackend = eventsBackend;
- eventsBackend.StandardMouseKeyboard = options.EventBackend.StandardMouseKeyboard || {};
- var mouseEventNode = eventsBackend.StandardMouseKeyboard.mouseEventNode || defaultMouseEventNode;
- eventsBackend.StandardMouseKeyboard.mouseEventNode = mouseEventNode;
- eventsBackend.StandardMouseKeyboard.keyboardEventNode = eventsBackend.StandardMouseKeyboard.keyboardEventNode || document;
-
- // hammer, Only activate it if we have a touch device in order to fix problems with IE11
- if ( 'ontouchstart' in window ) {
- eventsBackend.Hammer = eventsBackend.Hammer || {};
- eventsBackend.Hammer.eventNode = eventsBackend.Hammer.eventNode || defaultMouseEventNode;
- }
- // gamepad
- eventsBackend.GamePad = eventsBackend.GamePad || {};
-
- this._eventProxy = this.initEventProxy( options );
- },
-
- initOptions: function ( userOptions ) {
- // use default options
- var options = new Options();
-
- if ( userOptions ) {
- // user options override by user options
- options.extend( userOptions );
- }
-
- // if url options override url options
- options.extend( OptionsURL );
-
- // Activate global trace on log call
- if ( options.getBoolean( 'traceLogCall' ) === true ) Notify.traceLogCall = true;
-
- // Check if Frustum culling is enabled to calculate the clip planes
- if ( options.getBoolean( 'enableFrustumCulling' ) === true )
- this.getCamera().getRenderer().getCullVisitor().setEnableFrustumCulling( true );
-
-
- return options;
- },
-
- initWebGLContext: function ( canvas, options, error ) {
-
- // #FIXME see tojiro's blog for webgl lost context stuffs
- if ( options.get( 'SimulateWebGLLostContext' ) ) {
- canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas( canvas );
- canvas.loseContextInNCalls( options.get( 'SimulateWebGLLostContext' ) );
- }
-
- var gl = WebGLUtils.setupWebGL( canvas, options, error );
-
- canvas.addEventListener( 'webglcontextlost', function ( event ) {
- this.contextLost();
- event.preventDefault();
- }.bind( this ), false );
-
- canvas.addEventListener( 'webglcontextrestored', function () {
- this.contextRestored();
- }.bind( this ), false );
-
- if ( Notify.reportWebGLError || options.get( 'reportWebGLError' ) ) {
- gl = WebGLDebugUtils.makeDebugContext( gl );
- }
-
- this.initWebGLCaps( gl );
- this.setGraphicContext( gl );
-
- return gl;
- },
-
- initRun: function ( options ) {
-
- if ( options.getBoolean( 'GLSLOptimizer' ) === true ) {
-
- var Shader = require( 'osg/Shader' );
- Shader.enableGLSLOptimizer = true;
-
- this._runPromise = getGLSLOptimizer();
- this._runPromise.then( function ( glslOptimizer ) {
- Shader.glslOptimizer = glslOptimizer;
- if ( Shader.glslOptimizer )
- Notify.log( 'uses glsl optimizer, use ?log=info to see shader output' );
- else
- Notify.error( 'failed to load glsl optimizer' );
- } ).catch( function ( error ) {
- Notify.error( error );
- } );
- }
-
- },
-
- setContextLostCallback: function ( cb ) {
- this._contextLostCallback = cb;
- // just in case callback registration
- // happens after the context lost
- if ( this._contextLost ) {
- cb();
- }
- },
-
- contextLost: function () {
- Notify.log( 'webgl context lost' );
- if ( this._contextLostCallback ) {
- this._contextLostCallback();
- }
- this._contextLost = true;
- window.cancelAnimationFrame( this._requestID );
- },
-
- contextRestored: function () {
- Notify.log( 'webgl context restored, but not supported - reload the page' );
- // Supporting it implies to have
- // reloaded all your resources:
- // textures, vertex/index buffers, shaders, frame buffers
- // so only set it back if you happen to have restored the context
- // this._contextLost = false;
- },
-
- init: function () {
- //this._done = false;
- },
-
- getUpdateVisitor: function () {
- return this._updateVisitor;
- },
-
- getState: function () {
- return this.getCamera().getRenderer().getState();
- },
-
- initStats: function ( options ) {
-
- var timerGPU = TimerGPU.instance( this.getGraphicContext() );
-
- if ( !options.getBoolean( 'stats' ) ) {
- timerGPU.disable();
- return;
- }
-
- this._stats = createStats( options );
-
- timerGPU.setCallback( this.callbackTimerGPU.bind( this ) );
- },
-
- callbackTimerGPU: function ( average, queryID ) {
- if ( this._stats ) this._stats.rStats( queryID ).set( average / 1e6 );
- },
-
- getViewerStats: function () {
- return this._stats;
- },
-
- renderingTraversal: function () {
-
- if ( this.getScene().getSceneData() )
- this.getScene().getSceneData().getBound();
-
-
- if ( this.getCamera() ) {
-
- var stats = this._stats;
- var timerGPU = TimerGPU.instance( this.getGraphicContext() );
-
- var renderer = this.getCamera().getRenderer();
-
- if ( stats ) stats.rStats( 'cull' ).start();
-
- renderer.cull();
-
- if ( stats ) stats.rStats( 'cull' ).end();
-
- timerGPU.pollQueries();
- timerGPU.start( 'glframe' );
-
- if ( stats ) {
- stats.rStats( 'render' ).start();
- }
-
- renderer.draw();
-
- if ( stats ) {
- stats.rStats( 'render' ).end();
- }
-
- timerGPU.end( 'glframe' );
-
- if ( stats ) {
- var cullVisitor = renderer.getCullVisitor();
- stats.rStats( 'cullcamera' ).set( cullVisitor._numCamera );
- stats.rStats( 'cullmatrixtransform' ).set( cullVisitor._numMatrixTransform );
- stats.rStats( 'cullprojection' ).set( cullVisitor._numProjection );
- stats.rStats( 'cullnode' ).set( cullVisitor._numNode );
- stats.rStats( 'cullightsource' ).set( cullVisitor._numLightSource );
- stats.rStats( 'cullgeometry' ).set( cullVisitor._numGeometry );
- stats.rStats( 'pushstateset' ).set( renderer.getState()._numPushStateSet );
- }
-
- }
-
- },
-
-
- updateTraversal: function () {
-
- var stats = this._stats;
-
- if ( stats ) stats.rStats( 'update' ).start();
-
- // update the scene
- this._updateVisitor.resetStats();
- this.getScene().updateSceneGraph( this._updateVisitor );
-
- if ( stats ) stats.rStats( 'updatecallback' ).set( this._updateVisitor._numUpdateCallback );
-
- // Remove ExpiredSubgraphs from DatabasePager
- this.getDatabasePager().releaseGLExpiredSubgraphs( 0.005 );
- // In OSG this.is deferred until the draw traversal, to handle multiple contexts
- this.flushDeletedGLObjects( 0.005 );
-
- if ( stats ) stats.rStats( 'update' ).end();
-
- },
-
- advance: function ( simulationTime ) {
-
- var sTime = simulationTime;
-
- if ( sTime === undefined )
- sTime = Number.MAX_VALUE;
-
- var frameStamp = this._frameStamp;
- var previousFrameNumber = frameStamp.getFrameNumber();
-
- frameStamp.setFrameNumber( previousFrameNumber + 1 );
-
- var deltaS = Timer.instance().deltaS( this._startTick, Timer.instance().tick() );
- frameStamp.setReferenceTime( deltaS );
-
- var lastSimulationTime = frameStamp.getSimulationTime();
- frameStamp.setSimulationTime( sTime === Number.MAX_VALUE ? deltaS : sTime ); // set simul time
- frameStamp.setDeltaTime( frameStamp.getSimulationTime() - lastSimulationTime ); // compute delta since last tick
-
- },
-
- beginFrame: function () {
-
- var stats = this._stats;
-
- if ( stats ) {
- stats.rStats( 'frame' ).start();
- stats.glS.start();
-
- stats.rStats( 'rAF' ).tick();
- stats.rStats( 'FPS' ).frame();
- }
-
- },
-
- endFrame: function () {
-
- var frameNumber = this.getFrameStamp().getFrameNumber();
-
- var stats = this._stats;
- var rStats = stats ? stats.rStats : undefined;
-
- // update texture stats
- if ( rStats ) {
- Texture.getTextureManager( this.getGraphicContext() ).updateStats( frameNumber, rStats );
- rStats( 'frame' ).end();
-
- rStats( 'rStats' ).start();
- rStats().update();
- rStats( 'rStats' ).end();
- }
-
- },
-
- checkNeedToDoFrame: function () {
- return this._requestContinousUpdate || this._requestRedraw;
- },
-
- frame: function () {
-
- // _contextLost check for code calling viewer::frame directly
- // (likely force preload gl resource or direct render control )
- if ( this._contextLost ) return;
-
- this.beginFrame();
-
- this.advance();
-
- // update viewport if a resize occured
- var canvasSizeChanged = this.updateViewport();
-
- // update inputs devices
- this.updateEventProxy( this._eventProxy, this.getFrameStamp() );
-
- // setup framestamp
- this._updateVisitor.setFrameStamp( this.getFrameStamp() );
- // Update Manipulator/Event
- if ( this.getManipulator() ) {
- this.getManipulator().update( this._updateVisitor );
- mat4.copy( this.getCamera().getViewMatrix(), this.getManipulator().getInverseMatrix() );
- }
-
- if ( this.checkNeedToDoFrame() || canvasSizeChanged ) {
- this._requestRedraw = false;
- this.updateTraversal();
- this.renderingTraversal();
- }
-
- this.endFrame();
-
- // submit frame to vr headset
- if ( this._hmd && this._hmd.isPresenting )
- this._hmd.submitFrame();
- },
-
- setDone: function ( bool ) {
- this._done = bool;
- },
-
- done: function () {
- return this._done;
- },
-
- _runImplementation: function () {
- var self = this;
- var render = function () {
- if ( !self.done() ) {
- self._requestID = self._requestAnimationFrame( render, self.getGraphicContext().canvas );
- self.frame();
- }
- };
- render();
- },
-
- run: function () {
-
- var self = this;
- this._runPromise.then( function () {
- self._runImplementation();
- } ).catch( function () {
- self._runImplementation();
- } );
-
- },
-
- setVRDisplay: function ( hmd ) {
- this._hmd = hmd;
- this._requestAnimationFrame = hmd.requestAnimationFrame.bind( hmd );
- },
-
- getVRDisplay: function () {
- return this._hmd;
- },
-
- setPresentVR: function ( bool ) {
- if ( !this._hmd ) {
- Notify.warn( 'no hmd device provided to the viewer!' );
- return P.reject();
- }
-
- // reset position/orientation of hmd device
- if ( !this._hmd.capabilities.hasPosition )
- this._hmd.resetPose();
-
- if ( !this._hmd.capabilities.canPresent )
- return P.reject();
-
- if ( bool ) {
- var layers = [ {
- source: this.getGraphicContext().canvas
- } ];
- return this._hmd.requestPresent( layers );
-
- } else {
- return this._hmd.exitPresent();
- }
- },
-
- setupManipulator: function ( manipulator /*, dontBindDefaultEvent */ ) {
- if ( manipulator === undefined ) {
- manipulator = new OrbitManipulator();
- }
-
- if ( manipulator.setNode !== undefined ) {
- manipulator.setNode( this.getSceneData() );
- } else {
- // for backward compatibility
- manipulator.view = this;
- }
-
- manipulator.setCamera( this.getCamera() );
- this.setManipulator( manipulator );
- },
-
-
- // updateViewport
- updateViewport: function () {
-
- var gl = this.getGraphicContext();
- var canvas = gl.canvas;
-
- var hasChanged = this.computeCanvasSize( canvas );
- if ( !hasChanged )
- return false;
-
- var camera = this.getCamera();
- var vp = camera.getViewport();
-
- var prevWidth = vp.width();
- var prevHeight = vp.height();
-
- var widthChangeRatio = canvas.width / prevWidth;
- var heightChangeRatio = canvas.height / prevHeight;
- var aspectRatioChange = widthChangeRatio / heightChangeRatio;
- vp.setViewport( Math.round( vp.x() * widthChangeRatio ), Math.round( vp.y() * heightChangeRatio ), Math.round( vp.width() * widthChangeRatio ), Math.round( vp.height() * heightChangeRatio ) );
-
- if ( aspectRatioChange !== 1.0 ) {
- mat4.mul( camera.getProjectionMatrix(), camera.getProjectionMatrix(), mat4.fromScaling( mat4.create(), [ 1.0 / aspectRatioChange, 1.0, 1.0 ] ) );
- }
-
- return true;
- },
-
- // intialize all input devices
- initEventProxy: function ( argsObject ) {
- var args = argsObject || {};
- var deviceEnabled = {};
-
- var lists = EventProxy;
- var argumentEventBackend = args.EventBackend;
-
-
- // loop on each devices and try to initialize it
- var keys = window.Object.keys( lists );
- for ( var i = 0, l = keys.length; i < l; i++ ) {
- var device = keys[ i ];
-
- // check if the config has a require
- var initialize = true;
- var argDevice = {};
- if ( argumentEventBackend && ( argumentEventBackend[ device ] !== undefined ) ) {
- var bool = argumentEventBackend[ device ].enable;
- initialize = bool !== undefined ? bool : true;
- argDevice = argumentEventBackend[ device ];
- }
-
- // extend argDevice with regular options eg:
- // var options = {
- // EventBackend: {
- // Hammer: {
- // drag_max_touches: 4,
- // transform_min_scale: 0.08,
- // transform_min_rotation: 180,
- // transform_always_block: true
- // }
- // },
- // zoomscroll: false
- // };
-
- // to options merged:
- // var options = {
- // drag_max_touches: 4,
- // transform_min_scale: 0.08,
- // transform_min_rotation: 180,
- // transform_always_block: true,
- // zoomscroll: false
- // };
- //
- var options = new Options();
- options.extend( argDevice ).extend( argsObject );
- delete options.EventBackend;
-
- if ( initialize ) {
- var inputDevice = new lists[ device ]( this );
- inputDevice.init( options );
- deviceEnabled[ device ] = inputDevice;
- }
- }
- return deviceEnabled;
- },
- updateEventProxy: function ( list, frameStamp ) {
- var keys = window.Object.keys( list );
- keys.forEach( function ( key ) {
- var device = list[ key ];
- if ( device.update )
- device.update( frameStamp );
- } );
- },
-
- setManipulator: function ( manipulator ) {
-
- if ( this._manipulator )
- this.removeEventProxy();
-
- if ( !manipulator.getCamera() )
- manipulator.setCamera( this.getCamera() );
-
- View.prototype.setManipulator.call( this, manipulator );
- },
-
- removeEventProxy: function () {
- var list = this._eventProxy;
- var keys = window.Object.keys( list );
- keys.forEach( function ( key ) {
- var device = list[ key ];
- if ( device.remove )
- device.remove();
- } );
- },
-
- getEventProxy: function () {
- return this._eventProxy;
- }
-
-} );
-
-module.exports = Viewer;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/createStats.js b/app/static/app/js/vendor/osgjs/osgViewer/createStats.js
deleted file mode 100644
index 1fd7381e..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/createStats.js
+++ /dev/null
@@ -1,152 +0,0 @@
-'use strict';
-
-var MACROUTILS = require( 'osg/Utils' );
-var BrowserStats = window.BrowserStats;
-var glStats = window.glStats;
-var rStats = window.rStats;
-
-var CanvasStats = function ( opts ) {
-
- this.bS = new BrowserStats();
- this.glS = new glStats();
-
- var values = {
- frame: {
- caption: 'Total frame time (ms)',
- over: 16,
- average: true
- },
- fps: {
- caption: 'Framerate (FPS)',
- below: 30
- },
- calls: {
- caption: 'Calls (three.js)',
- over: 3000
- },
- raf: {
- caption: 'Time since last rAF (ms)',
- average: true,
- avgMs: 500
- },
- rstats: {
- caption: 'rStats update (ms)',
- average: true,
- avgMs: 100
- },
- update: {
- caption: 'update',
- average: true
- },
- cull: {
- caption: 'cull',
- average: true
- },
- render: {
- caption: 'render',
- average: true
- },
- glframe: {
- caption: 'glframe',
- average: true
- },
-
- textureused: {
- caption: 'texture used'
- },
- texturereserved: {
- caption: 'texture reserved'
- },
- texturetotal: {
- caption: 'texture total'
- },
-
- pushstateset: {
- caption: 'num pushStateSet'
- },
- updatecallback: {
- caption: 'num updateCallback'
- },
-
- cullcamera: {
- caption: 'camera'
- },
- cullmatrixtransform: {
- caption: 'matrixTransform'
- },
- cullprojection: {
- caption: 'projection'
- },
- cullnode: {
- caption: 'node'
- },
- culllightsource: {
- caption: 'lightSource'
- },
- cullgeometry: {
- caption: 'geometry'
- }
- };
-
- var fractions = [ {
- base: 'frame',
- steps: [ 'update', 'cull', 'render' ]
- } ];
-
- var groups = [ {
- caption: 'Framerate',
- values: [ 'fps', 'raf' ]
- }, {
- caption: 'Frame Budget',
- values: [ 'frame', 'update', 'cull', 'render', 'glframe' ]
- }, {
- caption: 'Scene Graph',
- values: [ 'pushstateset', 'updatecallback' ]
- }, {
- caption: 'Cull',
- values: [ 'cullnode', 'cullmatrixtransform', 'cullgeometry', 'cullcamera', 'culllighsource', 'cullprojection' ]
- }, {
- caption: 'Texture Memory',
- values: [ 'texturereserved', 'textureused', 'texturetotal' ]
- } ];
-
- var plugins = [ this.bS, this.glS ];
-
- if ( opts ) {
- if ( opts.values ) MACROUTILS.objectMix( values, opts.values );
- if ( opts.groups ) Array.prototype.unshift.apply( groups, opts.groups );
- if ( opts.fractions ) Array.prototype.push.apply( fractions, opts.fractions );
- if ( opts.plugins ) Array.prototype.push.apply( plugins, opts.plugins );
- }
-
- this.rStats = new rStats( {
- values: values,
- groups: groups,
- fractions: fractions,
- plugins: plugins,
- colours: [ '#cc9933', '#f20041', '#69818c', '#d90074', '#b6f2ee', '#660044', '#50664d', '#330022', '#f2eeb6', '#ee00ff', '#806460', '#1600a6', '#994d57', '#00004d', '#f279da', '#002933', '#395073', '#00eeff', '#79baf2', '#008066', '#79f2aa', '#00ff66', '#1a331d', '#004d14', '#8c6c46', '#388c00', '#602080', '#ff8800', '#6d3df2', '#995200', '#0d1233', '#402200', '#3d6df2', '#330e00', '#e6f23d', '#730000' ]
- } );
-
-};
-
-var createStats = function ( options ) {
- // in case the deps are not here
- if ( !rStats ) return undefined;
-
-
- var css = '.rs-base{ position: absolute; z-index: 10000; padding: 10px; background-color: #222; font-size: 12px; line-height: 1.2em; width: 350px; font-family: \'Roboto Condensed\', tahoma, sans-serif; left: 0; top: 0; overflow: hidden; } .rs-base h1{ margin: 0; padding: 0; font-size: 1.4em; color: #fff; margin-bottom: 5px; cursor: pointer; } .rs-base div.rs-group{ margin-bottom: 10px; } .rs-base div.rs-group.hidden{ display: none; } .rs-base div.rs-fraction{ position: relative; margin-bottom: 5px; } .rs-base div.rs-fraction p{ width: 145px; text-align: right; margin: 0; padding: 0; } .rs-base div.rs-legend{ position: absolute; line-height: 1em; } .rs-base div.rs-counter-base{ position: relative; margin: 2px 0; height: 1em; } .rs-base span.rs-counter-id{ position: absolute; left: 0; top: 0; } .rs-base div.rs-counter-value{ position: absolute; left: 115px; width: 30px; height: 1em; top: 0; text-align: right; } .rs-base canvas.rs-canvas{ position: absolute; right: 0; } ',
- head = document.head || document.getElementsByTagName( 'head' )[ 0 ],
- style = document.createElement( 'style' );
-
- style.type = 'text/css';
- if ( style.styleSheet ) {
- style.styleSheet.cssText = css;
- } else {
- style.appendChild( document.createTextNode( css ) );
- }
- head.appendChild( style );
-
- return new CanvasStats( options.rstats );
-};
-
-module.exports = createStats;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/DeviceOrientation.js b/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/DeviceOrientation.js
deleted file mode 100644
index 6ea99dd7..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/DeviceOrientation.js
+++ /dev/null
@@ -1,75 +0,0 @@
-'use strict';
-
-var DeviceOrientation = function ( viewer ) {
- this._viewer = viewer;
- this._type = 'DeviceOrientation';
- this._enable = false;
-
- // Landscape mobile orientation testing defaults
- this._deviceOrientation = undefined;
- this._screenOrientation = window.orientation || 90;
-};
-
-DeviceOrientation.prototype = {
-
- setEnable: function ( bool ) {
- this._enable = bool;
- },
-
- getEnable: function () {
- return this._enable;
- },
-
- init: function () {
-
- var self = this;
-
- // Check because Chrome send _one_ event with all angles to null
- window.addEventListener( 'deviceorientation', function ( rawEvtData ) {
- if ( rawEvtData.alpha !== null && rawEvtData.alpha !== undefined )
- self._deviceOrientation = rawEvtData;
- }, false );
-
- window.addEventListener( 'orientationchange', function () {
- if ( window.orientation !== null && window.orientation !== undefined )
- self._screenOrientation = window.orientation;
- }, false );
-
- },
-
- getManipulatorController: function () {
- return this._viewer.getManipulator().getControllerList()[ this._type ];
- },
-
- isValid: function () {
- if ( !this._enable )
- return false;
-
- if ( !this._deviceOrientation )
- return false;
-
- var manipulator = this._viewer.getManipulator();
- if ( !manipulator )
- return false;
-
- if ( !manipulator.getControllerList()[ this._type ] )
- return false;
-
- return true;
- },
-
- update: function () {
-
- if ( !this.isValid() )
- return;
-
- // update the manipulator with the rotation of the device
- var manipulatorAdapter = this.getManipulatorController();
- if ( manipulatorAdapter.update ) {
- manipulatorAdapter.update( this._deviceOrientation, this._screenOrientation );
- }
- }
-
-};
-
-module.exports = DeviceOrientation;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/GamePad.js b/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/GamePad.js
deleted file mode 100644
index 42c3e616..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/GamePad.js
+++ /dev/null
@@ -1,93 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-
-
-var GamePad = function ( viewer ) {
- this._viewer = viewer;
- this._type = 'GamePad';
- this._enable = true;
- this._gamepadIndex = -1;
-};
-
-GamePad.prototype = {
-
- setEnable: function ( bool ) {
- this._enable = bool;
- },
-
- getEnable: function () {
- return this._enable;
- },
-
- init: function ( /*args*/) {},
-
- isValid: function () {
- if ( !this._enable )
- return false;
-
- var manipulator = this._viewer.getManipulator();
- if ( !manipulator )
- return false;
-
- var constrollerList = manipulator.getControllerList();
- if ( !constrollerList[ this._type ] )
- return false;
-
- return true;
- },
-
- getManipulatorController: function () {
- return this._viewer.getManipulator().getControllerList()[ this._type ];
- },
-
- gamepadPoll: function () {
- if ( !navigator.getGamepads )
- return null;
- var gamepads = navigator.getGamepads();
- var gamepad = gamepads[ this._gamepadIndex ];
- if ( gamepad )
- return gamepad;
-
- for ( var i = 0, nb = gamepads.length; i < nb; ++i ) {
- var gm = gamepads[ i ];
- // https://code.google.com/p/chromium/issues/detail?id=413805
- if ( gm && gm.id && gm.id.indexOf( 'Unknown Gamepad' ) === -1 ) {
- this._gamepadIndex = i;
- this.onGamepadConnect( gm );
- return gm;
- }
- }
- if ( this._gamepadIndex >= 0 ) {
- this._gamepadIndex = -1;
- this.onGamepadConnect();
- }
- return null;
- },
-
- onGamepadConnect: function ( gamepad ) {
- Notify.log( 'Detected new gamepad!', gamepad );
- },
-
- onGamepadDisconnect: function () {
- Notify.log( 'Gamepad disconnected' );
- },
-
- // Called in each frame
- update: function () {
- // we poll instead
-
- if ( !this.isValid() )
- return;
-
- var gamepad = this.gamepadPoll();
- if ( !gamepad )
- return;
-
- var manipulatorAdapter = this.getManipulatorController();
- //manipulatorAdapter.setEventProxy(this);
- if ( manipulatorAdapter.update ) {
- manipulatorAdapter.update( gamepad );
- }
- }
-};
-module.exports = GamePad;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/Hammer.js b/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/Hammer.js
deleted file mode 100644
index f1eea35d..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/Hammer.js
+++ /dev/null
@@ -1,84 +0,0 @@
-'use strict';
-var Hammer = require( 'hammer' );
-
-
-var HammerController = function ( viewer ) {
- this._enable = true;
- this._viewer = viewer;
- this._type = 'Hammer';
-
- this._eventNode = undefined;
-
-};
-
-HammerController.prototype = {
-
- setEnable: function ( bool ) {
- this._enable = bool;
- },
-
- getEnable: function () {
- return this._enable;
- },
-
- init: function ( options ) {
-
- /*jshint camelcase: false */
-
- var deviceOptions = {
- prevent_default: true,
- drag_max_touches: 2,
- transform_min_scale: 0.08,
- transform_min_rotation: 180,
- transform_always_block: true,
- hold: false,
- release: false,
- swipe: false,
- tap: false
- };
- /*jshint camelcase: true */
-
- this._eventNode = options.eventNode;
-
- if ( this._eventNode ) {
-
- this._hammer = new Hammer( this._eventNode, deviceOptions );
-
- if ( options.getBoolean( 'scrollwheel' ) === false )
- this._hammer.get( 'pinch' ).set( {
- enable: false
- } );
- else
- this._hammer.get( 'pinch' ).set( {
- enable: true
- } );
-
- }
- },
-
- isValid: function () {
- if ( this._enable && this._viewer.getManipulator() && this._viewer.getManipulator().getControllerList()[ this._type ] )
- return true;
- return false;
- },
- getManipulatorController: function () {
- return this._viewer.getManipulator().getControllerList()[ this._type ];
- },
-
- // use the update to set the input device to mouse controller
- // it's needed to compute size
- update: function () {
- if ( !this.isValid() )
- return;
-
- // we pass directly hammer object
- this.getManipulatorController().setEventProxy( this._hammer );
- },
- remove: function () {
- if ( !this.isValid() )
- return;
- this.getManipulatorController().removeEventProxy( this._hammer );
- }
-
-};
-module.exports = HammerController;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/LeapMotion.js b/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/LeapMotion.js
deleted file mode 100644
index 9aa974c0..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/LeapMotion.js
+++ /dev/null
@@ -1,71 +0,0 @@
-'use strict';
-var Leap = undefined;
-var Notify = require( 'osg/notify' );
-
-var LeapMotion = function ( viewer ) {
- this._viewer = viewer;
- this._type = 'LeapMotion';
- this._enable = true;
-};
-
-LeapMotion.prototype = {
-
- setEnable: function ( bool ) {
- this._enable = bool;
- },
-
- getEnable: function () {
- return this._enable;
- },
-
- init: function ( args ) {
-
- // add condition if no leap in global space
- if ( typeof Leap === 'undefined' || !Leap.Controller )
- return;
-
- var self = this;
- this._controller = new Leap.Controller( {
- enableGestures: args.gestures || true,
- tryReconnectOnDisconnect: true,
- connectAttempts: 3
- } );
- this._controller.on( 'ready', function () {
- if ( args.readyCallback )
- args.readyCallback( self._controller );
- self._leapMotionReady = true;
- Notify.info( 'leapmotion ready' );
- } );
- this._controller.loop( this._update.bind( this ) );
- },
-
- isValid: function () {
- if ( !this._enable )
- return false;
-
- var manipulator = this._viewer.getManipulator();
- if ( !manipulator )
- return false;
-
- var constrollerList = manipulator.getControllerList();
- if ( !constrollerList[ this._type ] )
- return false;
-
- return true;
- },
- getManipulatorController: function () {
- return this._viewer.getManipulator().getControllerList()[ this._type ];
- },
-
- // this is binded
- _update: function ( frame ) {
- if ( !frame.valid || !this.isValid() ) {
- return;
- }
- var manipulatorAdapter = this.getManipulatorController();
- if ( manipulatorAdapter.update ) {
- manipulatorAdapter.update( frame );
- }
- }
-};
-module.exports = LeapMotion;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/StandardMouseKeyboard.js b/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/StandardMouseKeyboard.js
deleted file mode 100644
index b734396b..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/StandardMouseKeyboard.js
+++ /dev/null
@@ -1,256 +0,0 @@
-'use strict';
-var vec2 = require( 'osg/glMatrix' ).vec2;
-
-
-var StandardMouseKeyboard = function ( viewer ) {
- this._enable = true;
- this._viewer = viewer;
- this._type = 'StandardMouseKeyboard';
-
- this._mouseEventNode = undefined;
- this._wheelEventNode = undefined;
- this._keyboardEventNode = undefined;
- this._eventList = [ 'mousedown', 'mouseup', 'mouseout', 'mousemove', 'dblclick' ];
- this._mousePosition = vec2.create();
-};
-
-StandardMouseKeyboard.prototype = {
-
- setEnable: function ( bool ) {
- this._enable = bool;
- },
-
- getEnable: function () {
- return this._enable;
- },
-
- init: function ( options ) {
-
- this.removeEventListeners( this._mouseEventNode, this._wheelEventNode, this._keyboardEventNode );
-
- var mouse = options.mouseEventNode;
-
- var mousewheel = options.wheelEventNode || mouse;
- var keyboard = options.keyboardEventNode || mouse;
-
- if ( options.getBoolean( 'scrollwheel' ) === false )
- mousewheel = null;
-
- this.addEventListeners( mouse, mousewheel, keyboard );
- this._mouseEventNode = mouse;
- this._wheelEventNode = mousewheel;
- this._keyboardEventNode = keyboard;
- },
-
- addEventListeners: function ( mouse, mousewheel, keyboard ) {
- if ( mouse ) {
- for ( var i = 0, l = this._eventList.length; i < l; i++ ) {
- var ev = this._eventList[ i ];
- if ( this[ ev ] ) {
- mouse.addEventListener( ev, this[ ev ].bind( this ), false );
- }
- }
- }
- if ( mousewheel ) {
- mousewheel.addEventListener( 'DOMMouseScroll', this.mousewheel.bind( this ), false );
- mousewheel.addEventListener( 'mousewheel', this.mousewheel.bind( this ), false );
- mousewheel.addEventListener( 'MozMousePixelScroll', this.preventDefault.bind( this ), false );
- }
-
- if ( keyboard ) {
- keyboard.addEventListener( 'keydown', this.keydown.bind( this ), false );
- keyboard.addEventListener( 'keyup', this.keyup.bind( this ), false );
- }
- },
-
- removeEventListeners: function ( mouse, mousewheel, keyboard ) {
- if ( mouse ) {
- for ( var i = 0, l = this._eventList.length; i < l; i++ ) {
- var ev = this._eventList[ i ];
- if ( this[ ev ] ) {
- mouse.removeEventListener( ev, this[ ev ] );
- }
- }
- }
- if ( mousewheel ) {
- mousewheel.removeEventListener( 'DOMMouseScroll', this.mousewheel );
- mousewheel.removeEventListener( 'mousewheel', this.mousewheel );
- mousewheel.removeEventListener( 'MozMousePixelScroll', this.preventDefault );
- }
- if ( keyboard ) {
- keyboard.removeEventListener( 'keydown', this.keydown );
- keyboard.removeEventListener( 'keyup', this.keyup );
- }
- },
-
- isValid: function () {
- if ( this._enable && this._viewer.getManipulator() && this._viewer.getManipulator().getControllerList()[ this._type ] )
- return true;
- return false;
- },
- getManipulatorController: function () {
- return this._viewer.getManipulator().getControllerList()[ this._type ];
- },
-
- keyup: function ( ev ) {
-
- if ( this.isValid() && this.getManipulatorController().keyup )
- return this.getManipulatorController().keyup( ev );
-
- return undefined;
- },
-
- keydown: function ( ev ) {
-
- if ( this.isValid() && this.getManipulatorController().keydown )
- return this.getManipulatorController().keydown( ev );
-
- return undefined;
- },
-
- mousedown: function ( ev ) {
-
- if ( this.isValid() && this.getManipulatorController().mousedown )
- return this.getManipulatorController().mousedown( ev );
-
- return undefined;
- },
-
- mouseup: function ( ev ) {
-
- if ( this.isValid() && this.getManipulatorController().mouseup )
- return this.getManipulatorController().mouseup( ev );
-
- return undefined;
- },
-
- mouseout: function ( ev ) {
-
- if ( this.isValid() && this.getManipulatorController().mouseout )
- return this.getManipulatorController().mouseout( ev );
-
- return undefined;
- },
-
- mousemove: function ( ev ) {
-
- if ( this.isValid() && this.getManipulatorController().mousemove )
- return this.getManipulatorController().mousemove( ev );
-
- return undefined;
- },
-
- dblclick: function ( ev ) {
-
- if ( this.isValid() && this.getManipulatorController().dblclick )
- return this.getManipulatorController().dblclick( ev );
-
- return undefined;
- },
-
- mousewheel: function ( event ) {
-
- if ( !this.isValid() )
- return undefined;
-
- var manipulatorAdapter = this.getManipulatorController();
-
- if ( !manipulatorAdapter.mousewheel )
- return undefined;
-
- // from jquery
- var orgEvent = event || window.event,
- args = [].slice.call( arguments, 1 ),
- delta = 0,
- deltaX = 0,
- deltaY = 0;
-
- // Old school scrollwheel delta
- if ( event.wheelDelta ) {
- delta = event.wheelDelta / 120;
- }
- if ( event.detail ) {
- delta = -event.detail / 3;
- }
-
- // New school multidimensional scroll (touchpads) deltas
- deltaY = delta;
-
- // Gecko
- if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
- deltaY = 0;
- deltaX = -1 * delta;
- }
-
- // Webkit
- if ( orgEvent.wheelDeltaY !== undefined ) {
- deltaY = orgEvent.wheelDeltaY / 120;
- }
- if ( orgEvent.wheelDeltaX !== undefined ) {
- deltaX = -1 * orgEvent.wheelDeltaX / 120;
- }
- // Add event and delta to the front of the arguments
- args.unshift( event, delta, deltaX, deltaY );
-
- return this.getManipulatorController().mousewheel.apply( manipulatorAdapter, args );
- },
-
- preventDefault: function ( event ) {
- event.preventDefault();
- },
-
- divGlobalOffset: function ( obj ) {
- var x = 0,
- y = 0;
- x = obj.offsetLeft;
- y = obj.offsetTop;
- var body = document.getElementsByTagName( 'body' )[ 0 ];
- while ( obj.offsetParent && obj !== body ) {
- x += obj.offsetParent.offsetLeft;
- y += obj.offsetParent.offsetTop;
- obj = obj.offsetParent;
- }
- this._mousePosition[ 0 ] = x;
- this._mousePosition[ 1 ] = y;
- return this._mousePosition;
- },
-
- getPositionRelativeToCanvas: function ( e, result ) {
- var myObject = e.target;
- var posx, posy;
- if ( e.pageX || e.pageY ) {
- posx = e.pageX;
- posy = e.pageY;
- } else if ( e.clientX || e.clientY ) {
- posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
- posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
- }
-
- // posx and posy contain the mouse position relative to the document
- // Do something with this information
- var globalOffset = this.divGlobalOffset( myObject );
- posx = posx - globalOffset[ 0 ];
- posy = myObject.height - ( posy - globalOffset[ 1 ] );
-
- // copy data to result if need to keep result
- // else we use a tmp variable inside manipulator
- // that we override at each call
- if ( result === undefined ) {
- result = this._mousePosition;
- }
- result[ 0 ] = posx;
- result[ 1 ] = posy;
- return result;
- },
-
- // use the update to set the input device to mouse controller
- // it's needed to compute size
- update: function () {
- if ( !this.isValid() )
- return;
-
- this.getManipulatorController().setEventProxy( this );
- }
-
-};
-module.exports = StandardMouseKeyboard;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/WebVR.js b/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/WebVR.js
deleted file mode 100644
index e9826270..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/WebVR.js
+++ /dev/null
@@ -1,138 +0,0 @@
-'use strict';
-var Notify = require( 'osg/notify' );
-var quat = require( 'osg/glMatrix' ).quat;
-var vec3 = require( 'osg/glMatrix' ).vec3;
-var mat4 = require( 'osg/glMatrix' ).mat4;
-require( 'osgUtil/webvr-1-1' ); // polyfill
-
-
-var WebVR = function ( viewer ) {
- this._viewer = viewer;
-
- this._type = 'WebVR';
- this._enable = false;
- this._hmd = undefined;
- this._sensor = undefined;
-
- this._frameData = undefined;
- this._quat = quat.create();
- this._pos = vec3.create();
-
- this._worldScale = 1.0;
-};
-
-WebVR.prototype = {
-
- setWorldScale: function ( val ) {
- this._worldScale = val;
- },
-
- setEnable: function ( bool ) {
- this._enable = bool;
- },
-
- getEnable: function () {
- return this._enable;
- },
-
- init: function () {
-
- if ( !navigator.getVRDisplays )
- return;
-
- var self = this;
- navigator.getVRDisplays().then( function ( displays ) {
- if ( displays.length > 0 ) {
- self._hmd = displays[ 0 ];
- self._frameData = new window.VRFrameData();
- Notify.log( 'Found a VR display' );
- // currently it's the event proxy webvr that has the responsability of detecting vr devices
- self._viewer.setVRDisplay( self._hmd );
- }
- } );
- },
-
- getManipulatorController: function () {
- return this._viewer.getManipulator().getControllerList()[ this._type ];
- },
-
- isValid: function () {
- if ( !this._enable )
- return false;
-
- var manipulator = this._viewer.getManipulator();
- if ( !manipulator )
- return false;
-
- if ( !manipulator.getControllerList()[ this._type ] )
- return false;
-
- if ( !this._hmd )
- return false;
-
- return true;
- },
-
- update: ( function () {
- var tempQuat = quat.create();
- var tempPos = vec3.create();
-
- return function () {
-
- if ( !this.isValid() )
- return;
-
- var manipulatorAdapter = this.getManipulatorController();
-
- // update the manipulator with the rotation of the device
- if ( !manipulatorAdapter.update )
- return;
-
- if ( !this._hmd.capabilities.hasOrientation && !this._hmd.capabilities.hasPosition )
- return;
-
- this._hmd.getFrameData( this._frameData );
-
- var pose = this._frameData.pose;
-
- if ( !pose )
- return;
-
- // WebVR up vector is Y
- // OSGJS up vector is Z
-
- var sitToStand = this._hmd.stageParameters && this._hmd.stageParameters.sittingToStandingTransform;
-
- var q = pose.orientation;
- if ( q ) {
- if ( sitToStand ) {
- q = mat4.getRotation( tempQuat, sitToStand );
- quat.mul( q, q, pose.orientation );
- }
-
- this._quat[ 0 ] = q[ 0 ];
- this._quat[ 1 ] = -q[ 2 ];
- this._quat[ 2 ] = q[ 1 ];
- this._quat[ 3 ] = q[ 3 ];
- }
-
- var pos = pose.position;
- if ( pos ) {
- if ( sitToStand ) {
- pos = vec3.transformMat4( tempPos, pos, sitToStand );
- }
- this._pos[ 0 ] = pos[ 0 ] * this._worldScale;
- this._pos[ 1 ] = -pos[ 2 ] * this._worldScale;
- this._pos[ 2 ] = pos[ 1 ] * this._worldScale;
- }
-
- manipulatorAdapter.update( this._quat, this._pos );
- };
- } )(),
-
-
- getHmd: function () {
- return this._hmd;
- }
-};
-module.exports = WebVR;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/eventProxy.js b/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/eventProxy.js
deleted file mode 100644
index 331b4a73..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/eventProxy/eventProxy.js
+++ /dev/null
@@ -1,16 +0,0 @@
-'use strict';
-var GamePad = require( 'osgViewer/eventProxy/GamePad' );
-var HammerOsg = require( 'osgViewer/eventProxy/Hammer' );
-var LeapMotion = require( 'osgViewer/eventProxy/LeapMotion' );
-var StandardMouseKeyboard = require( 'osgViewer/eventProxy/StandardMouseKeyboard' );
-var WebVR = require( 'osgViewer/eventProxy/WebVR' );
-var DeviceOrientation = require( 'osgViewer/eventProxy/DeviceOrientation' );
-
-module.exports = {
- GamePad: GamePad,
- Hammer: HammerOsg,
- LeapMotion: LeapMotion,
- StandardMouseKeyboard: StandardMouseKeyboard,
- WebVR: WebVR,
- DeviceOrientation: DeviceOrientation
-};
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/osgViewer.js b/app/static/app/js/vendor/osgjs/osgViewer/osgViewer.js
deleted file mode 100644
index a9183405..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/osgViewer.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-var Renderer = require( 'osgViewer/Renderer' );
-var View = require( 'osgViewer/View' );
-var Viewer = require( 'osgViewer/Viewer' );
-var EventProxy = require( 'osgViewer/eventProxy/eventProxy' );
-var Scene = require( 'osgViewer/Scene' );
-
-
-var osgViewer = {};
-
-osgViewer.Renderer = Renderer;
-osgViewer.View = View;
-osgViewer.Viewer = Viewer;
-osgViewer.EventProxy = EventProxy;
-osgViewer.Scene = Scene;
-
-module.exports = osgViewer;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/webgl-debug.js b/app/static/app/js/vendor/osgjs/osgViewer/webgl-debug.js
deleted file mode 100644
index b1556665..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/webgl-debug.js
+++ /dev/null
@@ -1,926 +0,0 @@
-// jshint ignore: start
-
-'use strict';
-var Notify = require( 'osg/notify' );
-
-//Copyright (c) 2009 The Chromium Authors. All rights reserved.
-//Use of this source code is governed by a BSD-style license that can be
-//found in the LICENSE file.
-
-// Various functions for helping debug WebGL apps.
-
-var WebGLDebugUtils = function () {
-
- /**
- * Which arguements are enums.
- * @type {!Object.}
- */
- var glValidEnumContexts = {
-
- // Generic setters and getters
-
- 'enable': {
- 0: true
- },
- 'disable': {
- 0: true
- },
- 'getParameter': {
- 0: true
- },
-
- // Rendering
-
- 'drawArrays': {
- 0: true
- },
- 'drawElements': {
- 0: true,
- 2: true
- },
-
- // Shaders
-
- 'createShader': {
- 0: true
- },
- 'getShaderParameter': {
- 1: true
- },
- 'getProgramParameter': {
- 1: true
- },
-
- // Vertex attributes
-
- 'getVertexAttrib': {
- 1: true
- },
- 'vertexAttribPointer': {
- 2: true
- },
-
- // Textures
-
- 'bindTexture': {
- 0: true
- },
- 'activeTexture': {
- 0: true
- },
- 'getTexParameter': {
- 0: true,
- 1: true
- },
- 'texParameterf': {
- 0: true,
- 1: true
- },
- 'texParameteri': {
- 0: true,
- 1: true,
- 2: true
- },
- 'texImage2D': {
- 0: true,
- 2: true,
- 6: true,
- 7: true
- },
- 'texSubImage2D': {
- 0: true,
- 6: true,
- 7: true
- },
- 'copyTexImage2D': {
- 0: true,
- 2: true
- },
- 'copyTexSubImage2D': {
- 0: true
- },
- 'generateMipmap': {
- 0: true
- },
-
- // Buffer objects
-
- 'bindBuffer': {
- 0: true
- },
- 'bufferData': {
- 0: true,
- 2: true
- },
- 'bufferSubData': {
- 0: true
- },
- 'getBufferParameter': {
- 0: true,
- 1: true
- },
-
- // Renderbuffers and framebuffers
-
- 'pixelStorei': {
- 0: true,
- 1: true
- },
- 'readPixels': {
- 4: true,
- 5: true
- },
- 'bindRenderbuffer': {
- 0: true
- },
- 'bindFramebuffer': {
- 0: true
- },
- 'checkFramebufferStatus': {
- 0: true
- },
- 'framebufferRenderbuffer': {
- 0: true,
- 1: true,
- 2: true
- },
- 'framebufferTexture2D': {
- 0: true,
- 1: true,
- 2: true
- },
- 'getFramebufferAttachmentParameter': {
- 0: true,
- 1: true,
- 2: true
- },
- 'getRenderbufferParameter': {
- 0: true,
- 1: true
- },
- 'renderbufferStorage': {
- 0: true,
- 1: true
- },
-
- // Frame buffer operations (clear, blend, depth test, stencil)
-
- 'clear': {
- 0: true
- },
- 'depthFunc': {
- 0: true
- },
- 'blendFunc': {
- 0: true,
- 1: true
- },
- 'blendFuncSeparate': {
- 0: true,
- 1: true,
- 2: true,
- 3: true
- },
- 'blendEquation': {
- 0: true
- },
- 'blendEquationSeparate': {
- 0: true,
- 1: true
- },
- 'stencilFunc': {
- 0: true
- },
- 'stencilFuncSeparate': {
- 0: true,
- 1: true
- },
- 'stencilMaskSeparate': {
- 0: true
- },
- 'stencilOp': {
- 0: true,
- 1: true,
- 2: true
- },
- 'stencilOpSeparate': {
- 0: true,
- 1: true,
- 2: true,
- 3: true
- },
-
- // Culling
-
- 'cullFace': {
- 0: true
- },
- 'frontFace': {
- 0: true
- }
- };
-
- /**
- * Map of numbers to names.
- * @type {Object}
- */
- var glEnums = null;
-
- /**
- * Initializes this module. Safe to call more than once.
- * @param {!WebGLRenderingContext} ctx A WebGL context. If
- * you have more than one context it doesn't matter which one
- * you pass in, it is only used to pull out constants.
- */
- function init( ctx ) {
- if ( glEnums === null ) {
- glEnums = {};
- for ( var propertyName in ctx ) {
- if ( typeof ctx[ propertyName ] === 'number' ) {
- glEnums[ ctx[ propertyName ] ] = propertyName;
- }
- }
- }
- }
-
- /**
- * Checks the utils have been initialized.
- */
- function checkInit() {
- if ( glEnums === null ) {
- throw 'WebGLDebugUtils.init(ctx) not called';
- }
- }
-
- /**
- * Returns true or false if value matches any WebGL enum
- * @param {*} value Value to check if it might be an enum.
- * @return {boolean} True if value matches one of the WebGL defined enums
- */
- function mightBeEnum( value ) {
- checkInit();
- return ( glEnums[ value ] !== undefined );
- }
-
- /**
- * Gets an string version of an WebGL enum.
- *
- * Example:
- * var str = WebGLDebugUtil.glEnumToString(ctx.getError());
- *
- * @param {number} value Value to return an enum for
- * @return {string} The string version of the enum.
- */
- function glEnumToString( value ) {
- checkInit();
- var name = glEnums[ value ];
- return ( name !== undefined ) ? name :
- ( '*UNKNOWN WebGL ENUM (0x' + value.toString( 16 ) + ')' );
- }
-
- /**
- * Returns the string version of a WebGL argument.
- * Attempts to convert enum arguments to strings.
- * @param {string} functionName the name of the WebGL function.
- * @param {number} argumentIndx the index of the argument.
- * @param {*} value The value of the argument.
- * @return {string} The value as a string.
- */
- function glFunctionArgToString( functionName, argumentIndex, value ) {
- var funcInfo = glValidEnumContexts[ functionName ];
- if ( funcInfo !== undefined ) {
- if ( funcInfo[ argumentIndex ] ) {
- return glEnumToString( value );
- }
- }
- return value.toString();
- }
-
- function makePropertyWrapper( wrapper, original, propertyName ) {
- //Notify.log("wrap prop: " + propertyName);
- wrapper.__defineGetter__( propertyName, function () {
- return original[ propertyName ];
- } );
- // TODO(gmane): this needs to handle properties that take more than
- // one value?
- wrapper.__defineSetter__( propertyName, function ( value ) {
- //Notify.log("set: " + propertyName);
- original[ propertyName ] = value;
- } );
- }
-
- // Makes a function that calls a function on another object.
- function makeFunctionWrapper( original, functionName ) {
- //Notify.log("wrap fn: " + functionName);
- var f = original[ functionName ];
- return function () {
- //Notify.log("call: " + functionName);
- var result = f.apply( original, arguments );
- return result;
- };
- }
-
- /**
- * Given a WebGL context returns a wrapped context that calls
- * gl.getError after every command and calls a function if the
- * result is not gl.NO_ERROR.
- *
- * @param {!WebGLRenderingContext} ctx The webgl context to
- * wrap.
- * @param {!function(err, funcName, args): void} opt_onErrorFunc
- * The function to call when gl.getError returns an
- * error. If not specified the default function calls
- * Notify.log with a message.
- */
- function makeDebugContext( ctx, opt_onErrorFunc ) {
- init( ctx );
- opt_onErrorFunc = opt_onErrorFunc || function ( err, functionName, args ) {
- // apparently we can't do args.join(",");
- var argStr = "";
- for ( var ii = 0; ii < args.length; ++ii ) {
- argStr += ( ( ii === 0 ) ? '' : ', ' ) +
- glFunctionArgToString( functionName, ii, args[ ii ] );
- }
- Notify.log( "WebGL error " + glEnumToString( err ) + " in " + functionName +
- "(" + argStr + ")" );
- };
-
- // Holds booleans for each GL error so after we get the error ourselves
- // we can still return it to the client app.
- var glErrorShadow = {};
-
- // Makes a function that calls a WebGL function and then calls getError.
- function makeErrorWrapper( ctx, functionName ) {
- return function () {
- var result = ctx[ functionName ].apply( ctx, arguments );
- var err = ctx.getError();
- if ( err !== 0 ) {
- glErrorShadow[ err ] = true;
- opt_onErrorFunc( err, functionName, arguments );
- }
- return result;
- };
- }
-
- // Make a an object that has a copy of every property of the WebGL context
- // but wraps all functions.
- var wrapper = {};
- for ( var propertyName in ctx ) {
- if ( typeof ctx[ propertyName ] == 'function' ) {
- wrapper[ propertyName ] = makeErrorWrapper( ctx, propertyName );
- } else {
- makePropertyWrapper( wrapper, ctx, propertyName );
- }
- }
-
- // Override the getError function with one that returns our saved results.
- wrapper.getError = function () {
- for ( var err in glErrorShadow ) {
- if ( glErrorShadow[ err ] ) {
- glErrorShadow[ err ] = false;
- return err;
- }
- }
- return ctx.NO_ERROR;
- };
-
- return wrapper;
- }
-
- function resetToInitialState( ctx ) {
- var numAttribs = ctx.getParameter( ctx.MAX_VERTEX_ATTRIBS );
- var tmp = ctx.createBuffer();
- ctx.bindBuffer( ctx.ARRAY_BUFFER, tmp );
- var ii;
- for ( ii = 0; ii < numAttribs; ++ii ) {
- ctx.disableVertexAttribArray( ii );
- ctx.vertexAttribPointer( ii, 4, ctx.FLOAT, false, 0, 0 );
- ctx.vertexAttrib1f( ii, 0 );
- }
- ctx.deleteBuffer( tmp );
-
- var numTextureUnits = ctx.getParameter( ctx.MAX_TEXTURE_IMAGE_UNITS );
- for ( ii = 0; ii < numTextureUnits; ++ii ) {
- ctx.activeTexture( ctx.TEXTURE0 + ii );
- ctx.bindTexture( ctx.TEXTURE_CUBE_MAP, null );
- ctx.bindTexture( ctx.TEXTURE_2D, null );
- }
-
- ctx.activeTexture( ctx.TEXTURE0 );
- ctx.useProgram( null );
- ctx.bindBuffer( ctx.ARRAY_BUFFER, null );
- ctx.bindBuffer( ctx.ELEMENT_ARRAY_BUFFER, null );
- ctx.bindFramebuffer( ctx.FRAMEBUFFER, null );
- ctx.bindRenderbuffer( ctx.RENDERBUFFER, null );
- ctx.disable( ctx.BLEND );
- ctx.disable( ctx.CULL_FACE );
- ctx.disable( ctx.DEPTH_TEST );
- ctx.disable( ctx.DITHER );
- ctx.disable( ctx.SCISSOR_TEST );
- ctx.blendColor( 0, 0, 0, 0 );
- ctx.blendEquation( ctx.FUNC_ADD );
- ctx.blendFunc( ctx.ONE, ctx.ZERO );
- ctx.clearColor( 0, 0, 0, 0 );
- ctx.clearDepth( 1 );
- ctx.clearStencil( -1 );
- ctx.colorMask( true, true, true, true );
- ctx.cullFace( ctx.BACK );
- ctx.depthFunc( ctx.LESS );
- ctx.depthMask( true );
- ctx.depthRange( 0, 1 );
- ctx.frontFace( ctx.CCW );
- ctx.hint( ctx.GENERATE_MIPMAP_HINT, ctx.DONT_CARE );
- ctx.lineWidth( 1 );
- ctx.pixelStorei( ctx.PACK_ALIGNMENT, 4 );
- ctx.pixelStorei( ctx.UNPACK_ALIGNMENT, 4 );
- ctx.pixelStorei( ctx.UNPACK_FLIP_Y_WEBGL, false );
- ctx.pixelStorei( ctx.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false );
- // TODO: Delete this IF.
- if ( ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL ) {
- ctx.pixelStorei( ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL, ctx.BROWSER_DEFAULT_WEBGL );
- }
- ctx.polygonOffset( 0, 0 );
- ctx.sampleCoverage( 1, false );
- ctx.scissor( 0, 0, ctx.canvas.width, ctx.canvas.height );
- ctx.stencilFunc( ctx.ALWAYS, 0, 0xFFFFFFFF );
- ctx.stencilMask( 0xFFFFFFFF );
- ctx.stencilOp( ctx.KEEP, ctx.KEEP, ctx.KEEP );
- ctx.viewport( 0, 0, ctx.canvas.width, ctx.canvas.height );
- ctx.clear( ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT | ctx.STENCIL_BUFFER_BIT );
-
- // TODO: This should NOT be needed but Firefox fails with 'hint'
- while ( ctx.getError() ) {}
- }
-
- function makeLostContextSimulatingCanvas( canvas ) {
- var unwrappedContext_;
- //var wrappedContext_;
- var onLost_ = [];
- var onRestored_ = [];
- var wrappedContext_ = {};
- var contextId_ = 1;
- var contextLost_ = false;
- var resourceId_ = 0;
- var resourceDb_ = [];
- var numCallsToLoseContext_ = 0;
- var numCalls_ = 0;
- var canRestore_ = false;
- var restoreTimeout_ = 0;
-
- // Holds booleans for each GL error so can simulate errors.
- var glErrorShadow_ = {};
-
- canvas.getContext = function ( f ) {
- return function () {
- var ctx = f.apply( canvas, arguments );
- // Did we get a context and is it a WebGL context?
- if ( ctx instanceof WebGLRenderingContext ) {
- if ( ctx != unwrappedContext_ ) {
- if ( unwrappedContext_ ) {
- throw "got different context";
- }
- unwrappedContext_ = ctx;
- wrappedContext_ = makeLostContextSimulatingContext( unwrappedContext_ );
- }
- return wrappedContext_;
- }
- return ctx;
- };
- }( canvas.getContext );
-
- function wrapEvent( listener ) {
- if ( typeof ( listener ) == "function" ) {
- return listener;
- } else {
- return function ( info ) {
- listener.handleEvent( info );
- };
- }
- }
-
- var addOnContextLostListener = function ( listener ) {
- onLost_.push( wrapEvent( listener ) );
- };
-
- var addOnContextRestoredListener = function ( listener ) {
- onRestored_.push( wrapEvent( listener ) );
- };
-
-
- function wrapAddEventListener( canvas ) {
- var f = canvas.addEventListener;
- canvas.addEventListener = function ( type, listener, bubble ) {
- switch ( type ) {
- case 'webglcontextlost':
- addOnContextLostListener( listener );
- break;
- case 'webglcontextrestored':
- addOnContextRestoredListener( listener );
- break;
- default:
- f.apply( canvas, arguments );
- }
- };
- }
-
- wrapAddEventListener( canvas );
-
- canvas.loseContext = function () {
- if ( !contextLost_ ) {
- contextLost_ = true;
- numCallsToLoseContext_ = 0;
- ++contextId_;
- while ( unwrappedContext_.getError() ) {}
- clearErrors();
- glErrorShadow_[ unwrappedContext_.CONTEXT_LOST_WEBGL ] = true;
- var event = makeWebGLContextEvent( "context lost" );
- var callbacks = onLost_.slice();
- setTimeout( function () {
- //Notify.log("numCallbacks:" + callbacks.length);
- for ( var ii = 0; ii < callbacks.length; ++ii ) {
- //Notify.log("calling callback:" + ii);
- callbacks[ ii ]( event );
- }
- if ( restoreTimeout_ >= 0 ) {
- setTimeout( function () {
- canvas.restoreContext();
- }, restoreTimeout_ );
- }
- }, 0 );
- }
- };
-
- canvas.restoreContext = function () {
- if ( contextLost_ ) {
- if ( onRestored_.length ) {
- setTimeout( function () {
- if ( !canRestore_ ) {
- throw "can not restore. webglcontestlost listener did not call event.preventDefault";
- }
- freeResources();
- resetToInitialState( unwrappedContext_ );
- contextLost_ = false;
- numCalls_ = 0;
- canRestore_ = false;
- var callbacks = onRestored_.slice();
- var event = makeWebGLContextEvent( "context restored" );
- for ( var ii = 0; ii < callbacks.length; ++ii ) {
- callbacks[ ii ]( event );
- }
- }, 0 );
- }
- }
- };
-
- canvas.loseContextInNCalls = function ( numCalls ) {
- if ( contextLost_ ) {
- throw "You can not ask a lost contet to be lost";
- }
- numCallsToLoseContext_ = numCalls_ + numCalls;
- };
-
- canvas.getNumCalls = function () {
- return numCalls_;
- };
-
- canvas.setRestoreTimeout = function ( timeout ) {
- restoreTimeout_ = timeout;
- };
-
- function isWebGLObject( obj ) {
- //return false;
- return ( obj instanceof WebGLBuffer ||
- obj instanceof WebGLFramebuffer ||
- obj instanceof WebGLProgram ||
- obj instanceof WebGLRenderbuffer ||
- obj instanceof WebGLShader ||
- obj instanceof WebGLTexture );
- }
-
- function checkResources( args ) {
- for ( var ii = 0; ii < args.length; ++ii ) {
- var arg = args[ ii ];
- if ( isWebGLObject( arg ) ) {
- return arg.__webglDebugContextLostId__ == contextId_;
- }
- }
- return true;
- }
-
- function clearErrors() {
- var k = window.Object.keys( glErrorShadow_ );
- for ( var ii = 0; ii < k.length; ++ii ) {
- delete glErrorShadow_[ k ];
- }
- }
-
- function loseContextIfTime() {
- ++numCalls_;
- if ( !contextLost_ ) {
- if ( numCallsToLoseContext_ == numCalls_ ) {
- canvas.loseContext();
- }
- }
- }
-
- // Makes a function that simulates WebGL when out of context.
- function makeLostContextFunctionWrapper( ctx, functionName ) {
- var f = ctx[ functionName ];
- return function () {
- // Notify.log("calling:" + functionName);
- // Only call the functions if the context is not lost.
- loseContextIfTime();
- if ( !contextLost_ ) {
- //if (!checkResources(arguments)) {
- // glErrorShadow_[wrappedContext_.INVALID_OPERATION] = true;
- // return;
- //}
- var result = f.apply( ctx, arguments );
- return result;
- }
- };
- }
-
- function freeResources() {
- for ( var ii = 0; ii < resourceDb_.length; ++ii ) {
- var resource = resourceDb_[ ii ];
- if ( resource instanceof WebGLBuffer ) {
- unwrappedContext_.deleteBuffer( resource );
- } else if ( resource instanceof WebGLFramebuffer ) {
- unwrappedContext_.deleteFramebuffer( resource );
- } else if ( resource instanceof WebGLProgram ) {
- unwrappedContext_.deleteProgram( resource );
- } else if ( resource instanceof WebGLRenderbuffer ) {
- unwrappedContext_.deleteRenderbuffer( resource );
- } else if ( resource instanceof WebGLShader ) {
- unwrappedContext_.deleteShader( resource );
- } else if ( resource instanceof WebGLTexture ) {
- unwrappedContext_.deleteTexture( resource );
- }
- }
- }
-
- function makeWebGLContextEvent( statusMessage ) {
- return {
- statusMessage: statusMessage,
- preventDefault: function () {
- canRestore_ = true;
- }
- };
- }
-
-
- function makeLostContextSimulatingContext( ctx ) {
- // copy all functions and properties to wrapper
- for ( var propertyName in ctx ) {
- if ( typeof ctx[ propertyName ] == 'function' ) {
- wrappedContext_[ propertyName ] = makeLostContextFunctionWrapper(
- ctx, propertyName );
- } else {
- makePropertyWrapper( wrappedContext_, ctx, propertyName );
- }
- }
-
- // Wrap a few functions specially.
- wrappedContext_.getError = function () {
- loseContextIfTime();
- var err;
- if ( !contextLost_ ) {
- while ( err = unwrappedContext_.getError() ) {
- glErrorShadow_[ err ] = true;
- }
- }
- for ( err in glErrorShadow_ ) {
- if ( glErrorShadow_[ err ] ) {
- delete glErrorShadow_[ err ];
- return err;
- }
- }
- return wrappedContext_.NO_ERROR;
- };
-
- var creationFunctions = [
- "createBuffer",
- "createFramebuffer",
- "createProgram",
- "createRenderbuffer",
- "createShader",
- "createTexture"
- ];
- var functionName, ii;
- for ( ii = 0; ii < creationFunctions.length; ++ii ) {
- functionName = creationFunctions[ ii ];
- wrappedContext_[ functionName ] = function ( f ) {
- return function () {
- loseContextIfTime();
- if ( contextLost_ ) {
- return null;
- }
- var obj = f.apply( ctx, arguments );
- obj.__webglDebugContextLostId__ = contextId_;
- resourceDb_.push( obj );
- return obj;
- };
- }( ctx[ functionName ] );
- }
-
- var functionsThatShouldReturnNull = [
- "getActiveAttrib",
- "getActiveUniform",
- "getBufferParameter",
- "getContextAttributes",
- "getAttachedShaders",
- "getFramebufferAttachmentParameter",
- "getParameter",
- "getProgramParameter",
- "getProgramInfoLog",
- "getRenderbufferParameter",
- "getShaderParameter",
- "getShaderInfoLog",
- "getShaderSource",
- "getTexParameter",
- "getUniform",
- "getUniformLocation",
- "getVertexAttrib"
- ];
- for ( ii = 0; ii < functionsThatShouldReturnNull.length; ++ii ) {
- functionName = functionsThatShouldReturnNull[ ii ];
- wrappedContext_[ functionName ] = function ( f ) {
- return function () {
- loseContextIfTime();
- if ( contextLost_ ) {
- return null;
- }
- return f.apply( ctx, arguments );
- };
- }( wrappedContext_[ functionName ] );
- }
-
- var isFunctions = [
- "isBuffer",
- "isEnabled",
- "isFramebuffer",
- "isProgram",
- "isRenderbuffer",
- "isShader",
- "isTexture"
- ];
- for ( ii = 0; ii < isFunctions.length; ++ii ) {
- functionName = isFunctions[ ii ];
- wrappedContext_[ functionName ] = function ( f ) {
- return function () {
- loseContextIfTime();
- if ( contextLost_ ) {
- return false;
- }
- return f.apply( ctx, arguments );
- };
- }( wrappedContext_[ functionName ] );
- }
-
- wrappedContext_.checkFramebufferStatus = function ( f ) {
- return function () {
- loseContextIfTime();
- if ( contextLost_ ) {
- return wrappedContext_.FRAMEBUFFER_UNSUPPORTED;
- }
- return f.apply( ctx, arguments );
- };
- }( wrappedContext_.checkFramebufferStatus );
-
- wrappedContext_.getAttribLocation = function ( f ) {
- return function () {
- loseContextIfTime();
- if ( contextLost_ ) {
- return -1;
- }
- return f.apply( ctx, arguments );
- };
- }( wrappedContext_.getAttribLocation );
-
- wrappedContext_.getVertexAttribOffset = function ( f ) {
- return function () {
- loseContextIfTime();
- if ( contextLost_ ) {
- return 0;
- }
- return f.apply( ctx, arguments );
- };
- }( wrappedContext_.getVertexAttribOffset );
-
- wrappedContext_.isContextLost = function () {
- return contextLost_;
- };
-
- return wrappedContext_;
- }
-
- // TODO: find why this is there ?
- return canvas;
- }
-
- return {
- /**
- * Initializes this module. Safe to call more than once.
- * @param {!WebGLRenderingContext} ctx A WebGL context. If
- }
- * you have more than one context it doesn't matter which one
- * you pass in, it is only used to pull out constants.
- */
- 'init': init,
-
- /**
- * Returns true or false if value matches any WebGL enum
- * @param {*} value Value to check if it might be an enum.
- * @return {boolean} True if value matches one of the WebGL defined enums
- */
- 'mightBeEnum': mightBeEnum,
-
- /**
- * Gets an string version of an WebGL enum.
- *
- * Example:
- * WebGLDebugUtil.init(ctx);
- * var str = WebGLDebugUtil.glEnumToString(ctx.getError());
- *
- * @param {number} value Value to return an enum for
- * @return {string} The string version of the enum.
- */
- 'glEnumToString': glEnumToString,
-
- /**
- * Converts the argument of a WebGL function to a string.
- * Attempts to convert enum arguments to strings.
- *
- * Example:
- * WebGLDebugUtil.init(ctx);
- * var str = WebGLDebugUtil.glFunctionArgToString('bindTexture', 0, gl.TEXTURE_2D);
- *
- * would return 'TEXTURE_2D'
- *
- * @param {string} functionName the name of the WebGL function.
- * @param {number} argumentIndx the index of the argument.
- * @param {*} value The value of the argument.
- * @return {string} The value as a string.
- */
- 'glFunctionArgToString': glFunctionArgToString,
-
- /**
- * Given a WebGL context returns a wrapped context that calls
- * gl.getError after every command and calls a function if the
- * result is not NO_ERROR.
- *
- * You can supply your own function if you want. For example, if you'd like
- * an exception thrown on any GL error you could do this
- *
- * function throwOnGLError(err, funcName, args) {
- * throw WebGLDebugUtils.glEnumToString(err) + " was caused by call to" +
- * funcName;
- * };
- *
- * ctx = WebGLDebugUtils.makeDebugContext(
- * canvas.getContext("webgl"), throwOnGLError);
- *
- * @param {!WebGLRenderingContext} ctx The webgl context to wrap.
- * @param {!function(err, funcName, args): void} opt_onErrorFunc The function
- * to call when gl.getError returns an error. If not specified the default
- * function calls Notify.log with a message.
- */
- 'makeDebugContext': makeDebugContext,
-
- /**
- * Given a canvas element returns a wrapped canvas element that will
- * simulate lost context. The canvas returned adds the following functions.
- *
- * loseContext:
- * simulates a lost context event.
- *
- * restoreContext:
- * simulates the context being restored.
- *
- * lostContextInNCalls:
- * loses the context after N gl calls.
- *
- * getNumCalls:
- * tells you how many gl calls there have been so far.
- *
- * setRestoreTimeout:
- * sets the number of milliseconds until the context is restored
- * after it has been lost. Defaults to 0. Pass -1 to prevent
- * automatic restoring.
- *
- * @param {!Canvas} canvas The canvas element to wrap.
- */
- 'makeLostContextSimulatingCanvas': makeLostContextSimulatingCanvas,
-
- /**
- * Resets a context to the initial state.
- * @param {!WebGLRenderingContext} ctx The webgl context to
- * reset.
- */
- 'resetToInitialState': resetToInitialState
- };
-
-}();
-
-module.exports = WebGLDebugUtils;
diff --git a/app/static/app/js/vendor/osgjs/osgViewer/webgl-utils.js b/app/static/app/js/vendor/osgjs/osgViewer/webgl-utils.js
deleted file mode 100644
index 4796c716..00000000
--- a/app/static/app/js/vendor/osgjs/osgViewer/webgl-utils.js
+++ /dev/null
@@ -1,210 +0,0 @@
-// jshint ignore: start
-
-/*
- * Copyright 2010, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-/**
- * @fileoverview This file contains functions every webgl program will need
- * a version of one way or another.
- *
- * Instead of setting up a context manually it is recommended to
- * use. This will check for success or failure. On failure it
- * will attempt to present an approriate message to the user.
- *
- * gl = WebGLUtils.setupWebGL(canvas);
- *
- * For animated WebGL apps use of setTimeout or setInterval are
- * discouraged. It is recommended you structure your rendering
- * loop like this.
- *
- * function render() {
- * window.requestAnimationFrame(render, canvas);
- *
- * // do rendering
- * ...
- * }
- * render();
- *
- * This will call your rendering function up to the refresh rate
- * of your display but will stop rendering if your app is not
- * visible.
- */
-
-'use strict';
-var WebGLUtils = function () {
-
- /**
- * Creates the HTLM for a failure message
- * @param {string} canvasContainerId id of container of th
- * canvas.
- * @return {string} The html.
- */
- var makeFailHTML = function ( msg ) {
- return '' +
- '
' + msg + '
';
- // return '' +
- // '
' +
- // '
' +
- // '
' +
- // '
' + msg + '
' +
- // '
' +
- // '
';
- };
-
- /**
- * Mesasge for getting a webgl browser
- * @type {string}
- */
- var GET_A_WEBGL_BROWSER = '' +
- 'This page requires a browser that supports WebGL. ' +
- 'Click here to upgrade your browser.';
-
- /**
- * Mesasge for need better hardware
- * @type {string}
- */
- var OTHER_PROBLEM = '' +
- "It doesn't appear your computer can support WebGL. " +
- 'Click here for more information.';
-
- /**
- * Creates a webgl context. If creation fails it will
- * change the contents of the container of the