Skip to content

Commit 040930b

Browse files
committed
feat(vk): 更新案例参数细节
1 parent 9e19ae0 commit 040930b

File tree

4 files changed

+76
-29
lines changed

4 files changed

+76
-29
lines changed

miniprogram/packageAPI/pages/ar/gaussian-splatting/gaussian-splatting-ar.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Component({
2323
renderByXRFrame: false, // 是否使用 xr-frame渲染
2424
renderByWebGL2: true, // 是否使用WebGL2渲染
2525
workerOn: true,
26-
maxGaussians: 50000,
26+
maxGaussians: 100000,
2727
},
2828
lifetimes: {
2929
/**
@@ -653,34 +653,52 @@ Component({
653653
let modelMatrixT = mat4.create();
654654
let modelMatrixR = mat4.create();
655655
let modelMatrixS = mat4.create();
656-
const splatScale = 0.2;
657-
mat4.scale(modelMatrixS, mat4.create(), [splatScale, splatScale, splatScale])
658-
mat4.rotate(modelMatrixR, modelMatrixS, 0, [0, 1, 0])
656+
let splatScale = 0.2;
657+
let splatRotationAngle = 0;
658+
let splatRotationFlag = [0, 1, 0];
659+
let splatTranslate = [0, 0, 0];
659660

660661
// 针对不同场景设置不同的 世界矩阵
661662
switch(id) {
662663
case 'room':
663-
mat4.translate(modelMatrixT, modelMatrixR, [0, -2, 1])
664+
splatScale = 0.6;
665+
splatTranslate = [0, -1, 0];
666+
splatRotationAngle = - Math.PI / 180 * 26;
667+
splatRotationFlag = [1, 0, 0];
664668
break;
665669
case 'garden':
666-
mat4.translate(modelMatrixT, modelMatrixR, [0, -1, 1])
670+
splatScale = 0.6;
671+
splatTranslate = [0, -2, 0];
672+
splatRotationAngle = - Math.PI / 180 * 20;
673+
splatRotationFlag = [1, 0, 0];
667674
break;
668675
case 'stump':
669-
mat4.translate(modelMatrixT, modelMatrixR, [0, 0.5, 0])
676+
splatScale = 0.6;
677+
splatTranslate = [0, 0, 0];
670678
break;
671679
case 'oneflower':
672-
mat4.translate(modelMatrixT, modelMatrixR, [0, -1.5, -3])
680+
splatScale = 0.2;
681+
splatTranslate = [-0.5, -2, -4];
682+
splatRotationAngle = - Math.PI / 180 * 40;
683+
splatRotationFlag = [1, 0, 0];
673684
break;
674685
case 'usj':
675-
mat4.translate(modelMatrixT, modelMatrixR, [0, 1, 0])
686+
splatTranslate = [0, 1, 0];
676687
break;
677688
case 'sakura':
678-
mat4.translate(modelMatrixT, modelMatrixR, [-1.6, 0, -1])
689+
splatTranslate = [-1.6, 0, -1];
690+
break;
691+
case '0517cruch':
692+
splatScale = 0.5;
693+
splatTranslate = [0, 0, 0];
679694
break;
680695
default:
681-
mat4.copy(modelMatrixT, modelMatrixR);
682696
break;
683697
}
698+
699+
mat4.scale(modelMatrixS, mat4.create(), [splatScale, splatScale, splatScale])
700+
mat4.rotate(modelMatrixR, modelMatrixS, splatRotationAngle, splatRotationFlag)
701+
mat4.translate(modelMatrixT, modelMatrixR, splatTranslate)
684702
mat4.copy(modelMatrixLocal, modelMatrixT);
685703

686704
// Y轴反转矩阵

miniprogram/packageAPI/pages/ar/gaussian-splatting/gaussian-splatting-ar.wxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<button class="btn" type="primary" data-id="oneflower" bindtap="onTapControl">盆栽</button>
3030
<button class="btn" type="primary" data-id="usj" bindtap="onTapControl">USJ马里奥</button>
3131
<button class="btn" type="primary" data-id="sakura" bindtap="onTapControl">樱花小道</button>
32+
<!-- <button class="btn" type="primary" data-id="0517cruch" bindtap="onTapControl">教堂花园</button> -->
3233
</view>
3334
</view>
3435
<view class="input-wrap">

miniprogram/packageAPI/pages/ar/gaussian-splatting/gaussian-splatting.js

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Component({
2020
renderByXRFrame: false, // 是否使用 xr-frame渲染
2121
renderByWebGL2: true, // 是否使用WebGL2渲染
2222
workerOn: true,
23-
maxGaussians: 50000,
23+
maxGaussians: 100000,
2424
},
2525
lifetimes: {
2626
/**
@@ -114,15 +114,19 @@ Component({
114114
let modelMatrixT = mat4.create();
115115
let modelMatrixR = mat4.create();
116116
let modelMatrixS = mat4.create();
117-
const splatScale = 1;
118-
mat4.scale(modelMatrixS, mat4.create(), [splatScale, splatScale, splatScale])
119-
mat4.rotate(modelMatrixR, modelMatrixS, 0, [0, 1, 0])
117+
let splatScale = 1;
118+
let splatRotationAngle = 0;
119+
let splatRotationFlag = [0, 1, 0];
120+
let splatTranslate = [0, 0, 0];
120121

121122
// 针对不同场景设置不同的 本地矩阵
122123
// Setup Camera
123124
switch(id) {
124125
case 'room':
125-
mat4.translate(modelMatrixT, modelMatrixR, [0, -2, 1])
126+
splatScale = 0.6;
127+
splatTranslate = [0, -3, 0];
128+
splatRotationAngle = - Math.PI / 180 * 26;
129+
splatRotationFlag = [1, 0, 0];
126130
this.camera.updateCameraInfo(
127131
// target
128132
[0, 0, 0],
@@ -135,7 +139,10 @@ Component({
135139
)
136140
break;
137141
case 'garden':
138-
mat4.translate(modelMatrixT, modelMatrixR, [0, -1, 1])
142+
splatScale = 0.6;
143+
splatTranslate = [0, -2, 0];
144+
splatRotationAngle = - Math.PI / 180 * 20;
145+
splatRotationFlag = [1, 0, 0];
139146
this.camera.updateCameraInfo(
140147
// target
141148
[0, 0, 0],
@@ -144,11 +151,12 @@ Component({
144151
// phi
145152
Math.PI/2,
146153
// raidus
147-
8
154+
2
148155
)
149156
break;
150157
case 'stump':
151-
mat4.translate(modelMatrixT, modelMatrixR, [0, 1, 0])
158+
splatScale = 0.5;
159+
splatTranslate = [0, 0, 0];
152160
this.camera.updateCameraInfo(
153161
// target
154162
[0, 0, 0],
@@ -157,11 +165,14 @@ Component({
157165
// phi
158166
Math.PI / 4,
159167
// raidus
160-
4
168+
2
161169
)
162170
break;
163171
case 'oneflower':
164-
mat4.translate(modelMatrixT, modelMatrixR, [0, -1.5, -3])
172+
splatScale = 0.1;
173+
splatTranslate = [-0.5, -2, -4];
174+
splatRotationAngle = - Math.PI / 180 * 40;
175+
splatRotationFlag = [1, 0, 0];
165176
this.camera.updateCameraInfo(
166177
// target
167178
[0, 0, 0],
@@ -170,11 +181,11 @@ Component({
170181
// phi
171182
Math.PI/2,
172183
// raidus
173-
12
184+
1
174185
)
175186
break;
176187
case 'usj':
177-
mat4.translate(modelMatrixT, modelMatrixR, [0, 1, 0])
188+
splatTranslate = [0, 1, 0];
178189
this.camera.updateCameraInfo(
179190
// target
180191
[0, 0, 0],
@@ -183,11 +194,11 @@ Component({
183194
// phi
184195
Math.PI / 2,
185196
// raidus
186-
4
197+
1
187198
)
188199
break;
189200
case 'sakura':
190-
mat4.translate(modelMatrixT, modelMatrixR, [-1.6, 0, -1])
201+
splatTranslate = [-1.6, 0, -1];
191202
this.camera.updateCameraInfo(
192203
// target
193204
[0, 0, 0],
@@ -196,11 +207,27 @@ Component({
196207
// phi
197208
Math.PI * 3 / 5,
198209
// raidus
199-
0.5
210+
1
211+
)
212+
break;
213+
case '0517cruch':
214+
splatTranslate = [0, 0, 0];
215+
this.camera.updateCameraInfo(
216+
// target
217+
[0, 0, 0],
218+
// theta
219+
-Math.PI / 2,
220+
// phi
221+
Math.PI/2,
222+
// raidus
223+
1
200224
)
201225
break;
202226
}
203227

228+
mat4.scale(modelMatrixS, mat4.create(), [splatScale, splatScale, splatScale])
229+
mat4.rotate(modelMatrixR, modelMatrixS, splatRotationAngle, splatRotationFlag)
230+
mat4.translate(modelMatrixT, modelMatrixR, splatTranslate)
204231
mat4.copy(modelMatrixLocal, modelMatrixT);
205232

206233
// Y轴反转矩阵
@@ -213,7 +240,7 @@ Component({
213240

214241
// 世界矩阵
215242
const modelWorld = mat4.create();
216-
// mat4.translate(modelWorld, mat4.create(), [0, 10, 0])
243+
// mat4.translate(modelWorld, mat4.create(), [0, 1, 0])
217244
mat4.multiply(splatModelMatrix, modelWorld, modelMatrixLocalFix);
218245
this.camera.modelMatrix = splatModelMatrix;
219246

@@ -395,7 +422,7 @@ Component({
395422
const cameraParameters = {
396423
up: [0, 1.0, 0.0],
397424
target: [0, 0, 0],
398-
camera: [Math.PI/2, Math.PI/2, 4], // theta phi radius
425+
camera: [Math.PI/2, Math.PI/2, 1], // theta phi radius
399426
}
400427
this.camera = new CameraWebGL(gl, this.worker, cameraParameters)
401428

@@ -450,7 +477,7 @@ Component({
450477
const projMatrix = this.camera.projMatrix;
451478
const viewMatrix = this.camera.viewMatrix;
452479
let modelMatrix = mat4.create();
453-
const cubeScale = 0.1;
480+
const cubeScale = 0.02;
454481
mat4.scale(modelMatrix, mat4.create(), [cubeScale, cubeScale, cubeScale])
455482
this.drawCubeMesh(gl, projMatrix, viewMatrix, modelMatrix)
456483

miniprogram/packageAPI/pages/ar/gaussian-splatting/gaussian-splatting.wxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<button class="btn" type="primary" data-id="oneflower" bindtap="onTapControl">盆栽</button>
3030
<button class="btn" type="primary" data-id="usj" bindtap="onTapControl">USJ马里奥</button>
3131
<button class="btn" type="primary" data-id="sakura" bindtap="onTapControl">樱花小道</button>
32+
<!-- <button class="btn" type="primary" data-id="0517cruch" bindtap="onTapControl">教堂花园</button> -->
3233
</view>
3334
</view>
3435
<view class="input-wrap">

0 commit comments

Comments
 (0)