Merge pull request #8880 from hyperlogic/feature/controller-display
Show hand controllers in away.js
After Width: | Height: | Size: 788 KiB |
After Width: | Height: | Size: 558 KiB |
BIN
interface/resources/meshes/controller/vive_body.fbx
Normal file
BIN
interface/resources/meshes/controller/vive_button.fbx
Normal file
BIN
interface/resources/meshes/controller/vive_l_grip.fbx
Normal file
BIN
interface/resources/meshes/controller/vive_r_grip.fbx
Normal file
BIN
interface/resources/meshes/controller/vive_sys_button.fbx
Normal file
BIN
interface/resources/meshes/controller/vive_tips.fbm/Blank.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
interface/resources/meshes/controller/vive_tips.fbm/Grip.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
interface/resources/meshes/controller/vive_tips.fbm/Rotate.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
interface/resources/meshes/controller/vive_tips.fbm/Teleport.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
interface/resources/meshes/controller/vive_tips.fbm/Trigger.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
interface/resources/meshes/controller/vive_tips.fbx
Normal file
BIN
interface/resources/meshes/controller/vive_trackpad.fbx
Normal file
BIN
interface/resources/meshes/controller/vive_trigger.fbx
Normal file
|
@ -57,6 +57,20 @@ bool HMDScriptingInterface::isHandControllerAvailable() {
|
|||
return PluginUtils::isHandControllerAvailable();
|
||||
}
|
||||
|
||||
void HMDScriptingInterface::requestShowHandControllers() {
|
||||
_showHandControllersCount++;
|
||||
emit shouldShowHandControllersChanged();
|
||||
}
|
||||
|
||||
void HMDScriptingInterface::requestHideHandControllers() {
|
||||
_showHandControllersCount--;
|
||||
emit shouldShowHandControllersChanged();
|
||||
}
|
||||
|
||||
bool HMDScriptingInterface::shouldShowHandControllers() const {
|
||||
return _showHandControllersCount > 0;
|
||||
}
|
||||
|
||||
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
|
||||
glm::vec3 hudIntersection;
|
||||
auto instance = DependencyManager::get<HMDScriptingInterface>();
|
||||
|
|
|
@ -41,6 +41,10 @@ public:
|
|||
Q_INVOKABLE bool isHMDAvailable();
|
||||
Q_INVOKABLE bool isHandControllerAvailable();
|
||||
|
||||
Q_INVOKABLE void requestShowHandControllers();
|
||||
Q_INVOKABLE void requestHideHandControllers();
|
||||
Q_INVOKABLE bool shouldShowHandControllers() const;
|
||||
|
||||
Q_INVOKABLE bool setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) const;
|
||||
|
||||
Q_INVOKABLE void disableHandLasers(int hands) const;
|
||||
|
@ -61,6 +65,9 @@ public:
|
|||
// rotate the overlay UI sphere so that it is centered about the the current HMD position and orientation
|
||||
Q_INVOKABLE void centerUI();
|
||||
|
||||
signals:
|
||||
bool shouldShowHandControllersChanged();
|
||||
|
||||
public:
|
||||
HMDScriptingInterface();
|
||||
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
||||
|
@ -77,6 +84,7 @@ private:
|
|||
|
||||
bool getHUDLookAtPosition3D(glm::vec3& result) const;
|
||||
glm::mat4 getWorldHMDMatrix() const;
|
||||
std::atomic<int> _showHandControllersCount { 0 };
|
||||
};
|
||||
|
||||
#endif // hifi_HMDScriptingInterface_h
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <EntityScriptingInterface.h>
|
||||
#include <MessagesClient.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <PathUtils.h>
|
||||
#include <ResourceScriptingInterface.h>
|
||||
#include <NodeList.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
@ -1136,6 +1137,10 @@ QUrl ScriptEngine::resolvePath(const QString& include) const {
|
|||
return url;
|
||||
}
|
||||
|
||||
QUrl ScriptEngine::resourcesPath() const {
|
||||
return QUrl::fromLocalFile(PathUtils::resourcesPath());
|
||||
}
|
||||
|
||||
void ScriptEngine::print(const QString& message) {
|
||||
emit printedMessage(message);
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ public:
|
|||
Q_INVOKABLE void clearTimeout(QObject* timer) { stopTimer(reinterpret_cast<QTimer*>(timer)); }
|
||||
Q_INVOKABLE void print(const QString& message);
|
||||
Q_INVOKABLE QUrl resolvePath(const QString& path) const;
|
||||
Q_INVOKABLE QUrl resourcesPath() const;
|
||||
|
||||
// Entity Script Related methods
|
||||
static void loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const EntityItemID& entityID, const QString& entityScript, bool forceRedownload);
|
||||
|
|
|
@ -23,6 +23,7 @@ var DEFAULT_SCRIPTS = [
|
|||
"system/mod.js",
|
||||
"system/selectAudioDevice.js",
|
||||
"system/notifications.js",
|
||||
"system/controllers/controllerDisplayManager.js",
|
||||
"system/controllers/handControllerGrab.js",
|
||||
"system/controllers/handControllerPointer.js",
|
||||
"system/controllers/squeezeHands.js",
|
||||
|
@ -125,4 +126,4 @@ Script.scriptEnding.connect(function() {
|
|||
removeMenuItem();
|
||||
});
|
||||
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
|
|
|
@ -177,6 +177,8 @@ function goAway(fromStartup) {
|
|||
playAwayAnimation(); // animation is still seen by others
|
||||
showOverlay();
|
||||
|
||||
HMD.requestShowHandControllers();
|
||||
|
||||
// tell the Reticle, we want to stop capturing the mouse until we come back
|
||||
Reticle.allowMouseCapture = false;
|
||||
// Allow users to find their way to other applications, our menus, etc.
|
||||
|
@ -215,6 +217,8 @@ function goActive() {
|
|||
MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting.
|
||||
stopAwayAnimation();
|
||||
|
||||
HMD.requestHideHandControllers();
|
||||
|
||||
// update the UI sphere to be centered about the current HMD orientation.
|
||||
HMD.centerUI();
|
||||
|
||||
|
|
|
@ -1,26 +1,45 @@
|
|||
var VISIBLE_BY_DEFAULT = false;
|
||||
//
|
||||
// controllerDisplay.js
|
||||
//
|
||||
// Created by Anthony J. Thibault on 10/20/16
|
||||
// Originally created by Ryan Huffman on 9/21/2016
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
/* globals createControllerDisplay:true deleteControllerDisplay:true */
|
||||
|
||||
var PARENT_ID = "{00000000-0000-0000-0000-000000000001}";
|
||||
|
||||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
function clamp(value, min, max) {
|
||||
if (value < min) {
|
||||
return min;
|
||||
} else if (value > max) {
|
||||
return max;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function resolveHardware(path) {
|
||||
var parts = path.split(".");
|
||||
function resolveInner(base, path, i) {
|
||||
if (i >= path.length) {
|
||||
return base;
|
||||
}
|
||||
return resolveInner(base[path[i]], path, ++i);
|
||||
}
|
||||
return resolveInner(Controller.Hardware, parts, 0);
|
||||
}
|
||||
|
||||
createControllerDisplay = function(config) {
|
||||
var controllerDisplay = {
|
||||
overlays: [],
|
||||
partOverlays: {
|
||||
},
|
||||
parts: {
|
||||
},
|
||||
partOverlays: {},
|
||||
parts: {},
|
||||
mappingName: "mapping-display",
|
||||
|
||||
setVisible: function(visible) {
|
||||
print("CONTROLLER_DISPLAY::Setting visible", this.overlays.length);
|
||||
for (var i = 0; i < this.overlays.length; ++i) {
|
||||
print("i", i, this.overlays[i]);
|
||||
Overlays.editOverlay(this.overlays[i], {
|
||||
visible: visible
|
||||
});
|
||||
|
@ -30,7 +49,6 @@ createControllerDisplay = function(config) {
|
|||
setPartVisible: function(partName, visible) {
|
||||
return;
|
||||
if (partName in this.partOverlays) {
|
||||
debug("Setting part visible", partName, visible);
|
||||
for (var i = 0; i < this.partOverlays[partName].length; ++i) {
|
||||
Overlays.editOverlay(this.partOverlays[partName][i], {
|
||||
//visible: visible
|
||||
|
@ -41,7 +59,6 @@ createControllerDisplay = function(config) {
|
|||
|
||||
setLayerForPart: function(partName, layerName) {
|
||||
if (partName in this.parts) {
|
||||
debug("Setting layer...", partName, layerName);
|
||||
var part = this.parts[partName];
|
||||
if (part.textureLayers && layerName in part.textureLayers) {
|
||||
var layer = part.textureLayers[layerName];
|
||||
|
@ -50,6 +67,9 @@ createControllerDisplay = function(config) {
|
|||
textures[part.textureName] = layer.defaultTextureURL;
|
||||
}
|
||||
for (var i = 0; i < this.partOverlays[partName].length; ++i) {
|
||||
|
||||
// AJT: REMOVE
|
||||
print("AJT: Overlays.editOverlays(" + partName + ", " + i + ", { textures: " + JSON.stringify(textures) + " })");
|
||||
Overlays.editOverlay(this.partOverlays[partName][i], {
|
||||
textures: textures
|
||||
});
|
||||
|
@ -64,8 +84,7 @@ createControllerDisplay = function(config) {
|
|||
var position = controller.position;
|
||||
|
||||
if (controller.naturalPosition) {
|
||||
position = Vec3.sum(Vec3.multiplyQbyV(
|
||||
controller.rotation, controller.naturalPosition), position);
|
||||
position = Vec3.sum(Vec3.multiplyQbyV(controller.rotation, controller.naturalPosition), position);
|
||||
}
|
||||
|
||||
var overlayID = Overlays.addOverlay("model", {
|
||||
|
@ -75,26 +94,17 @@ createControllerDisplay = function(config) {
|
|||
localPosition: position,
|
||||
parentID: PARENT_ID,
|
||||
parentJointIndex: controller.jointIndex,
|
||||
ignoreRayIntersection: true,
|
||||
ignoreRayIntersection: true
|
||||
});
|
||||
|
||||
controllerDisplay.overlays.push(overlayID);
|
||||
overlayID = null;
|
||||
|
||||
function clamp(value, min, max) {
|
||||
if (value < min) {
|
||||
return min;
|
||||
} else if (value > max) {
|
||||
return max
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
if (controller.parts) {
|
||||
for (var partName in controller.parts) {
|
||||
var part = controller.parts[partName];
|
||||
var partPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, part.naturalPosition));
|
||||
var innerRotation = controller.rotation
|
||||
var innerRotation = controller.rotation;
|
||||
|
||||
controllerDisplay.parts[partName] = controller.parts[partName];
|
||||
|
||||
|
@ -104,7 +114,7 @@ createControllerDisplay = function(config) {
|
|||
localRotation: innerRotation,
|
||||
parentID: PARENT_ID,
|
||||
parentJointIndex: controller.jointIndex,
|
||||
ignoreRayIntersection: true,
|
||||
ignoreRayIntersection: true
|
||||
};
|
||||
|
||||
if (part.defaultTextureLayer) {
|
||||
|
@ -113,10 +123,9 @@ createControllerDisplay = function(config) {
|
|||
properties['textures'] = textures;
|
||||
}
|
||||
|
||||
var overlayID = Overlays.addOverlay("model", properties);
|
||||
overlayID = Overlays.addOverlay("model", properties);
|
||||
|
||||
if (part.type == "rotational") {
|
||||
var range = part.maxValue - part.minValue;
|
||||
if (part.type === "rotational") {
|
||||
mapping.from([part.input]).peek().to(function(controller, overlayID, part) {
|
||||
return function(value) {
|
||||
value = clamp(value, part.minValue, part.maxValue);
|
||||
|
@ -127,7 +136,7 @@ createControllerDisplay = function(config) {
|
|||
|
||||
var offset = { x: 0, y: 0, z: 0 };
|
||||
if (part.origin) {
|
||||
var offset = Vec3.multiplyQbyV(rotation, part.origin);
|
||||
offset = Vec3.multiplyQbyV(rotation, part.origin);
|
||||
offset = Vec3.subtract(offset, part.origin);
|
||||
}
|
||||
|
||||
|
@ -138,20 +147,9 @@ createControllerDisplay = function(config) {
|
|||
localPosition: partPosition,
|
||||
localRotation: Quat.multiply(controller.rotation, rotation)
|
||||
});
|
||||
}
|
||||
};
|
||||
}(controller, overlayID, part));
|
||||
} else if (part.type == "touchpad") {
|
||||
function resolveHardware(path) {
|
||||
var parts = path.split(".");
|
||||
function resolveInner(base, path, i) {
|
||||
if (i >= path.length) {
|
||||
return base;
|
||||
}
|
||||
return resolveInner(base[path[i]], path, ++i);
|
||||
}
|
||||
return resolveInner(Controller.Hardware, parts, 0);
|
||||
}
|
||||
|
||||
} else if (part.type === "touchpad") {
|
||||
var visibleInput = resolveHardware(part.visibleInput);
|
||||
var xinput = resolveHardware(part.xInput);
|
||||
var yinput = resolveHardware(part.yInput);
|
||||
|
@ -165,7 +163,8 @@ createControllerDisplay = function(config) {
|
|||
});
|
||||
mapping.from([yinput]).peek().invert().to(function(value) {
|
||||
});
|
||||
} else if (part.type == "static") {
|
||||
} else if (part.type === "static") {
|
||||
// do nothing
|
||||
} else {
|
||||
print("TYPE NOT SUPPORTED: ", part.type);
|
||||
}
|
||||
|
@ -180,16 +179,11 @@ createControllerDisplay = function(config) {
|
|||
}
|
||||
Controller.enableMapping(controllerDisplay.mappingName);
|
||||
return controllerDisplay;
|
||||
}
|
||||
|
||||
ControllerDisplay = function() {
|
||||
};
|
||||
|
||||
deleteControllerDisplay = function(controllerDisplay) {
|
||||
print("Deleting controller display");
|
||||
for (var i = 0; i < controllerDisplay.overlays.length; ++i) {
|
||||
Overlays.deleteOverlay(controllerDisplay.overlays[i]);
|
||||
}
|
||||
Controller.disableMapping(controllerDisplay.mappingName);
|
||||
}
|
||||
|
||||
};
|
|
@ -1,49 +1,24 @@
|
|||
if (!Function.prototype.bind) {
|
||||
Function.prototype.bind = function(oThis) {
|
||||
if (typeof this !== 'function') {
|
||||
// closest thing possible to the ECMAScript 5
|
||||
// internal IsCallable function
|
||||
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
|
||||
}
|
||||
//
|
||||
// controllerDisplayManager.js
|
||||
//
|
||||
// Created by Anthony J. Thibault on 10/20/16
|
||||
// Originally created by Ryan Huffman on 9/21/2016
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
var aArgs = Array.prototype.slice.call(arguments, 1),
|
||||
fToBind = this,
|
||||
fNOP = function() {},
|
||||
fBound = function() {
|
||||
return fToBind.apply(this instanceof fNOP
|
||||
? this
|
||||
: oThis,
|
||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
||||
};
|
||||
/* globals ControllerDisplayManager:true createControllerDisplay deleteControllerDisplay
|
||||
VIVE_CONTROLLER_CONFIGURATION_LEFT VIVE_CONTROLLER_CONFIGURATION_RIGHT */
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
|
||||
if (this.prototype) {
|
||||
// Function.prototype doesn't have a prototype property
|
||||
fNOP.prototype = this.prototype;
|
||||
}
|
||||
fBound.prototype = new fNOP();
|
||||
|
||||
return fBound;
|
||||
};
|
||||
}
|
||||
|
||||
Script.setTimeout(function() { print('timeout') }, 100);
|
||||
(function () {
|
||||
|
||||
Script.include("controllerDisplay.js");
|
||||
Script.include("viveControllerConfiguration.js");
|
||||
|
||||
function debug() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("CONTROLLER DEBUG:");
|
||||
print.apply(this, args);
|
||||
}
|
||||
|
||||
var zeroPosition = { x: 0, y: 0, z: 0 };
|
||||
var zeroRotation = { x: 0, y: 0, z: 0, w: 1 };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Management of controller display //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Management of controller display
|
||||
//
|
||||
ControllerDisplayManager = function() {
|
||||
var self = this;
|
||||
var controllerLeft = null;
|
||||
|
@ -51,30 +26,24 @@ ControllerDisplayManager = function() {
|
|||
var controllerCheckerIntervalID = null;
|
||||
|
||||
this.setLeftVisible = function(visible) {
|
||||
print("settings controller display to visible");
|
||||
if (controllerLeft) {
|
||||
print("doign it...", visible);
|
||||
controllerLeft.setVisible(visible);
|
||||
}
|
||||
};
|
||||
|
||||
this.setRightVisible = function(visible) {
|
||||
print("settings controller display to visible");
|
||||
if (controllerRight) {
|
||||
print("doign it...", visible);
|
||||
controllerRight.setVisible(visible);
|
||||
}
|
||||
};
|
||||
|
||||
function updateControllers() {
|
||||
if (HMD.active) {
|
||||
if (HMD.active && HMD.shouldShowHandControllers()) {
|
||||
if ("Vive" in Controller.Hardware) {
|
||||
if (!controllerLeft) {
|
||||
debug("Found vive left!");
|
||||
controllerLeft = createControllerDisplay(VIVE_CONTROLLER_CONFIGURATION_LEFT);
|
||||
}
|
||||
if (!controllerRight) {
|
||||
debug("Found vive right!");
|
||||
controllerRight = createControllerDisplay(VIVE_CONTROLLER_CONFIGURATION_RIGHT);
|
||||
}
|
||||
// We've found the controllers, we no longer need to look for active controllers
|
||||
|
@ -83,17 +52,14 @@ ControllerDisplayManager = function() {
|
|||
controllerCheckerIntervalID = null;
|
||||
}
|
||||
} else {
|
||||
debug("HMD active, but no controllers found");
|
||||
self.deleteControllerDisplays();
|
||||
if (controllerCheckerIntervalID == null) {
|
||||
if (!controllerCheckerIntervalID) {
|
||||
controllerCheckerIntervalID = Script.setInterval(updateControllers, 1000);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debug("HMD inactive");
|
||||
// We aren't in HMD mode, we no longer need to look for active controllers
|
||||
if (controllerCheckerIntervalID) {
|
||||
debug("Clearing controller checker interval");
|
||||
Script.clearInterval(controllerCheckerIntervalID);
|
||||
controllerCheckerIntervalID = null;
|
||||
}
|
||||
|
@ -103,39 +69,34 @@ ControllerDisplayManager = function() {
|
|||
|
||||
Messages.subscribe('Controller-Display');
|
||||
var handleMessages = function(channel, message, sender) {
|
||||
var i, data, name, visible;
|
||||
if (!controllerLeft && !controllerRight) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender === MyAvatar.sessionUUID) {
|
||||
if (channel === 'Controller-Display') {
|
||||
var data = JSON.parse(message);
|
||||
var name = data.name;
|
||||
var visible = data.visible;
|
||||
//c.setDisplayAnnotation(name, visible);
|
||||
data = JSON.parse(message);
|
||||
name = data.name;
|
||||
visible = data.visible;
|
||||
if (controllerLeft) {
|
||||
if (name in controllerLeft.annotations) {
|
||||
debug("hiding");
|
||||
for (var i = 0; i < controllerLeft.annotations[name].length; ++i) {
|
||||
debug("hiding", i);
|
||||
for (i = 0; i < controllerLeft.annotations[name].length; ++i) {
|
||||
Overlays.editOverlay(controllerLeft.annotations[name][i], { visible: visible });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (controllerRight) {
|
||||
if (name in controllerRight.annotations) {
|
||||
debug("hiding");
|
||||
for (var i = 0; i < controllerRight.annotations[name].length; ++i) {
|
||||
debug("hiding", i);
|
||||
for (i = 0; i < controllerRight.annotations[name].length; ++i) {
|
||||
Overlays.editOverlay(controllerRight.annotations[name][i], { visible: visible });
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (channel === 'Controller-Display-Parts') {
|
||||
debug('here part');
|
||||
var data = JSON.parse(message);
|
||||
for (var name in data) {
|
||||
var visible = data[name];
|
||||
data = JSON.parse(message);
|
||||
for (name in data) {
|
||||
visible = data[name];
|
||||
if (controllerLeft) {
|
||||
controllerLeft.setPartVisible(name, visible);
|
||||
}
|
||||
|
@ -144,8 +105,8 @@ ControllerDisplayManager = function() {
|
|||
}
|
||||
}
|
||||
} else if (channel === 'Controller-Set-Part-Layer') {
|
||||
var data = JSON.parse(message);
|
||||
for (var name in data) {
|
||||
data = JSON.parse(message);
|
||||
for (name in data) {
|
||||
var layer = data[name];
|
||||
if (controllerLeft) {
|
||||
controllerLeft.setLayerForPart(name, layer);
|
||||
|
@ -154,20 +115,17 @@ ControllerDisplayManager = function() {
|
|||
controllerRight.setLayerForPart(name, layer);
|
||||
}
|
||||
}
|
||||
} else if (channel == 'Hifi-Object-Manipulation') {// && sender == MyAvatar.sessionUUID) {
|
||||
//print("got manip");
|
||||
var data = JSON.parse(message);
|
||||
//print("post data", data);
|
||||
var visible = data.action != 'equip';
|
||||
//print("Calling...");
|
||||
if (data.joint == "LeftHand") {
|
||||
} else if (channel === 'Hifi-Object-Manipulation') {
|
||||
data = JSON.parse(message);
|
||||
visible = data.action !== 'equip';
|
||||
if (data.joint === "LeftHand") {
|
||||
self.setLeftVisible(visible);
|
||||
} else if (data.joint == "RightHand") {
|
||||
} else if (data.joint === "RightHand") {
|
||||
self.setRightVisible(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Messages.messageReceived.connect(handleMessages);
|
||||
|
||||
|
@ -183,12 +141,24 @@ ControllerDisplayManager = function() {
|
|||
};
|
||||
|
||||
this.destroy = function() {
|
||||
print("Destroying controller display");
|
||||
Messages.messageReceived.disconnect(handleMessages);
|
||||
|
||||
HMD.displayModeChanged.disconnect(updateControllers);
|
||||
HMD.shouldShowHandControllersChanged.disconnect(updateControllers);
|
||||
|
||||
self.deleteControllerDisplays();
|
||||
};
|
||||
|
||||
HMD.displayModeChanged.connect(updateControllers);
|
||||
HMD.shouldShowHandControllersChanged.connect(updateControllers);
|
||||
|
||||
updateControllers();
|
||||
}
|
||||
};
|
||||
|
||||
var controllerDisplayManager = new ControllerDisplayManager();
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
controllerDisplayManager.destroy();
|
||||
});
|
||||
|
||||
}());
|
|
@ -11,7 +11,10 @@
|
|||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
/* global setEntityCustomData, getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, setGrabCommunications */
|
||||
|
||||
/* global setEntityCustomData, getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings,
|
||||
Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, setGrabCommunications */
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
//
|
||||
// viveControllerConfiguration.js
|
||||
//
|
||||
// Created by Anthony J. Thibault on 10/20/16
|
||||
// Originally created by Ryan Huffman on 9/21/2016
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
/* globals VIVE_CONTROLLER_CONFIGURATION_LEFT:true VIVE_CONTROLLER_CONFIGURATION_RIGHT:true */
|
||||
/* eslint camelcase: ["error", { "properties": "never" }] */
|
||||
|
||||
var LEFT_JOINT_INDEX = MyAvatar.getJointIndex("_CONTROLLER_LEFTHAND");
|
||||
var RIGHT_JOINT_INDEX = MyAvatar.getJointIndex("_CONTROLLER_RIGHTHAND");
|
||||
|
||||
|
@ -44,8 +57,11 @@ var viveNaturalPosition = {
|
|||
z: 0.06380049744620919
|
||||
};
|
||||
|
||||
var viveModelURL = "atp:/controller/vive_body.fbx";
|
||||
var viveTipsModelURL = "atp:/controller/vive_tips.fbx"
|
||||
var BASE_URL = Script.resourcesPath();
|
||||
var TIP_TEXTURE_BASE_URL = BASE_URL + "meshes/controller/vive_tips.fbm/";
|
||||
|
||||
var viveModelURL = BASE_URL + "meshes/controller/vive_body.fbx";
|
||||
var viveTipsModelURL = BASE_URL + "meshes/controller/vive_tips.fbx";
|
||||
|
||||
VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
||||
name: "Vive",
|
||||
|
@ -70,20 +86,20 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
defaultTextureLayer: "blank",
|
||||
textureLayers: {
|
||||
blank: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Blank.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "Blank.png"
|
||||
},
|
||||
trigger: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Trigger.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Trigger.png"
|
||||
},
|
||||
arrows: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Rotate.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Rotate.png"
|
||||
},
|
||||
grip: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Grip.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Grip.png"
|
||||
},
|
||||
teleport: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Teleport.png",
|
||||
},
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Teleport.png"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -91,7 +107,7 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
// and swaps in textures based on the thumb position.
|
||||
touchpad: {
|
||||
type: "touchpad",
|
||||
modelURL: "atp:/controller/vive_trackpad.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_trackpad.fbx",
|
||||
visibleInput: "Vive.RSTouch",
|
||||
xInput: "Vive.LX",
|
||||
yInput: "Vive.LY",
|
||||
|
@ -105,64 +121,63 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
disable_defaultTextureLayer: "blank",
|
||||
disable_textureLayers: {
|
||||
blank: {
|
||||
defaultTextureURL: "atp:/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-blank.jpg",
|
||||
defaultTextureURL: BASE_URL + "meshes/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-blank.jpg"
|
||||
},
|
||||
teleport: {
|
||||
defaultTextureURL: "atp:/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-teleport-active-LG.jpg",
|
||||
defaultTextureURL: BASE_URL + "meshes/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-teleport-active-LG.jpg"
|
||||
},
|
||||
arrows: {
|
||||
defaultTextureURL: "atp:/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-look-arrows.jpg",
|
||||
defaultTextureURL: BASE_URL + "meshes/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-look-arrows.jpg"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
trigger: {
|
||||
type: "rotational",
|
||||
modelURL: "atp:/controller/vive_trigger.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_trigger.fbx",
|
||||
input: Controller.Standard.LT,
|
||||
naturalPosition: {"x":0.000004500150680541992,"y":-0.027690507471561432,"z":0.04830199480056763},
|
||||
origin: { x: 0, y: -0.015, z: -0.00 },
|
||||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
axis: { x: -1, y: 0, z: 0 },
|
||||
maxAngle: 20,
|
||||
maxAngle: 20
|
||||
},
|
||||
|
||||
l_grip: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_l_grip.fbx",
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
modelURL: BASE_URL + "meshes/controller/vive_l_grip.fbx",
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
},
|
||||
|
||||
r_grip: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_r_grip.fbx",
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
modelURL: BASE_URL + "meshes/controller/vive_r_grip.fbx",
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
},
|
||||
|
||||
sys_button: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_sys_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311},
|
||||
modelURL: BASE_URL + "meshes/controller/vive_sys_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311}
|
||||
},
|
||||
|
||||
button: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_button.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
},
|
||||
button2: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_button.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
|
||||
VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
||||
name: "Vive Right",
|
||||
controllers: [
|
||||
|
@ -192,20 +207,20 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
defaultTextureLayer: "blank",
|
||||
textureLayers: {
|
||||
blank: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Blank.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Blank.png"
|
||||
},
|
||||
trigger: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Trigger.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Trigger.png"
|
||||
},
|
||||
arrows: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Rotate.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Rotate.png"
|
||||
},
|
||||
grip: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Grip.png",
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Grip.png"
|
||||
},
|
||||
teleport: {
|
||||
defaultTextureURL: viveTipsModelURL + "/Controller-Tips.fbm/Teleport.png",
|
||||
},
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Teleport.png"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -213,7 +228,7 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
// and swaps in textures based on the thumb position.
|
||||
touchpad: {
|
||||
type: "touchpad",
|
||||
modelURL: "atp:/controller/vive_trackpad.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_trackpad.fbx",
|
||||
visibleInput: "Vive.RSTouch",
|
||||
xInput: "Vive.RX",
|
||||
yInput: "Vive.RY",
|
||||
|
@ -227,58 +242,58 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
disable_defaultTextureLayer: "blank",
|
||||
disable_textureLayers: {
|
||||
blank: {
|
||||
defaultTextureURL: "atp:/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-blank.jpg",
|
||||
defaultTextureURL: BASE_URL + "meshes/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-blank.jpg"
|
||||
},
|
||||
teleport: {
|
||||
defaultTextureURL: "atp:/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-teleport-active-LG.jpg",
|
||||
defaultTextureURL: BASE_URL + "meshes/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-teleport-active-LG.jpg"
|
||||
},
|
||||
arrows: {
|
||||
defaultTextureURL: "atp:/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-look-arrows-active.jpg",
|
||||
defaultTextureURL: BASE_URL + "meshes/controller/vive_trackpad.fbx/Touchpad.fbm/touchpad-look-arrows-active.jpg"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
trigger: {
|
||||
type: "rotational",
|
||||
modelURL: "atp:/controller/vive_trigger.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_trigger.fbx",
|
||||
input: Controller.Standard.RT,
|
||||
naturalPosition: {"x":0.000004500150680541992,"y":-0.027690507471561432,"z":0.04830199480056763},
|
||||
origin: { x: 0, y: -0.015, z: -0.00 },
|
||||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
axis: { x: -1, y: 0, z: 0 },
|
||||
maxAngle: 25,
|
||||
maxAngle: 25
|
||||
},
|
||||
|
||||
l_grip: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_l_grip.fbx",
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
modelURL: BASE_URL + "meshes/controller/vive_l_grip.fbx",
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
},
|
||||
|
||||
r_grip: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_r_grip.fbx",
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
modelURL: BASE_URL + "meshes/controller/vive_r_grip.fbx",
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
},
|
||||
|
||||
sys_button: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_sys_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311},
|
||||
modelURL: BASE_URL + "meshes/controller/vive_sys_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311}
|
||||
},
|
||||
|
||||
button: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_button.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
},
|
||||
button2: {
|
||||
type: "static",
|
||||
modelURL: "atp:/controller/vive_button.fbx",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
|
@ -9,7 +9,6 @@
|
|||
//
|
||||
|
||||
Script.include("entityData.js");
|
||||
Script.include("viveHandsv2.js");
|
||||
Script.include("lighter/createButaneLighter.js");
|
||||
Script.include("tutorialEntityIDs.js");
|
||||
|
||||
|
@ -235,7 +234,7 @@ var stepDisableControllers = function(name) {
|
|||
}
|
||||
stepDisableControllers.prototype = {
|
||||
start: function(onFinish) {
|
||||
controllerDisplayManager = new ControllerDisplayManager();
|
||||
HMD.requestShowHandControllers();
|
||||
disableEverything();
|
||||
|
||||
onFinish();
|
||||
|
@ -276,10 +275,7 @@ function reenableEverything() {
|
|||
setControllerPartLayer('touchpad', 'blank');
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
MyAvatar.shouldRenderLocally = true;
|
||||
if (controllerDisplayManager) {
|
||||
controllerDisplayManager.destroy();
|
||||
controllerDisplayManager = null;
|
||||
}
|
||||
HMD.requestHideHandControllers();
|
||||
setAwayEnabled(true);
|
||||
}
|
||||
|
||||
|
|