Merge pull request #160 from potree/develop

Develop
This commit is contained in:
Markus Schütz 2015-07-14 12:41:35 +02:00
commit 8c171aaacf
20 changed files with 1162 additions and 749 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,6 +21,8 @@ Potree.Shaders["pointcloud.vs"] = [
"//#define MAX_SHADOWS 0",
"//#define MAX_BONES 58",
"",
"#define max_clip_boxes 30",
"",
"",
"attribute float intensity;",
"attribute float classification;",
@ -32,12 +34,13 @@ Potree.Shaders["pointcloud.vs"] = [
"uniform float screenHeight;",
"uniform float fov;",
"uniform float spacing;",
"uniform float blendDepth;",
"uniform float near;",
"uniform float far;",
"uniform float level;",
"uniform float visibleNodesOffset;",
"",
"#if defined use_clip_box",
" uniform mat4 clipBoxes[clip_box_count];",
" uniform mat4 clipBoxes[max_clip_boxes];",
"#endif",
"",
"",
@ -45,13 +48,15 @@ Potree.Shaders["pointcloud.vs"] = [
"uniform float heightMax;",
"uniform float intensityMin;",
"uniform float intensityMax;",
"uniform float size;",
"uniform float minSize;",
"uniform float maxSize;",
"uniform float nodeSize;",
"uniform float size; // pixel size factor",
"uniform float minSize; // minimum pixel size",
"uniform float maxSize; // maximum pixel size",
"uniform float octreeSize;",
"uniform vec3 bbMin;",
"uniform vec3 bbSize;",
"uniform vec3 uColor;",
"uniform float opacity;",
"uniform float clipBoxCount;",
"",
"",
"uniform sampler2D visibleNodes;",
@ -106,12 +111,12 @@ Potree.Shaders["pointcloud.vs"] = [
" * find the tree depth at the point position",
" */",
"float getLocalTreeDepth(){",
" vec3 offset = vec3(0.0, 0.0, 0.0);",
" float iOffset = 0.0;",
" float depth = 0.0;",
" for(float i = 0.0; i <= levels + 1.0; i++){",
" vec3 offset = bbMin;",
" float iOffset = visibleNodesOffset;",
" float depth = level;",
" for(float i = 0.0; i <= 1000.0; i++){",
" ",
" float nodeSizeAtLevel = nodeSize / pow(2.0, i);",
" float nodeSizeAtLevel = octreeSize / pow(2.0, i + level);",
" vec3 index3d = (position - offset) / nodeSizeAtLevel;",
" index3d = floor(index3d + 0.5);",
" float index = 4.0*index3d.x + 2.0*index3d.y + index3d.z;",
@ -155,7 +160,7 @@ Potree.Shaders["pointcloud.vs"] = [
" vec3 size = bbSize; ",
" vec3 pos = position;",
" ",
" for(float i = 0.0; i <= levels + 1.0; i++){",
" for(float i = 0.0; i <= 1000.0; i++){",
" ",
" vec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));",
" ",
@ -218,7 +223,7 @@ Potree.Shaders["pointcloud.vs"] = [
" vOpacity = opacity;",
" vLinearDepth = -mvPosition.z;",
" vDepth = mvPosition.z / gl_Position.w;",
" vNormal = normalMatrix * normal;",
" vNormal = normalize(normalMatrix * normal);",
"",
"",
" // ---------------------",
@ -301,7 +306,11 @@ Potree.Shaders["pointcloud.vs"] = [
" ",
" #if defined use_clip_box",
" bool insideAny = false;",
" for(int i = 0; i < clip_box_count; i++){",
" for(int i = 0; i < max_clip_boxes; i++){",
" if(i == int(clipBoxCount)){",
" break;",
" }",
" ",
" 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;",
@ -392,7 +401,6 @@ Potree.Shaders["pointcloud.fs"] = [
"uniform float pcIndex;",
"uniform float screenWidth;",
"uniform float screenHeight;",
"uniform float blendDepth;",
"",
"uniform sampler2D depthMap;",
"",
@ -424,7 +432,7 @@ Potree.Shaders["pointcloud.fs"] = [
" #if defined weighted_splats",
" vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight);",
" float depth = texture2D(depthMap, uv).r;",
" if(vLinearDepth > depth + vRadius * 0.5){",
" if(vLinearDepth > depth + vRadius){",
" discard;",
" }",
" #endif",

File diff suppressed because one or more lines are too long

View File

@ -78,7 +78,7 @@ void main() {
<script src="../build/js/potree.js"></script>
<script src="./js/ProgressBar.js"></script>
<!-- uncomment this to debug changes to the individual js files -->
<!--
<script src="../src/PointCloudOctree.js"></script>
@ -91,6 +91,7 @@ void main() {
<script src="../src/FirstPersonControls.js"></script>
<script src="../src/utils/ProfileTool.js"></script>
<script src="../src/utils/MeasuringTool.js"></script>
<script src="../src/utils/TransformationTool.js"></script>
<script src="../src/utils/VolumeTool.js"></script>
<script src="../src/utils.js"></script>
<script src="../src/LRU.js"></script>
@ -100,8 +101,14 @@ void main() {
<script src="../src/arena4d/PointCloudArena4DGeometry.js"></script>
-->
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
<!-- INCLUDE SETTINGS HERE -->
<!--<script src="../libs/plasio/js/laslaz.js"></script>
<script src="../libs/plasio/vendor/bluebird.js"></script>
<script src="../build/js/laslaz.js"></script>
-->
<!-- INFOS / STATS -->
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
@ -137,13 +144,26 @@ void main() {
cameraPosition: [3.6, 4.367, 4],// other options: cameraPosition: [10,10,10],
cameraTarget: null, // other options: cameraTarget: [0,0,0],
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
quality: "Squares", // other options: "Circles", "Interpolation", "Splats"
quality: null, // other options: "Circles", "Interpolation", "Splats"
fov: 75, // other options: "Circles", "Interpolation", "Splats"
material: "RGB", // other options: "Height", "Intensity", "Classification"
pointLimit: 1, // max number of points in millions
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
pointSize: 1.0
};
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
sceneProperties.navigation = "Orbit";
}
if(sceneProperties.quality === null){
if(Potree.Features.SHADER_INTERPOLATION.isSupported()){
sceneProperties.quality = "Interpolation";
}else{
sceneProperties.quality = "Squares";
}
}
var fov = sceneProperties.fov;
var pointSize = sceneProperties.pointSize;
@ -157,6 +177,7 @@ void main() {
var isFlipYZ = false;
var useDEMCollisions = false;
var minNodeSize = 150;
var directionalLight;
var showStats = false;
var showBoundingBox = false;
@ -199,7 +220,15 @@ void main() {
};
function setQuality(value){
quality = value;
if(value == "Interpolation" && !Potree.Features.SHADER_INTERPOLATION.isSupported()){
quality = "Squares";
}else if(value == "Splats" && !Potree.Features.SHADER_SPLATS.isSupported()){
quality = "Squares";
}else{
quality = value;
}
};
function setMaterial(value){
@ -296,18 +325,20 @@ void main() {
for(var i = 0; i < attributes.attributes.length; i++){
var attribute = attributes.attributes[i];
if(attribute === PointAttribute.COLOR_PACKED){
if(attribute === Potree.PointAttribute.COLOR_PACKED){
options.push("RGB");
}else if(attribute === PointAttribute.INTENSITY){
}else if(attribute === Potree.PointAttribute.INTENSITY){
options.push("Intensity");
options.push("Intensity Gradient");
}else if(attribute === PointAttribute.CLASSIFICATION){
}else if(attribute === Potree.PointAttribute.CLASSIFICATION){
options.push("Classification");
}else if(attribute === PointAttribute.NORMAL_SPHEREMAPPED){
options.push("Phong");
options.push("Normal");
}
}
if(attributes.hasNormals()){
options.push("Phong");
options.push("Normal");
}
options.push("Height");
options.push("Tree Depth");
}
@ -438,7 +469,7 @@ void main() {
// load pointcloud
if(pointcloudPath.indexOf("cloud.js") > 0){
POCLoader.load(pointcloudPath, function(geometry){
Potree.POCLoader.load(pointcloudPath, function(geometry){
pointcloud = new Potree.PointCloudOctree(geometry);
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
@ -553,13 +584,12 @@ void main() {
window.addEventListener( 'keydown', onKeyDown, false );
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight.position.set( 10, 10, 10 );
directionalLight.lookAt( new THREE.Vector3(0, 0, 0));
scenePointCloud.add( directionalLight );
var light = new THREE.AmbientLight( 0x707070 ); // soft white light
var light = new THREE.AmbientLight( 0x555555 ); // soft white light
scenePointCloud.add( light );
}
@ -614,10 +644,15 @@ void main() {
};
var intensityMax = null;
var heightMin = null;
var heightMax = null;
function update(){
Potree.pointLoadLimit = pointCountTarget * 2 * 1000 * 1000;
directionalLight.position.copy(camera.position);
directionalLight.lookAt(new THREE.Vector3().addVectors(camera.position, camera.getWorldDirection()));
if(pointcloud){
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
@ -643,10 +678,15 @@ void main() {
}
}
}
if(!heightMin){
heightMin = bbWorld.min.y;
heightMax = bbWorld.max.y;
}
pointcloud.material.clipMode = clipMode;
pointcloud.material.heightMin = bbWorld.min.y;
pointcloud.material.heightMax = bbWorld.max.y;
pointcloud.material.heightMin = heightMin;
pointcloud.material.heightMax = heightMax;
pointcloud.material.intensityMin = 0;
pointcloud.material.intensityMax = intensityMax;
pointcloud.showBoundingBox = showBoundingBox;
@ -834,17 +874,11 @@ void main() {
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.size = pointSize;
pointcloud.material.opacity = opacity;
pointcloud.material.pointColorType = pointColorType;
//if(pointcloud instanceof Potree.PointCloudOctree){
pointcloud.material.pointSizeType = pointSizeType;
//}else if(pointcloud instanceof Potree.PointCloudArena4D){
// //var pst = pointSizeType === Potree.PointSizeType.ADAPTIVE ? Potree.PointSizeType.ATTENUATED : pointSizeType;
// pointcloud.material.pointSizeType = pst;
//}
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = false;
@ -944,10 +978,7 @@ void main() {
rtDepth.setSize(width, height);
rtNormalize.setSize(width, height);
renderer.clear();
//renderer.render(sceneBG, cameraBG);
// render skybox
if(showSkybox){
skybox.camera.rotation.copy(camera.rotation);
renderer.render(skybox.scene, skybox.camera);
@ -957,71 +988,118 @@ void main() {
renderer.render(scene, camera);
if(pointcloud){
if(!weightedMaterial){
pointcloud.originalMaterial = pointcloud.material;
depthMaterial = new Potree.PointCloudMaterial();
weightedMaterial = new Potree.PointCloudMaterial();
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.update(camera, renderer);
var vn = pointcloud.visibleNodes;
// init materials
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
if(typeof node._hqsplats === "undefined"){
var hq = {
originalMaterial: node.material,
depthMaterial: new Potree.PointCloudMaterial(),
weightedMaterial: new Potree.PointCloudMaterial()
}
hq.depthMaterial.pointColorType = Potree.PointColorType.DEPTH;
hq.depthMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.depthMaterial.interpolate = false;
hq.depthMaterial.weighted = false;
hq.depthMaterial.minSize = 2;
hq.depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.depthMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
hq.weightedMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.weightedMaterial.interpolate = false;
hq.weightedMaterial.weighted = true;
hq.weightedMaterial.minSize = 2;
hq.weightedMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.weightedMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
node._hqsplats = hq;
}
}
pointcloud.material = depthMaterial;
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = Potree.PointColorType.DEPTH;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolate");
pointcloud.material.weighted = false;
pointcloud.material.minSize = 2;
pointcloud.material.screenWidth = width;
pointcloud.material.screenHeight = height;
pointcloud.update(camera, renderer);
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
var origType = pointcloud.material.pointColorType;
renderer.render(scenePointCloud, camera, rtDepth);
pointcloud.material = weightedMaterial;
{// DEPTH PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.depthMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
renderer.render(scenePointCloud, camera, rtDepth);
}
{// ATTRIBUTE PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.weightedMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.pointColorType = pointColorType;
material.depthMap = rtDepth;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.render(scenePointCloud, camera, rtNormalize);
}
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = pointColorType;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = true;
pointcloud.material.minSize = 2;
pointcloud.material.depthMap = rtDepth;
pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20);
pointcloud.update(camera, renderer);
renderer.render(scenePointCloud, camera, rtNormalize);
volumeTool.render();
profileTool.render();
// NORMALIZATION PASS
renderer.render(sceneNormalize, cameraBG);
// reset material
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
node.material = node._hqsplats.originalMaterial;
}
volumeTool.render();
renderer.clearDepth();
profileTool.render();
measuringTool.render();
transformationTool.render();
}
}
function loop() {
@ -1040,7 +1118,6 @@ void main() {
initThree();
//initGUI();
loop();
</script>

View File

@ -78,7 +78,7 @@ void main() {
<script src="../build/js/potree.js"></script>
<script src="./js/ProgressBar.js"></script>
<!-- uncomment this to debug changes to the individual js files -->
<!--
<script src="../src/PointCloudOctree.js"></script>
@ -91,6 +91,7 @@ void main() {
<script src="../src/FirstPersonControls.js"></script>
<script src="../src/utils/ProfileTool.js"></script>
<script src="../src/utils/MeasuringTool.js"></script>
<script src="../src/utils/TransformationTool.js"></script>
<script src="../src/utils/VolumeTool.js"></script>
<script src="../src/utils.js"></script>
<script src="../src/LRU.js"></script>
@ -100,13 +101,14 @@ void main() {
<script src="../src/arena4d/PointCloudArena4DGeometry.js"></script>
-->
<script src="../libs/plasio/js/laslaz.js"></script>
<script src="../libs/plasio/vendor/bluebird.js"></script>
<script src="../build/js/laslaz.js"></script>
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
<!-- INCLUDE SETTINGS HERE -->
<script src="../libs/plasio/js/laslaz.js"></script>
<script src="../libs/plasio/vendor/bluebird.js"></script>
<script src="../build/js/laslaz.js"></script>
<!-- INFOS / STATS -->
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
@ -142,13 +144,26 @@ void main() {
cameraPosition: [3.6, 4.367, 4],// other options: cameraPosition: [10,10,10],
cameraTarget: null, // other options: cameraTarget: [0,0,0],
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
quality: "Squares", // other options: "Circles", "Interpolation", "Splats"
quality: null, // other options: "Circles", "Interpolation", "Splats"
fov: 75, // other options: "Circles", "Interpolation", "Splats"
material: "RGB", // other options: "Height", "Intensity", "Classification"
pointLimit: 1, // max number of points in millions
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
pointSize: 1.0
};
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
sceneProperties.navigation = "Orbit";
}
if(sceneProperties.quality === null){
if(Potree.Features.SHADER_INTERPOLATION.isSupported()){
sceneProperties.quality = "Interpolation";
}else{
sceneProperties.quality = "Squares";
}
}
var fov = sceneProperties.fov;
var pointSize = sceneProperties.pointSize;
@ -162,6 +177,7 @@ void main() {
var isFlipYZ = false;
var useDEMCollisions = false;
var minNodeSize = 150;
var directionalLight;
var showStats = false;
var showBoundingBox = false;
@ -204,7 +220,15 @@ void main() {
};
function setQuality(value){
quality = value;
if(value == "Interpolation" && !Potree.Features.SHADER_INTERPOLATION.isSupported()){
quality = "Squares";
}else if(value == "Splats" && !Potree.Features.SHADER_SPLATS.isSupported()){
quality = "Squares";
}else{
quality = value;
}
};
function setMaterial(value){
@ -301,18 +325,20 @@ void main() {
for(var i = 0; i < attributes.attributes.length; i++){
var attribute = attributes.attributes[i];
if(attribute === PointAttribute.COLOR_PACKED){
if(attribute === Potree.PointAttribute.COLOR_PACKED){
options.push("RGB");
}else if(attribute === PointAttribute.INTENSITY){
}else if(attribute === Potree.PointAttribute.INTENSITY){
options.push("Intensity");
options.push("Intensity Gradient");
}else if(attribute === PointAttribute.CLASSIFICATION){
}else if(attribute === Potree.PointAttribute.CLASSIFICATION){
options.push("Classification");
}else if(attribute === PointAttribute.NORMAL_SPHEREMAPPED){
options.push("Phong");
options.push("Normal");
}
}
if(attributes.hasNormals()){
options.push("Phong");
options.push("Normal");
}
options.push("Height");
options.push("Tree Depth");
}
@ -443,7 +469,7 @@ void main() {
// load pointcloud
if(pointcloudPath.indexOf("cloud.js") > 0){
POCLoader.load(pointcloudPath, function(geometry){
Potree.POCLoader.load(pointcloudPath, function(geometry){
pointcloud = new Potree.PointCloudOctree(geometry);
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
@ -558,13 +584,12 @@ void main() {
window.addEventListener( 'keydown', onKeyDown, false );
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight.position.set( 10, 10, 10 );
directionalLight.lookAt( new THREE.Vector3(0, 0, 0));
scenePointCloud.add( directionalLight );
var light = new THREE.AmbientLight( 0x707070 ); // soft white light
var light = new THREE.AmbientLight( 0x555555 ); // soft white light
scenePointCloud.add( light );
}
@ -619,10 +644,15 @@ void main() {
};
var intensityMax = null;
var heightMin = null;
var heightMax = null;
function update(){
Potree.pointLoadLimit = pointCountTarget * 2 * 1000 * 1000;
directionalLight.position.copy(camera.position);
directionalLight.lookAt(new THREE.Vector3().addVectors(camera.position, camera.getWorldDirection()));
if(pointcloud){
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
@ -648,10 +678,15 @@ void main() {
}
}
}
if(!heightMin){
heightMin = bbWorld.min.y;
heightMax = bbWorld.max.y;
}
pointcloud.material.clipMode = clipMode;
pointcloud.material.heightMin = bbWorld.min.y;
pointcloud.material.heightMax = bbWorld.max.y;
pointcloud.material.heightMin = heightMin;
pointcloud.material.heightMax = heightMax;
pointcloud.material.intensityMin = 0;
pointcloud.material.intensityMax = intensityMax;
pointcloud.showBoundingBox = showBoundingBox;
@ -839,17 +874,11 @@ void main() {
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.size = pointSize;
pointcloud.material.opacity = opacity;
pointcloud.material.pointColorType = pointColorType;
//if(pointcloud instanceof Potree.PointCloudOctree){
pointcloud.material.pointSizeType = pointSizeType;
//}else if(pointcloud instanceof Potree.PointCloudArena4D){
// //var pst = pointSizeType === Potree.PointSizeType.ADAPTIVE ? Potree.PointSizeType.ATTENUATED : pointSizeType;
// pointcloud.material.pointSizeType = pst;
//}
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = false;
@ -949,10 +978,7 @@ void main() {
rtDepth.setSize(width, height);
rtNormalize.setSize(width, height);
renderer.clear();
//renderer.render(sceneBG, cameraBG);
// render skybox
if(showSkybox){
skybox.camera.rotation.copy(camera.rotation);
renderer.render(skybox.scene, skybox.camera);
@ -962,71 +988,118 @@ void main() {
renderer.render(scene, camera);
if(pointcloud){
if(!weightedMaterial){
pointcloud.originalMaterial = pointcloud.material;
depthMaterial = new Potree.PointCloudMaterial();
weightedMaterial = new Potree.PointCloudMaterial();
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.update(camera, renderer);
var vn = pointcloud.visibleNodes;
// init materials
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
if(typeof node._hqsplats === "undefined"){
var hq = {
originalMaterial: node.material,
depthMaterial: new Potree.PointCloudMaterial(),
weightedMaterial: new Potree.PointCloudMaterial()
}
hq.depthMaterial.pointColorType = Potree.PointColorType.DEPTH;
hq.depthMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.depthMaterial.interpolate = false;
hq.depthMaterial.weighted = false;
hq.depthMaterial.minSize = 2;
hq.depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.depthMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
hq.weightedMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.weightedMaterial.interpolate = false;
hq.weightedMaterial.weighted = true;
hq.weightedMaterial.minSize = 2;
hq.weightedMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.weightedMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
node._hqsplats = hq;
}
}
pointcloud.material = depthMaterial;
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = Potree.PointColorType.DEPTH;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolate");
pointcloud.material.weighted = false;
pointcloud.material.minSize = 2;
pointcloud.material.screenWidth = width;
pointcloud.material.screenHeight = height;
pointcloud.update(camera, renderer);
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
var origType = pointcloud.material.pointColorType;
renderer.render(scenePointCloud, camera, rtDepth);
pointcloud.material = weightedMaterial;
{// DEPTH PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.depthMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
renderer.render(scenePointCloud, camera, rtDepth);
}
{// ATTRIBUTE PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.weightedMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.pointColorType = pointColorType;
material.depthMap = rtDepth;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.render(scenePointCloud, camera, rtNormalize);
}
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = pointColorType;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = true;
pointcloud.material.minSize = 2;
pointcloud.material.depthMap = rtDepth;
pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20);
pointcloud.update(camera, renderer);
renderer.render(scenePointCloud, camera, rtNormalize);
volumeTool.render();
profileTool.render();
// NORMALIZATION PASS
renderer.render(sceneNormalize, cameraBG);
// reset material
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
node.material = node._hqsplats.originalMaterial;
}
volumeTool.render();
renderer.clearDepth();
profileTool.render();
measuringTool.render();
transformationTool.render();
}
}
function loop() {
@ -1045,7 +1118,6 @@ void main() {
initThree();
//initGUI();
loop();
</script>

View File

@ -78,7 +78,7 @@ void main() {
<script src="../build/js/potree.js"></script>
<script src="./js/ProgressBar.js"></script>
<!-- uncomment this to debug changes to the individual js files -->
<!--
<script src="../src/PointCloudOctree.js"></script>
@ -91,6 +91,7 @@ void main() {
<script src="../src/FirstPersonControls.js"></script>
<script src="../src/utils/ProfileTool.js"></script>
<script src="../src/utils/MeasuringTool.js"></script>
<script src="../src/utils/TransformationTool.js"></script>
<script src="../src/utils/VolumeTool.js"></script>
<script src="../src/utils.js"></script>
<script src="../src/LRU.js"></script>
@ -100,13 +101,14 @@ void main() {
<script src="../src/arena4d/PointCloudArena4DGeometry.js"></script>
-->
<script src="../libs/plasio/js/laslaz.js"></script>
<script src="../libs/plasio/vendor/bluebird.js"></script>
<script src="../build/js/laslaz.js"></script>
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
<!-- INCLUDE SETTINGS HERE -->
<script src="../libs/plasio/js/laslaz.js"></script>
<script src="../libs/plasio/vendor/bluebird.js"></script>
<script src="../build/js/laslaz.js"></script>
<!-- INFOS / STATS -->
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
@ -142,13 +144,26 @@ void main() {
cameraPosition: [3.6, 4.367, 4],// other options: cameraPosition: [10,10,10],
cameraTarget: null, // other options: cameraTarget: [0,0,0],
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
quality: "Squares", // other options: "Circles", "Interpolation", "Splats"
quality: null, // other options: "Circles", "Interpolation", "Splats"
fov: 75, // other options: "Circles", "Interpolation", "Splats"
material: "RGB", // other options: "Height", "Intensity", "Classification"
pointLimit: 1, // max number of points in millions
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
pointSize: 1.0
};
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
sceneProperties.navigation = "Orbit";
}
if(sceneProperties.quality === null){
if(Potree.Features.SHADER_INTERPOLATION.isSupported()){
sceneProperties.quality = "Interpolation";
}else{
sceneProperties.quality = "Squares";
}
}
var fov = sceneProperties.fov;
var pointSize = sceneProperties.pointSize;
@ -162,6 +177,7 @@ void main() {
var isFlipYZ = false;
var useDEMCollisions = false;
var minNodeSize = 150;
var directionalLight;
var showStats = false;
var showBoundingBox = false;
@ -204,7 +220,15 @@ void main() {
};
function setQuality(value){
quality = value;
if(value == "Interpolation" && !Potree.Features.SHADER_INTERPOLATION.isSupported()){
quality = "Squares";
}else if(value == "Splats" && !Potree.Features.SHADER_SPLATS.isSupported()){
quality = "Squares";
}else{
quality = value;
}
};
function setMaterial(value){
@ -301,18 +325,20 @@ void main() {
for(var i = 0; i < attributes.attributes.length; i++){
var attribute = attributes.attributes[i];
if(attribute === PointAttribute.COLOR_PACKED){
if(attribute === Potree.PointAttribute.COLOR_PACKED){
options.push("RGB");
}else if(attribute === PointAttribute.INTENSITY){
}else if(attribute === Potree.PointAttribute.INTENSITY){
options.push("Intensity");
options.push("Intensity Gradient");
}else if(attribute === PointAttribute.CLASSIFICATION){
}else if(attribute === Potree.PointAttribute.CLASSIFICATION){
options.push("Classification");
}else if(attribute === PointAttribute.NORMAL_SPHEREMAPPED){
options.push("Phong");
options.push("Normal");
}
}
if(attributes.hasNormals()){
options.push("Phong");
options.push("Normal");
}
options.push("Height");
options.push("Tree Depth");
}
@ -443,7 +469,7 @@ void main() {
// load pointcloud
if(pointcloudPath.indexOf("cloud.js") > 0){
POCLoader.load(pointcloudPath, function(geometry){
Potree.POCLoader.load(pointcloudPath, function(geometry){
pointcloud = new Potree.PointCloudOctree(geometry);
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
@ -558,13 +584,12 @@ void main() {
window.addEventListener( 'keydown', onKeyDown, false );
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight.position.set( 10, 10, 10 );
directionalLight.lookAt( new THREE.Vector3(0, 0, 0));
scenePointCloud.add( directionalLight );
var light = new THREE.AmbientLight( 0x707070 ); // soft white light
var light = new THREE.AmbientLight( 0x555555 ); // soft white light
scenePointCloud.add( light );
}
@ -619,10 +644,15 @@ void main() {
};
var intensityMax = null;
var heightMin = null;
var heightMax = null;
function update(){
Potree.pointLoadLimit = pointCountTarget * 2 * 1000 * 1000;
directionalLight.position.copy(camera.position);
directionalLight.lookAt(new THREE.Vector3().addVectors(camera.position, camera.getWorldDirection()));
if(pointcloud){
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
@ -648,10 +678,15 @@ void main() {
}
}
}
if(!heightMin){
heightMin = bbWorld.min.y;
heightMax = bbWorld.max.y;
}
pointcloud.material.clipMode = clipMode;
pointcloud.material.heightMin = bbWorld.min.y;
pointcloud.material.heightMax = bbWorld.max.y;
pointcloud.material.heightMin = heightMin;
pointcloud.material.heightMax = heightMax;
pointcloud.material.intensityMin = 0;
pointcloud.material.intensityMax = intensityMax;
pointcloud.showBoundingBox = showBoundingBox;
@ -839,17 +874,11 @@ void main() {
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.size = pointSize;
pointcloud.material.opacity = opacity;
pointcloud.material.pointColorType = pointColorType;
//if(pointcloud instanceof Potree.PointCloudOctree){
pointcloud.material.pointSizeType = pointSizeType;
//}else if(pointcloud instanceof Potree.PointCloudArena4D){
// //var pst = pointSizeType === Potree.PointSizeType.ADAPTIVE ? Potree.PointSizeType.ATTENUATED : pointSizeType;
// pointcloud.material.pointSizeType = pst;
//}
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = false;
@ -949,10 +978,7 @@ void main() {
rtDepth.setSize(width, height);
rtNormalize.setSize(width, height);
renderer.clear();
//renderer.render(sceneBG, cameraBG);
// render skybox
if(showSkybox){
skybox.camera.rotation.copy(camera.rotation);
renderer.render(skybox.scene, skybox.camera);
@ -962,71 +988,118 @@ void main() {
renderer.render(scene, camera);
if(pointcloud){
if(!weightedMaterial){
pointcloud.originalMaterial = pointcloud.material;
depthMaterial = new Potree.PointCloudMaterial();
weightedMaterial = new Potree.PointCloudMaterial();
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.update(camera, renderer);
var vn = pointcloud.visibleNodes;
// init materials
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
if(typeof node._hqsplats === "undefined"){
var hq = {
originalMaterial: node.material,
depthMaterial: new Potree.PointCloudMaterial(),
weightedMaterial: new Potree.PointCloudMaterial()
}
hq.depthMaterial.pointColorType = Potree.PointColorType.DEPTH;
hq.depthMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.depthMaterial.interpolate = false;
hq.depthMaterial.weighted = false;
hq.depthMaterial.minSize = 2;
hq.depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.depthMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
hq.weightedMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.weightedMaterial.interpolate = false;
hq.weightedMaterial.weighted = true;
hq.weightedMaterial.minSize = 2;
hq.weightedMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.weightedMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
node._hqsplats = hq;
}
}
pointcloud.material = depthMaterial;
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = Potree.PointColorType.DEPTH;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolate");
pointcloud.material.weighted = false;
pointcloud.material.minSize = 2;
pointcloud.material.screenWidth = width;
pointcloud.material.screenHeight = height;
pointcloud.update(camera, renderer);
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
var origType = pointcloud.material.pointColorType;
renderer.render(scenePointCloud, camera, rtDepth);
pointcloud.material = weightedMaterial;
{// DEPTH PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.depthMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
renderer.render(scenePointCloud, camera, rtDepth);
}
{// ATTRIBUTE PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.weightedMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.pointColorType = pointColorType;
material.depthMap = rtDepth;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.render(scenePointCloud, camera, rtNormalize);
}
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = pointColorType;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = true;
pointcloud.material.minSize = 2;
pointcloud.material.depthMap = rtDepth;
pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20);
pointcloud.update(camera, renderer);
renderer.render(scenePointCloud, camera, rtNormalize);
volumeTool.render();
profileTool.render();
// NORMALIZATION PASS
renderer.render(sceneNormalize, cameraBG);
// reset material
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
node.material = node._hqsplats.originalMaterial;
}
volumeTool.render();
renderer.clearDepth();
profileTool.render();
measuringTool.render();
transformationTool.render();
}
}
function loop() {
@ -1045,7 +1118,6 @@ void main() {
initThree();
//initGUI();
loop();
</script>

View File

@ -77,7 +77,7 @@
camera.lookAt(new THREE.Vector3(0,0,0));
// load pointcloud
POCLoader.load(pointcloudPath, function(geometry){
Potree.POCLoader.load(pointcloudPath, function(geometry){
pointcloud = new Potree.PointCloudOctree(geometry);
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;

View File

@ -91,6 +91,7 @@ void main() {
<script src="../src/FirstPersonControls.js"></script>
<script src="../src/utils/ProfileTool.js"></script>
<script src="../src/utils/MeasuringTool.js"></script>
<script src="../src/utils/TransformationTool.js"></script>
<script src="../src/utils/VolumeTool.js"></script>
<script src="../src/utils.js"></script>
<script src="../src/LRU.js"></script>
@ -104,6 +105,10 @@ void main() {
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
<!-- INCLUDE SETTINGS HERE -->
<!--<script src="../libs/plasio/js/laslaz.js"></script>
<script src="../libs/plasio/vendor/bluebird.js"></script>
<script src="../build/js/laslaz.js"></script>
-->
<!-- INFOS / STATS -->
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
@ -136,19 +141,30 @@ void main() {
<script>
var sceneProperties = {
path: "../../../../pointclouds/mschuetz/lion/lion.ply_converted/cloud.js",
path: "../resources/pointclouds/lion_takanawa/cloud.js",
path: "../resources/pointclouds/vol_total/cloud.js",
cameraPosition: null, // other options: cameraPosition: [10,10,10],
cameraTarget: null, // other options: cameraTarget: [0,0,0],
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
quality: "Squares", // other options: "Circles", "Interpolation", "Splats"
fov: 75, // other options: "Circles", "Interpolation", "Splats"
material: "RGB", // other options: "Height", "Intensity", "Classification"
pointLimit: 1, // max number of points in millions
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
cameraPosition: null, // other options: cameraPosition: [10,10,10],
cameraTarget: null, // other options: cameraTarget: [0,0,0],
sizeType: "Adaptive", // other options: "Fixed", "Attenuated"
quality: null, // options: "Squares", "Circles", "Interpolation", "Splats"
fov: 75, // other options: "Circles", "Interpolation", "Splats"
material: "RGB", // other options: "Height", "Intensity", "Classification"
pointLimit: 1, // max number of points in millions
navigation: "Orbit", // other options: "Earth", "Orbit", "Flight"
pointSize: 1.0
};
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
sceneProperties.navigation = "Orbit";
}
if(sceneProperties.quality === null){
if(Potree.Features.SHADER_INTERPOLATION.isSupported()){
sceneProperties.quality = "Interpolation";
}else{
sceneProperties.quality = "Squares";
}
}
var fov = sceneProperties.fov;
var pointSize = sceneProperties.pointSize;
@ -162,6 +178,7 @@ void main() {
var isFlipYZ = false;
var useDEMCollisions = false;
var minNodeSize = 150;
var directionalLight;
var showStats = false;
var showBoundingBox = false;
@ -204,7 +221,15 @@ void main() {
};
function setQuality(value){
quality = value;
if(value == "Interpolation" && !Potree.Features.SHADER_INTERPOLATION.isSupported()){
quality = "Squares";
}else if(value == "Splats" && !Potree.Features.SHADER_SPLATS.isSupported()){
quality = "Squares";
}else{
quality = value;
}
};
function setMaterial(value){
@ -301,18 +326,20 @@ void main() {
for(var i = 0; i < attributes.attributes.length; i++){
var attribute = attributes.attributes[i];
if(attribute === PointAttribute.COLOR_PACKED){
if(attribute === Potree.PointAttribute.COLOR_PACKED){
options.push("RGB");
}else if(attribute === PointAttribute.INTENSITY){
}else if(attribute === Potree.PointAttribute.INTENSITY){
options.push("Intensity");
options.push("Intensity Gradient");
}else if(attribute === PointAttribute.CLASSIFICATION){
}else if(attribute === Potree.PointAttribute.CLASSIFICATION){
options.push("Classification");
}else if(attribute === PointAttribute.NORMAL_SPHEREMAPPED){
options.push("Phong");
options.push("Normal");
}
}
if(attributes.hasNormals()){
options.push("Phong");
options.push("Normal");
}
options.push("Height");
options.push("Tree Depth");
}
@ -443,7 +470,7 @@ void main() {
// load pointcloud
if(pointcloudPath.indexOf("cloud.js") > 0){
POCLoader.load(pointcloudPath, function(geometry){
Potree.POCLoader.load(pointcloudPath, function(geometry){
pointcloud = new Potree.PointCloudOctree(geometry);
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
@ -558,13 +585,12 @@ void main() {
window.addEventListener( 'keydown', onKeyDown, false );
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight.position.set( 10, 10, 10 );
directionalLight.lookAt( new THREE.Vector3(0, 0, 0));
scenePointCloud.add( directionalLight );
var light = new THREE.AmbientLight( 0x707070 ); // soft white light
var light = new THREE.AmbientLight( 0x555555 ); // soft white light
scenePointCloud.add( light );
}
@ -619,10 +645,15 @@ void main() {
};
var intensityMax = null;
var heightMin = null;
var heightMax = null;
function update(){
Potree.pointLoadLimit = pointCountTarget * 2 * 1000 * 1000;
directionalLight.position.copy(camera.position);
directionalLight.lookAt(new THREE.Vector3().addVectors(camera.position, camera.getWorldDirection()));
if(pointcloud){
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
@ -648,10 +679,15 @@ void main() {
}
}
}
if(!heightMin){
heightMin = bbWorld.min.y;
heightMax = bbWorld.max.y;
}
pointcloud.material.clipMode = clipMode;
pointcloud.material.heightMin = bbWorld.min.y;
pointcloud.material.heightMax = bbWorld.max.y;
pointcloud.material.heightMin = heightMin;
pointcloud.material.heightMax = heightMax;
pointcloud.material.intensityMin = 0;
pointcloud.material.intensityMax = intensityMax;
pointcloud.showBoundingBox = showBoundingBox;
@ -839,17 +875,11 @@ void main() {
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.size = pointSize;
pointcloud.material.opacity = opacity;
pointcloud.material.pointColorType = pointColorType;
//if(pointcloud instanceof Potree.PointCloudOctree){
pointcloud.material.pointSizeType = pointSizeType;
//}else if(pointcloud instanceof Potree.PointCloudArena4D){
// //var pst = pointSizeType === Potree.PointSizeType.ADAPTIVE ? Potree.PointSizeType.ATTENUATED : pointSizeType;
// pointcloud.material.pointSizeType = pst;
//}
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = false;
@ -949,10 +979,7 @@ void main() {
rtDepth.setSize(width, height);
rtNormalize.setSize(width, height);
renderer.clear();
//renderer.render(sceneBG, cameraBG);
// render skybox
if(showSkybox){
skybox.camera.rotation.copy(camera.rotation);
renderer.render(skybox.scene, skybox.camera);
@ -962,71 +989,118 @@ void main() {
renderer.render(scene, camera);
if(pointcloud){
if(!weightedMaterial){
pointcloud.originalMaterial = pointcloud.material;
depthMaterial = new Potree.PointCloudMaterial();
weightedMaterial = new Potree.PointCloudMaterial();
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.update(camera, renderer);
var vn = pointcloud.visibleNodes;
// init materials
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
if(typeof node._hqsplats === "undefined"){
var hq = {
originalMaterial: node.material,
depthMaterial: new Potree.PointCloudMaterial(),
weightedMaterial: new Potree.PointCloudMaterial()
}
hq.depthMaterial.pointColorType = Potree.PointColorType.DEPTH;
hq.depthMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.depthMaterial.interpolate = false;
hq.depthMaterial.weighted = false;
hq.depthMaterial.minSize = 2;
hq.depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.depthMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
hq.weightedMaterial.pointShape = Potree.PointShape.CIRCLE;
hq.weightedMaterial.interpolate = false;
hq.weightedMaterial.weighted = true;
hq.weightedMaterial.minSize = 2;
hq.weightedMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
hq.weightedMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray();
node._hqsplats = hq;
}
}
pointcloud.material = depthMaterial;
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = Potree.PointColorType.DEPTH;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolate");
pointcloud.material.weighted = false;
pointcloud.material.minSize = 2;
pointcloud.material.screenWidth = width;
pointcloud.material.screenHeight = height;
pointcloud.update(camera, renderer);
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
var origType = pointcloud.material.pointColorType;
renderer.render(scenePointCloud, camera, rtDepth);
pointcloud.material = weightedMaterial;
{// DEPTH PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.depthMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.clearTarget( rtDepth, true, true, true );
renderer.clearTarget( rtNormalize, true, true, true );
renderer.render(scenePointCloud, camera, rtDepth);
}
{// ATTRIBUTE PASS
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
var material = node._hqsplats.weightedMaterial;
material.size = pointSize;
material.pointSizeType = pointSizeType;
material.screenWidth = width;
material.screenHeight = height;
material.pointColorType = pointColorType;
material.depthMap = rtDepth;
material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture;
material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value;
material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x;
material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
material.uniforms.level.value = node.level;
material.fov = camera.fov * (Math.PI / 180);
material.spacing = pointcloud.pcoGeometry.spacing;
material.near = camera.near;
material.far = camera.far;
node.material = material;
}
renderer.render(scenePointCloud, camera, rtNormalize);
}
// get rid of this
pointcloud.material.size = pointSize;
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
pointcloud.material.opacity = opacity;
pointcloud.material.pointSizeType = pointSizeType;
pointcloud.material.pointColorType = pointColorType;
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
pointcloud.material.interpolate = (quality === "Interpolation");
pointcloud.material.weighted = true;
pointcloud.material.minSize = 2;
pointcloud.material.depthMap = rtDepth;
pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20);
pointcloud.update(camera, renderer);
renderer.render(scenePointCloud, camera, rtNormalize);
volumeTool.render();
profileTool.render();
// NORMALIZATION PASS
renderer.render(sceneNormalize, cameraBG);
// reset material
for(var i = 0; i < vn.length; i++){
var node = vn[i].node;
node.material = node._hqsplats.originalMaterial;
}
volumeTool.render();
renderer.clearDepth();
profileTool.render();
measuringTool.render();
transformationTool.render();
}
}
function loop() {
@ -1045,7 +1119,6 @@ void main() {
initThree();
//initGUI();
loop();
</script>

View File

@ -30,13 +30,32 @@ Potree.Features = function(){
SHADER_INTERPOLATION: {
isSupported: function(){
//if(typeof this.shaderInterpolationSupported === "undefined"){
// var material = new Potree.PointCloudMaterial();
// material.interpolate = true;
//
// var vs = gl.createShader(gl.VERTEX_SHADER);
// var fs = gl.createShader(gl.FRAGMENT_SHADER);
// gl.shaderSource(vs, material.vertexShader);
// gl.shaderSource(fs, material.fragmentShader);
//
// gl.compileShader(vs);
// gl.compileShader(fs);
//
// var successVS = gl.getShaderParameter(vs, gl.COMPILE_STATUS);
// var successFS = gl.getShaderParameter(fs, gl.COMPILE_STATUS);
// this.shaderInterpolationSupported = successVS && successFS;
//}
//
//return this.shaderInterpolationSupported;
var supported = true;
supported = supported && gl.getExtension("EXT_frag_depth");
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
return supported;
}
},
SHADER_SPLATS: {

View File

@ -81,7 +81,6 @@ Potree.PointCloudOctree = function(geometry, material){
this.visibleNodes = [];
this.visibleGeometry = [];
this.pickTarget;
this.pickMaterial;
this.maxLevel = 0;
this.generateDEM = false;
@ -197,9 +196,36 @@ Potree.PointCloudOctree.prototype.updateProfileRequests = function(){
Potree.PointCloudOctree.prototype.updatePointCloud = function(node, element, stack, visibleGeometryNames){
this.numVisibleNodes++;
this.numVisiblePoints += node.numPoints;
node.material = this.material;
this.visibleNodes.push(element);
node.material.fov = camera.fov * (Math.PI / 180);
node.material.screenWidth = renderer.domElement.clientWidth;
node.material.screenHeight = renderer.domElement.clientHeight;
node.material.spacing = this.pcoGeometry.spacing;
node.material.near = camera.near;
node.material.far = camera.far;
node.material.pointColorType = this.material.pointColorType;
node.material.pointSizeType = this.material.pointSizeType;
node.material.pointShape = this.material.pointShape;
node.material.interpolate = this.material.interpolate;
node.material.size = this.material.size;
node.material.heightMin = this.material.heightMin;
node.material.heightMax = this.material.heightMax;
node.material.intensityMin = this.material.intensityMin;
node.material.intensityMax = this.material.intensityMax;
node.material.weighted = this.material.weighted;
node.material.opacity = this.material.opacity;
node.material.minSize = this.material.minSize;
node.material.uniforms.level.value = node.level;
node.material.setClipBoxes(this.material.clipBoxes);
node.material.clipMode = this.material.clipMode;
node.material.uniforms.octreeSize.value = this.pcoGeometry.boundingBox.size().x;
node.material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray();
node.material.uniforms.visibleNodes.value = this.material.visibleNodesTexture;
if(node.level){
this.maxLevel = Math.max(node.level, this.maxLevel);
}
@ -237,26 +263,6 @@ Potree.PointCloudOctree.prototype.updatePointCloud = function(node, element, sta
}
}
Potree.PointCloudOctree.prototype.updateMaterial = function(vn, camera, renderer){
this.material.fov = camera.fov * (Math.PI / 180);
this.material.screenWidth = renderer.domElement.clientWidth;
this.material.screenHeight = renderer.domElement.clientHeight;
this.material.spacing = this.pcoGeometry.spacing;
this.material.near = camera.near;
this.material.far = camera.far;
this.material.octreeLevels = this.maxLevel;
if(this.material.pointSizeType){
if(this.material.pointSizeType === Potree.PointSizeType.ADAPTIVE
|| this.material.pointColorType === Potree.PointColorType.OCTREE_DEPTH){
this.updateVisibilityTexture(this.material, vn);
}
}
};
Potree.PointCloudOctree.prototype.updateLoadQueue = function(vn){
if(this.loadQueue.length > 0){
if(this.loadQueue.length >= 2){
@ -346,7 +352,15 @@ Potree.PointCloudOctree.prototype.update = function(camera, renderer){
vn.push(this.visibleNodes[i].node);
}
this.updateMaterial(vn, camera, renderer);
// update visibility texture
if(this.material.pointSizeType){
if(this.material.pointSizeType === Potree.PointSizeType.ADAPTIVE
|| this.material.pointColorType === Potree.PointColorType.OCTREE_DEPTH){
this.updateVisibilityTexture(this.material, vn);
}
}
Potree.PointCloudOctree.lru.freeMemory();
};
@ -495,6 +509,7 @@ Potree.PointCloudOctree.prototype.updateVisibilityTexture = function(material, v
for(var i = 0; i < visibleNodes.length; i++){
var node = visibleNodes[i];
node.material.uniforms.visibleNodesOffset.value = i;
var children = [];
for(var j = 0; j < node.children.length; j++){
@ -526,7 +541,6 @@ Potree.PointCloudOctree.prototype.updateVisibilityTexture = function(material, v
}
material.uniforms.nodeSize.value = this.pcoGeometry.boundingBox.size().x;
texture.needsUpdate = true;
}
@ -577,7 +591,8 @@ Potree.PointCloudOctree.prototype.replaceProxy = function(proxy){
var geometryNode = proxy.geometryNode;
if(geometryNode.loaded === true){
var geometry = geometryNode.geometry;
var node = new THREE.PointCloud(geometry, this.material);
var material = new Potree.PointCloudMaterial();
var node = new THREE.PointCloud(geometry, material);
node.name = proxy.name;
node.level = proxy.level;
node.numPoints = proxy.numPoints;
@ -993,45 +1008,15 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
);
}
this.pickTarget.setSize(width, height);
// setup pick material.
// use the same point size functions as the main material to get the same point sizes.
if(!this.pickMaterial){
this.pickMaterial = new Potree.PointCloudMaterial();
this.pickMaterial.pointColorType = Potree.PointColorType.POINT_INDEX;
this.pickMaterial.pointSizeType = Potree.PointSizeType.FIXED;
}
this.pickMaterial.pointSizeType = this.material.pointSizeType;
this.pickMaterial.size = this.material.size;
if(this.pickMaterial.pointSizeType === Potree.PointSizeType.ADAPTIVE){
this.updateVisibilityTexture(this.pickMaterial, nodes);
}
this.pickMaterial.fov = this.material.fov;
this.pickMaterial.screenWidth = this.material.screenWidth;
this.pickMaterial.screenHeight = this.material.screenHeight;
this.pickMaterial.spacing = this.material.spacing;
this.pickMaterial.near = this.material.near;
this.pickMaterial.far = this.material.far;
this.pickMaterial.octreeLevels = this.material.octreeLevels;
this.pickMaterial.pointShape = this.material.pointShape;
var _gl = renderer.context;
_gl.enable(_gl.SCISSOR_TEST);
_gl.scissor(pixelPos.x - (pickWindowSize - 1) / 2, pixelPos.y - (pickWindowSize - 1) / 2,pickWindowSize,pickWindowSize);
_gl.disable(_gl.SCISSOR_TEST);
var material = this.pickMaterial;
renderer.setRenderTarget( this.pickTarget );
renderer.setDepthTest( material.depthTest );
renderer.setDepthWrite( material.depthWrite )
renderer.setBlending( THREE.NoBlending );
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
@ -1049,10 +1034,32 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
continue;
}
material.pcIndex = i;
if(!object.pickMaterial){
object.pickMaterial = new Potree.PointCloudMaterial();
}
if(material.program){
var program = material.program.program;
object.pickMaterial.pointColorType = Potree.PointColorType.POINT_INDEX;
object.pickMaterial.pointSizeType = this.material.pointSizeType;
object.pickMaterial.size = this.material.size;
object.pickMaterial.fov = this.material.fov;
object.pickMaterial.screenWidth = this.material.screenWidth;
object.pickMaterial.screenHeight = this.material.screenHeight;
object.pickMaterial.spacing = this.material.spacing;
object.pickMaterial.near = this.material.near;
object.pickMaterial.far = this.material.far;
object.pickMaterial.pointShape = this.material.pointShape;
object.pickMaterial.uniforms.level.value = object.level;
object.pickMaterial.uniforms.octreeSize.value = this.pcoGeometry.boundingBox.size().x;
object.pickMaterial.uniforms.bbMin.value = object.pcoGeometry.boundingBox.min.toArray();
object.pickMaterial.uniforms.visibleNodesTexture = this.material.visibleNodesTexture;
object.pickMaterial.uniforms.visibleNodes.value = this.material.visibleNodesTexture;
object.pickMaterial.uniforms.pcIndex.value = i;
if(object.pickMaterial.program){
var program = object.pickMaterial.program.program;
_gl.useProgram( program );
//_gl.disable( _gl.BLEND );
@ -1065,11 +1072,20 @@ Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params)
//}
_gl.enableVertexAttribArray( attributePointer );
_gl.vertexAttribPointer( attributePointer, attributeSize, _gl.UNSIGNED_BYTE, true, 0, 0 );
_gl.uniform1f(material.program.uniforms.pcIndex, material.pcIndex);
//
// _gl.uniform1f(object.pickMaterial.program.uniforms.pcIndex, object.pickMaterial.pcIndex);
}
renderer.renderBufferDirect(camera, [], null, material, geometry, object);
renderer.renderBufferDirect(camera, [], null, object.pickMaterial, geometry, object);
if(object.pickMaterial.program){
var program = object.pickMaterial.program.program;
_gl.useProgram( program );
var attributePointer = _gl.getAttribLocation(program, "indices");
var attributeSize = 4;
_gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.attributes.indices.buffer );
_gl.disableVertexAttribArray( attributePointer );
}
}
var pixelCount = pickWindowSize * pickWindowSize;

View File

@ -160,7 +160,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function(
var parentName = name.substring(0, name.length-1);
var parentNode = nodes[parentName];
var level = name.length-1;
var boundingBox = POCLoader.createChildAABB(parentNode.boundingBox, index);
var boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index);
var currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
currentNode.level = level;

View File

@ -68,15 +68,19 @@ Potree.BinaryLoader.prototype.parse = function(node, buffer){
var attribute = buffers[property].attribute;
var numElements = attribute.numElements;
if(parseInt(property) === PointAttributeNames.POSITION_CARTESIAN){
if(parseInt(property) === Potree.PointAttributeNames.POSITION_CARTESIAN){
geometry.addAttribute("position", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === PointAttributeNames.COLOR_PACKED){
}else if(parseInt(property) === Potree.PointAttributeNames.COLOR_PACKED){
geometry.addAttribute("color", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === PointAttributeNames.INTENSITY){
}else if(parseInt(property) === Potree.PointAttributeNames.INTENSITY){
geometry.addAttribute("intensity", new THREE.BufferAttribute(new Float32Array(buffer), 1));
}else if(parseInt(property) === PointAttributeNames.CLASSIFICATION){
}else if(parseInt(property) === Potree.PointAttributeNames.CLASSIFICATION){
geometry.addAttribute("classification", new THREE.BufferAttribute(new Float32Array(buffer), 1));
}else if(parseInt(property) === PointAttributeNames.NORMAL_SPHEREMAPPED){
}else if(parseInt(property) === Potree.PointAttributeNames.NORMAL_SPHEREMAPPED){
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === Potree.PointAttributeNames.NORMAL_OCT16){
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}else if(parseInt(property) === Potree.PointAttributeNames.NORMAL){
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(buffer), 3));
}
}

View File

@ -6,7 +6,7 @@
*
* @author Markus Schuetz
*/
function POCLoader(){
Potree.POCLoader = function(){
}
@ -17,7 +17,7 @@ function POCLoader(){
* @param url
* @param loadingFinishedListener executed after loading the binary has been finished
*/
POCLoader.load = function load(url, callback) {
Potree.POCLoader.load = function load(url, callback) {
try{
var pco = new Potree.PointCloudOctreeGeometry();
pco.url = url;
@ -72,7 +72,7 @@ POCLoader.load = function load(url, callback) {
pco.loader = new Potree.LasLazLoader(fMno.version);
}else{
pco.loader = new Potree.BinaryLoader(fMno.version, boundingBox, fMno.scale);
pco.pointAttributes = new PointAttributes(pco.pointAttributes);
pco.pointAttributes = new Potree.PointAttributes(pco.pointAttributes);
}
var nodes = {};
@ -102,7 +102,7 @@ POCLoader.load = function load(url, callback) {
var parentName = name.substring(0, name.length-1);
var parentNode = nodes[parentName];
var level = name.length-1;
var boundingBox = POCLoader.createChildAABB(parentNode.boundingBox, index);
var boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index);
var node = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
node.level = level;
@ -125,13 +125,13 @@ POCLoader.load = function load(url, callback) {
}
};
POCLoader.loadPointAttributes = function(mno){
Potree.POCLoader.loadPointAttributes = function(mno){
var fpa = mno.pointAttributes;
var pa = new PointAttributes();
var pa = new Potree.PointAttributes();
for(var i = 0; i < fpa.length; i++){
var pointAttribute = PointAttribute[fpa[i]];
var pointAttribute = Potree.PointAttribute[fpa[i]];
pa.add(pointAttribute);
}
@ -139,7 +139,7 @@ POCLoader.loadPointAttributes = function(mno){
};
POCLoader.createChildAABB = function(aabb, childIndex){
Potree.POCLoader.createChildAABB = function(aabb, childIndex){
var V3 = THREE.Vector3;
var min = aabb.min;
var max = aabb.max;

View File

@ -1,28 +1,24 @@
Potree.PointAttributeNames = {};
//function PointAttributeNames(){
//
//}
var PointAttributeNames = {};
PointAttributeNames.POSITION_CARTESIAN = 0; // float x, y, z;
PointAttributeNames.COLOR_PACKED = 1; // byte r, g, b, a; I = [0,1]
PointAttributeNames.COLOR_FLOATS_1 = 2; // float r, g, b; I = [0,1]
PointAttributeNames.COLOR_FLOATS_255 = 3; // float r, g, b; I = [0,255]
PointAttributeNames.NORMAL_FLOATS = 4; // float x, y, z;
PointAttributeNames.FILLER = 5;
PointAttributeNames.INTENSITY = 6;
PointAttributeNames.CLASSIFICATION = 7;
PointAttributeNames.NORMAL_SPHEREMAPPED = 8;
Potree.PointAttributeNames.POSITION_CARTESIAN = 0; // float x, y, z;
Potree.PointAttributeNames.COLOR_PACKED = 1; // byte r, g, b, a; I = [0,1]
Potree.PointAttributeNames.COLOR_FLOATS_1 = 2; // float r, g, b; I = [0,1]
Potree.PointAttributeNames.COLOR_FLOATS_255 = 3; // float r, g, b; I = [0,255]
Potree.PointAttributeNames.NORMAL_FLOATS = 4; // float x, y, z;
Potree.PointAttributeNames.FILLER = 5;
Potree.PointAttributeNames.INTENSITY = 6;
Potree.PointAttributeNames.CLASSIFICATION = 7;
Potree.PointAttributeNames.NORMAL_SPHEREMAPPED = 8;
Potree.PointAttributeNames.NORMAL_OCT16 = 9;
Potree.PointAttributeNames.NORMAL = 10;
/**
* Some types of possible point attribute data formats
*
* @class
*/
var PointAttributeTypes = {
Potree.PointAttributeTypes = {
DATA_TYPE_DOUBLE : {ordinal : 0, size: 8},
DATA_TYPE_FLOAT : {ordinal : 1, size: 4},
DATA_TYPE_INT8 : {ordinal : 2, size: 1},
@ -36,8 +32,8 @@ var PointAttributeTypes = {
};
var i = 0;
for(var obj in PointAttributeTypes){
PointAttributeTypes[i] = PointAttributeTypes[obj];
for(var obj in Potree.PointAttributeTypes){
Potree.PointAttributeTypes[i] = Potree.PointAttributeTypes[obj];
i++;
}
@ -50,46 +46,54 @@ for(var obj in PointAttributeTypes){
* @param size
* @returns
*/
function PointAttribute(name, type, numElements){
Potree.PointAttribute = function(name, type, numElements){
this.name = name;
this.type = type;
this.numElements = numElements;
this.byteSize = this.numElements * this.type.size;
}
PointAttribute.POSITION_CARTESIAN = new PointAttribute(
PointAttributeNames.POSITION_CARTESIAN,
PointAttributeTypes.DATA_TYPE_FLOAT, 3);
Potree.PointAttribute.POSITION_CARTESIAN = new Potree.PointAttribute(
Potree.PointAttributeNames.POSITION_CARTESIAN,
Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3);
PointAttribute.RGBA_PACKED = new PointAttribute(
PointAttributeNames.COLOR_PACKED,
PointAttributeTypes.DATA_TYPE_INT8, 4);
Potree.PointAttribute.RGBA_PACKED = new Potree.PointAttribute(
Potree.PointAttributeNames.COLOR_PACKED,
Potree.PointAttributeTypes.DATA_TYPE_INT8, 4);
PointAttribute.COLOR_PACKED = PointAttribute.RGBA_PACKED;
Potree.PointAttribute.COLOR_PACKED = Potree.PointAttribute.RGBA_PACKED;
PointAttribute.RGB_PACKED = new PointAttribute(
PointAttributeNames.COLOR_PACKED,
PointAttributeTypes.DATA_TYPE_INT8, 3);
Potree.PointAttribute.RGB_PACKED = new Potree.PointAttribute(
Potree.PointAttributeNames.COLOR_PACKED,
Potree.PointAttributeTypes.DATA_TYPE_INT8, 3);
PointAttribute.NORMAL_FLOATS = new PointAttribute(
PointAttributeNames.NORMAL_FLOATS,
PointAttributeTypes.DATA_TYPE_FLOAT, 3);
Potree.PointAttribute.NORMAL_FLOATS = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL_FLOATS,
Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3);
PointAttribute.FILLER_1B = new PointAttribute(
PointAttributeNames.FILLER,
PointAttributeTypes.DATA_TYPE_UINT8, 1);
Potree.PointAttribute.FILLER_1B = new Potree.PointAttribute(
Potree.PointAttributeNames.FILLER,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1);
PointAttribute.INTENSITY = new PointAttribute(
PointAttributeNames.INTENSITY,
PointAttributeTypes.DATA_TYPE_UINT16, 1);
Potree.PointAttribute.INTENSITY = new Potree.PointAttribute(
Potree.PointAttributeNames.INTENSITY,
Potree.PointAttributeTypes.DATA_TYPE_UINT16, 1);
PointAttribute.CLASSIFICATION = new PointAttribute(
PointAttributeNames.CLASSIFICATION,
PointAttributeTypes.DATA_TYPE_UINT8, 1);
Potree.PointAttribute.CLASSIFICATION = new Potree.PointAttribute(
Potree.PointAttributeNames.CLASSIFICATION,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 1);
PointAttribute.NORMAL_SPHEREMAPPED = new PointAttribute(
PointAttributeNames.NORMAL_SPHEREMAPPED,
PointAttributeTypes.DATA_TYPE_UINT8, 2);
Potree.PointAttribute.NORMAL_SPHEREMAPPED = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL_SPHEREMAPPED,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2);
Potree.PointAttribute.NORMAL_OCT16 = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL_OCT16,
Potree.PointAttributeTypes.DATA_TYPE_UINT8, 2);
Potree.PointAttribute.NORMAL = new Potree.PointAttribute(
Potree.PointAttributeNames.NORMAL,
Potree.PointAttributeTypes.DATA_TYPE_FLOAT, 3);
/**
* Ordered list of PointAttributes used to identify how points are aligned in a buffer.
@ -97,22 +101,15 @@ PointAttribute.NORMAL_SPHEREMAPPED = new PointAttribute(
* @class
*
*/
function PointAttributes(pointAttributes){
Potree.PointAttributes = function(pointAttributes){
this.attributes = new Array();
this.byteSize = 0;
this.size = 0;
if(pointAttributes != null){
// does not work in chrome v24
// for(var pointAttribute of pointAttributes){
// this.attributes.push(pointAttribute);
// this.byteSize += pointAttribute.byteSize;
// this.size++;
// }
if(pointAttributes != null){
for(var i = 0; i < pointAttributes.length; i++){
var pointAttributeName = pointAttributes[i];
var pointAttribute = PointAttribute[pointAttributeName];
var pointAttribute = Potree.PointAttribute[pointAttributeName];
this.attributes.push(pointAttribute);
this.byteSize += pointAttribute.byteSize;
this.size++;
@ -120,16 +117,16 @@ function PointAttributes(pointAttributes){
}
}
PointAttributes.prototype.add = function(pointAttribute){
Potree.PointAttributes.prototype.add = function(pointAttribute){
this.attributes.push(pointAttribute);
this.byteSize += pointAttribute.byteSize;
this.size++;
};
PointAttributes.prototype.hasColors = function(){
Potree.PointAttributes.prototype.hasColors = function(){
for(var name in this.attributes){
var pointAttribute = this.attributes[name];
if(pointAttribute.name === PointAttributeNames.COLOR_PACKED){
if(pointAttribute.name === Potree.PointAttributeNames.COLOR_PACKED){
return true;
}
}
@ -137,10 +134,14 @@ PointAttributes.prototype.hasColors = function(){
return false;
};
PointAttributes.prototype.hasNormals = function(){
Potree.PointAttributes.prototype.hasNormals = function(){
for(var name in this.attributes){
var pointAttribute = this.attributes[name];
if(pointAttribute === PointAttribute.NORMAL_SPHEREMAPPED || pointAttribute === PointAttribute.NORMAL_FLOATS){
if(
pointAttribute === Potree.PointAttribute.NORMAL_SPHEREMAPPED ||
pointAttribute === Potree.PointAttribute.NORMAL_FLOATS ||
pointAttribute === Potree.PointAttribute.NORMAL ||
pointAttribute === Potree.PointAttribute.NORMAL_OCT16){
return true;
}
}

View File

@ -82,6 +82,8 @@ Potree.TreeType = {
};
Potree.PointCloudMaterial = function(parameters){
THREE.Material.call( this );
parameters = parameters || {};
var color = new THREE.Color( 0x000000 );
@ -99,12 +101,10 @@ Potree.PointCloudMaterial = function(parameters){
this._pointShape = Potree.PointShape.SQUARE;
this._interpolate = false;
this._pointColorType = Potree.PointColorType.RGB;
this._levels = 6.0;
this._useClipBox = false;
this.numClipBoxes = 0;
this._clipMode = Potree.ClipMode.DISABLED;
this._weighted = false;
this._blendDepth = 0.1;
this._depthMap;
this._gradient = Potree.Gradients.RAINBOW;
this._classification = Potree.Classification.DEFAULT;
@ -129,18 +129,21 @@ Potree.PointCloudMaterial = function(parameters){
size: { type: "f", value: 10 },
minSize: { type: "f", value: 2 },
maxSize: { type: "f", value: 2 },
nodeSize: { type: "f", value: nodeSize },
octreeSize: { type: "f", value: 0 },
bbMin: { type: "fv", value: [0,0,0] },
bbSize: { type: "fv", value: [0,0,0] },
heightMin: { type: "f", value: 0.0 },
heightMax: { type: "f", value: 1.0 },
intensityMin: { type: "f", value: 0.0 },
intensityMax: { type: "f", value: 1.0 },
clipBoxCount: { type: "f", value: 0 },
level: { type: "f", value: 0 },
visibleNodesOffset: { type: "f", value: 0 },
visibleNodes: { type: "t", value: this.visibleNodesTexture },
pcIndex: { type: "f", value: 0 },
gradient: { type: "t", value: this.gradientTexture },
classificationLUT: { type: "t", value: this.classificationTexture },
clipBoxes: { type: "Matrix4fv", value: [] },
blendDepth: { type: "f", value: this._blendDepth },
depthMap: { type: "t", value: null },
diffuse: { type: "fv", value: [1,1,1]},
ambient: { type: "fv", value: [0.1, 0.1, 0.1]},
@ -253,7 +256,6 @@ Potree.PointCloudMaterial.prototype.getDefines = function(){
defines += "#define attenuated_point_size\n";
}else if(this.pointSizeType === Potree.PointSizeType.ADAPTIVE){
defines += "#define adaptive_point_size\n";
defines += "#define levels " + Math.max(0, this._levels - 2).toFixed(1) + "\n";
}
if(this.pointShape === Potree.PointShape.SQUARE){
@ -314,22 +316,29 @@ Potree.PointCloudMaterial.prototype.getDefines = function(){
if(this.numClipBoxes > 0){
defines += "#define use_clip_box\n";
defines += "#define clip_box_count " + this.numClipBoxes + "\n";
}
return defines;
};
Potree.PointCloudMaterial.prototype.setClipBoxes = function(clipBoxes){
var numBoxes = clipBoxes.length;
this.numClipBoxes = numBoxes;
if(!clipBoxes){
return;
}
this.clipBoxes = clipBoxes;
var doUpdate = (this.numClipBoxes != clipBoxes.length) && (clipBoxes.length === 0 || this.numClipBoxes === 0);
this.numClipBoxes = clipBoxes.length;
this.uniforms.clipBoxCount.value = this.numClipBoxes;
if(this.uniforms.clipBoxes.value.length / 16 !== numBoxes){
this.uniforms.clipBoxes.value = new Float32Array(numBoxes * 16);
if(doUpdate){
this.updateShaderSource();
}
for(var i = 0; i < numBoxes; i++){
this.uniforms.clipBoxes.value = new Float32Array(this.numClipBoxes * 16);
for(var i = 0; i < this.numClipBoxes; i++){
var box = clipBoxes[i];
this.uniforms.clipBoxes.value.set(box.elements, 16*i);
@ -375,18 +384,6 @@ Object.defineProperty(Potree.PointCloudMaterial.prototype, "spacing", {
}
});
Object.defineProperty(Potree.PointCloudMaterial.prototype, "blendDepth", {
get: function(){
return this.uniforms.blendDepth.value;
},
set: function(value){
if(this.uniforms.blendDepth.value !== value){
this.uniforms.blendDepth.value = value;
//this.updateShaderSource();
}
}
});
Object.defineProperty(Potree.PointCloudMaterial.prototype, "useClipBox", {
get: function(){
return this._useClipBox;
@ -454,7 +451,6 @@ Object.defineProperty(Potree.PointCloudMaterial.prototype, "near", {
set: function(value){
if(this.uniforms.near.value !== value){
this.uniforms.near.value = value;
//this.updateShaderSource();
}
}
});
@ -466,7 +462,6 @@ Object.defineProperty(Potree.PointCloudMaterial.prototype, "far", {
set: function(value){
if(this.uniforms.far.value !== value){
this.uniforms.far.value = value;
//this.updateShaderSource();
}
}
});
@ -476,21 +471,11 @@ Object.defineProperty(Potree.PointCloudMaterial.prototype, "opacity", {
return this.uniforms.opacity.value;
},
set: function(value){
if(this.uniforms.opacity.value !== value){
this.uniforms.opacity.value = value;
this.updateShaderSource();
}
}
});
Object.defineProperty(Potree.PointCloudMaterial.prototype, "levels", {
get: function(){
return this._levels;
},
set: function(value){
if(this._levels !== value){
this._levels = value;
this.updateShaderSource();
if(this.uniforms.opacity){
if(this.uniforms.opacity.value !== value){
this.uniforms.opacity.value = value;
this.updateShaderSource();
}
}
}
});

View File

@ -62,7 +62,6 @@ uniform float far;
uniform float pcIndex;
uniform float screenWidth;
uniform float screenHeight;
uniform float blendDepth;
uniform sampler2D depthMap;
@ -94,7 +93,7 @@ void main() {
#if defined weighted_splats
vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight);
float depth = texture2D(depthMap, uv).r;
if(vLinearDepth > depth + vRadius * 0.5){
if(vLinearDepth > depth + vRadius){
discard;
}
#endif

View File

@ -20,6 +20,8 @@
//#define MAX_SHADOWS 0
//#define MAX_BONES 58
#define max_clip_boxes 30
attribute float intensity;
attribute float classification;
@ -31,12 +33,13 @@ uniform float screenWidth;
uniform float screenHeight;
uniform float fov;
uniform float spacing;
uniform float blendDepth;
uniform float near;
uniform float far;
uniform float level;
uniform float visibleNodesOffset;
#if defined use_clip_box
uniform mat4 clipBoxes[clip_box_count];
uniform mat4 clipBoxes[max_clip_boxes];
#endif
@ -44,13 +47,15 @@ uniform float heightMin;
uniform float heightMax;
uniform float intensityMin;
uniform float intensityMax;
uniform float size;
uniform float minSize;
uniform float maxSize;
uniform float nodeSize;
uniform float size; // pixel size factor
uniform float minSize; // minimum pixel size
uniform float maxSize; // maximum pixel size
uniform float octreeSize;
uniform vec3 bbMin;
uniform vec3 bbSize;
uniform vec3 uColor;
uniform float opacity;
uniform float clipBoxCount;
uniform sampler2D visibleNodes;
@ -105,12 +110,12 @@ bool isBitSet(float number, float index){
* find the tree depth at the point position
*/
float getLocalTreeDepth(){
vec3 offset = vec3(0.0, 0.0, 0.0);
float iOffset = 0.0;
float depth = 0.0;
for(float i = 0.0; i <= levels + 1.0; i++){
vec3 offset = bbMin;
float iOffset = visibleNodesOffset;
float depth = level;
for(float i = 0.0; i <= 1000.0; i++){
float nodeSizeAtLevel = nodeSize / pow(2.0, i);
float nodeSizeAtLevel = octreeSize / pow(2.0, i + level);
vec3 index3d = (position - offset) / nodeSizeAtLevel;
index3d = floor(index3d + 0.5);
float index = 4.0*index3d.x + 2.0*index3d.y + index3d.z;
@ -154,7 +159,7 @@ float getLocalTreeDepth(){
vec3 size = bbSize;
vec3 pos = position;
for(float i = 0.0; i <= levels + 1.0; i++){
for(float i = 0.0; i <= 1000.0; i++){
vec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));
@ -217,7 +222,7 @@ void main() {
vOpacity = opacity;
vLinearDepth = -mvPosition.z;
vDepth = mvPosition.z / gl_Position.w;
vNormal = normalMatrix * normal;
vNormal = normalize(normalMatrix * normal);
// ---------------------
@ -300,7 +305,11 @@ void main() {
#if defined use_clip_box
bool insideAny = false;
for(int i = 0; i < clip_box_count; i++){
for(int i = 0; i < max_clip_boxes; i++){
if(i == int(clipBoxCount)){
break;
}
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;

View File

@ -338,7 +338,7 @@ Potree.TransformationTool = function(scene, camera, renderer){
pointOnLine.unproject(scope.camera);
var diff = scope.sceneRoot.position.clone().sub(pointOnLine);
diff.multiply(new THREE.Vector3(-1, -1, 1)).addScalar(1);
diff.multiply(new THREE.Vector3(-1, -1, 1));
for(var i = 0; i < scope.targets.length; i++){
var target = scope.targets[i];

View File

@ -49,7 +49,7 @@ onmessage = function(event){
for(var i = 0; i < pointAttributes.attributes.length; i++){
var pointAttribute = pointAttributes.attributes[i];
if(pointAttribute.name === PointAttribute.POSITION_CARTESIAN.name){
if(pointAttribute.name === Potree.PointAttribute.POSITION_CARTESIAN.name){
var buff = new ArrayBuffer(numPoints*4*3);
var positions = new Float32Array(buff);
@ -68,7 +68,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.COLOR_PACKED.name){
}else if(pointAttribute.name === Potree.PointAttribute.COLOR_PACKED.name){
var buff = new ArrayBuffer(numPoints*4*3);
var colors = new Float32Array(buff);
@ -81,7 +81,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.INTENSITY.name){
}else if(pointAttribute.name === Potree.PointAttribute.INTENSITY.name){
var buff = new ArrayBuffer(numPoints*4);
var intensities = new Float32Array(buff);
@ -93,7 +93,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.CLASSIFICATION.name){
}else if(pointAttribute.name === Potree.PointAttribute.CLASSIFICATION.name){
var buff = new ArrayBuffer(numPoints*4);
var classifications = new Float32Array(buff);
@ -105,7 +105,7 @@ onmessage = function(event){
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === PointAttribute.NORMAL_SPHEREMAPPED.name){
}else if(pointAttribute.name === Potree.PointAttribute.NORMAL_SPHEREMAPPED.name){
var buff = new ArrayBuffer(numPoints*4*3);
var normals = new Float32Array(buff);
@ -137,7 +137,51 @@ onmessage = function(event){
}
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === Potree.PointAttribute.NORMAL_OCT16.name){
var buff = new ArrayBuffer(numPoints*4*3);
var normals = new Float32Array(buff);
for(var j = 0; j < numPoints; j++){
var bx = cv.getUint8(offset + j * pointAttributes.byteSize + 0);
var by = cv.getUint8(offset + j * pointAttributes.byteSize + 1);
var u = (bx / 255) * 2 - 1;
var v = (by / 255) * 2 - 1;
var z = 1 - Math.abs(u) - Math.abs(v);
if(z >= 0){
var x = u;
var y = v;
}else{
var x = - (v/Math.sign(v) - 1) / Math.sign(u);
var y = - (u/Math.sign(u) - 1) / Math.sign(v);
}
var length = Math.sqrt(x*x + y*y + z*z);
x = x / length;
y = y / length;
z = z / length;
normals[3*j + 0] = x;
normals[3*j + 1] = y;
normals[3*j + 2] = z;
}
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}else if(pointAttribute.name === Potree.PointAttribute.NORMAL.name){
var buff = new ArrayBuffer(numPoints*4*3);
var normals = new Float32Array(buff);
for(var j = 0; j < numPoints; j++){
var x = cv.getFloat(offset + j * pointAttributes.byteSize + 0);
var y = cv.getFloat(offset + j * pointAttributes.byteSize + 4);
var z = cv.getFloat(offset + j * pointAttributes.byteSize + 8);
normals[3*j + 0] = x;
normals[3*j + 1] = y;
normals[3*j + 2] = z;
}
attributeBuffers[pointAttribute.name] = { buffer: buff, attribute: pointAttribute};
}
offset += pointAttribute.byteSize;