{"action":"created","issue":{"url":"https://api.github.com/repos/potree/potree/issues/375","repository_url":"https://api.github.com/repos/potree/potree","labels_url":"https://api.github.com/repos/potree/potree/issues/375/labels{/name}","comments_url":"https://api.github.com/repos/potree/potree/issues/375/comments","events_url":"https://api.github.com/repos/potree/potree/issues/375/events","html_url":"https://github.com/potree/potree/issues/375","id":249833240,"number":375,"title":"How to import 3D shapefile ? ","user":{"login":"ChirstopheD","id":30654183,"avatar_url":"https://avatars3.githubusercontent.com/u/30654183?v=4","gravatar_id":"","url":"https://api.github.com/users/ChirstopheD","html_url":"https://github.com/ChirstopheD","followers_url":"https://api.github.com/users/ChirstopheD/followers","following_url":"https://api.github.com/users/ChirstopheD/following{/other_user}","gists_url":"https://api.github.com/users/ChirstopheD/gists{/gist_id}","starred_url":"https://api.github.com/users/ChirstopheD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChirstopheD/subscriptions","organizations_url":"https://api.github.com/users/ChirstopheD/orgs","repos_url":"https://api.github.com/users/ChirstopheD/repos","events_url":"https://api.github.com/users/ChirstopheD/events{/privacy}","received_events_url":"https://api.github.com/users/ChirstopheD/received_events","type":"User","site_admin":false},"labels":[{"id":669952629,"url":"https://api.github.com/repos/potree/potree/labels/data-format","name":"data-format","color":"d4c5f9","default":false},{"id":10872175,"url":"https://api.github.com/repos/potree/potree/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-08-12T20:19:06Z","updated_at":"2017-08-16T12:38:29Z","closed_at":null,"body":"Hi, \r\n\r\nI want to import 3D shapefiles into my potree viewer. I tested to adapt the example but it doesn't work. My point cloud and my 3D shapefile are into the same coordinate system (cartesian): EPSG:3944 _ RGF93 / CC44. +proj=lcc +lat_1=43.25 +lat_2=44.75 +lat_0=44 +lon_0=3 +x_0=1700000 +y_0=3200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  \r\n\r\nCan you help me to correctly code it ? \r\n\r\nThanks in advance for your help. \r\n\r\nKind regards. \r\n\r\nChristophe D. "},"comment":{"url":"https://api.github.com/repos/potree/potree/issues/comments/322757369","html_url":"https://github.com/potree/potree/issues/375#issuecomment-322757369","issue_url":"https://api.github.com/repos/potree/potree/issues/375","id":322757369,"user":{"login":"monodo","id":3356536,"avatar_url":"https://avatars0.githubusercontent.com/u/3356536?v=4","gravatar_id":"","url":"https://api.github.com/users/monodo","html_url":"https://github.com/monodo","followers_url":"https://api.github.com/users/monodo/followers","following_url":"https://api.github.com/users/monodo/following{/other_user}","gists_url":"https://api.github.com/users/monodo/gists{/gist_id}","starred_url":"https://api.github.com/users/monodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monodo/subscriptions","organizations_url":"https://api.github.com/users/monodo/orgs","repos_url":"https://api.github.com/users/monodo/repos","events_url":"https://api.github.com/users/monodo/events{/privacy}","received_events_url":"https://api.github.com/users/monodo/received_events","type":"User","site_admin":false},"created_at":"2017-08-16T12:38:29Z","updated_at":"2017-08-16T12:38:29Z","body":"Not yet tried to import shapefiles but...\r\n\r\nAs an alternative solution, you might want to use geojson (export with QGIS for instance). Here is a basic example for points and linestrings : \r\n\r\n```Potree.VectorLoader = {};\r\nPotree.VectorLoader.GeoJSON = function(url, params, scene) {\r\n\r\n\r\n    $.ajax({\r\n        url: Potree.resourcePath + url ,\r\n        dataType: 'json',\r\n        success: function(geojson) {\r\n            \r\n            var pointMaterial, lineMaterial, polyMaterial;\r\n            if (params.pointMaterial) {\r\n                pointMaterial = params.pointMaterial;\r\n            } else {\r\n                pointMaterial = new THREE.PointsMaterial({\r\n                    size: 3,\r\n                    color: 0Xff0000,\r\n                    sizeAttenuation: false \r\n                });\r\n            }\r\n            \r\n            if (params.lineMaterial) {\r\n                lineMaterial = params.lineMaterial;\r\n            } else {\r\n                lineMaterial = new THREE.LineBasicMaterial({\r\n                    color: 0x00ffff,\r\n                    linewidth: 5\r\n                });\r\n            }\r\n\r\n            for (var i=0; i<geojson.features.length; i++) {\r\n                \r\n                var coord = geojson.features[i].geometry.coordinates;\r\n                var geotype = geojson.features[i].geometry.type;\r\n                \r\n                if (geotype.toLowerCase() == 'point') {\r\n                    var pointGeometry = new THREE.Geometry();\r\n                    pointGeometry.vertices.push(new THREE.Vector3(coord[0], coord[1], coord[2]));\r\n                    var point = new THREE.PointCloud(pointGeometry, pointMaterial );\r\n                    scene.add(point);\r\n                } else if (geotype.toLowerCase() == 'linestring') {\r\n                    \r\n                        var lineGeometry = new THREE.Geometry();\r\n                        for (var j=0; j<coord.length; j++) {\r\n                            lineGeometry.vertices.push(\r\n                                new THREE.Vector3(coord[j][0], coord[j][1], coord[j][2])\r\n                            );\r\n                        }\r\n\r\n                        var line = new THREE.Line(lineGeometry, lineMaterial );\r\n                        scene.add(line);\r\n                } else {\r\n                    console.log(geojson.features[i].geometry.type + 'Geometry type not (yet) supported');\r\n                }\r\n            }\r\n        },\r\n        error: function(req, status, err) {\r\n            console.log('Potree: error loading geojson', status, err );\r\n        }\r\n    });\r\n\r\n}\r\n```\r\n\r\nYou can then load a geojson containing 3d lines this way:\r\n\r\n```\r\n     // Load 3D lines\r\n        var params = {}\r\n        params.lineMaterial = new THREE.LineDashedMaterial({\r\n            color: 0xffffff,\r\n            linewidth: 10\r\n        }); \r\n\r\nPotree.VectorLoader.GeoJSON(path_to_your_geojson, params, viewer.scene.scene);\r\n```\r\n\r\nFor 3D buildings, here is a solution for loading ply data. You can export your shapefile with meshlab for instance: \r\n\r\n```\r\nPotree.VectorLoader.PLYBuildingsLOD2 = function(url, params) {      \r\n    var loader = new THREE.PLYLoader();\r\n    loader.load( Potree.resourcePath + url, (geometry) => {\r\n        geometry.computeVertexNormals();\r\n        var material;\r\n        if (!params.material){\r\n            material = new THREE.MeshPhongMaterial({\r\n                  color: 0x4292f4\r\n            });\r\n        } else {\r\n            material = params.material;\r\n        }\r\n        {\r\n\r\n            let mesh = new THREE.Mesh( geometry );\r\n            mesh.scale.multiplyScalar(1);\r\n            mesh.rotation.set(Math.PI, Math.PI, Math.PI)\r\n            viewer.scene.scene.add(mesh);\r\n\r\n        } \r\n    });\r\n}\r\n```\r\n\r\nAnd load your PLY data this way:\r\n\r\n```\r\n        var buildingParams = {};\r\n        buildingParams.material = new THREE.MeshStandardMaterial({\r\n            color: 0xb47d55,\r\n            shading: THREE.FlatShading,\r\n            emissive: 0x483939\r\n\r\n        });\r\n        Potree.VectorLoader.PLYBuildingsLOD2(\"path_to_your_ply_data\", buildingParams)\r\n````\r\n\r\nAs you see, it's quite easy to load vector data into a THREEjs scene...as long as it remain small in volume. \r\n\r\nThe next big (huge) challenge for potree/potreeConverter is to integrate line & polygon geometries is to support them in the tiling process...\r\n\r\nWould anyone around here be interested to participate into the funding of such a developpment ?"}}
{"actor":{"display_login":"monodo"}}