mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 03:03:35 +02:00
viveTouchpadTest.js: don't throw if there is no Vive controller attached.
This commit is contained in:
parent
c91455a291
commit
95ef543f25
1 changed files with 20 additions and 16 deletions
|
@ -46,25 +46,29 @@ function shutdown() {
|
||||||
}
|
}
|
||||||
Script.scriptEnding.connect(shutdown);
|
Script.scriptEnding.connect(shutdown);
|
||||||
|
|
||||||
prevPose = Controller.getPoseValue(Controller.Hardware.Vive.LeftHand);
|
function viveIsConnected() {
|
||||||
|
return Controller.Hardware.Vive;
|
||||||
|
}
|
||||||
|
|
||||||
function update(dt) {
|
function update(dt) {
|
||||||
var thumbDown = Controller.getValue(Controller.Hardware.Vive.RSTouch);
|
if (viveIsConnected()) {
|
||||||
if (thumbDown) {
|
var thumbDown = Controller.getValue(Controller.Hardware.Vive.RSTouch);
|
||||||
var x = Controller.getValue(Controller.Hardware.Vive.RX);
|
if (thumbDown) {
|
||||||
var y = Controller.getValue(Controller.Hardware.Vive.RY);
|
var x = Controller.getValue(Controller.Hardware.Vive.RX);
|
||||||
var xOffset = Vec3.multiply(boxZAxis, x);
|
var y = Controller.getValue(Controller.Hardware.Vive.RY);
|
||||||
var yOffset = Vec3.multiply(boxYAxis, y);
|
var xOffset = Vec3.multiply(boxZAxis, x);
|
||||||
var offset = Vec3.sum(xOffset, yOffset);
|
var yOffset = Vec3.multiply(boxYAxis, y);
|
||||||
Entities.editEntity(boxEntity, {position: Vec3.sum(boxPosition, offset)});
|
var offset = Vec3.sum(xOffset, yOffset);
|
||||||
|
Entities.editEntity(boxEntity, {position: Vec3.sum(boxPosition, offset)});
|
||||||
|
}
|
||||||
|
if (thumbDown && !prevThumbDown) {
|
||||||
|
Entities.editEntity(boxEntity, {color: GREEN});
|
||||||
|
}
|
||||||
|
if (!thumbDown && prevThumbDown) {
|
||||||
|
Entities.editEntity(boxEntity, {color: GRAY});
|
||||||
|
}
|
||||||
|
prevThumbDown = thumbDown;
|
||||||
}
|
}
|
||||||
if (thumbDown && !prevThumbDown) {
|
|
||||||
Entities.editEntity(boxEntity, {color: GREEN});
|
|
||||||
}
|
|
||||||
if (!thumbDown && prevThumbDown) {
|
|
||||||
Entities.editEntity(boxEntity, {color: GRAY});
|
|
||||||
}
|
|
||||||
prevThumbDown = thumbDown;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
|
|
Loading…
Reference in a new issue