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 Float32Arrays 14 * 15 * @author Markus Sch�tz 16 */ 17 Float32Array = Float32Array; 18 19 /** 20 * @memberOf Float32Array 21 */ 22 Float32Array.prototype.toString = function() { 23 var msg = ""; 24 for ( var i = 0; i < this.length; i++) { 25 msg += this[i] + ", "; 26 } 27 return msg; 28 }; 29 30 /** 31 * Stellt die Werte des Arrays als NxN Matrix dar wobei N = Sqrt(length) 32 * 33 */ 34 Float32Array.prototype.toMatrixFormString = function() { 35 var msg = ""; 36 for ( var i = 0; i < this.length; i++) { 37 if (i != 0 && (i) % 4 == 0) { 38 msg += "\n"; 39 } 40 msg += this[i].toFixed(3) + "\t"; 41 // msg += this[i].toPrecision(2) + ", "; 42 } 43 return msg; 44 }; 45 46 47 Object.defineProperties(Float32Array.prototype, { 48 'x': { 49 get: function(){ 50 return this[0]; 51 } 52 }, 53 'y': { 54 get: function(){ 55 return this[1]; 56 } 57 }, 58 'z': { 59 get: function(){ 60 return this[2]; 61 } 62 }, 63 'r': { 64 get: function(){ 65 return this[0]; 66 } 67 }, 68 'g': { 69 get: function(){ 70 return this[1]; 71 } 72 }, 73 'b': { 74 get: function(){ 75 return this[2]; 76 } 77 }, 78 'a': { 79 get: function(){ 80 return this[3]; 81 } 82 } 83 });