Potree在web端显示大型点云模型文件

一、克隆项目代码(准备好上网工具,得先有node.js npm 环境)

复制代码
git clone https://github.com/potree/potree.git

二、依赖安装(换淘宝镜像能快一些)

复制代码
cd potree
npm install

三、运行

复制代码
npm start

四、使用样例

打开浏览器,输入http://localhost:1234/,即可看到 Potree 的界面。

打开任意examples下的html查看模型

五、换成自己的点云模型

将地址中的cloud.js换成自己模型的地址。

复制代码
// Load and add point cloud to scene
		Potree.loadPointCloud("http://5.9.65.151/mschuetz/potree/resources/pointclouds/helimap/360/MLS_drive1/cloud.js", "MLS", e => {
			let scene = viewer.scene;
			let pointcloud = e.pointcloud;
			
			let material = pointcloud.material;
			material.size = 0.5;
			material.minSize = 2.0;
			material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
			material.shape = Potree.PointShape.SQUARE;
			material.activeAttributeName = "rgba";
			
			scene.addPointCloud(pointcloud);

			viewer.scene.view.setView(
				[2652381.103, 1249049.447, 411.636],
				[2652364.407, 1249077.205, 399.696],
			);

			run();
		});

		async function run(){

			proj4.defs("WGS84", "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
			proj4.defs("pointcloud", viewer.getProjection());
			let transform = proj4("WGS84", "pointcloud");

			let params = {
				transform: transform
			};

Potree加载的点云格式为OCTree格式的数据结构,无法直接加载格式为LAS,LCD,PLY等格式的点云文件,所以我们需要通过PotreeConverter来将普通的点云格式文件转换为OCtree格式的点云文件。去github下载PotreeConverter对模型文件进行格式转换,只能转换las格式的文件。

复制代码
https://github.com/potree/PotreeConverter
1.7版本可用

win系统下载目录执行如下样例指令

复制代码
PotreeConverter.exe D:\\test.las -o D:\\output

linux系统,可加上版本新版本不好用

复制代码
git clone https://github.com/potree/PotreeConverter.git
cd PotreeConverter
mkdir build && cd build
cmake ..
make

完成以后执行
PotreeConverter /home/yr/test.las -o /home/yr/output
即可得到模型

转换后的文件结构

换成自己的点云后的效果图

相关推荐
vipbic12 小时前
解决npm publish的404/403和配置警告全记录
前端·npm·node.js
时光轻浅,半夏挽歌13 小时前
python不同格式文件的读写方式(json等)
python·json
ttod_qzstudio14 小时前
深入理解 TypeScript 数组的 find 与 filter 方法:精准查找的艺术
javascript·typescript·filter·find
冬男zdn14 小时前
优雅处理数组的几个实用方法
前端·javascript
克喵的水银蛇14 小时前
Flutter 通用标签选择组件:TagSelector 支持单选 / 多选
javascript·windows·flutter
2503_9284115614 小时前
12.9 Vue3+Vuex+Js+El-Plus+vite(项目搭建)
开发语言·javascript·ecmascript
Kaze_story15 小时前
Vue第四节:组件化、组件生命周期
前端·javascript·vue.js
元境15 小时前
“3D数字内容创新发展高峰论坛”在京成功举办,多项重要合作与课题启动
3d
妮妮分享15 小时前
H5获取定位的方式是什么?
java·前端·javascript
weixin_4399306415 小时前
前端js日期计算跨月导致的错误
开发语言·前端·javascript