Skip to content

Commit 4cadfd4

Browse files
committed
(vk)提交高斯溅射预览部分的ply解析逻辑
1 parent a80b1fb commit 4cadfd4

File tree

11 files changed

+474
-0
lines changed

11 files changed

+474
-0
lines changed

miniprogram/app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"pages/ar/photo-body-detect/photo-body-detect",
106106
"pages/ar/photo-face-detect/photo-face-detect",
107107
"pages/ar/photo-depth-detect/photo-depth-detect",
108+
"pages/ar/gaussian-splatting/gaussian-splatting",
108109
"pages/page/set-navigation-bar-title/set-navigation-bar-title",
109110
"pages/page/navigation-bar-loading/navigation-bar-loading",
110111
"pages/page/navigator/navigator",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Component({
2+
behaviors: [],
3+
properties: {
4+
},
5+
data: {
6+
renderTargetWidth: 0,
7+
renderTargetHeight: 0,
8+
pixelRatioReady: false,
9+
},
10+
lifetimes: {},
11+
methods: {
12+
handleReady({detail}) {
13+
const xrScene = this.scene = detail.value;
14+
console.log('xr-scene', xrScene);
15+
16+
const camera = this.scene.getElementById("camera").getComponent("camera");
17+
18+
// 暴露scene对象到外部进行定制
19+
this.triggerEvent('sceneReady', {scene: xrScene, camera: camera});
20+
},
21+
}
22+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"component": true,
3+
"usingComponents": {},
4+
"renderer": "xr-frame"
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<xr-scene id="xr-scene" bind:ready="handleReady">
2+
<xr-assets>
3+
</xr-assets>
4+
<xr-env env-data="xr-frame-team-workspace-day" />
5+
<xr-node>
6+
<xr-node node-id="center" position="0 0 0"></xr-node>
7+
<xr-mesh node-id="mesh-plane" position="0 -1 0" rotation="0 0 0" scale="2 0.2 2" geometry="cube" uniforms="u_baseColorFactor:0.5 0.4 0.3 1" ></xr-mesh>
8+
<xr-camera
9+
id="camera" node-id="camera" position="0 2 2" clear-color="0.8 0.8 0.8 1"
10+
target="center"
11+
near="0.01" far="1000"
12+
camera-orbit-control=""
13+
></xr-camera>
14+
</xr-node>
15+
<xr-node node-id="lights">
16+
<xr-light type="ambient" color="1 1 1" intensity="1" />
17+
<xr-light type="directional" rotation="80 20 0" color="1 1 1" intensity="2"/>
18+
</xr-node>
19+
</xr-scene>

miniprogram/packageAPI/pages/ar/components/xr-frame-render/index.wxss

Whitespace-only changes.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import arBehavior from '../behavior/behavior-ar'
2+
import xrFrameBehavior from '../behavior/behavior-xrframe'
3+
import { loadPly } from './lib/handler-ply'
4+
5+
// VK 投影矩阵参数定义
6+
const NEAR = 0.01
7+
const FAR = 1000
8+
9+
let loggerOnce = false;
10+
11+
Component({
12+
behaviors: [arBehavior, xrFrameBehavior],
13+
data: {
14+
theme: 'light',
15+
widthScale: 1, // canvas宽度缩放值
16+
heightScale: 0.9, // canvas高度缩放值
17+
hintBoxList: [], // 显示提示盒子列表,
18+
cameraPosition: 1 // 默认前置
19+
},
20+
markerIndex: 0, // 使用的 marker 索引
21+
hintInfo: undefined, // 提示框信息
22+
lifetimes: {
23+
/**
24+
* 生命周期函数--监听页面加载
25+
*/
26+
detached() {
27+
console.log("页面detached")
28+
if (wx.offThemeChange) {
29+
wx.offThemeChange()
30+
}
31+
},
32+
ready() {
33+
console.log("页面准备完全")
34+
this.setData({
35+
theme: wx.getSystemInfoSync().theme || 'light'
36+
})
37+
38+
if (wx.onThemeChange) {
39+
wx.onThemeChange(({theme}) => {
40+
this.setData({theme})
41+
})
42+
}
43+
},
44+
},
45+
46+
methods: {
47+
// 对应案例的初始化逻辑,由统一的 behavior 触发
48+
init() {
49+
50+
console.log('start init');
51+
52+
// const plyLoader = new PLYLoader();
53+
// console.log('plyLoader', plyLoader)
54+
55+
// const plySrc = 'http://10.9.169.135:8000/ply/point_cloud_7000.ply';
56+
57+
const filePath = wx.env.USER_DATA_PATH + '/point.ply';
58+
wx.downloadFile({
59+
filePath: filePath,
60+
url: plySrc,
61+
success: (res) => {
62+
console.log("下载回调", res);
63+
const fs = wx.getFileSystemManager()
64+
fs.readFile({
65+
filePath: res.filePath,
66+
position: 0,
67+
success: async (res) => {
68+
console.log("读文件回调,结果返回为", res)
69+
70+
// const plyInfo = plyLoader.parsePLYBuffer(res.data);
71+
72+
const plyInfo = loadPly(res.data);
73+
74+
console.log("plyLoader return", plyInfo)
75+
76+
},
77+
fail(res) {
78+
wx.hideLoading();
79+
wx.showToast({
80+
title: res.errMsg,
81+
icon: 'none',
82+
duration: 2000
83+
})
84+
console.error(res)
85+
}
86+
});
87+
},
88+
fail(res) {
89+
wx.hideLoading();
90+
wx.showToast({
91+
title: res.errMsg,
92+
icon: 'none',
93+
duration: 2000
94+
})
95+
console.error(res)
96+
}
97+
});
98+
},
99+
100+
loop() {
101+
102+
}
103+
},
104+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"usingComponents": {
3+
"xr-frame-render-canvas": "../components/xr-frame-render/index"
4+
},
5+
"disableScroll": true,
6+
"renderer": "webview",
7+
"navigationBarTitleText": "高斯溅射预览"
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
<view class="page" data-weui-theme="{{theme}}">
3+
<view
4+
class="canvas-wrap" style="width: {{widthScale * 100}}%; height: {{heightScale * 100}}%"
5+
>
6+
<xr-frame-render-canvas
7+
disable-scroll
8+
id="canvas"
9+
width="{{width}}"
10+
height="{{height}}"
11+
style="width:{{domWidth}}px;height:{{domHeight}}px;"
12+
bind:sceneReady="handleXRSceneReady"
13+
></xr-frame-render-canvas>
14+
15+
</view>
16+
17+
<view class="hint-bottom page-body-text tc">
18+
<text>提示:渲染高斯溅射产物</text>
19+
</view>
20+
</view>
21+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.canvas-wrap {
2+
position: relative;
3+
width: 100%;
4+
background-color: #000;
5+
}
6+
7+
.canvas-wrap canvas {
8+
position: absolute;
9+
left: 0;
10+
top: 0;
11+
width: 100%;
12+
height: 100%;
13+
}
14+
15+
.canvas-wrap #canvas {
16+
position: absolute;
17+
left: 0;
18+
top: 0;
19+
width: 100%;
20+
height: 100%;
21+
}
22+
23+
24+
.hint-bottom {
25+
position: absolute;
26+
left: 20px;
27+
right: 20px;
28+
bottom: 20px;
29+
padding: 5px 10px;
30+
font-size: 14px;
31+
color: #fff;
32+
background-color: rgba(0, 0, 0, 0.4);
33+
border-radius: 6px;
34+
}
35+
36+
.hint-bottom .btn-wrap {
37+
display: flex;
38+
}
39+
40+
.hint-bottom .btn{
41+
flex: 1;
42+
margin: 10px 5px;
43+
font-size: 18px;
44+
line-height: 24px;
45+
}

0 commit comments

Comments
 (0)