Skip to content

Commit 4b6eb30

Browse files
committed
imp: gaze third person compensation
1 parent cac0703 commit 4b6eb30

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/core/entities/PlayerLocal.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ const m1 = new THREE.Matrix4()
3939
const m2 = new THREE.Matrix4()
4040
const m3 = new THREE.Matrix4()
4141

42+
const gazeTiltAngle = 10 * DEG2RAD
43+
const gazeTiltAxis = new THREE.Vector3(1, 0, 0) // X-axis for pitch
44+
4245
// TODO: de-dup createVRMFactory.js has a copy
4346
const Modes = {
4447
IDLE: 0,
@@ -911,6 +914,11 @@ export class PlayerLocal extends Entity {
911914
this.gaze.copy(FORWARD).applyQuaternion(this.world.xr.camera.quaternion)
912915
} else {
913916
this.gaze.copy(FORWARD).applyQuaternion(this.cam.quaternion)
917+
if (!this.firstPerson) {
918+
// tilt slightly up in third person as people look from above
919+
v1.copy(gazeTiltAxis).applyQuaternion(this.cam.quaternion) // tilt in cam space
920+
this.gaze.applyAxisAngle(v1, gazeTiltAngle) // positive for upward tilt
921+
}
914922
}
915923

916924
// apply locomotion

src/core/extras/createVRMFactory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ export function createVRMFactory(glb, setupMaterial) {
318318
minAngle: -30,
319319
maxAngle: 30,
320320
smoothing: 0.4,
321-
weight: 0.5,
321+
weight: 0.6,
322322
})
323323
aimBone('head', loco.gazeDir, delta, {
324324
minAngle: -30,
325325
maxAngle: 30,
326326
smoothing: 0.4,
327-
weight: 1,
327+
weight: 0.6,
328328
})
329329
}
330330
// tvrm.humanoid.update(elapsed)

0 commit comments

Comments
 (0)