xzw преди 2 години
родител
ревизия
a009950741

+ 10 - 8
gulpfile.js

@@ -61,15 +61,15 @@ let lazyLibs = {
 };
 
 let shaders = [
-	"src/materials/shaders/pointcloud.vs",
-	"src/materials/shaders/pointcloud.fs",
+	"src/materials/shaders/pointcloud_new.vs",
+	"src/materials/shaders/pointcloud_new.fs",
 	"src/materials/shaders/pointcloud_sm.vs",
 	"src/materials/shaders/pointcloud_sm.fs",
 	"src/materials/shaders/normalize.vs",
 	"src/materials/shaders/normalize.fs",
 	"src/materials/shaders/normalize_and_edl.fs",
-	"src/materials/shaders/edl.vs",
-	"src/materials/shaders/edl.fs",
+	"src/materials/shaders/edl_new.vs",
+	"src/materials/shaders/edl_new.fs",
 	"src/materials/shaders/blur.vs",
 	"src/materials/shaders/blur.fs",
     //add:
@@ -78,7 +78,9 @@ let shaders = [
     "src/materials/shaders/copyCubeMap.vs",
 	"src/materials/shaders/copyCubeMap.fs",
 	"src/materials/shaders/basicTextured.vs",
-	"src/materials/shaders/basicTextured.fs",
+	"src/materials/shaders/basicTextured.fs", 
+    
+    
 ];
 
 
@@ -88,9 +90,9 @@ let shaders = [
 // from the command line to start the server (default port is 8080)
 gulp.task('webserver', gulp.series(async function() {
 	server = connect.server({
-		port: 5000,
-        host:'0.0.0.0',
-		https: false,
+		port: 1234,
+        host:'192.168.0.113',
+		https: true,
 	});
 }));
 

+ 4 - 4
src/ExtendPointCloudOctree.js

@@ -1,7 +1,7 @@
 
 import * as THREE from "../libs/three.js/build/three.module.js";
  
-import {PointCloudMaterial} from "./materials/PointCloudMaterial.js";
+import {ExtendPointCloudMaterial} from "./materials/ExtendPointCloudMaterial.js";
  
 import {PointCloudOctree} from './PointCloudOctree.js'
 import {PointSizeType } from "./defines.js";
@@ -9,10 +9,10 @@ import math from './custom/utils/math.js'
 
 export class ExtendPointCloudOctree extends PointCloudOctree{
     constructor(geometry, material){
-        
+        material = material || new ExtendPointCloudMaterial();
         super(geometry, material)
         
-        
+         
         this.boundingBox = this.pcoGeometry.tightBoundingBox//this.pcoGeometry.boundingBox;  //boundingBox是正方体,所以换掉
 		this.boundingSphere = this.boundingBox.getBoundingSphere(new THREE.Sphere());
         this.nodeMaxLevel = 0;//add
@@ -234,7 +234,7 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 		if (!this.pickState) {
 			let scene = new THREE.Scene();
 
-			let material = new Potree.PointCloudMaterial();
+			let material = new ExtendPointCloudMaterial();
 			material.activeAttributeName = "indices";
 
 			let renderTarget = new THREE.WebGLRenderTarget(

+ 1 - 1
src/PointCloudOctree.js

@@ -100,7 +100,7 @@ export class PointCloudOctreeNode extends PointCloudTreeNode {
 	}
 };
 
-export class PointCloudOctree extends PointCloudTree {
+export class PointCloudOctree extends PointCloudTree {//base
 	constructor (geometry, material) {
 		super();
 

+ 1 - 1
src/Potree.js

@@ -35,7 +35,7 @@ export * from "./materials/EyeDomeLightingMaterial.js";
 export * from "./materials/Gradients.js";
 export * from "./materials/NormalizationEDLMaterial.js";
 export * from "./materials/NormalizationMaterial.js";
-export * from "./materials/PointCloudMaterial.js";
+export * from "./materials/ExtendPointCloudMaterial.js";
 
 export * from "./loader/POCLoader.js";
 export * from "./modules/loader/2.0/OctreeLoader.js";

+ 1 - 1
src/custom/note.txt

@@ -32,7 +32,7 @@ pick时是showPanos模式会报错,为什么node.geometry没有?!
 
 
 
-
+modules文件夹改好了
 
 
 

+ 97 - 11
src/custom/potree.shim.js

@@ -17,10 +17,10 @@ import {Box3Helper} from "../utils/Box3Helper.js";
 import {KeyCodes} from "../KeyCodes.js";
 import {HQSplatRenderer} from "../viewer/HQSplatRenderer.js";
 import {LRU} from "../LRU.js";
-
+import {PointCloudMaterial} from '../materials/PointCloudMaterial.js'
  
 import {PointCloudOctreeGeometry, PointCloudOctreeGeometryNode} from '../PointCloudOctreeGeometry.js'
-    
+import {Shaders} from "../../build/shaders/shaders.js";  
  
 
 
@@ -150,7 +150,7 @@ Utils.loadSkybox = function(path) {
     let parent = new THREE.Object3D("skybox_root");
 
     let camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 100000);
-    if(!window.axisYup)  camera.up.set(0, 0, 1);
+    if(!window.axisYup)  camera.up.set(0, 0, 1);//add
     let scene = new THREE.Scene();
 
     let format = '.jpg';
@@ -266,13 +266,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
         }
         
     }
-    
-    
      
-    
-    
-    
-    
     let allPointclouds = [] 
     for(let pointcloud of pointclouds){ 
         
@@ -327,6 +321,43 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
     
 };
 
+
+
+Utils.pixelsArrayToDataUrl = function(pixels, width, height, compressRatio = 0.7) {
+    let canvas = document.createElement('canvas');
+    canvas.width = width;
+    canvas.height = height;
+
+    let context = canvas.getContext('2d');
+
+    pixels = new pixels.constructor(pixels);
+
+    /* for (let i = 0; i < pixels.length; i++) {
+        pixels[i * 4 + 3] = 255;
+    } */ 
+    // flip vertically
+    let bytesPerLine = width * 4;
+    for(let i = 0; i < parseInt(height / 2); i++){
+        let j = height - i - 1;
+
+        let lineI = pixels.slice(i * bytesPerLine, i * bytesPerLine + bytesPerLine);
+        let lineJ = pixels.slice(j * bytesPerLine, j * bytesPerLine + bytesPerLine);
+        pixels.set(lineJ, i * bytesPerLine);
+        pixels.set(lineI, j * bytesPerLine);
+    }
+    
+    
+    
+    let imageData = context.createImageData(width, height);
+    imageData.data.set(pixels);
+    context.putImageData(imageData, 0, 0);
+
+    let dataURL = canvas.toDataURL(compressRatio);
+
+    return dataURL;
+}
+
+
 Utils.renderTargetToDataUrl = function(renderTarget, width, height, renderer, compressRatio = 0.7){
     let pixelCount = width * height;
     let buffer = new Uint8Array(4 * pixelCount);
@@ -1127,7 +1158,52 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
 
 KeyCodes.BACKSPACE = 8
 
- 
+PointCloudMaterial.prototype.updateShaderSource = function(){
+    let vs = Shaders['pointcloud_new.vs']; //改
+    let fs = Shaders['pointcloud_new.fs']; //改
+    let definesString = this.getDefines();
+
+    let vsVersionIndex = vs.indexOf("#version ");
+    let fsVersionIndex = fs.indexOf("#version ");
+
+    if(vsVersionIndex >= 0){
+        vs = vs.replace(/(#version .*)/, `$1\n${definesString}`)
+    }else{
+        vs = `${definesString}\n${vs}`;
+    }
+
+    if(fsVersionIndex >= 0){
+        fs = fs.replace(/(#version .*)/, `$1\n${definesString}`)
+    }else{
+        fs = `${definesString}\n${fs}`;
+    }
+
+    this.vertexShader = vs;
+    this.fragmentShader = fs;
+
+    if (this.opacity === 1.0 && !this.useFilterByNormal) {//add useFilterByNormal
+        this.blending = THREE.NoBlending;
+        this.transparent = false;
+        this.depthTest = true;
+        this.depthWrite = true;
+        this.depthFunc = THREE.LessEqualDepth;
+    } else if (  (this.opacity < 1.0 ||this.useFilterByNormal) &&   !this.useEDL) {//add useFilterByNormal
+        this.blending = THREE.AdditiveBlending;
+        this.transparent = true;
+        this.depthTest = false;
+        this.depthWrite = true;
+        this.depthFunc = THREE.AlwaysDepth;
+    }
+
+    if (this.weighted) {
+        this.blending = THREE.AdditiveBlending;
+        this.transparent = true;
+        this.depthTest = true;
+        this.depthWrite = false;
+    }
+
+    this.needsUpdate = true;
+}
 
 
 {//HQSplatRenderer
@@ -1555,5 +1631,15 @@ LRU.prototype.freeMemory = function(){
 }
 
 
-
+LRU.prototype.disposeSubtree = function(t) {//add from navvis 25.js
+    var e = [t];
+    t.traverse((function(t) {
+        t.loaded && e.push(t)
+    }));
+    for (var n = 0, i = e; n < i.length; n++) {
+        var o = i[n];
+        o.dispose(),
+        this.remove(o)
+    }
+}
 

+ 1 - 1
src/custom/utils/WorkerPool.js

@@ -1,7 +1,7 @@
 /**
  * @author Deepkolos / https://github.com/deepkolos
  */
-
+//用于KTX2Loader
 export class WorkerPool {
 
 	constructor( pool = 4 ) {

+ 30 - 0
src/materials/ExtendEyeDomeLightingMaterial.js

@@ -0,0 +1,30 @@
+
+
+import * as THREE from "../../libs/three.js/build/three.module.js";
+import {Shaders} from "../../build/shaders/shaders.js";
+import {EyeDomeLightingMaterial} from './EyeDomeLightingMaterial.js'
+//
+// Algorithm by Christian Boucheny
+// shader code taken and adapted from CloudCompare
+//
+// see
+// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL
+// http://www.kitware.com/source/home/post/9
+// https://tel.archives-ouvertes.fr/tel-00438464/document p. 115+ (french)
+
+export class ExtendEyeDomeLightingMaterial extends EyeDomeLightingMaterial{
+
+	constructor(parameters = {}){
+		super(parameters);
+
+		delete this.uniforms.screenWidth
+		delete this.uniforms.screenHeight
+        this.uniforms.resolution = { type: 'v2',  value: new THREE.Vector2()}  
+        this.uniforms.useEDL = { type: 'i',  value: 1 } 
+        this.vertexShader = this.getDefines() + Shaders['edl_new.vs'] //改
+        this.fragmentShader = this.getDefines() + Shaders['edl_new.fs'] //改
+		 
+	} 
+	
+}
+

+ 7 - 7
src/materials/EyeDomeLightingMaterial.js

@@ -1,4 +1,4 @@
-
+ 
 import * as THREE from "../../libs/three.js/build/three.module.js";
 import {Shaders} from "../../build/shaders/shaders.js";
 
@@ -11,15 +11,15 @@ import {Shaders} from "../../build/shaders/shaders.js";
 // http://www.kitware.com/source/home/post/9
 // https://tel.archives-ouvertes.fr/tel-00438464/document p. 115+ (french)
 
-export class EyeDomeLightingMaterial extends THREE.RawShaderMaterial{
+export class EyeDomeLightingMaterial extends THREE.RawShaderMaterial{//base
 
 	constructor(parameters = {}){
 		super();
 
 		let uniforms = {
-			/* screenWidth:    { type: 'f', 	value: 0 },
-			screenHeight:   { type: 'f', 	value: 0 }, */ 
-            resolution:    { type: 'v2',  value: new THREE.Vector2() },
+			screenWidth:    { type: 'f', 	value: 0 },
+			screenHeight:   { type: 'f', 	value: 0 },
+                                                                       
 			edlStrength:    { type: 'f', 	value: 1.0 },
 			uNear:          { type: 'f', 	value: 1.0 },
 			uFar:           { type: 'f', 	value: 1.0 },
@@ -32,7 +32,7 @@ export class EyeDomeLightingMaterial extends THREE.RawShaderMaterial{
 			uProj:          { type: "Matrix4fv", value: [] },
             
             
-            useEDL:         { type: 'i', 	value: 1 }//add
+                                                         
 		};
 
 		this.setValues({
@@ -73,7 +73,7 @@ export class EyeDomeLightingMaterial extends THREE.RawShaderMaterial{
 	}
 
 	set neighbourCount(value){
-		if (this._neighbourCount !== value) { //周围八个格子
+		if (this._neighbourCount !== value) {//周围八个格子
 			this._neighbourCount = value;
 			this.neighbours = new Float32Array(this._neighbourCount * 2);
 			for (let c = 0; c < this._neighbourCount; c++) {

+ 35 - 153
src/materials/PointCloudMaterial.js

@@ -5,7 +5,7 @@ import {Gradients} from "./Gradients.js";
 import {Shaders} from "../../build/shaders/shaders.js";
 import {ClassificationScheme} from "./ClassificationScheme.js";
 import {PointSizeType, PointShape, TreeType, ElevationGradientRepeat} from "../defines.js";
-import {Features} from "../Features.js";
+                                        
 //
 // how to calculate the radius of a projected sphere in screen space
 // http://stackoverflow.com/questions/21648630/radius-of-projected-sphere-in-screen-space
@@ -13,14 +13,10 @@ import {Features} from "../Features.js";
 //
 
 
-export class PointCloudMaterial extends THREE.RawShaderMaterial {
+export class PointCloudMaterial extends THREE.RawShaderMaterial {//base
 	constructor (parameters = {}) {
 		super();
 
-        
-        
-        
-        
 		this.visibleNodesTexture = Utils.generateDataTexture(2048, 1, new THREE.Color(0xffffff));
 		this.visibleNodesTexture.minFilter = THREE.NearestFilter;
 		this.visibleNodesTexture.magFilter = THREE.NearestFilter;
@@ -35,7 +31,7 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 
 		let pointSize = getValid(parameters.size, 1.0);
 		let minSize = getValid(parameters.minSize, 2.0);
-		let maxSize = getValid(parameters.maxSize, 1550.0);
+		let maxSize = getValid(parameters.maxSize, 50.0);
 		let treeType = getValid(parameters.treeType, TreeType.OCTREE);
 
 		this._pointSizeType = PointSizeType.FIXED;
@@ -44,10 +40,10 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		this.clipBoxes = [];
 		this.clipPolygons = [];
 		this._weighted = false;
-		this._gradient = Gradients.RAINBOW//Gradients.SPECTRAL;//海拔贴图种类
+		this._gradient = Gradients.SPECTRAL;
 		this.gradientTexture = PointCloudMaterial.generateGradientTexture(this._gradient);
 		this._matcap = "matcap.jpg";
-		this.matcapTexture = Potree.PointCloudMaterial.generateMatcapTexture(this._matcap);
+		this.matcapTexture = PointCloudMaterial.generateMatcapTexture(this._matcap);
 		this.lights = false;
 		this.fog = false;
 		this._treeType = treeType;
@@ -60,7 +56,7 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 
 		this._defaultIntensityRangeChanged = false;
 		this._defaultElevationRangeChanged = false;
-  
+
 		{
 			const [width, height] = [256, 1];
 			let data = new Uint8Array(width * 4);
@@ -90,9 +86,8 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 			blendHardness:		{ type: "f", value: 2.0 },
 			blendDepthSupplement:	{ type: "f", value: 0.0 },
 			fov:				{ type: "f", value: 1.0 },
-			/* screenWidth:		{ type: "f", value: 1.0 },
-			screenHeight:		{ type: "f", value: 1.0 }, */
-            resolution:    { type: 'v2',  value: new THREE.Vector2() },
+			screenWidth:		{ type: "f", value: 1.0 },
+			screenHeight:		{ type: "f", value: 1.0 },
 			near:				{ type: "f", value: 0.1 },
 			far:				{ type: "f", value: 1.0 },
 			uColor:				{ type: "c", value: new THREE.Color( 0xffffff ) },
@@ -155,43 +150,6 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 			uFilterPointSourceIDClipRange:		{ type: "fv", value: [0, 65535]},
 			matcapTextureUniform: 	{ type: "t", value: this.matcapTexture },
 			backfaceCulling: { type: "b", value: false },
-            
-            ////////////////add
-            //usePanoMap:{ type: "i", value: 0 }, 
-			progress: {
-				type: "f",
-				value: 0
-			},
-            easeInOutRatio:{
-                type: "f",
-				value: 0.3
-            },
-			pano0Map: {
-				type: "t",
-				value: null
-			},
-			pano0Position: {
-				type: "v3",
-				value: new THREE.Vector3
-			},
-			pano0Matrix: {
-				type: "m4",
-				value: new THREE.Matrix4
-			},
-			pano1Map: {
-				type: "t",
-				value: null
-			},
-			pano1Position: {
-				type: "v3",
-				value: new THREE.Vector3
-			},
-			pano1Matrix: {
-				type: "m4",
-				value: new THREE.Matrix4
-            },    
-            
-            
 		};
 
 		this.classification = ClassificationScheme.DEFAULT;
@@ -223,7 +181,7 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		this.defines.delete(key);
 	}
 
-	updateShaderSource () { 
+	updateShaderSource () {
 
 		let vs = Shaders['pointcloud.vs'];
 		let fs = Shaders['pointcloud.fs'];
@@ -247,13 +205,13 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		this.vertexShader = vs;
 		this.fragmentShader = fs;
 
-		if (this.opacity === 1.0 && !this.useFilterByNormal) {//add useFilterByNormal
+		if (this.opacity === 1.0) {
 			this.blending = THREE.NoBlending;
 			this.transparent = false;
 			this.depthTest = true;
 			this.depthWrite = true;
 			this.depthFunc = THREE.LessEqualDepth;
-		} else if (  (this.opacity < 1.0 ||this.useFilterByNormal) &&   !this.useEDL) {//add useFilterByNormal
+		} else if (this.opacity < 1.0 && !this.useEDL) {
 			this.blending = THREE.AdditiveBlending;
 			this.transparent = true;
 			this.depthTest = false;
@@ -273,7 +231,7 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 
 	getDefines () {
 		let defines = [];
- 
+
 		if (this.pointSizeType === PointSizeType.FIXED) {
 			defines.push('#define fixed_point_size');
 		} else if (this.pointSizeType === PointSizeType.ATTENUATED) {
@@ -281,22 +239,16 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		} else if (this.pointSizeType === PointSizeType.ADAPTIVE) {
 			defines.push('#define adaptive_point_size');
 		}
-        
-        if(!Features.EXT_DEPTH.isSupported() && this.shape === PointShape.PARABOLOID){
-            this.shape = PointShape.SQUARE ;//强行替换
-        }
-        
-        
+
 		if (this.shape === PointShape.SQUARE) {
 			defines.push('#define square_point_shape');
 		} else if (this.shape === PointShape.CIRCLE) {
 			defines.push('#define circle_point_shape');
-		}  else if (this.shape === PointShape.PARABOLOID) { 
+		} else if (this.shape === PointShape.PARABOLOID) {
 			defines.push('#define paraboloid_point_shape');
-		}  
-        //console.log('this.shape PARABOLOID', this.shape, this.shape === PointShape.PARABOLOID)
-
-		if (this._useEDL || this.fakeEDL) {
+		}
+                                                                                                
+		if (this._useEDL) {
 			defines.push('#define use_edl');
 		}
 
@@ -540,7 +492,7 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		}
 	}
 
-	/* get screenWidth () {
+	get screenWidth () {
 		return this.uniforms.screenWidth.value;
 	}
 
@@ -549,7 +501,7 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 			this.uniforms.screenWidth.value = value;
 			// this.updateShaderSource();
 		}
-	} 
+	}
 
 	get screenHeight () {
 		return this.uniforms.screenHeight.value;
@@ -560,19 +512,8 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 			this.uniforms.screenHeight.value = value;
 			// this.updateShaderSource();
 		}
-	}*/
-    
-    //add--------------
-    get resolution(){
-        return this.uniforms.resolution.value
-    }
-    set resolution(value){
-        this.uniforms.resolution.value.copy(value);
-    }
-    //--------------
-    
-    
-    
+	}
+                    
 	get near () {
 		return this.uniforms.near.value;
 	}
@@ -640,9 +581,6 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 	}
 
 	set pointSizeType (value) {
-        
-        if(typeof value == 'string' )value = PointSizeType[value]
-        
 		if (this._pointSizeType !== value) {
 			this._pointSizeType = value;
 			this.updateShaderSource();              //这句表明这个属性频繁更改会卡顿
@@ -667,48 +605,24 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 			this.updateShaderSource();
 		}
 	}
-    
-    get fakeEDL(){
-		return this._fakeEDL;
-	}
-    set fakeEDL (value) {//add
-		if (this._fakeEDL !== value) {
-			this._fakeEDL = value;
-			this.updateShaderSource();
-		}
-	}
+
 	get color () {
 		return this.uniforms.uColor.value;
 	}
 
-	set color (value) {//改
-        
-        if(value == this.color_)return
-        let color = value;
-		//if (!this.uniforms.uColor.value.equals(value)) {
-        if(typeof value == 'string') {
-            var colorArr = Potree.config.colors[value]  
-            if(!colorArr){ 
-                //console.warn('没找到该颜色值'+ value)
-            }else{
-                color = new THREE.Color().fromArray(colorArr).multiplyScalar(1/255)
-            }                
-            
-        }    
-        this.uniforms.uColor.value.set(color)  
-        //this.uniforms.uColor.value.copy(value);
+	set color (value) {
+		if (!this.uniforms.uColor.value.equals(value)) {
+			this.uniforms.uColor.value.copy(value);
 			
-        this.dispatchEvent({
-            type: 'color_changed',
-            target: this
-        });
-        this.dispatchEvent({
-            type: 'material_property_changed',
-            target: this
-        });
-		//}
-        
-        this.color_ = value //记录下str
+			this.dispatchEvent({
+				type: 'color_changed',
+				target: this
+			});
+			this.dispatchEvent({
+				type: 'material_property_changed',
+				target: this
+			});
+		}
 	}
 
 	get shape () {
@@ -765,9 +679,6 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		}
 	}
 
-
-     
-
 	get minSize(){
 		return this.uniforms.minSize.value;
 	}
@@ -1116,7 +1027,7 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		}
 	}
 
-	static generateGradientTexture (gradient) { 
+	static generateGradientTexture (gradient) {
 		let size = 64;
 
 		// create canvas
@@ -1175,33 +1086,6 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 		this._hiddenListeners = undefined;
 	};
 
-    ////////////////////////add
-    setProjectedPanos(pano0, pano1, progressValue, easeInOutRatio){
-        
-        //this.uniforms.usePanoMap.value = 1
-        this.usePanoMap = true
-        
- 		progressValue!=void 0 && (this.uniforms.progress.value = progressValue);
-		//pano0.ensureSkyboxReadyForRender();
-		this.uniforms.pano0Map.value = pano0.getSkyboxTexture()
-		this.uniforms.pano0Position.value.copy(pano0.position)
-		this.uniforms.pano0Matrix.value.copy(pano0.panoMatrix  );
-		//pano1.ensureSkyboxReadyForRender();
- 
-        this.uniforms.easeInOutRatio.value =  easeInOutRatio || 0; //之前做点云和全景混合时加的,为了让点云颜色柔和切换到全景颜色。如不混合就0
-		
-		this.uniforms.pano1Map.value = pano1.getSkyboxTexture()
-		this.uniforms.pano1Position.value.copy(pano1.position)
-		this.uniforms.pano1Matrix.value.copy(pano1.panoMatrix   );
-           
-        //this.updateShaderSource()
-        //this.needsUpdate = true;
- 	}
-    stopProjectedPanos(){
-        //this.uniforms.usePanoMap.value = 0
-        this.usePanoMap = false
-    } 
-
 	// copyFrom(from){
 
 	// 	var a = 10;
@@ -1214,7 +1098,5 @@ export class PointCloudMaterial extends THREE.RawShaderMaterial {
 	// copy(from){
 	// 	this.copyFrom(from);
 	// }
-    
-    
 
 }

+ 28 - 48
src/materials/shaders/edl.fs

@@ -9,18 +9,15 @@
 precision mediump float;
 precision mediump int;
 
-//uniform float screenWidth;
-//uniform float screenHeight;
-uniform vec2 resolution;
-
-
+uniform float screenWidth;
+uniform float screenHeight;
 uniform vec2 neighbours[NEIGHBOUR_COUNT];
 uniform float edlStrength;
 uniform float radius;
 uniform float opacity;
 
-//uniform float uNear;
-//uniform float uFar;
+uniform float uNear;
+uniform float uFar;
 
 uniform mat4 uProj;
 
@@ -29,25 +26,23 @@ uniform sampler2D uEDLDepth;
 
 varying vec2 vUv;
 
-uniform int useEDL;
-
 float response(float depth){
-	vec2 uvRadius = radius / resolution;             //vec2(screenWidth, screenHeight);
+	vec2 uvRadius = radius / vec2(screenWidth, screenHeight);
 	
 	float sum = 0.0;
 	
 	for(int i = 0; i < NEIGHBOUR_COUNT; i++){
 		vec2 uvNeighbor = vUv + uvRadius * neighbours[i];
-		//获取周围八个格子的值
+		
 		float neighbourDepth = texture2D(uEDLColor, uvNeighbor).a;
 		neighbourDepth = (neighbourDepth == 1.0) ? 0.0 : neighbourDepth;
 
 		if(neighbourDepth != 0.0){
-			//if(depth == 0.0){
-			//	sum += 100.0;
-			//}else{
-				sum += max(0.0, depth - neighbourDepth);  //获取差值
-			//}
+			if(depth == 0.0){
+				sum += 100.0;
+			}else{
+				sum += max(0.0, depth - neighbourDepth);
+			}
 		}
 	}
 	
@@ -59,38 +54,23 @@ void main(){
 	
 	float depth = cEDL.a;
 	depth = (depth == 1.0) ? 0.0 : depth;
-    
-    if(depth == 0.0){ //去掉这句就能在无点云像素的地方渲染outline,但会遮住其他mesh
+	float res = response(depth);
+	float shade = exp(-res * 300.0 * edlStrength);
+
+	gl_FragColor = vec4(cEDL.rgb * shade, opacity);
+
+	{ // write regular hyperbolic depth values to depth buffer
+		float dl = pow(2.0, depth);
+
+		vec4 dp = uProj * vec4(0.0, 0.0, -dl, 1.0);
+		float pz = dp.z / dp.w;
+		float fragDepth = (pz + 1.0) / 2.0;
+
+		gl_FragDepthEXT = fragDepth;
+	}
+
+	if(depth == 0.0){
 		discard;
 	}
-    
-    
-    if(useEDL == 1){
-        float res = response(depth);
-        
-        //if(depth == 0.0 && res == 0.0){   //test
-        //    discard;
-        //}
-         
-        float shade = exp(-res * 300.0 * edlStrength); //自然常数e为底的指数函数
-
-        gl_FragColor = vec4(cEDL.rgb * shade, opacity); 
-        
-        //const vec3 outlineColor = vec3(1.0,0.0,0.0);//test -outline
-        //gl_FragColor = vec4(mix(cEDL.rgb, outlineColor, -res), opacity );
-    }else{//加  不改颜色的情况 
-        gl_FragColor = vec4(cEDL.rgb, opacity);
-    } 
-    
-    
-    { // write regular hyperbolic depth values to depth buffer  修改深度
-        float dl = pow(2.0, depth);
-
-        vec4 dp = uProj * vec4(0.0, 0.0, -dl, 1.0);
-        float pz = dp.z / dp.w;
-        float fragDepth = (pz + 1.0) / 2.0;
-
-        gl_FragDepthEXT = fragDepth;
-    }
-	
+
 }

+ 0 - 102
src/materials/shaders/pointcloud - 原始.fs

@@ -1,102 +0,0 @@
-
-#if defined paraboloid_point_shape
-	#extension GL_EXT_frag_depth : enable
-#endif
-
-precision highp float;
-precision highp int;
-
-uniform mat4 viewMatrix;
-uniform mat4 uViewInv;
-uniform mat4 uProjInv;
-uniform vec3 cameraPosition;
-
-
-uniform mat4 projectionMatrix;
-uniform float uOpacity;
-
-uniform float blendHardness;
-uniform float blendDepthSupplement;
-uniform float fov;
-uniform float uSpacing;
-uniform float near;
-uniform float far;
-uniform float uPCIndex;
-uniform float uScreenWidth;
-uniform float uScreenHeight;
-
-varying vec3	vColor;
-varying float	vLogDepth;
-varying vec3	vViewPosition;
-varying float	vRadius;
-varying float 	vPointSize;
-varying vec3 	vPosition;
-
-
-float specularStrength = 1.0;
-
-void main() {
-
-	// gl_FragColor = vec4(vColor, 1.0);
-
-	vec3 color = vColor;
-	float depth = gl_FragCoord.z;
-
-	#if defined(circle_point_shape) || defined(paraboloid_point_shape) 
-		float u = 2.0 * gl_PointCoord.x - 1.0;
-		float v = 2.0 * gl_PointCoord.y - 1.0;
-	#endif
-	
-	#if defined(circle_point_shape) 
-		float cc = u*u + v*v;
-		if(cc > 1.0){
-			discard;
-		}
-	#endif
-		
-	#if defined color_type_indices
-		gl_FragColor = vec4(color, uPCIndex / 255.0);
-	#else
-		gl_FragColor = vec4(color, uOpacity);
-	#endif
-
-	#if defined paraboloid_point_shape
-		float wi = 0.0 - ( u*u + v*v);
-		vec4 pos = vec4(vViewPosition, 1.0);
-		pos.z += wi * vRadius;
-		float linearDepth = -pos.z;
-		pos = projectionMatrix * pos;
-		pos = pos / pos.w;
-		float expDepth = pos.z;
-		depth = (pos.z + 1.0) / 2.0;
-		gl_FragDepthEXT = depth;
-		
-		#if defined(color_type_depth)
-			color.r = linearDepth;
-			color.g = expDepth;
-		#endif
-		
-		#if defined(use_edl)
-			gl_FragColor.a = log2(linearDepth);
-		#endif
-		
-	#else
-		#if defined(use_edl)
-			gl_FragColor.a = vLogDepth;
-		#endif
-	#endif
-
-	#if defined(weighted_splats)
-		float distance = 2.0 * length(gl_PointCoord.xy - 0.5);
-		float weight = max(0.0, 1.0 - distance);
-		weight = pow(weight, 1.5);
-
-		gl_FragColor.a = weight;
-		gl_FragColor.xyz = gl_FragColor.xyz * weight;
-	#endif
-
-	//gl_FragColor = vec4(0.0, 0.7, 0.0, 1.0);
-	
-}
-
-

+ 0 - 981
src/materials/shaders/pointcloud - 原始.vs

@@ -1,981 +0,0 @@
-
-precision highp float;
-precision highp int;
-
-#define max_clip_polygons 8
-#define PI 3.141592653589793
-
-attribute vec3 position;
-attribute vec3 color;
-attribute float intensity;
-attribute float classification;
-attribute float returnNumber;
-attribute float numberOfReturns;
-attribute float pointSourceID;
-attribute vec4 indices;
-attribute float spacing;
-attribute float gpsTime;
-attribute vec3 normal;
-attribute float aExtra;
-
-uniform mat4 modelMatrix;
-uniform mat4 modelViewMatrix;
-uniform mat4 projectionMatrix;
-uniform mat4 viewMatrix;
-uniform mat4 uViewInv;
-
-uniform float uScreenWidth;
-uniform float uScreenHeight;
-uniform float fov;
-uniform float near;
-uniform float far;
-
-uniform bool uDebug;
-
-uniform bool uUseOrthographicCamera;
-uniform float uOrthoWidth;
-uniform float uOrthoHeight;
-
-#define CLIPTASK_NONE 0
-#define CLIPTASK_HIGHLIGHT 1
-#define CLIPTASK_SHOW_INSIDE 2
-#define CLIPTASK_SHOW_OUTSIDE 3
-
-#define CLIPMETHOD_INSIDE_ANY 0
-#define CLIPMETHOD_INSIDE_ALL 1
-
-uniform int clipTask;
-uniform int clipMethod;
-#if defined(num_clipboxes) && num_clipboxes > 0
-	uniform mat4 clipBoxes[num_clipboxes];
-#endif
-
-#if defined(num_clipspheres) && num_clipspheres > 0
-	uniform mat4 uClipSpheres[num_clipspheres];
-#endif
-
-#if defined(num_clippolygons) && num_clippolygons > 0
-	uniform int uClipPolygonVCount[num_clippolygons];
-	uniform vec3 uClipPolygonVertices[num_clippolygons * 8];
-	uniform mat4 uClipPolygonWVP[num_clippolygons];
-#endif
-
-
-uniform float size;
-uniform float minSize;
-uniform float maxSize;
-
-uniform float uPCIndex;
-uniform float uOctreeSpacing;
-uniform float uNodeSpacing;
-uniform float uOctreeSize;
-uniform vec3 uBBSize;
-uniform float uLevel;
-uniform float uVNStart;
-uniform bool uIsLeafNode;
-
-uniform vec3 uColor;
-uniform float uOpacity;
-
-uniform vec2 elevationRange;
-uniform vec2 intensityRange;
-
-uniform vec2 uFilterReturnNumberRange;
-uniform vec2 uFilterNumberOfReturnsRange;
-uniform vec2 uFilterPointSourceIDClipRange;
-uniform vec2 uFilterGPSTimeClipRange;
-uniform float uGpsScale;
-uniform float uGpsOffset;
-
-uniform vec2 uNormalizedGpsBufferRange;
-
-uniform vec3 uIntensity_gbc;
-uniform vec3 uRGB_gbc;
-uniform vec3 uExtra_gbc;
-
-uniform float uTransition;
-uniform float wRGB;
-uniform float wIntensity;
-uniform float wElevation;
-uniform float wClassification;
-uniform float wReturnNumber;
-uniform float wSourceID;
-
-uniform vec2 uExtraNormalizedRange;
-uniform vec2 uExtraRange;
-uniform float uExtraScale;
-uniform float uExtraOffset;
-
-uniform vec3 uShadowColor;
-
-uniform sampler2D visibleNodes;
-uniform sampler2D gradient;
-uniform sampler2D classificationLUT;
-
-#if defined(color_type_matcap)
-uniform sampler2D matcapTextureUniform;
-#endif
-uniform bool backfaceCulling;
-
-#if defined(num_shadowmaps) && num_shadowmaps > 0
-uniform sampler2D uShadowMap[num_shadowmaps];
-uniform mat4 uShadowWorldView[num_shadowmaps];
-uniform mat4 uShadowProj[num_shadowmaps];
-#endif
-
-varying vec3	vColor;
-varying float	vLogDepth;
-varying vec3	vViewPosition;
-varying float 	vRadius;
-varying float 	vPointSize;
-
-
-float round(float number){
-	return floor(number + 0.5);
-}
-
-// 
-//    ###    ########     ###    ########  ######## #### ##     ## ########     ######  #### ######## ########  ######  
-//   ## ##   ##     ##   ## ##   ##     ##    ##     ##  ##     ## ##          ##    ##  ##       ##  ##       ##    ## 
-//  ##   ##  ##     ##  ##   ##  ##     ##    ##     ##  ##     ## ##          ##        ##      ##   ##       ##       
-// ##     ## ##     ## ##     ## ########     ##     ##  ##     ## ######       ######   ##     ##    ######    ######  
-// ######### ##     ## ######### ##           ##     ##   ##   ##  ##                ##  ##    ##     ##             ## 
-// ##     ## ##     ## ##     ## ##           ##     ##    ## ##   ##          ##    ##  ##   ##      ##       ##    ## 
-// ##     ## ########  ##     ## ##           ##    ####    ###    ########     ######  #### ######## ########  ######  
-// 																			
-
-
-// ---------------------
-// OCTREE
-// ---------------------
-
-#if (defined(adaptive_point_size) || defined(color_type_level_of_detail)) && defined(tree_type_octree)
-/**
- * number of 1-bits up to inclusive index position
- * number is treated as if it were an integer in the range 0-255
- *
- */
-int numberOfOnes(int number, int index){
-	int numOnes = 0;
-	int tmp = 128;
-	for(int i = 7; i >= 0; i--){
-		
-		if(number >= tmp){
-			number = number - tmp;
-
-			if(i <= index){
-				numOnes++;
-			}
-		}
-		
-		tmp = tmp / 2;
-	}
-
-	return numOnes;
-}
-
-
-/**
- * checks whether the bit at index is 1
- * number is treated as if it were an integer in the range 0-255
- *
- */
-bool isBitSet(int number, int index){
-
-	// weird multi else if due to lack of proper array, int and bitwise support in WebGL 1.0
-	int powi = 1;
-	if(index == 0){
-		powi = 1;
-	}else if(index == 1){
-		powi = 2;
-	}else if(index == 2){
-		powi = 4;
-	}else if(index == 3){
-		powi = 8;
-	}else if(index == 4){
-		powi = 16;
-	}else if(index == 5){
-		powi = 32;
-	}else if(index == 6){
-		powi = 64;
-	}else if(index == 7){
-		powi = 128;
-	}else{
-		return false;
-	}
-
-	int ndp = number / powi;
-
-	return mod(float(ndp), 2.0) != 0.0;
-}
-
-
-/**
- * find the LOD at the point position
- */
-float getLOD(){
-	
-	vec3 offset = vec3(0.0, 0.0, 0.0);
-	int iOffset = int(uVNStart);
-	float depth = uLevel;
-	for(float i = 0.0; i <= 30.0; i++){
-		float nodeSizeAtLevel = uOctreeSize / pow(2.0, i + uLevel + 0.0);
-		
-		vec3 index3d = (position-offset) / nodeSizeAtLevel;
-		index3d = floor(index3d + 0.5);
-		int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
-		
-		vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
-		int mask = int(round(value.r * 255.0));
-
-		if(isBitSet(mask, index)){
-			// there are more visible child nodes at this position
-			int advanceG = int(round(value.g * 255.0)) * 256;
-			int advanceB = int(round(value.b * 255.0));
-			int advanceChild = numberOfOnes(mask, index - 1);
-			int advance = advanceG + advanceB + advanceChild;
-
-			iOffset = iOffset + advance;
-			
-			depth++;
-		}else{
-			// no more visible child nodes at this position
-			//return value.a * 255.0;
-
-			float lodOffset = (255.0 * value.a) / 10.0 - 10.0;
-
-			return depth  + lodOffset;
-		}
-		
-		offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;
-	}
-		
-	return depth;
-}
-
-float getSpacing(){
-	vec3 offset = vec3(0.0, 0.0, 0.0);
-	int iOffset = int(uVNStart);
-	float depth = uLevel;
-	float spacing = uNodeSpacing;
-	for(float i = 0.0; i <= 30.0; i++){
-		float nodeSizeAtLevel = uOctreeSize / pow(2.0, i + uLevel + 0.0);
-		
-		vec3 index3d = (position-offset) / nodeSizeAtLevel;
-		index3d = floor(index3d + 0.5);
-		int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
-		
-		vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
-		int mask = int(round(value.r * 255.0));
-		float spacingFactor = value.a;
-
-		if(i > 0.0){
-			spacing = spacing / (255.0 * spacingFactor);
-		}
-		
-
-		if(isBitSet(mask, index)){
-			// there are more visible child nodes at this position
-			int advanceG = int(round(value.g * 255.0)) * 256;
-			int advanceB = int(round(value.b * 255.0));
-			int advanceChild = numberOfOnes(mask, index - 1);
-			int advance = advanceG + advanceB + advanceChild;
-
-			iOffset = iOffset + advance;
-
-			//spacing = spacing / (255.0 * spacingFactor);
-			//spacing = spacing / 3.0;
-			
-			depth++;
-		}else{
-			// no more visible child nodes at this position
-			return spacing;
-		}
-		
-		offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;
-	}
-		
-	return spacing;
-}
-
-float getPointSizeAttenuation(){
-	return pow(2.0, getLOD());
-}
-
-
-#endif
-
-
-// ---------------------
-// KD-TREE
-// ---------------------
-
-#if (defined(adaptive_point_size) || defined(color_type_level_of_detail)) && defined(tree_type_kdtree)
-
-float getLOD(){
-	vec3 offset = vec3(0.0, 0.0, 0.0);
-	float iOffset = 0.0;
-	float depth = 0.0;
-		
-		
-	vec3 size = uBBSize;	
-	vec3 pos = position;
-		
-	for(float i = 0.0; i <= 1000.0; i++){
-		
-		vec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));
-		
-		int children = int(value.r * 255.0);
-		float next = value.g * 255.0;
-		int split = int(value.b * 255.0);
-		
-		if(next == 0.0){
-		 	return depth;
-		}
-		
-		vec3 splitv = vec3(0.0, 0.0, 0.0);
-		if(split == 1){
-			splitv.x = 1.0;
-		}else if(split == 2){
-		 	splitv.y = 1.0;
-		}else if(split == 4){
-		 	splitv.z = 1.0;
-		}
-		
-		iOffset = iOffset + next;
-		
-		float factor = length(pos * splitv / size);
-		if(factor < 0.5){
-			// left
-		if(children == 0 || children == 2){
-				return depth;
-			}
-		}else{
-			// right
-			pos = pos - size * splitv * 0.5;
-			if(children == 0 || children == 1){
-				return depth;
-			}
-			if(children == 3){
-				iOffset = iOffset + 1.0;
-			}
-		}
-		size = size * ((1.0 - (splitv + 1.0) / 2.0) + 0.5);
-		
-		depth++;
-	}
-		
-		
-	return depth;	
-}
-
-float getPointSizeAttenuation(){
-	return 0.5 * pow(1.3, getLOD());
-}
-
-#endif
-
-
-
-// 
-//    ###    ######## ######## ########  #### ########  ##     ## ######## ########  ######  
-//   ## ##      ##       ##    ##     ##  ##  ##     ## ##     ##    ##    ##       ##    ## 
-//  ##   ##     ##       ##    ##     ##  ##  ##     ## ##     ##    ##    ##       ##       
-// ##     ##    ##       ##    ########   ##  ########  ##     ##    ##    ######    ######  
-// #########    ##       ##    ##   ##    ##  ##     ## ##     ##    ##    ##             ## 
-// ##     ##    ##       ##    ##    ##   ##  ##     ## ##     ##    ##    ##       ##    ## 
-// ##     ##    ##       ##    ##     ## #### ########   #######     ##    ########  ######                                                                               
-// 
-
-
-
-// formula adapted from: http://www.dfstudios.co.uk/articles/programming/image-programming-algorithms/image-processing-algorithms-part-5-contrast-adjustment/
-float getContrastFactor(float contrast){
-	return (1.0158730158730156 * (contrast + 1.0)) / (1.0158730158730156 - contrast);
-}
-
-vec3 getRGB(){
-	vec3 rgb = color;
-	
-	rgb = pow(rgb, vec3(uRGB_gbc.x));
-	rgb = rgb + uRGB_gbc.y;
-	rgb = (rgb - 0.5) * getContrastFactor(uRGB_gbc.z) + 0.5;
-	rgb = clamp(rgb, 0.0, 1.0);
-
-	return rgb;
-}
-
-float getIntensity(){
-	float w = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);
-	w = pow(w, uIntensity_gbc.x);
-	w = w + uIntensity_gbc.y;
-	w = (w - 0.5) * getContrastFactor(uIntensity_gbc.z) + 0.5;
-	w = clamp(w, 0.0, 1.0);
-
-	return w;
-}
-
-vec3 getGpsTime(){
-
-	float w = (gpsTime + uGpsOffset) * uGpsScale;
-
-
-	vec3 c = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
-
-
-	// vec2 r = uNormalizedGpsBufferRange;
-	// float w = gpsTime * (r.y - r.x) + r.x;
-	// w = clamp(w, 0.0, 1.0);
-	// vec3 c = texture2D(gradient, vec2(w,1.0-w)).rgb;
-	
-	return c;
-}
-
-vec3 getElevation(){
-	vec4 world = modelMatrix * vec4( position, 1.0 );
-	float w = (world.z - elevationRange.x) / (elevationRange.y - elevationRange.x);
-	vec3 cElevation = texture2D(gradient, vec2(w,1.0-w)).rgb;
-	
-	return cElevation;
-}
-
-vec4 getClassification(){
-	vec2 uv = vec2(classification / 255.0, 0.5);
-	vec4 classColor = texture2D(classificationLUT, uv);
-	
-	return classColor;
-}
-
-vec3 getReturns(){
-
-	// 0b 00_000_111
-	float rn = mod(returnNumber, 8.0);
-	// 0b 00_111_000
-	float nr = mod(returnNumber / 8.0, 8.0);
-
-	if(nr <= 1.0){
-		return vec3(1.0, 0.0, 0.0);
-	}else{
-		return vec3(0.0, 1.0, 0.0);
-	}
-
-	// return vec3(nr / 4.0, 0.0, 0.0);
-
-	// if(nr == 1.0){
-	// 	return vec3(1.0, 1.0, 0.0);
-	// }else{
-	// 	if(rn == 1.0){
-	// 		return vec3(1.0, 0.0, 0.0);
-	// 	}else if(rn == nr){
-	// 		return vec3(0.0, 0.0, 1.0);
-	// 	}else{
-	// 		return vec3(0.0, 1.0, 0.0);
-	// 	}
-	// }
-
-	// if(numberOfReturns == 1.0){
-	// 	return vec3(1.0, 1.0, 0.0);
-	// }else{
-	// 	if(returnNumber == 1.0){
-	// 		return vec3(1.0, 0.0, 0.0);
-	// 	}else if(returnNumber == numberOfReturns){
-	// 		return vec3(0.0, 0.0, 1.0);
-	// 	}else{
-	// 		return vec3(0.0, 1.0, 0.0);
-	// 	}
-	// }
-}
-
-vec3 getReturnNumber(){
-	if(numberOfReturns == 1.0){
-		return vec3(1.0, 1.0, 0.0);
-	}else{
-		if(returnNumber == 1.0){
-			return vec3(1.0, 0.0, 0.0);
-		}else if(returnNumber == numberOfReturns){
-			return vec3(0.0, 0.0, 1.0);
-		}else{
-			return vec3(0.0, 1.0, 0.0);
-		}
-	}
-}
-
-vec3 getNumberOfReturns(){
-	float value = numberOfReturns;
-
-	float w = value / 6.0;
-
-	vec3 color = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
-
-	return color;
-}
-
-vec3 getSourceID(){
-	float w = mod(pointSourceID, 10.0) / 10.0;
-	return texture2D(gradient, vec2(w,1.0 - w)).rgb;
-}
-
-vec3 getCompositeColor(){
-	vec3 c;
-	float w;
-
-	c += wRGB * getRGB();
-	w += wRGB;
-	
-	c += wIntensity * getIntensity() * vec3(1.0, 1.0, 1.0);
-	w += wIntensity;
-	
-	c += wElevation * getElevation();
-	w += wElevation;
-	
-	c += wReturnNumber * getReturnNumber();
-	w += wReturnNumber;
-	
-	c += wSourceID * getSourceID();
-	w += wSourceID;
-	
-	vec4 cl = wClassification * getClassification();
-	c += cl.a * cl.rgb;
-	w += wClassification * cl.a;
-
-	c = c / w;
-	
-	if(w == 0.0){
-		//c = color;
-		gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-	}
-	
-	return c;
-}
-
-
-vec3 getNormal(){
-	//vec3 n_hsv = vec3( modelMatrix * vec4( normal, 0.0 )) * 0.5 + 0.5; // (n_world.xyz + vec3(1.,1.,1.)) / 2.;
-	vec3 n_view = normalize( vec3(modelViewMatrix * vec4( normal, 0.0 )) );
-	return n_view;
-}
-bool applyBackfaceCulling() {
-	// Black not facing vertices / Backface culling
-	vec3 e = normalize(vec3(modelViewMatrix * vec4( position, 1. )));
-	vec3 n = getNormal(); // normalize( vec3(modelViewMatrix * vec4( normal, 0.0 )) );
-
-	if((uUseOrthographicCamera && n.z <= 0.) || (!uUseOrthographicCamera && dot( n, e ) >= 0.)) { 
-		return true;
-	} else {
-		return false;
-	}
-}
-
-#if defined(color_type_matcap)
-// Matcap Material
-vec3 getMatcap(){ 
-	vec3 eye = normalize( vec3( modelViewMatrix * vec4( position, 1. ) ) ); 
-	if(uUseOrthographicCamera) { 
-		eye = vec3(0., 0., -1.);
-	}
-	vec3 r_en = reflect( eye, getNormal() ); // or r_en = e - 2. * dot( n, e ) * n;
-	float m = 2. * sqrt(pow( r_en.x, 2. ) + pow( r_en.y, 2. ) + pow( r_en.z + 1., 2. ));
-	vec2 vN = r_en.xy / m + .5;
-	return texture2D(matcapTextureUniform, vN).rgb; 
-}
-#endif
-
-vec3 getExtra(){
-
-	float w = (aExtra + uExtraOffset) * uExtraScale;
-	w = clamp(w, 0.0, 1.0);
-
-	vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-
-	// vec2 r = uExtraNormalizedRange;
-
-	// float w = aExtra * (r.y - r.x) + r.x;
-
-	// w = (w - uExtraRange.x) / (uExtraRange.y - uExtraRange.x);
-
-	// w = clamp(w, 0.0, 1.0);
-
-	// vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-
-	return color;
-}
-
-vec3 getColor(){
-	vec3 color;
-	
-	#ifdef color_type_rgba
-		color = getRGB();
-	#elif defined color_type_height || defined color_type_elevation
-		color = getElevation();
-	#elif defined color_type_rgb_height
-		vec3 cHeight = getElevation();
-		color = (1.0 - uTransition) * getRGB() + uTransition * cHeight;
-	#elif defined color_type_depth
-		float linearDepth = gl_Position.w;
-		float expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;
-		color = vec3(linearDepth, expDepth, 0.0);
-		//color = vec3(1.0, 0.5, 0.3);
-	#elif defined color_type_intensity
-		float w = getIntensity();
-		color = vec3(w, w, w);
-	#elif defined color_type_gps_time
-		color = getGpsTime();
-	#elif defined color_type_intensity_gradient
-		float w = getIntensity();
-		color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-	#elif defined color_type_color
-		color = uColor;
-	#elif defined color_type_level_of_detail
-		float depth = getLOD();
-		float w = depth / 10.0;
-		color = texture2D(gradient, vec2(w,1.0-w)).rgb;
-	#elif defined color_type_indices
-		color = indices.rgb;
-	#elif defined color_type_classification
-		vec4 cl = getClassification(); 
-		color = cl.rgb;
-	#elif defined color_type_return_number
-		color = getReturnNumber();
-	#elif defined color_type_returns
-		color = getReturns();
-	#elif defined color_type_number_of_returns
-		color = getNumberOfReturns();
-	#elif defined color_type_source_id
-		color = getSourceID();
-	#elif defined color_type_point_source_id
-		color = getSourceID();
-	#elif defined color_type_normal
-		color = (modelMatrix * vec4(normal, 0.0)).xyz;
-	#elif defined color_type_phong
-		color = color;
-	#elif defined color_type_composite
-		color = getCompositeColor();
-	#elif defined color_type_matcap
-		color = getMatcap();
-	#else 
-		color = getExtra();
-	#endif
-	
-	if (backfaceCulling && applyBackfaceCulling()) {
-		color = vec3(0.);
-	}
-
-	return color;
-}
-
-float getPointSize(){
-	float pointSize = 1.0;
-	
-	float slope = tan(fov / 2.0);
-	float projFactor = -0.5 * uScreenHeight / (slope * vViewPosition.z);
-
-	float scale = length(
-		modelViewMatrix * vec4(0, 0, 0, 1) - 
-		modelViewMatrix * vec4(uOctreeSpacing, 0, 0, 1)
-	) / uOctreeSpacing;
-	projFactor = projFactor * scale;
-	
-	float r = uOctreeSpacing * 1.7;
-	vRadius = r;
-	#if defined fixed_point_size
-		pointSize = size;
-	#elif defined attenuated_point_size
-		if(uUseOrthographicCamera){
-			pointSize = size;
-		}else{
-			pointSize = size * spacing * projFactor;
-			//pointSize = pointSize * projFactor;
-		}
-	#elif defined adaptive_point_size
-		if(uUseOrthographicCamera) {
-			float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
-			pointSize = (worldSpaceSize / uOrthoWidth) * uScreenWidth;
-		} else {
-			float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
-			pointSize = worldSpaceSize * projFactor;
-		}
-	#endif
-
-	pointSize = max(minSize, pointSize);
-	pointSize = min(maxSize, pointSize);
-	
-	vRadius = pointSize / projFactor;
-
-	return pointSize;
-}
-
-#if defined(num_clippolygons) && num_clippolygons > 0
-bool pointInClipPolygon(vec3 point, int polyIdx) {
-
-	mat4 wvp = uClipPolygonWVP[polyIdx];
-	//vec4 screenClipPos = uClipPolygonVP[polyIdx] * modelMatrix * vec4(point, 1.0);
-	//screenClipPos.xy = screenClipPos.xy / screenClipPos.w * 0.5 + 0.5;
-
-	vec4 pointNDC = wvp * vec4(point, 1.0);
-	pointNDC.xy = pointNDC.xy / pointNDC.w;
-
-	int j = uClipPolygonVCount[polyIdx] - 1;
-	bool c = false;
-	for(int i = 0; i < 8; i++) {
-		if(i == uClipPolygonVCount[polyIdx]) {
-			break;
-		}
-
-		//vec4 verti = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + i], 1);
-		//vec4 vertj = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + j], 1);
-
-		//verti.xy = verti.xy / verti.w;
-		//vertj.xy = vertj.xy / vertj.w;
-
-		//verti.xy = verti.xy / verti.w * 0.5 + 0.5;
-		//vertj.xy = vertj.xy / vertj.w * 0.5 + 0.5;
-
-		vec3 verti = uClipPolygonVertices[polyIdx * 8 + i];
-		vec3 vertj = uClipPolygonVertices[polyIdx * 8 + j];
-
-		if( ((verti.y > pointNDC.y) != (vertj.y > pointNDC.y)) && 
-			(pointNDC.x < (vertj.x-verti.x) * (pointNDC.y-verti.y) / (vertj.y-verti.y) + verti.x) ) {
-			c = !c;
-		}
-		j = i;
-	}
-
-	return c;
-}
-#endif
-
-void doClipping(){
-
-	{
-		vec4 cl = getClassification(); 
-		if(cl.a == 0.0){
-			gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-			
-			return;
-		}
-	}
-
-	#if defined(clip_return_number_enabled)
-	{ // return number filter
-		vec2 range = uFilterReturnNumberRange;
-		if(returnNumber < range.x || returnNumber > range.y){
-			gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-			
-			return;
-		}
-	}
-	#endif
-
-	#if defined(clip_number_of_returns_enabled)
-	{ // number of return filter
-		vec2 range = uFilterNumberOfReturnsRange;
-		if(numberOfReturns < range.x || numberOfReturns > range.y){
-			gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-			
-			return;
-		}
-	}
-	#endif
-
-	#if defined(clip_gps_enabled)
-	{ // GPS time filter
-		float time = (gpsTime + uGpsOffset) * uGpsScale;
-		vec2 range = uFilterGPSTimeClipRange;
-
-		if(time < range.x || time > range.y){
-			gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-			
-			return;
-		}
-	}
-	#endif
-
-	#if defined(clip_point_source_id_enabled)
-	{ // point source id filter
-		vec2 range = uFilterPointSourceIDClipRange;
-		if(pointSourceID < range.x || pointSourceID > range.y){
-			gl_Position = vec4(100.0, 100.0, 100.0, 0.0);
-			
-			return;
-		}
-	}
-	#endif
-
-	int clipVolumesCount = 0;
-	int insideCount = 0;
-
-	#if defined(num_clipboxes) && num_clipboxes > 0
-		for(int i = 0; i < num_clipboxes; i++){
-			vec4 clipPosition = clipBoxes[i] * modelMatrix * vec4( position, 1.0 );
-			bool inside = -0.5 <= clipPosition.x && clipPosition.x <= 0.5;
-			inside = inside && -0.5 <= clipPosition.y && clipPosition.y <= 0.5;
-			inside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5;
-
-			insideCount = insideCount + (inside ? 1 : 0);
-			clipVolumesCount++;
-		}	
-	#endif
-
-	#if defined(num_clippolygons) && num_clippolygons > 0
-		for(int i = 0; i < num_clippolygons; i++) {
-			bool inside = pointInClipPolygon(position, i);
-
-			insideCount = insideCount + (inside ? 1 : 0);
-			clipVolumesCount++;
-		}
-	#endif
-
-	bool insideAny = insideCount > 0;
-	bool insideAll = (clipVolumesCount > 0) && (clipVolumesCount == insideCount);
-
-	if(clipMethod == CLIPMETHOD_INSIDE_ANY){
-		if(insideAny && clipTask == CLIPTASK_HIGHLIGHT){
-			vColor.r += 0.5;
-		}else if(!insideAny && clipTask == CLIPTASK_SHOW_INSIDE){
-			gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-		}else if(insideAny && clipTask == CLIPTASK_SHOW_OUTSIDE){
-			gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-		}
-	}else if(clipMethod == CLIPMETHOD_INSIDE_ALL){
-		if(insideAll && clipTask == CLIPTASK_HIGHLIGHT){
-			vColor.r += 0.5;
-		}else if(!insideAll && clipTask == CLIPTASK_SHOW_INSIDE){
-			gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-		}else if(insideAll && clipTask == CLIPTASK_SHOW_OUTSIDE){
-			gl_Position = vec4(100.0, 100.0, 100.0, 1.0);
-		}
-	}
-}
-
-
-
-// 
-// ##     ##    ###    #### ##    ## 
-// ###   ###   ## ##    ##  ###   ## 
-// #### ####  ##   ##   ##  ####  ## 
-// ## ### ## ##     ##  ##  ## ## ## 
-// ##     ## #########  ##  ##  #### 
-// ##     ## ##     ##  ##  ##   ### 
-// ##     ## ##     ## #### ##    ## 
-//
-
-void main() {
-	vec4 mvPosition = modelViewMatrix * vec4(position, 1.0 );
-	vViewPosition = mvPosition.xyz;
-	gl_Position = projectionMatrix * mvPosition;
-	vLogDepth = log2(-mvPosition.z);
-
-	//gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
-	//gl_PointSize = 5.0;
-
-	// POINT SIZE
-	float pointSize = getPointSize();
-	//float pointSize = 2.0;
-	gl_PointSize = pointSize;
-	vPointSize = pointSize;
-
-	// COLOR
-	vColor = getColor();
-	// vColor = vec3(1.0, 0.0, 0.0);
-
-	//gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
-	//gl_Position = vec4(position.xzy / 1000.0, 1.0 );
-
-	//gl_PointSize = 5.0;
-	//vColor = vec3(1.0, 1.0, 1.0);
-
-	// only for "replacing" approaches
-	// if(getLOD() != uLevel){
-	// 	gl_Position = vec4(10.0, 10.0, 10.0, 1.0);
-	// }
-
-
-	#if defined hq_depth_pass
-		float originalDepth = gl_Position.w;
-		float adjustedDepth = originalDepth + 2.0 * vRadius;
-		float adjust = adjustedDepth / originalDepth;
-
-		mvPosition.xyz = mvPosition.xyz * adjust;
-		gl_Position = projectionMatrix * mvPosition;
-	#endif
-
-
-	// CLIPPING
-	doClipping();
-
-	#if defined(num_clipspheres) && num_clipspheres > 0
-		for(int i = 0; i < num_clipspheres; i++){
-			vec4 sphereLocal = uClipSpheres[i] * mvPosition;
-
-			float distance = length(sphereLocal.xyz);
-
-			if(distance < 1.0){
-				float w = distance;
-				vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
-				
-				vColor = cGradient;
-				//vColor = cGradient * 0.7 + vColor * 0.3;
-			}
-		}
-	#endif
-
-	#if defined(num_shadowmaps) && num_shadowmaps > 0
-
-		const float sm_near = 0.1;
-		const float sm_far = 10000.0;
-
-		for(int i = 0; i < num_shadowmaps; i++){
-			vec3 viewPos = (uShadowWorldView[i] * vec4(position, 1.0)).xyz;
-			float distanceToLight = abs(viewPos.z);
-			
-			vec4 projPos = uShadowProj[i] * uShadowWorldView[i] * vec4(position, 1);
-			vec3 nc = projPos.xyz / projPos.w;
-			
-			float u = nc.x * 0.5 + 0.5;
-			float v = nc.y * 0.5 + 0.5;
-
-			vec2 sampleStep = vec2(1.0 / (2.0*1024.0), 1.0 / (2.0*1024.0)) * 1.5;
-			vec2 sampleLocations[9];
-			sampleLocations[0] = vec2(0.0, 0.0);
-			sampleLocations[1] = sampleStep;
-			sampleLocations[2] = -sampleStep;
-			sampleLocations[3] = vec2(sampleStep.x, -sampleStep.y);
-			sampleLocations[4] = vec2(-sampleStep.x, sampleStep.y);
-
-			sampleLocations[5] = vec2(0.0, sampleStep.y);
-			sampleLocations[6] = vec2(0.0, -sampleStep.y);
-			sampleLocations[7] = vec2(sampleStep.x, 0.0);
-			sampleLocations[8] = vec2(-sampleStep.x, 0.0);
-
-			float visibleSamples = 0.0;
-			float numSamples = 0.0;
-
-			float bias = vRadius * 2.0;
-
-			for(int j = 0; j < 9; j++){
-				vec4 depthMapValue = texture2D(uShadowMap[i], vec2(u, v) + sampleLocations[j]);
-
-				float linearDepthFromSM = depthMapValue.x + bias;
-				float linearDepthFromViewer = distanceToLight;
-
-				if(linearDepthFromSM > linearDepthFromViewer){
-					visibleSamples += 1.0;
-				}
-
-				numSamples += 1.0;
-			}
-
-			float visibility = visibleSamples / numSamples;
-
-			if(u < 0.0 || u > 1.0 || v < 0.0 || v > 1.0 || nc.x < -1.0 || nc.x > 1.0 || nc.y < -1.0 || nc.y > 1.0 || nc.z < -1.0 || nc.z > 1.0){
-				//vColor = vec3(0.0, 0.0, 0.2);
-			}else{
-				//vColor = vec3(1.0, 1.0, 1.0) * visibility + vec3(1.0, 1.0, 1.0) * vec3(0.5, 0.0, 0.0) * (1.0 - visibility);
-				vColor = vColor * visibility + vColor * uShadowColor * (1.0 - visibility);
-			}
-
-
-		}
-
-	#endif
-}

+ 8 - 91
src/materials/shaders/pointcloud.fs

@@ -2,41 +2,10 @@
 #if defined paraboloid_point_shape
 	#extension GL_EXT_frag_depth : enable
 #endif
-#define PI 3.141592653589793
-
-
 
 precision highp float;
 precision highp int;
 
-/*
-#if defined(usePanoMap) 
-    
-    uniform samplerCube pano0Map;   //随便设置一个samplerCube去使用都会让点云消失
-    uniform samplerCube pano1Map;
-     
-    uniform float progress;
-    uniform float easeInOutRatio;
-
-     
-    uniform vec3 pano0Position;
-    uniform mat4 pano0Matrix; 
-    uniform vec3 pano1Position;
-    uniform mat4 pano1Matrix;
-    varying vec3 vWorldPosition0;
-    varying vec3 vWorldPosition1;
-
-#endif 
-*/
-
-
-
-//------------
-
-
-
-
-
 uniform mat4 viewMatrix;
 uniform mat4 uViewInv;
 uniform mat4 uProjInv;
@@ -44,8 +13,7 @@ uniform vec3 cameraPosition;
 
 
 uniform mat4 projectionMatrix;
-//uniform float uOpacity;
-varying float vOpacity; //add
+uniform float uOpacity;
 
 uniform float blendHardness;
 uniform float blendDepthSupplement;
@@ -67,49 +35,11 @@ varying vec3 	vPosition;
 
 float specularStrength = 1.0;
 
-
-vec2 getSamplerCoord( vec3 direction ) 
-{
-    direction = normalize(direction);
-    float tx=atan(direction.x,-direction.y)/(PI*2.0)+0.5;
-    float ty=acos(direction.z)/PI;
-
-    return vec2(tx,ty);
-}  
-
-
-
-
 void main() {
 
-    vec3 color = vColor;  
-	 
-    
-    /*#if defined(usePanoMap) //加     经测试,即使全部写在fragment里也是无论pointsize多大都是一个点一个颜色,所以干脆写在vectex里
-    
-    
-        vec4 colorFromPano0=textureCube(pano0Map,vWorldPosition0.xyz);
-        vec4 colorFromPano1=textureCube(pano1Map,vWorldPosition1.xyz);
-        
-        color = mix(colorFromPano0,colorFromPano1,progress).xyz; 
-        
-        
-        //float easeInOutRatio = 0.0;  //缓冲,渐变点云到贴图的颜色 
-        if(progress < easeInOutRatio){
-            float easeProgress = (easeInOutRatio - progress) / easeInOutRatio; 
-            color = mix(color,vColor,easeProgress); 
-        }else if(progress > 1.0 - easeInOutRatio){ 
-            float easeProgress = (progress - (1.0 - easeInOutRatio) ) / easeInOutRatio; 
-            color = mix(color,vColor,easeProgress); 
-        }
-        
-        
-    #else 
-        color = vColor;
-    #endif*/
-   
-   
-    
+	// gl_FragColor = vec4(vColor, 1.0);
+
+	vec3 color = vColor;
 	float depth = gl_FragCoord.z;
 
 	#if defined(circle_point_shape) || defined(paraboloid_point_shape) 
@@ -123,25 +53,12 @@ void main() {
 			discard;
 		}
 	#endif
-	
-
- 
-
-	
- 
-    #if defined color_type_indices    //pick point recognize
-		gl_FragColor = vec4(color, uPCIndex / 255.0); //uPCIndex : node Index
+		
+	#if defined color_type_indices
+		gl_FragColor = vec4(color, uPCIndex / 255.0);
 	#else
-		gl_FragColor = vec4(color, vOpacity);
+		gl_FragColor = vec4(color, uOpacity);
 	#endif
-    
-    
-    
-    
-    
-    
-    
-    
 
 	#if defined paraboloid_point_shape
 		float wi = 0.0 - ( u*u + v*v);

+ 128 - 293
src/materials/shaders/pointcloud.vs

@@ -5,40 +5,6 @@ precision highp int;
 #define max_clip_polygons 8
 #define PI 3.141592653589793
 
- 
-
-
-
-#if defined(usePanoMap) 
-    
-    uniform samplerCube pano0Map;   //随便设置一个samplerCube去使用都会让点云消失
-    uniform samplerCube pano1Map;
-     
-    uniform float progress;
-    uniform float easeInOutRatio;
-
-    
-    uniform vec3 pano0Position;
-    uniform mat4 pano0Matrix; 
-    uniform vec3 pano1Position;
-    uniform mat4 pano1Matrix;
-    /*
-    varying vec3 vWorldPosition0;
-    varying vec3 vWorldPosition1;
-    */
-#endif 
-
-
-
-
- 
-
-//--------------
-
-
-
-
-
 attribute vec3 position;
 attribute vec3 color;
 attribute float intensity;
@@ -46,7 +12,7 @@ attribute float classification;
 attribute float returnNumber;
 attribute float numberOfReturns;
 attribute float pointSourceID;
-attribute vec4 indices;    //每个点的index
+attribute vec4 indices;
 attribute float spacing;
 attribute float gpsTime;
 attribute vec3 normal;
@@ -58,18 +24,12 @@ uniform mat4 projectionMatrix;
 uniform mat4 viewMatrix;
 uniform mat4 uViewInv;
 
-//uniform float uScreenWidth;
-//uniform float uScreenHeight;
-uniform vec2 resolution;
-
-
+uniform float uScreenWidth;
+uniform float uScreenHeight;
 uniform float fov;
 uniform float near;
 uniform float far;
 
-
-
-
 uniform bool uDebug;
 
 uniform bool uUseOrthographicCamera;
@@ -115,10 +75,7 @@ uniform float uVNStart;
 uniform bool uIsLeafNode;
 
 uniform vec3 uColor;
-uniform float uOpacity; 
-varying float vOpacity; //add
-
-
+uniform float uOpacity;
 
 uniform vec2 elevationRange;
 uniform vec2 intensityRange;
@@ -127,8 +84,6 @@ uniform vec2 uFilterReturnNumberRange;
 uniform vec2 uFilterNumberOfReturnsRange;
 uniform vec2 uFilterPointSourceIDClipRange;
 uniform vec2 uFilterGPSTimeClipRange;
-//uniform float ufilterByNormalThreshold;    
-
 uniform float uGpsScale;
 uniform float uGpsOffset;
 
@@ -168,8 +123,6 @@ uniform mat4 uShadowWorldView[num_shadowmaps];
 uniform mat4 uShadowProj[num_shadowmaps];
 #endif
 
-
-
 varying vec3	vColor;
 varying float	vLogDepth;
 varying vec3	vViewPosition;
@@ -260,8 +213,8 @@ bool isBitSet(int number, int index){
 /**
  * find the LOD at the point position
  */
-float getLOD(){//////
-	 
+float getLOD(){
+	
 	vec3 offset = vec3(0.0, 0.0, 0.0);
 	int iOffset = int(uVNStart);
 	float depth = uLevel;
@@ -603,7 +556,6 @@ vec3 getNormal(){
 }
 bool applyBackfaceCulling() {
 	// Black not facing vertices / Backface culling
-      
 	vec3 e = normalize(vec3(modelViewMatrix * vec4( position, 1. )));
 	vec3 n = getNormal(); // normalize( vec3(modelViewMatrix * vec4( normal, 0.0 )) );
 
@@ -653,8 +605,6 @@ vec3 getColor(){
 	
 	#ifdef color_type_rgba
 		color = getRGB();
-         
-        
 	#elif defined color_type_height || defined color_type_elevation
 		color = getElevation();
 	#elif defined color_type_rgb_height
@@ -706,10 +656,10 @@ vec3 getColor(){
 		color = getExtra();
 	#endif
 	
-	if (backfaceCulling && applyBackfaceCulling()){
-        //color = vec3(0.);
-    }
-    //applyBackfaceCulling直接返回false或者注释color = vec3(0.);都没问题
+	if (backfaceCulling && applyBackfaceCulling()) {
+		color = vec3(0.);
+	}
+
 	return color;
 }
 
@@ -717,39 +667,29 @@ float getPointSize(){
 	float pointSize = 1.0;
 	
 	float slope = tan(fov / 2.0);
-	float projFactor = -0.5 * resolution.y / (slope * vViewPosition.z);
-    
-    
-    
-    /*
+	float projFactor = -0.5 * uScreenHeight / (slope * vViewPosition.z);
+
 	float scale = length(
 		modelViewMatrix * vec4(0, 0, 0, 1) - 
 		modelViewMatrix * vec4(uOctreeSpacing, 0, 0, 1)
 	) / uOctreeSpacing;
-    
 	projFactor = projFactor * scale;
-	*/
-    
-    
+	
 	float r = uOctreeSpacing * 1.7;
-	//vRadius = r;
-     
-    
+	vRadius = r;
 	#if defined fixed_point_size
 		pointSize = size;
 	#elif defined attenuated_point_size
 		if(uUseOrthographicCamera){
-			pointSize = size * 10.0;  //加个乘数
-		}else{  //近大远小,模拟真实mesh,边缘放大
-			//pointSize = size * spacing * projFactor;  //spacing是attribute  为空  如果有这个值就能更自适应填补
-            //pointSize = size * uOctreeSpacing * projFactor / 18.0; //直接用cloud的spacing里,不过因为都一样所以可能没有什么意义
+			pointSize = size;
+		}else{
+			pointSize = size * spacing * projFactor;
 			//pointSize = pointSize * projFactor;
-            pointSize = size * projFactor  ;
 		}
 	#elif defined adaptive_point_size
 		if(uUseOrthographicCamera) {
 			float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
-			pointSize = (worldSpaceSize / uOrthoWidth) * resolution.x;    //uScreenWidth;
+			pointSize = (worldSpaceSize / uOrthoWidth) * uScreenWidth;
 		} else {
 			float worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();
 			pointSize = worldSpaceSize * projFactor;
@@ -919,228 +859,123 @@ void doClipping(){
 // ##     ## ##     ## #### ##    ## 
 //
 
+void main() {
+	vec4 mvPosition = modelViewMatrix * vec4(position, 1.0 );
+	vViewPosition = mvPosition.xyz;
+	gl_Position = projectionMatrix * mvPosition;
+	vLogDepth = log2(-mvPosition.z);
 
-vec2 getSamplerCoord( vec3 direction ) 
-{
-    direction = normalize(direction);
-    float tx=atan(direction.x,-direction.y)/(PI*2.0)+0.5;
-    float ty=acos(direction.z)/PI;
+	//gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
+	//gl_PointSize = 5.0;
 
-    return vec2(tx,ty);
-}  
+	// POINT SIZE
+	float pointSize = getPointSize();
+	//float pointSize = 2.0;
+	gl_PointSize = pointSize;
+	vPointSize = pointSize;
 
-vec3 transformAxis( vec3 direction ) //navvis->4dkk
-{
-    float y = direction.y;
-    direction.y = direction.z;
-    direction.z = -y;
-    return  direction;
-}
+	// COLOR
+	vColor = getColor();
+	// vColor = vec3(1.0, 0.0, 0.0);
+
+	//gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
+	//gl_Position = vec4(position.xzy / 1000.0, 1.0 );
+
+	//gl_PointSize = 5.0;
+	//vColor = vec3(1.0, 1.0, 1.0);
+
+	// only for "replacing" approaches
+	// if(getLOD() != uLevel){
+	// 	gl_Position = vec4(10.0, 10.0, 10.0, 1.0);
+	// }
+
+
+	#if defined hq_depth_pass
+		float originalDepth = gl_Position.w;
+		float adjustedDepth = originalDepth + 2.0 * vRadius;
+		float adjust = adjustedDepth / originalDepth;
+
+		mvPosition.xyz = mvPosition.xyz * adjust;
+		gl_Position = projectionMatrix * mvPosition;
+	#endif
 
-void main() {
-    //bool filtered_by_normal = false; 
-    float normalZ = 0.0;
-
-
-
-    #ifdef use_filter_by_normal
-        /*if(abs(getNormal().z) > 0.4) { //ufilterByNormalThreshold 暂定 3
-			// Move point outside clip space space to discard it.
-			//gl_Position = vec4(0.0, 0.0, 2.0, 1.0);   //gl_Position的可视区域是 x,y,z都是[-1,1]  
-            //return;
-            //filtered_by_normal = true; //标记一下。不直接不绘制,因为有的法线都是垂直向上
-             
-		}*/
-        
-        normalZ = abs(getNormal().z);
-    #endif
-     
-    vec4 mvPosition = modelViewMatrix * vec4(position, 1.0 );
-    vViewPosition = mvPosition.xyz;
-    gl_Position = projectionMatrix * mvPosition;
-    vLogDepth = log2(-mvPosition.z);
-    
-    
-     
-    // COLOR
-    //加-------------------
-    #if defined(usePanoMap)
-        vec4 worldPosition = modelMatrix * vec4(position, 1.0);
-         
-        vec3 positionLocalToPanoCenter0 = worldPosition.xyz - pano0Position;
-        vec3 vWorldPosition0 = (vec4(positionLocalToPanoCenter0, 1.0) * pano0Matrix).xyz; 
-        vWorldPosition0.x *= -1.0;
-        vWorldPosition0 = transformAxis(vWorldPosition0);
-        
-        vec3 positionLocalToPanoCenter1 = worldPosition.xyz - pano1Position;
-        vec3 vWorldPosition1 = (vec4(positionLocalToPanoCenter1, 1.0) * pano1Matrix).xyz; 
-        vWorldPosition1.x *= -1.0;
-        vWorldPosition1 = transformAxis(vWorldPosition1);
-         
-        /*
-        vec2 samplerCoord0 = getSamplerCoord(vWorldPosition0.xyz);
-        vec2 samplerCoord1 = getSamplerCoord(vWorldPosition1.xyz); 
-        vec4 colorFromPano0 = texture2D(pano0Map,samplerCoord0);
-        vec4 colorFromPano1 = texture2D(pano1Map,samplerCoord1);
-        */
-        
-        
-        
-        
-        vec4 colorFromPano0=textureCube(pano0Map,vWorldPosition0.xyz);
-        vec4 colorFromPano1=textureCube(pano1Map,vWorldPosition1.xyz);
-
-        vColor = mix(colorFromPano0,colorFromPano1,progress).xyz; 
-
-         
-        //float easeInOutRatio = 0.0;  //缓冲,渐变点云到贴图的颜色 
-        if(progress < easeInOutRatio){
-            float easeProgress = (easeInOutRatio - progress) / easeInOutRatio;
-            vec3 vColor1 = getColor();
-            vColor = mix(vColor,vColor1,easeProgress); 
-        }else if(progress > 1.0 - easeInOutRatio){ 
-            float easeProgress = (progress - (1.0 - easeInOutRatio) ) / easeInOutRatio;
-            vec3 vColor1 = getColor();
-            vColor = mix(vColor,vColor1,easeProgress); 
-        }
-        
-
-    #else
-     
-        vColor = getColor();
-    
-    #endif
-   
-   
-    //-------------------        
- 
-    #ifdef attenuated_opacity  
-        //zoom不会改变z 所以这并不是用在分屏时候的
-        //vOpacity = uOpacity * exp(-length(-mvPosition.xyz) / 1000.0);  // e为底的指数函数  opacityAttenuation = 1000
-        vOpacity = uOpacity  * exp(gl_Position.z/50.0); 
-        vOpacity = clamp(vOpacity, 0.001, 1.0);          
-        /*if(filtered_by_normal){//垂直朝相机时降低透明度 
-            vOpacity *= 0.2; 
-            vOpacity = clamp(vOpacity, 0.0001, 0.1);    
-        } */  
-    #else
-        vOpacity = uOpacity;
-        /*if(filtered_by_normal){//垂直朝相机时降低透明度 
-        /*if(filtered_by_normal){//垂直朝相机时降低透明度 
-            vOpacity *= 0.3; 
-            vOpacity = clamp(vOpacity, 0.0001, 0.1);    
-        }*/ 
-        
-        vOpacity *= max(0.1,  (1.0 - normalZ));
-    #endif
-	 
-
-    // POINT SIZE
-    float pointSize = getPointSize();
-    
-    gl_PointSize = pointSize;
-    vPointSize = pointSize;
-
-    
-    
-    
-     
-
-    // only for "replacing" approaches
-    // if(getLOD() != uLevel){
-    // 	gl_Position = vec4(10.0, 10.0, 10.0, 1.0);
-    // }
-
-
-    #if defined hq_depth_pass
-        float originalDepth = gl_Position.w;
-        float adjustedDepth = originalDepth + 2.0 * vRadius;
-        float adjust = adjustedDepth / originalDepth;
-
-        mvPosition.xyz = mvPosition.xyz * adjust;
-        gl_Position = projectionMatrix * mvPosition;
-    #endif
-
-
-    // CLIPPING
-    doClipping();
-
-    #if defined(num_clipspheres) && num_clipspheres > 0
-        for(int i = 0; i < num_clipspheres; i++){
-            vec4 sphereLocal = uClipSpheres[i] * mvPosition;
-
-            float distance = length(sphereLocal.xyz);
-
-            if(distance < 1.0){
-                float w = distance;
-                vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
-                
-                vColor = cGradient;
-                //vColor = cGradient * 0.7 + vColor * 0.3;
-            }
-        }
-    #endif
-
-    #if defined(num_shadowmaps) && num_shadowmaps > 0
-
-        const float sm_near = 0.1;
-        const float sm_far = 10000.0;
-
-        for(int i = 0; i < num_shadowmaps; i++){
-            vec3 viewPos = (uShadowWorldView[i] * vec4(position, 1.0)).xyz;
-            float distanceToLight = abs(viewPos.z);
-            
-            vec4 projPos = uShadowProj[i] * uShadowWorldView[i] * vec4(position, 1);
-            vec3 nc = projPos.xyz / projPos.w;
-            
-            float u = nc.x * 0.5 + 0.5;
-            float v = nc.y * 0.5 + 0.5;
-
-            vec2 sampleStep = vec2(1.0 / (2.0*1024.0), 1.0 / (2.0*1024.0)) * 1.5;
-            vec2 sampleLocations[9];
-            sampleLocations[0] = vec2(0.0, 0.0);
-            sampleLocations[1] = sampleStep;
-            sampleLocations[2] = -sampleStep;
-            sampleLocations[3] = vec2(sampleStep.x, -sampleStep.y);
-            sampleLocations[4] = vec2(-sampleStep.x, sampleStep.y);
-
-            sampleLocations[5] = vec2(0.0, sampleStep.y);
-            sampleLocations[6] = vec2(0.0, -sampleStep.y);
-            sampleLocations[7] = vec2(sampleStep.x, 0.0);
-            sampleLocations[8] = vec2(-sampleStep.x, 0.0);
-
-            float visibleSamples = 0.0;
-            float numSamples = 0.0;
-
-            float bias = vRadius * 2.0;
-
-            for(int j = 0; j < 9; j++){
-                vec4 depthMapValue = texture2D(uShadowMap[i], vec2(u, v) + sampleLocations[j]);
-
-                float linearDepthFromSM = depthMapValue.x + bias;
-                float linearDepthFromViewer = distanceToLight;
-
-                if(linearDepthFromSM > linearDepthFromViewer){
-                    visibleSamples += 1.0;
-                }
-
-                numSamples += 1.0;
-            }
-
-            float visibility = visibleSamples / numSamples;
 
-            if(u < 0.0 || u > 1.0 || v < 0.0 || v > 1.0 || nc.x < -1.0 || nc.x > 1.0 || nc.y < -1.0 || nc.y > 1.0 || nc.z < -1.0 || nc.z > 1.0){
-                //vColor = vec3(0.0, 0.0, 0.2);
-            }else{
-                //vColor = vec3(1.0, 1.0, 1.0) * visibility + vec3(1.0, 1.0, 1.0) * vec3(0.5, 0.0, 0.0) * (1.0 - visibility);
-                vColor = vColor * visibility + vColor * uShadowColor * (1.0 - visibility);
-            }
+	// CLIPPING
+	doClipping();
 
+	#if defined(num_clipspheres) && num_clipspheres > 0
+		for(int i = 0; i < num_clipspheres; i++){
+			vec4 sphereLocal = uClipSpheres[i] * mvPosition;
 
-        }
+			float distance = length(sphereLocal.xyz);
 
-    #endif
+			if(distance < 1.0){
+				float w = distance;
+				vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
+				
+				vColor = cGradient;
+				//vColor = cGradient * 0.7 + vColor * 0.3;
+			}
+		}
+	#endif
+
+	#if defined(num_shadowmaps) && num_shadowmaps > 0
+
+		const float sm_near = 0.1;
+		const float sm_far = 10000.0;
+
+		for(int i = 0; i < num_shadowmaps; i++){
+			vec3 viewPos = (uShadowWorldView[i] * vec4(position, 1.0)).xyz;
+			float distanceToLight = abs(viewPos.z);
+			
+			vec4 projPos = uShadowProj[i] * uShadowWorldView[i] * vec4(position, 1);
+			vec3 nc = projPos.xyz / projPos.w;
+			
+			float u = nc.x * 0.5 + 0.5;
+			float v = nc.y * 0.5 + 0.5;
 
-    
-    
+			vec2 sampleStep = vec2(1.0 / (2.0*1024.0), 1.0 / (2.0*1024.0)) * 1.5;
+			vec2 sampleLocations[9];
+			sampleLocations[0] = vec2(0.0, 0.0);
+			sampleLocations[1] = sampleStep;
+			sampleLocations[2] = -sampleStep;
+			sampleLocations[3] = vec2(sampleStep.x, -sampleStep.y);
+			sampleLocations[4] = vec2(-sampleStep.x, sampleStep.y);
+
+			sampleLocations[5] = vec2(0.0, sampleStep.y);
+			sampleLocations[6] = vec2(0.0, -sampleStep.y);
+			sampleLocations[7] = vec2(sampleStep.x, 0.0);
+			sampleLocations[8] = vec2(-sampleStep.x, 0.0);
+
+			float visibleSamples = 0.0;
+			float numSamples = 0.0;
+
+			float bias = vRadius * 2.0;
+
+			for(int j = 0; j < 9; j++){
+				vec4 depthMapValue = texture2D(uShadowMap[i], vec2(u, v) + sampleLocations[j]);
+
+				float linearDepthFromSM = depthMapValue.x + bias;
+				float linearDepthFromViewer = distanceToLight;
+
+				if(linearDepthFromSM > linearDepthFromViewer){
+					visibleSamples += 1.0;
+				}
+
+				numSamples += 1.0;
+			}
+
+			float visibility = visibleSamples / numSamples;
+
+			if(u < 0.0 || u > 1.0 || v < 0.0 || v > 1.0 || nc.x < -1.0 || nc.x > 1.0 || nc.y < -1.0 || nc.y > 1.0 || nc.z < -1.0 || nc.z > 1.0){
+				//vColor = vec3(0.0, 0.0, 0.2);
+			}else{
+				//vColor = vec3(1.0, 1.0, 1.0) * visibility + vec3(1.0, 1.0, 1.0) * vec3(0.5, 0.0, 0.0) * (1.0 - visibility);
+				vColor = vColor * visibility + vColor * uShadowColor * (1.0 - visibility);
+			}
+
+
+		}
+
+	#endif
 }

+ 0 - 64
src/modules/CameraAnimation/CamAniEditor.js

@@ -1,64 +0,0 @@
-import * as THREE from "../../../libs/three.js/build/three.module.js"; 
-import {CameraAnimation} from './CameraAnimationNew.js'
-
-
-
-let CamAniEditor = {
-    
-    
-     
-    
-    createAnimation(data){
-        let animation = new CameraAnimation(viewer);
-        if(data) { 
-            animation.name = data.name;
-            animation.duration = data.duration;
-            animation.useDurSlice = data.useDurSlice
-             
-            for(const cpdata of data.points){ 
-                /* const position = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.position, datasetId: Potree.settings.originDatasetId })
-                const target = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.target, datasetId: Potree.settings.originDatasetId })
-                 */
-                const position = new THREE.Vector3().copy(cpdata.position)
-                const target = new THREE.Vector3().copy(cpdata.target)  
-                const duration = cpdata.time
-                const cp = animation.createControlPoint(null, {position, target, duration}); 
-            }
-        }
-        
-        animation.changeCallback()
-        viewer.scene.addCameraAnimation(animation);
-         
-        return animation
-        
-    },
-    
-    
-    removeAnimation(animation){
-        animation.dispatchEvent('dispose')
-        viewer.scene.removeCameraAnimation(animation)
-    }
-    
-    
-    
-     
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-}
-
-
-export default CamAniEditor

+ 1 - 1
src/viewer/EDLRenderer.js

@@ -5,7 +5,7 @@ import {EyeDomeLightingMaterial} from "../materials/EyeDomeLightingMaterial.js";
 import {SphereVolume} from "../utils/Volume.js";
 import {Utils} from "../utils.js";
 
-export class EDLRenderer{
+export class EDLRenderer{//old 
 	constructor(viewer){
 		this.viewer = viewer;
 

+ 2 - 2
src/viewer/EDLRendererNew.js

@@ -1,7 +1,7 @@
 
 import * as THREE from "../../libs/three.js/build/three.module.js";
 import {PointCloudSM} from "../utils/PointCloudSM.js";
-import {EyeDomeLightingMaterial} from "../materials/EyeDomeLightingMaterial.js";
+import {ExtendEyeDomeLightingMaterial} from "../materials/ExtendEyeDomeLightingMaterial.js";
 import {SphereVolume} from "../utils/Volume.js";
 import {Utils} from "../utils.js";
 import {copyShader} from '../materials/shaders/otherShaders.js'
@@ -29,7 +29,7 @@ export class EDLRenderer{//Eye-Dome Lighting 眼罩照明
 			return;
 		}
 
-		this.edlMaterial = new EyeDomeLightingMaterial();
+		this.edlMaterial = new ExtendEyeDomeLightingMaterial();
 		this.edlMaterial.depthTest = true;
 		this.edlMaterial.depthWrite = true;
 		this.edlMaterial.transparent = true;

+ 46 - 0
src/viewer/PropertyPanels/ExtendDistancePanel.js

@@ -0,0 +1,46 @@
+
+import {DistancePanel} from "./DistancePanel.js";
+import {MeasurePanel} from "./MeasurePanel.js"; 
+import {Profile} from "./../../utils/Profile.js";
+
+
+
+export class ExtendDistancePanel extends DistancePanel{
+	constructor(viewer, measurement, propertiesPanel){
+		super(viewer, measurement, propertiesPanel); 
+	}
+
+	update(){
+		let elCoordiantesContainer = this.elContent.find('.coordinates_table_container');
+		elCoordiantesContainer.empty();
+		elCoordiantesContainer.append(this.createCoordinatesTable(this.measurement.points));
+
+		let positions = this.measurement.points;
+		let distances = [];
+		for (let i = 0; i < positions.length - 1; i++) {
+			let d = positions[i].distanceTo(positions[i + 1]);
+			distances.push(d.toFixed(3));
+		}
+
+		let totalDistance = this.measurement.getTotalDistance().toFixed(3);
+		let elDistanceTable = this.elContent.find(`#distances_table`);
+		elDistanceTable.empty();
+
+		for (let i = 0; i < distances.length; i++) {
+			let label = (i === 0) ? 'Distances: ' : '';
+			let distance = distances[i];
+			let elDistance = $(`
+				<tr>
+					<th>${label}</th>
+					<td style="width: 100%; padding-left: 10px">${distance}</td>
+				</tr>`);
+			elDistanceTable.append(elDistance);
+		}
+
+		let elTotal = $(`
+			<tr>
+				<th>Total: </td><td style="width: 100%; padding-left: 10px">${totalDistance}</th>
+			</tr>`);
+		elDistanceTable.append(elTotal);
+	}
+};

+ 1 - 1
src/viewer/Scene.js

@@ -7,7 +7,7 @@ import {Utils} from "../utils.js";
 import {EventDispatcher} from "../EventDispatcher.js";
 
 
-export class Scene extends EventDispatcher{
+export class Scene extends EventDispatcher{//base
 
 	constructor(){
 		super();

+ 1 - 1
src/viewer/View.js

@@ -1,6 +1,6 @@
 import * as THREE from "../../libs/three.js/build/three.module.js";
 
-export class View{
+export class View{//base
 	constructor () {
 		this.position = new THREE.Vector3(0, 0, 0);
 

Файловите разлики са ограничени, защото са твърде много
+ 1958 - 0
src/viewer/sidebarNew.js


Файловите разлики са ограничени, защото са твърде много
+ 3 - 2
正式版手动更新备份/2022.11.14/potree.js


+ 2 - 1
正式版手动更新备份/2022.11.14/potreeFormat.js

@@ -65560,6 +65560,7 @@
             key: "exportSavingData",
             value: function() {
                 var e, i = this, t = {};
+                const rotQua = (new Sn()).setFromAxisAngle(new Cn(0,0,1), Math.PI)    
                 for (e in Potree.settings.datasetsPanos) {
                     var n = Potree.settings.datasetsPanos[e].panos.map(function(e) {
                         var t, n = [];
@@ -65569,7 +65570,7 @@
                             uuid: e.uuid,
                             pose: {
                                 translation: r(e.position.clone()),
-                                rotation: r((new Sn).setFromRotationMatrix(e.panoMatrix))
+                                rotation: r((new Sn).setFromRotationMatrix(e.panoMatrix)).premultiply(rotQua)
                             },
                             visibles: n
                         })

+ 2 - 2
正式版手动更新备份/2022.11.14/更改.txt

@@ -16,5 +16,5 @@ n = e.panos[0].dataPosition.clone()
 translation: r(e.position.clone().negate()),
 变为
 
-
-translation: r(e.position.clone()),
+const rotQua = (new Sn()).setFromAxisAngle(new Cn(0,0,1), Math.PI)    
+rotation: r((new Sn).setFromRotationMatrix(e.panoMatrix)).premultiply(rotQua)