1 /** 2 * potree.js 3 * http://potree.org 4 * 5 * Copyright 2012, Markus Sch�tz 6 * Licensed under the GPL Version 2 or later. 7 * - http://potree.org/wp/?page_id=7 8 * - http://www.gnu.org/licenses/gpl-3.0.html 9 * 10 */ 11 12 /** 13 * @class extensions for Arrays 14 * 15 * @author Markus Sch�tz 16 */ 17 Array = Array; 18 19 /** 20 * remove all occurences of element in the array 21 */ 22 Array.prototype.remove=function(element){ 23 var index = null; 24 while((index = this.indexOf(element)) != -1){ 25 this.splice(index, 1); 26 } 27 }; 28 29 Array.prototype.contains = function(element){ 30 var index = this.indexOf(element); 31 return index != -1; 32 }; 33 34 Object.defineProperties(Array.prototype, { 35 'x': { 36 get: function(){ 37 return this[0]; 38 } 39 }, 40 'y': { 41 get: function(){ 42 return this[1]; 43 } 44 }, 45 'z': { 46 get: function(){ 47 return this[2]; 48 } 49 }, 50 'r': { 51 get: function(){ 52 return this[0]; 53 } 54 }, 55 'g': { 56 get: function(){ 57 return this[1]; 58 } 59 }, 60 'b': { 61 get: function(){ 62 return this[2]; 63 } 64 }, 65 'a': { 66 get: function(){ 67 return this[3]; 68 } 69 } 70 }); 71