日期: 2025-11-06
目标: 完全参考robot_map_editor项目的渲染效果
// 动态点大小 + 发光效果 + 叠加混合
gl_PointSize = 5.0 * (300.0 / -mvPosition.z);
blending: THREE.AdditiveBlending
// 增强颜色亮度 30%
vec3 enhancedColor = vColor * 1.3;
// 固定点大小 0.8
gl_PointSize = 0.8;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
// 直接使用顶点颜色,无增强
gl_FragColor = vec4(vColor, 1.0);
文件更新:
src/views/map/vslam/utils/Utils.jssrc/views/map/vslam/utils/IntersectPointsMesh.js// 微弱环境光
const ambientLight = new THREE.AmbientLight(0x222222, 0.3)
// 半球光(天空光 + 地面光)
const hemiLight = new THREE.HemisphereLight(0xffffff, 0x080820, 20)
说明:
0xffffff: 天空颜色(白色)0x080820: 地面颜色(深蓝黑色)20: 光强度文件更新:
src/views/map/vslam/components/VSlamView.vuethis.viewer.setBackground('black') // ✅ 纯黑背景
// 极暗的网格辅助器(几乎不可见)
const gridHelper = new THREE.GridHelper(size, divisions, 0x111111, 0x0a0a0a)
| 参数 | robot_map_editor | pns-web(更新后) | 状态 |
|---|---|---|---|
| 点大小 | 0.8 |
0.8 |
✅ |
| 背景 | black |
black |
✅ |
| 光照 | HemisphereLight |
HemisphereLight |
✅ |
| Shader | 简单顶点颜色 | 简单顶点颜色 | ✅ |
| 混合模式 | 默认 | 默认 | ✅ |
| 颜色映射 | Z轴高度 → 蓝绿黄红 | Z轴高度 → 蓝绿黄红 | ✅ |
// Z 轴高度 → 颜色渐变
z < -1 → 蓝色 (0x0000ff)
-1 ≤ z < 5 → 蓝色 → 绿色
5 ≤ z < 10 → 绿色 → 黄色
10 ≤ z < 15 → 黄色 → 红色
z ≥ 15 → 红色 (0xff0000)
transparent: true(减少透明度排序开销)AdditiveBlending(减少混合计算)// 创建 ShaderMaterial 定义渲染方式(参考 robot_map_editor)
const material = new THREE.ShaderMaterial({
vertexShader: `
attribute vec3 color;
varying vec3 vColor;
void main() {
vColor = color;
gl_PointSize = 0.8;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
varying vec3 vColor;
void main() {
gl_FragColor = vec4(vColor, 1.0);
}
`
})
// 设置纯黑色背景(参考 robot_map_editor)
this.viewer.setBackground('black')
// 添加半球光(参考 robot_map_editor)
const hemiLight = new THREE.HemisphereLight(0xffffff, 0x080820, 20)
this.viewer.scene.scene.add(hemiLight)
# 清除缓存并刷新
Ctrl + F5 (Windows)
Cmd + Shift + R (Mac)
✅ 应该看到:
[VSlamView] 设置纯黑色背景
[VSlamView] 添加半球光
[VSlamView] Potree Viewer 初始化成功
打开浏览器性能监控(F12 → Performance):
结果: 完全一致!🎉
✅ src/views/map/vslam/utils/Utils.js
- 简化 Shader 材质
- 固定点大小 0.8
- 移除发光效果和颜色增强
✅ src/views/map/vslam/utils/IntersectPointsMesh.js
- 简化 Shader 材质
- 固定点大小 0.8
- 移除注释的复杂参数
✅ src/views/map/vslam/components/VSlamView.vue
- 更新光照系统为 HemisphereLight
- 保持黑色背景
// 在 Utils.js 和 IntersectPointsMesh.js 中
gl_PointSize = 0.8; // 可改为 0.6, 1.0, 1.2 等
// 在 VSlamView.vue 中
const hemiLight = new THREE.HemisphereLight(0xffffff, 0x080820, 20)
// ↑
// 可改为 10, 15, 25 等
// 在 VSlamView.vue 中
const gridHelper = new THREE.GridHelper(size, divisions, 0x111111, 0x0a0a0a)
// ↑ ↑
// 主网格色 次网格色
// 更亮: 0x333333, 0x1a1a1a
// 更暗: 0x080808, 0x050505
A: 修改 gl_PointSize 的值:
0.5 - 0.70.81.0 - 1.5A: 增加半球光强度:
const hemiLight = new THREE.HemisphereLight(0xffffff, 0x080820, 30) // 从 20 → 30
A: 当前使用原始颜色,如需增强可修改 Fragment Shader:
void main() {
vec3 enhancedColor = vColor * 1.2; // 增加 20% 亮度
gl_FragColor = vec4(enhancedColor, 1.0);
}
更新完成
版本: v2.0 - 完全对齐 robot_map_editor
日期: 2025-11-06
现在刷新浏览器查看效果!🚀