|
91 | 91 | <script src="../src/FirstPersonControls.js"></script>
|
92 | 92 | <script src="../src/utils/ProfileTool.js"></script>
|
93 | 93 | <script src="../src/utils/MeasuringTool.js"></script>
|
| 94 | + <script src="../src/utils/TransformationTool.js"></script> |
94 | 95 | <script src="../src/utils/VolumeTool.js"></script>
|
95 | 96 | <script src="../src/utils.js"></script>
|
96 | 97 | <script src="../src/LRU.js"></script>
|
|
104 | 105 |
|
105 | 106 | <!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
106 | 107 | <!-- INCLUDE SETTINGS HERE -->
|
| 108 | + <!--<script src="../libs/plasio/js/laslaz.js"></script> |
| 109 | + <script src="../libs/plasio/vendor/bluebird.js"></script> |
| 110 | + <script src="../build/js/laslaz.js"></script> |
| 111 | + --> |
107 | 112 |
|
108 | 113 | <!-- INFOS / STATS -->
|
109 | 114 | <div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
|
138 | 143 | if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
139 | 144 | sceneProperties.navigation = "Orbit";
|
140 | 145 | }
|
| 146 | + |
| 147 | + if(sceneProperties.quality === null){ |
| 148 | + if(Potree.Features.SHADER_INTERPOLATION.isSupported()){ |
| 149 | + sceneProperties.quality = "Interpolation"; |
| 150 | + }else{ |
| 151 | + sceneProperties.quality = "Squares"; |
| 152 | + } |
| 153 | + } |
141 | 154 |
|
142 | 155 |
|
143 | 156 | var fov = sceneProperties.fov;
|
|
195 | 208 | };
|
196 | 209 |
|
197 | 210 | function setQuality(value){
|
| 211 | + |
| 212 | + |
198 | 213 | if(value == "Interpolation" && !Potree.Features.SHADER_INTERPOLATION.isSupported()){
|
199 | 214 | quality = "Squares";
|
200 | 215 | }else if(value == "Splats" && !Potree.Features.SHADER_SPLATS.isSupported()){
|
|
298 | 313 | for(var i = 0; i < attributes.attributes.length; i++){
|
299 | 314 | var attribute = attributes.attributes[i];
|
300 | 315 |
|
301 |
| - if(attribute === PointAttribute.COLOR_PACKED){ |
| 316 | + if(attribute === Potree.PointAttribute.COLOR_PACKED){ |
302 | 317 | options.push("RGB");
|
303 |
| - }else if(attribute === PointAttribute.INTENSITY){ |
| 318 | + }else if(attribute === Potree.PointAttribute.INTENSITY){ |
304 | 319 | options.push("Intensity");
|
305 | 320 | options.push("Intensity Gradient");
|
306 |
| - }else if(attribute === PointAttribute.CLASSIFICATION){ |
| 321 | + }else if(attribute === Potree.PointAttribute.CLASSIFICATION){ |
307 | 322 | options.push("Classification");
|
308 |
| - }else if(attribute === PointAttribute.NORMAL_SPHEREMAPPED || attribute === PointAttribute.NORMAL_OCT16){ |
309 |
| - options.push("Phong"); |
310 |
| - options.push("Normal"); |
311 | 323 | }
|
312 | 324 | }
|
| 325 | + if(attributes.hasNormals()){ |
| 326 | + options.push("Phong"); |
| 327 | + options.push("Normal"); |
| 328 | + } |
| 329 | + |
313 | 330 | options.push("Height");
|
314 | 331 | options.push("Tree Depth");
|
315 | 332 | }
|
|
440 | 457 |
|
441 | 458 | // load pointcloud
|
442 | 459 | if(pointcloudPath.indexOf("cloud.js") > 0){
|
443 |
| - POCLoader.load(pointcloudPath, function(geometry){ |
| 460 | + Potree.POCLoader.load(pointcloudPath, function(geometry){ |
444 | 461 | pointcloud = new Potree.PointCloudOctree(geometry);
|
445 | 462 |
|
446 | 463 | pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
|
615 | 632 | };
|
616 | 633 |
|
617 | 634 | var intensityMax = null;
|
| 635 | + var heightMin = null; |
| 636 | + var heightMax = null; |
618 | 637 |
|
619 | 638 | function update(){
|
620 | 639 | Potree.pointLoadLimit = pointCountTarget * 2 * 1000 * 1000;
|
|
647 | 666 | }
|
648 | 667 | }
|
649 | 668 | }
|
| 669 | + |
| 670 | + if(!heightMin){ |
| 671 | + heightMin = bbWorld.min.y; |
| 672 | + heightMax = bbWorld.max.y; |
| 673 | + } |
650 | 674 |
|
651 | 675 | pointcloud.material.clipMode = clipMode;
|
652 |
| - pointcloud.material.heightMin = bbWorld.min.y; |
653 |
| - pointcloud.material.heightMax = bbWorld.max.y; |
| 676 | + pointcloud.material.heightMin = heightMin; |
| 677 | + pointcloud.material.heightMax = heightMax; |
654 | 678 | pointcloud.material.intensityMin = 0;
|
655 | 679 | pointcloud.material.intensityMax = intensityMax;
|
656 | 680 | pointcloud.showBoundingBox = showBoundingBox;
|
|
838 | 862 |
|
839 | 863 | var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
840 | 864 |
|
841 |
| - pointcloud.material.size = pointSize; |
842 | 865 | pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
| 866 | + pointcloud.material.size = pointSize; |
843 | 867 | pointcloud.material.opacity = opacity;
|
844 | 868 | pointcloud.material.pointColorType = pointColorType;
|
845 |
| - |
846 |
| - //if(pointcloud instanceof Potree.PointCloudOctree){ |
847 |
| - pointcloud.material.pointSizeType = pointSizeType; |
848 |
| - //}else if(pointcloud instanceof Potree.PointCloudArena4D){ |
849 |
| - // //var pst = pointSizeType === Potree.PointSizeType.ADAPTIVE ? Potree.PointSizeType.ATTENUATED : pointSizeType; |
850 |
| - // pointcloud.material.pointSizeType = pst; |
851 |
| - //} |
| 869 | + pointcloud.material.pointSizeType = pointSizeType; |
852 | 870 | pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
|
853 | 871 | pointcloud.material.interpolate = (quality === "Interpolation");
|
854 | 872 | pointcloud.material.weighted = false;
|
|
948 | 966 | rtDepth.setSize(width, height);
|
949 | 967 | rtNormalize.setSize(width, height);
|
950 | 968 |
|
951 |
| - |
952 | 969 | renderer.clear();
|
953 |
| - //renderer.render(sceneBG, cameraBG); |
954 |
| - // render skybox |
955 | 970 | if(showSkybox){
|
956 | 971 | skybox.camera.rotation.copy(camera.rotation);
|
957 | 972 | renderer.render(skybox.scene, skybox.camera);
|
|
961 | 976 | renderer.render(scene, camera);
|
962 | 977 |
|
963 | 978 | if(pointcloud){
|
964 |
| - if(!weightedMaterial){ |
965 |
| - pointcloud.originalMaterial = pointcloud.material; |
966 |
| - depthMaterial = new Potree.PointCloudMaterial(); |
967 |
| - weightedMaterial = new Potree.PointCloudMaterial(); |
968 |
| - } |
969 |
| - |
970 |
| - pointcloud.material = depthMaterial; |
971 |
| - |
972 |
| - var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld); |
973 |
| - |
974 |
| - // get rid of this |
975 |
| - pointcloud.material.size = pointSize; |
976 | 979 | pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
977 |
| - pointcloud.material.opacity = opacity; |
| 980 | + |
978 | 981 | pointcloud.material.pointSizeType = pointSizeType;
|
979 |
| - pointcloud.material.pointColorType = Potree.PointColorType.DEPTH; |
980 |
| - pointcloud.material.pointShape = Potree.PointShape.CIRCLE; |
981 |
| - pointcloud.material.interpolate = (quality === "Interpolate"); |
982 |
| - pointcloud.material.weighted = false; |
983 | 982 |
|
984 |
| - pointcloud.material.minSize = 2; |
985 |
| - pointcloud.material.screenWidth = width; |
986 |
| - pointcloud.material.screenHeight = height; |
987 |
| - |
988 | 983 | pointcloud.update(camera, renderer);
|
| 984 | + |
| 985 | + var vn = pointcloud.visibleNodes; |
989 | 986 |
|
990 |
| - renderer.clearTarget( rtDepth, true, true, true ); |
991 |
| - renderer.clearTarget( rtNormalize, true, true, true ); |
992 |
| - |
993 |
| - var origType = pointcloud.material.pointColorType; |
994 |
| - renderer.render(scenePointCloud, camera, rtDepth); |
995 |
| - |
996 |
| - pointcloud.material = weightedMaterial; |
997 |
| - |
| 987 | + // init materials |
| 988 | + for(var i = 0; i < vn.length; i++){ |
| 989 | + var node = vn[i].node; |
| 990 | + |
| 991 | + if(typeof node._hqsplats === "undefined"){ |
| 992 | + var hq = { |
| 993 | + originalMaterial: node.material, |
| 994 | + depthMaterial: new Potree.PointCloudMaterial(), |
| 995 | + weightedMaterial: new Potree.PointCloudMaterial() |
| 996 | + } |
| 997 | + |
| 998 | + hq.depthMaterial.pointColorType = Potree.PointColorType.DEPTH; |
| 999 | + hq.depthMaterial.pointShape = Potree.PointShape.CIRCLE; |
| 1000 | + hq.depthMaterial.interpolate = false; |
| 1001 | + hq.depthMaterial.weighted = false; |
| 1002 | + hq.depthMaterial.minSize = 2; |
| 1003 | + hq.depthMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x; |
| 1004 | + hq.depthMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray(); |
| 1005 | + |
| 1006 | + hq.weightedMaterial.pointShape = Potree.PointShape.CIRCLE; |
| 1007 | + hq.weightedMaterial.interpolate = false; |
| 1008 | + hq.weightedMaterial.weighted = true; |
| 1009 | + hq.weightedMaterial.minSize = 2; |
| 1010 | + hq.weightedMaterial.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x; |
| 1011 | + hq.weightedMaterial.uniforms.bbMin.value = pointcloud.pcoGeometry.boundingBox.min.toArray(); |
| 1012 | + |
| 1013 | + node._hqsplats = hq; |
| 1014 | + } |
| 1015 | + } |
998 | 1016 |
|
| 1017 | + {// DEPTH PASS |
| 1018 | + for(var i = 0; i < vn.length; i++){ |
| 1019 | + var node = vn[i].node; |
| 1020 | + |
| 1021 | + var material = node._hqsplats.depthMaterial; |
| 1022 | + |
| 1023 | + material.size = pointSize; |
| 1024 | + material.pointSizeType = pointSizeType; |
| 1025 | + material.screenWidth = width; |
| 1026 | + material.screenHeight = height; |
| 1027 | + material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture; |
| 1028 | + material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value; |
| 1029 | + material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x; |
| 1030 | + material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray(); |
| 1031 | + material.uniforms.level.value = node.level; |
| 1032 | + material.fov = camera.fov * (Math.PI / 180); |
| 1033 | + material.spacing = pointcloud.pcoGeometry.spacing; |
| 1034 | + material.near = camera.near; |
| 1035 | + material.far = camera.far; |
| 1036 | + |
| 1037 | + node.material = material; |
| 1038 | + } |
| 1039 | + |
| 1040 | + renderer.clearTarget( rtDepth, true, true, true ); |
| 1041 | + renderer.clearTarget( rtNormalize, true, true, true ); |
| 1042 | + renderer.render(scenePointCloud, camera, rtDepth); |
| 1043 | + } |
999 | 1044 |
|
1000 |
| - // get rid of this |
1001 |
| - pointcloud.material.size = pointSize; |
1002 |
| - pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000; |
1003 |
| - pointcloud.material.opacity = opacity; |
1004 |
| - pointcloud.material.pointSizeType = pointSizeType; |
1005 |
| - pointcloud.material.pointColorType = pointColorType; |
1006 |
| - pointcloud.material.pointShape = Potree.PointShape.CIRCLE; |
1007 |
| - pointcloud.material.interpolate = (quality === "Interpolation"); |
1008 |
| - pointcloud.material.weighted = true; |
1009 |
| - pointcloud.material.minSize = 2; |
1010 | 1045 |
|
1011 |
| - pointcloud.material.depthMap = rtDepth; |
1012 |
| - pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20); |
1013 |
| - pointcloud.update(camera, renderer); |
1014 |
| - renderer.render(scenePointCloud, camera, rtNormalize); |
| 1046 | + {// ATTRIBUTE PASS |
| 1047 | + for(var i = 0; i < vn.length; i++){ |
| 1048 | + var node = vn[i].node; |
| 1049 | + |
| 1050 | + var material = node._hqsplats.weightedMaterial; |
| 1051 | + |
| 1052 | + material.size = pointSize; |
| 1053 | + material.pointSizeType = pointSizeType; |
| 1054 | + material.screenWidth = width; |
| 1055 | + material.screenHeight = height; |
| 1056 | + material.pointColorType = pointColorType; |
| 1057 | + material.depthMap = rtDepth; |
| 1058 | + material.uniforms.visibleNodes.value = pointcloud.material.visibleNodesTexture; |
| 1059 | + material.uniforms.visibleNodesOffset.value = node._hqsplats.originalMaterial.uniforms.visibleNodesOffset.value; |
| 1060 | + material.uniforms.octreeSize.value = pointcloud.pcoGeometry.boundingBox.size().x; |
| 1061 | + material.uniforms.bbMin.value = node.pcoGeometry.boundingBox.min.toArray(); |
| 1062 | + material.uniforms.level.value = node.level; |
| 1063 | + material.fov = camera.fov * (Math.PI / 180); |
| 1064 | + material.spacing = pointcloud.pcoGeometry.spacing; |
| 1065 | + material.near = camera.near; |
| 1066 | + material.far = camera.far; |
| 1067 | + |
| 1068 | + node.material = material; |
| 1069 | + } |
| 1070 | + |
| 1071 | + renderer.render(scenePointCloud, camera, rtNormalize); |
| 1072 | + } |
1015 | 1073 |
|
1016 |
| - |
1017 |
| - volumeTool.render(); |
| 1074 | + // NORMALIZATION PASS |
1018 | 1075 | renderer.render(sceneNormalize, cameraBG);
|
1019 | 1076 |
|
| 1077 | + // reset material |
| 1078 | + for(var i = 0; i < vn.length; i++){ |
| 1079 | + var node = vn[i].node; |
| 1080 | + |
| 1081 | + node.material = node._hqsplats.originalMaterial; |
| 1082 | + } |
| 1083 | + |
1020 | 1084 |
|
| 1085 | + volumeTool.render(); |
1021 | 1086 | renderer.clearDepth();
|
1022 | 1087 | profileTool.render();
|
1023 | 1088 | measuringTool.render();
|
1024 | 1089 | transformationTool.render();
|
1025 |
| - |
1026 | 1090 | }
|
1027 |
| - |
1028 |
| - |
1029 | 1091 | }
|
1030 | 1092 |
|
1031 | 1093 | function loop() {
|
|
1044 | 1106 |
|
1045 | 1107 |
|
1046 | 1108 | initThree();
|
1047 |
| - //initGUI(); |
1048 | 1109 | loop();
|
1049 | 1110 |
|
1050 | 1111 | </script>
|
|
0 commit comments