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
即可得到模型

转换后的文件结构

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

相关推荐
星秀日3 小时前
JavaWeb--Ajax
前端·javascript·ajax
4_0_43 小时前
全栈视角:从零构建一个现代化的 Todo 应用
前端·node.js
星觅3 小时前
npm依赖结构解析
npm
BumBle4 小时前
uniapp 用css实现圆形进度条组件
前端·vue.js·uni-app
杏花春雨江南4 小时前
npm error Could not resolve dependency:
前端·npm·node.js
嫂子的姐夫4 小时前
10-七麦js扣代码
前端·javascript·爬虫·python·node.js·网络爬虫
Komorebi_99994 小时前
Vue3 + TypeScript provide/inject 小白学习笔记
前端·javascript·vue.js
少吃一口都不行4 小时前
脚手架学习
前端·javascript·学习
地方地方4 小时前
手写JavaScript 深拷贝
前端·javascript
yeyuningzi4 小时前
npm升级提示error engine not compatible with your version of node/npm: npm@11.6.2
前端·npm·node.js