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 * Specify how points are to be shaded 14 */ 15 var IlluminationMode = { 16 FLAT : {value:0, name: "Flat"}, 17 PHONG : {value:1, name: "Phong"}, 18 NORMALS : {value:2, name: "Normals"}, 19 POSITION : {value:3, name: "Position"} 20 }; 21 22 /** 23 * specify how points are to be rasterized 24 */ 25 var PointCloudRenderMode = { 26 FIXED_CIRCLE : {value:0, name: "fixed circle"}, 27 WEIGHTED_CIRCLE : {value:1, name: "weighted circle"}, 28 FILTERED_SPLAT : {value:3, name: "filtered splat"} 29 }; 30 31 /** 32 * Eierlegende wollmilchsau. 33 * combines different materials. 34 * 35 * @param name 36 * @class 37 * @augments Material 38 * @author Markus Sch�tz 39 */ 40 function PointCloudMaterial(name){ 41 Material.call(this, name); 42 43 this.renderMode = PointCloudRenderMode.WEIGHTED_CIRCLE; 44 45 this.filteredMaterial = new FilteredSplatsMaterial(name + "_filtered"); 46 this.weightedMaterial = new WeightedPointSizeMaterial(name + "_weighted"); 47 this.fixedMaterial = new FixedPointSizeMaterial(name + "_fixed"); 48 49 this.activeMaterial = this.weightedMaterial; 50 this.pointSize = 0.2; 51 this.blendDepth = 0.1; 52 this.illuminationMode = IlluminationMode.FLAT; 53 } 54 55 PointCloudMaterial.prototype = new Material(inheriting); 56 57 PointCloudMaterial.prototype.render = function(sceneNode, camera, lights){ 58 this.activeMaterial.render(sceneNode, camera, lights); 59 }; 60 61 ///** 62 // * @param renderMode type: PointCloudRenderMode 63 // */ 64 //PointCloudMaterial.prototype.setRenderMode = function(renderMode){ 65 // this.renderMode = renderMode; 66 // 67 // this.updateActiveMaterial(); 68 //}; 69 // 70 //PointCloudMaterial.prototype.updateActiveMaterial = function(){ 71 // if(this.illuminationMode == IlluminationMode.FLAT){ 72 // if(this.renderMode == PointCloudRenderMode.FIXED_CIRCLE){ 73 // this.activeMaterial = this.fixedMaterial; 74 // }else if(this.renderMode == PointCloudRenderMode.WEIGHTED_CIRCLE){ 75 // this.activeMaterial = this.weightedMaterial; 76 // }else if(this.renderMode == PointCloudRenderMode.FILTERED_SPLAT){ 77 // this.activeMaterial = this.filteredMaterial; 78 // } 79 // } 80 //}; 81 82 Object.defineProperty(PointCloudMaterial.prototype, 'renderMode', { 83 set: function(renderMode){ 84 this._renderMode = renderMode; 85 86 if(this.renderMode == PointCloudRenderMode.FIXED_CIRCLE){ 87 this.activeMaterial = this.fixedMaterial; 88 }else if(this.renderMode == PointCloudRenderMode.WEIGHTED_CIRCLE){ 89 this.activeMaterial = this.weightedMaterial; 90 }else if(this.renderMode == PointCloudRenderMode.FILTERED_SPLAT){ 91 this.activeMaterial = this.filteredMaterial; 92 } 93 }, 94 get: function(){ 95 return this._renderMode; 96 } 97 }); 98 99 Object.defineProperty(PointCloudMaterial.prototype, 'pointSize', { 100 set: function(pointSize){ 101 this._pointSize = pointSize; 102 this.filteredMaterial.pointSize = pointSize; 103 this.weightedMaterial.pointSize = pointSize; 104 this.fixedMaterial.pointSize = pointSize; 105 }, 106 get: function(){ 107 return this._pointSize; 108 } 109 }); 110 111 Object.defineProperty(PointCloudMaterial.prototype, 'blendDepth', { 112 set: function(blendDepth){ 113 this._blendDepth = blendDepth; 114 this.filteredMaterial.blendDepth = blendDepth; 115 }, 116 get: function(){ 117 return this._blendDepth; 118 } 119 }); 120 121 Object.defineProperty(PointCloudMaterial.prototype, 'illuminationMode', { 122 set: function(illuminationMode){ 123 this._illuminationMode = illuminationMode; 124 this.filteredMaterial.illuminationMode = illuminationMode; 125 this.weightedMaterial.illuminationMode = illuminationMode; 126 this.fixedMaterial.illuminationMode = illuminationMode; 127 }, 128 get: function(){ 129 return this._illuminationMode; 130 } 131 }); 132