mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-24 23:58:46 +02:00
fix stick.js
This commit is contained in:
parent
304fe49628
commit
7f3f202567
1 changed files with 5 additions and 13 deletions
|
@ -10,7 +10,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
var hand = "left";
|
var hand = "right";
|
||||||
var nullActionID = "00000000-0000-0000-0000-000000000000";
|
var nullActionID = "00000000-0000-0000-0000-000000000000";
|
||||||
var controllerID;
|
var controllerID;
|
||||||
var controllerActive;
|
var controllerActive;
|
||||||
|
@ -32,7 +32,7 @@ function makeNewStick() {
|
||||||
modelURL: "https://hifi-public.s3.amazonaws.com/eric/models/stick.fbx",
|
modelURL: "https://hifi-public.s3.amazonaws.com/eric/models/stick.fbx",
|
||||||
compoundShapeURL: "https://hifi-public.s3.amazonaws.com/eric/models/stick.obj",
|
compoundShapeURL: "https://hifi-public.s3.amazonaws.com/eric/models/stick.obj",
|
||||||
dimensions: {x: .11, y: .11, z: 1.0},
|
dimensions: {x: .11, y: .11, z: 1.0},
|
||||||
position: MyAvatar.getRightPalmPosition(), // initial position doesn't matter, as long as it's close
|
position: MyAvatar.rightHandPosition, // initial position doesn't matter, as long as it's close
|
||||||
rotation: MyAvatar.orientation,
|
rotation: MyAvatar.orientation,
|
||||||
damping: .1,
|
damping: .1,
|
||||||
collisionSoundURL: "http://public.highfidelity.io/sounds/Collisions-hitsandslaps/67LCollision07.wav",
|
collisionSoundURL: "http://public.highfidelity.io/sounds/Collisions-hitsandslaps/67LCollision07.wav",
|
||||||
|
@ -84,23 +84,15 @@ function mouseMoveEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function initControls(){
|
|
||||||
if (hand == "right") {
|
|
||||||
controllerID = 3; // right handed
|
|
||||||
} else {
|
|
||||||
controllerID = 4; // left handed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function update(deltaTime){
|
function update(deltaTime){
|
||||||
var palmPosition = Controller.getSpatialControlPosition(controllerID);
|
var handPose = (hand == "right") ? MyAvatar.rightHandPose : MyAvatar.leftHandPose;
|
||||||
|
var palmPosition = handPose.translation;
|
||||||
controllerActive = (Vec3.length(palmPosition) > 0);
|
controllerActive = (Vec3.length(palmPosition) > 0);
|
||||||
if(!controllerActive){
|
if(!controllerActive){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stickOrientation = Controller.getSpatialControlRawRotation(controllerID);
|
stickOrientation = handPose.rotation;
|
||||||
var adjustment = Quat.fromPitchYawRollDegrees(180, 0, 0);
|
var adjustment = Quat.fromPitchYawRollDegrees(180, 0, 0);
|
||||||
stickOrientation = Quat.multiply(stickOrientation, adjustment);
|
stickOrientation = Quat.multiply(stickOrientation, adjustment);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue