mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 19:14:59 +02:00
removed spin2App.js
This commit is contained in:
parent
48e08276bf
commit
8b5f96a023
1 changed files with 0 additions and 175 deletions
|
@ -1,175 +0,0 @@
|
|||
/* global Script, Vec3, MyAvatar, Tablet, Messages, Quat,
|
||||
DebugDraw, Mat4, Entities, Xform, Controller, Camera, console, document*/
|
||||
|
||||
Script.registerValue("ROTATEAPP", true);
|
||||
|
||||
var TABLET_BUTTON_NAME = "ROTATE";
|
||||
var CHANGE_OF_BASIS_ROTATION = { x: 0, y: 1, z: 0, w: 0 };
|
||||
var HEAD_TURN_THRESHOLD = 25.0;
|
||||
var LOADING_DELAY = 500;
|
||||
var AVERAGING_RATE = 0.03;
|
||||
var headPoseAverageOrientation = { x: 0, y: 0, z: 0, w: 1 };
|
||||
|
||||
// define state readings constructor
|
||||
function StateReading(headPose, rhandPose, lhandPose, diffFromAverageEulers) {
|
||||
this.headPose = headPose;
|
||||
this.rhandPose = rhandPose;
|
||||
this.lhandPose = lhandPose;
|
||||
this.diffFromAverageEulers = diffFromAverageEulers;
|
||||
}
|
||||
|
||||
//define current state readings object for holding tracker readings and current differences from averages
|
||||
var currentStateReadings = new StateReading(Controller.getPoseValue(Controller.Standard.Head),
|
||||
Controller.getPoseValue(Controller.Standard.RightHand), Controller.getPoseValue(Controller.Standard.LeftHand),
|
||||
{ x: 0, y: 0, z: 0 });
|
||||
|
||||
//declare the checkbox constructor
|
||||
function AppCheckbox(type,id,eventType,isChecked) {
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.eventType = eventType;
|
||||
this.data = {value: isChecked};
|
||||
}
|
||||
|
||||
// declare the html slider constructor
|
||||
function AppProperty(name, type, eventType, signalType, setFunction, initValue, convertToThreshold, convertToSlider, signalOn) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.eventType = eventType;
|
||||
this.signalType = signalType;
|
||||
this.setValue = setFunction;
|
||||
this.value = initValue;
|
||||
this.get = function () {
|
||||
return this.value;
|
||||
};
|
||||
this.convertToThreshold = convertToThreshold;
|
||||
this.convertToSlider = convertToSlider;
|
||||
}
|
||||
|
||||
var HTML_URL = Script.resolvePath("file:///c:/dev/high fidelity/hifi/scripts/developer/stepAppExtra.html");
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
|
||||
function manageClick() {
|
||||
if (activated) {
|
||||
tablet.gotoHomeScreen();
|
||||
} else {
|
||||
tablet.gotoWebScreen(HTML_URL);
|
||||
}
|
||||
}
|
||||
|
||||
var tabletButton = tablet.addButton({
|
||||
text: TABLET_BUTTON_NAME,
|
||||
icon: Script.resolvePath("http://hifi-content.s3.amazonaws.com/angus/stepApp/foot.svg"),
|
||||
activeIcon: Script.resolvePath("http://hifi-content.s3.amazonaws.com/angus/stepApp/foot.svg")
|
||||
});
|
||||
|
||||
function onKeyPress(event) {
|
||||
if (event.text === "'") {
|
||||
// when the sensors are reset, then reset the mode.
|
||||
RESET_MODE = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onWebEventReceived(msg) {
|
||||
var message = JSON.parse(msg);
|
||||
print(" we have a message from html dialog " + message.type);
|
||||
propArray.forEach(function (prop) {
|
||||
if (prop.eventType === message.type) {
|
||||
prop.setValue(prop.convertToThreshold(message.data.value));
|
||||
print("message from " + prop.name);
|
||||
// break;
|
||||
}
|
||||
});
|
||||
checkBoxArray.forEach(function(cbox) {
|
||||
if (cbox.eventType === message.type) {
|
||||
cbox.data.value = message.data.value;
|
||||
// break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initAppForm() {
|
||||
print("step app is loaded: " + documentLoaded);
|
||||
propArray.forEach(function (prop) {
|
||||
print(prop.name);
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
"type": "trigger",
|
||||
"id": prop.signalType,
|
||||
"data": { "value": "green" }
|
||||
}));
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
"type": "slider",
|
||||
"id": prop.name,
|
||||
"data": { "value": prop.convertToSlider(prop.value) }
|
||||
}));
|
||||
});
|
||||
checkBoxArray.forEach(function(cbox) {
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
"type": "checkboxtick",
|
||||
"id": cbox.id,
|
||||
"data": { value: cbox.data.value }
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function onScreenChanged(type, url) {
|
||||
print("Screen changed");
|
||||
if (type === "Web" && url === HTML_URL) {
|
||||
if (!activated) {
|
||||
// hook up to event bridge
|
||||
tablet.webEventReceived.connect(onWebEventReceived);
|
||||
print("after connect web event");
|
||||
MyAvatar.hmdLeanRecenterEnabled = false;
|
||||
Script.setTimeout(initAppForm, LOADING_DELAY);
|
||||
}
|
||||
activated = true;
|
||||
} else {
|
||||
if (activated) {
|
||||
// disconnect from event bridge
|
||||
tablet.webEventReceived.disconnect(onWebEventReceived);
|
||||
}
|
||||
activated = false;
|
||||
}
|
||||
}
|
||||
|
||||
function update(dt) {
|
||||
|
||||
// Update head information
|
||||
currentStateReadings.headPose = Controller.getPoseValue(Controller.Standard.Head);
|
||||
currentStateReadings.rhandPose = Controller.getPoseValue(Controller.Standard.RightHand);
|
||||
currentStateReadings.lhandPose = Controller.getPoseValue(Controller.Standard.LeftHand);
|
||||
|
||||
var headPoseRigSpace = Quat.multiply(CHANGE_OF_BASIS_ROTATION, currentStateReadings.headPose.rotation);
|
||||
headPoseAverageOrientation = Quat.slerp(headPoseAverageOrientation, headPoseRigSpace, AVERAGING_RATE);
|
||||
var headPoseAverageEulers = Quat.safeEulerAngles(headPoseAverageOrientation);
|
||||
|
||||
if (Math.abs(headPoseAverageEulers.y) > HEAD_TURN_THRESHOLD) {
|
||||
// Turn feet
|
||||
MyAvatar.triggerRotationRecenter();
|
||||
headPoseAverageOrientation = { x: 0, y: 0, z: 0, w: 1 };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function shutdownTabletApp() {
|
||||
tablet.removeButton(tabletButton);
|
||||
if (activated) {
|
||||
tablet.webEventReceived.disconnect(onWebEventReceived);
|
||||
tablet.gotoHomeScreen();
|
||||
}
|
||||
tablet.screenChanged.disconnect(onScreenChanged);
|
||||
}
|
||||
|
||||
tabletButton.clicked.connect(manageClick);
|
||||
tablet.screenChanged.connect(onScreenChanged);
|
||||
|
||||
Script.update.connect(update);
|
||||
|
||||
Controller.keyPressEvent.connect(onKeyPress);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
MyAvatar.hmdLeanRecenterEnabled = true;
|
||||
Script.update.disconnect(update);
|
||||
shutdownTabletApp();
|
||||
});
|
Loading…
Reference in a new issue