mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
handControllerMouse.js: transform hand controllers into sensor frame
This commit is contained in:
parent
3d71226f72
commit
26b4c904f3
1 changed files with 10 additions and 10 deletions
|
@ -57,6 +57,7 @@ var filteredRotatedRight = Vec3.UNIT_NEG_Y;
|
|||
|
||||
Script.update.connect(function(deltaTime) {
|
||||
|
||||
// avatar frame
|
||||
var poseRight = Controller.getPoseValue(Controller.Standard.RightHand);
|
||||
var poseLeft = Controller.getPoseValue(Controller.Standard.LeftHand);
|
||||
|
||||
|
@ -65,12 +66,13 @@ Script.update.connect(function(deltaTime) {
|
|||
var screenSizeX = screenSize.x;
|
||||
var screenSizeY = screenSize.y;
|
||||
|
||||
var rotatedRight = Vec3.multiplyQbyV(poseRight.rotation, Vec3.UNIT_NEG_Y);
|
||||
var rotatedLeft = Vec3.multiplyQbyV(poseLeft.rotation, Vec3.UNIT_NEG_Y);
|
||||
// transform hand facing vectors from avatar frame into sensor frame.
|
||||
var worldToSensorMatrix = Mat4.inverse(MyAvatar.sensorToWorldMatrix);
|
||||
var rotatedRight = Mat4.transformVector(worldToSensorMatrix, Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.multiplyQbyV(poseRight.rotation, Vec3.UNIT_NEG_Y)));
|
||||
var rotatedLeft = Mat4.transformVector(worldToSensorMatrix, Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.multiplyQbyV(poseLeft.rotation, Vec3.UNIT_NEG_Y)));
|
||||
|
||||
lastRotatedRight = rotatedRight;
|
||||
|
||||
|
||||
// Decide which hand should be controlling the pointer
|
||||
// by comparing which one is moving more, and by
|
||||
// tending to stay with the one moving more.
|
||||
|
@ -121,5 +123,3 @@ Script.update.connect(function(deltaTime) {
|
|||
Script.scriptEnding.connect(function(){
|
||||
mapping.disable();
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue