mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 05:34:20 +02:00
Tidying
This commit is contained in:
parent
136ea78873
commit
573a49853a
7 changed files with 67 additions and 82 deletions
|
@ -42,6 +42,10 @@ Hand = function (side) {
|
|||
|
||||
intersection = {};
|
||||
|
||||
if (!this instanceof Hand) {
|
||||
return new Hand(side);
|
||||
}
|
||||
|
||||
if (side === LEFT_HAND) {
|
||||
handController = Controller.Standard.LeftHand;
|
||||
controllerTrigger = Controller.Standard.LT;
|
||||
|
@ -183,10 +187,6 @@ Hand = function (side) {
|
|||
// Nothing to do.
|
||||
}
|
||||
|
||||
if (!this instanceof Hand) {
|
||||
return new Hand(side);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: valid,
|
||||
position: position,
|
||||
|
|
|
@ -49,6 +49,10 @@ Handles = function (side) {
|
|||
|
||||
i;
|
||||
|
||||
if (!this instanceof Handles) {
|
||||
return new Handles(side);
|
||||
}
|
||||
|
||||
CORNER_HANDLE_OVERLAY_AXES = [
|
||||
// Ordered such that items 4 apart are opposite corners - used in display().
|
||||
{ x: -0.5, y: -0.5, z: -0.5 },
|
||||
|
@ -350,10 +354,6 @@ Handles = function (side) {
|
|||
Overlays.deleteOverlay(boundingBoxOverlay);
|
||||
}
|
||||
|
||||
if (!this instanceof Handles) {
|
||||
return new Handles(side);
|
||||
}
|
||||
|
||||
return {
|
||||
display: display,
|
||||
isHandle: isHandle,
|
||||
|
|
|
@ -27,6 +27,10 @@ Highlights = function (side) {
|
|||
AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}",
|
||||
ZERO_ROTATION = Quat.fromVec3Radians(Vec3.ZERO);
|
||||
|
||||
if (!this instanceof Highlights) {
|
||||
return new Highlights();
|
||||
}
|
||||
|
||||
handOverlay = Overlays.addOverlay("sphere", {
|
||||
dimensions: HAND_HIGHLIGHT_DIMENSIONS,
|
||||
parentID: AVATAR_SELF_ID,
|
||||
|
@ -109,10 +113,6 @@ Highlights = function (side) {
|
|||
Overlays.deleteOverlay(handOverlay);
|
||||
}
|
||||
|
||||
if (!this instanceof Highlights) {
|
||||
return new Highlights();
|
||||
}
|
||||
|
||||
return {
|
||||
display: display,
|
||||
clear: clear,
|
||||
|
|
|
@ -32,7 +32,7 @@ Laser = function (side) {
|
|||
COLORS_GRAB_SEARCHING_FULL_SQUEEZE = { red: 250, green: 10, blue: 10 }, // Per handControllgerGrab.js.
|
||||
COLORS_GRAB_SEARCHING_HALF_SQUEEZE_BRIGHT,
|
||||
COLORS_GRAB_SEARCHING_FULL_SQUEEZE_BRIGHT,
|
||||
BRIGHT_POW = 0.06, // Per handControllgerGrab.js.
|
||||
BRIGHT_POW = 0.06, // Per handControllerGrab.js.
|
||||
|
||||
GRAB_POINT_SPHERE_OFFSET = { x: 0.04, y: 0.13, z: 0.039 }, // Per HmdDisplayPlugin.cpp and controllers.js.
|
||||
|
||||
|
@ -52,6 +52,10 @@ Laser = function (side) {
|
|||
|
||||
intersection;
|
||||
|
||||
if (!this instanceof Laser) {
|
||||
return new Laser(side);
|
||||
}
|
||||
|
||||
function colorPow(color, power) { // Per handControllerGrab.js.
|
||||
return {
|
||||
red: Math.pow(color.red / 255, power) * 255,
|
||||
|
@ -256,10 +260,6 @@ Laser = function (side) {
|
|||
Overlays.deleteOverlay(laserSphere);
|
||||
}
|
||||
|
||||
if (!this instanceof Laser) {
|
||||
return new Laser(side);
|
||||
}
|
||||
|
||||
return {
|
||||
setUIEntities: setUIEntities,
|
||||
update: update,
|
||||
|
|
|
@ -25,6 +25,10 @@ Selection = function (side) {
|
|||
scaleRootOrientation,
|
||||
ENTITY_TYPE = "entity";
|
||||
|
||||
if (!this instanceof Selection) {
|
||||
return new Selection(side);
|
||||
}
|
||||
|
||||
function traverseEntityTree(id, result) {
|
||||
// Recursively traverses tree of entities and their children, gather IDs and properties.
|
||||
var children,
|
||||
|
@ -307,10 +311,6 @@ Selection = function (side) {
|
|||
clear();
|
||||
}
|
||||
|
||||
if (!this instanceof Selection) {
|
||||
return new Selection(side);
|
||||
}
|
||||
|
||||
return {
|
||||
select: select,
|
||||
selection: getSelection,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
/* global ToolMenu */
|
||||
|
||||
ToolMenu = function (side, setAppScaleWithHandlesCallback) {
|
||||
ToolMenu = function (side, leftInputs, rightInputs, setAppScaleWithHandlesCallback) {
|
||||
// Tool menu displayed on top of forearm.
|
||||
|
||||
"use strict";
|
||||
|
@ -89,16 +89,15 @@ ToolMenu = function (side, setAppScaleWithHandlesCallback) {
|
|||
isButtonPressed = false,
|
||||
|
||||
// References.
|
||||
leftInputs,
|
||||
rightInputs,
|
||||
controlHand;
|
||||
|
||||
function setReferences(left, right) {
|
||||
leftInputs = left;
|
||||
rightInputs = right;
|
||||
controlHand = side === LEFT_HAND ? rightInputs.hand() : leftInputs.hand();
|
||||
|
||||
if (!this instanceof ToolMenu) {
|
||||
return new ToolMenu();
|
||||
}
|
||||
|
||||
controlHand = side === LEFT_HAND ? rightInputs.hand() : leftInputs.hand();
|
||||
|
||||
function setHand(uiSide) {
|
||||
side = uiSide;
|
||||
controlHand = side === LEFT_HAND ? rightInputs.hand() : leftInputs.hand();
|
||||
|
@ -190,14 +189,9 @@ ToolMenu = function (side, setAppScaleWithHandlesCallback) {
|
|||
clear();
|
||||
}
|
||||
|
||||
if (!this instanceof ToolMenu) {
|
||||
return new ToolMenu();
|
||||
}
|
||||
|
||||
return {
|
||||
setReferences: setReferences,
|
||||
setHand: setHand,
|
||||
getEntityIDs: getEntityIDs,
|
||||
entityIDs: getEntityIDs,
|
||||
update: update,
|
||||
display: display,
|
||||
clear: clear,
|
||||
|
|
|
@ -89,9 +89,15 @@
|
|||
|
||||
intersection = {};
|
||||
|
||||
|
||||
if (!this instanceof Inputs) {
|
||||
return new Inputs();
|
||||
}
|
||||
|
||||
hand = new Hand(side);
|
||||
laser = new Laser(side);
|
||||
|
||||
|
||||
function setUIEntities(entityIDs) {
|
||||
laser.setUIEntities(entityIDs);
|
||||
}
|
||||
|
@ -139,15 +145,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (!this instanceof Inputs) {
|
||||
return new Inputs();
|
||||
}
|
||||
|
||||
return {
|
||||
setUIEntities: setUIEntities,
|
||||
hand: getHand,
|
||||
laser: getLaser,
|
||||
getIntersection: getIntersection,
|
||||
intersection: getIntersection,
|
||||
update: update,
|
||||
clear: clear,
|
||||
destroy: destroy
|
||||
|
@ -155,35 +157,29 @@
|
|||
};
|
||||
|
||||
|
||||
UI = function (side, setAppScaleWithHandlesCallback) {
|
||||
UI = function (side, leftInputs, rightInputs, setAppScaleWithHandlesCallback) {
|
||||
// Tool menu and Create palette.
|
||||
|
||||
var // Primary objects.
|
||||
toolMenu,
|
||||
|
||||
// References.
|
||||
leftInputs,
|
||||
rightInputs,
|
||||
|
||||
isDisplaying = false,
|
||||
|
||||
getIntersection, // Function.
|
||||
intersection;
|
||||
|
||||
toolMenu = new ToolMenu(side, setAppScaleWithHandlesCallback);
|
||||
getIntersection; // Function.
|
||||
|
||||
|
||||
function setReferences(left, right) {
|
||||
leftInputs = left;
|
||||
rightInputs = right;
|
||||
getIntersection = side === LEFT_HAND ? rightInputs.getIntersection : leftInputs.getIntersection;
|
||||
|
||||
toolMenu.setReferences(left, right);
|
||||
if (!this instanceof UI) {
|
||||
return new UI();
|
||||
}
|
||||
|
||||
toolMenu = new ToolMenu(side, leftInputs, rightInputs, setAppScaleWithHandlesCallback);
|
||||
|
||||
getIntersection = side === LEFT_HAND ? rightInputs.intersection : leftInputs.intersection;
|
||||
|
||||
|
||||
function setHand(side) {
|
||||
toolMenu.setHand(side);
|
||||
getIntersection = side === LEFT_HAND ? rightInputs.getIntersection : leftInputs.getIntersection;
|
||||
getIntersection = side === LEFT_HAND ? rightInputs.intersection : leftInputs.intersection;
|
||||
}
|
||||
|
||||
function display() {
|
||||
|
@ -191,17 +187,16 @@
|
|||
|
||||
toolMenu.display();
|
||||
|
||||
uiEntityIDs = toolMenu.getEntityIDs();
|
||||
leftInputs.setUIEntities(uiEntityIDs);
|
||||
rightInputs.setUIEntities(uiEntityIDs);
|
||||
uiEntityIDs = toolMenu.entityIDs();
|
||||
leftInputs.setUIEntities(side === RIGHT_HAND ? uiEntityIDs : []);
|
||||
rightInputs.setUIEntities(side === LEFT_HAND ? uiEntityIDs : []);
|
||||
|
||||
isDisplaying = true;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if (isDisplaying) {
|
||||
intersection = getIntersection();
|
||||
toolMenu.update(intersection.overlayID);
|
||||
toolMenu.update(getIntersection().overlayID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,12 +215,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (!this instanceof UI) {
|
||||
return new UI();
|
||||
}
|
||||
|
||||
return {
|
||||
setReferences: setReferences,
|
||||
setHand: setHand,
|
||||
display: display,
|
||||
update: update,
|
||||
|
@ -238,7 +228,16 @@
|
|||
Editor = function (side) {
|
||||
// An entity selection, entity highlights, and entity handles.
|
||||
|
||||
var otherEditor, // Other hand's Editor object.
|
||||
var
|
||||
// Primary objects.
|
||||
selection,
|
||||
highlights,
|
||||
handles,
|
||||
|
||||
// References.
|
||||
otherEditor, // Other hand's Editor object.
|
||||
hand,
|
||||
laser,
|
||||
|
||||
// Editor states.
|
||||
EDITOR_IDLE = 0,
|
||||
|
@ -258,15 +257,6 @@
|
|||
isOtherEditorEditingEntityID = false,
|
||||
hoveredOverlayID = null,
|
||||
|
||||
// Primary objects.
|
||||
selection,
|
||||
highlights,
|
||||
handles,
|
||||
|
||||
// Input objects.
|
||||
hand,
|
||||
laser,
|
||||
|
||||
// Position values.
|
||||
initialHandOrientationInverse,
|
||||
initialHandToSelectionVector,
|
||||
|
@ -293,6 +283,11 @@
|
|||
getIntersection, // Function.
|
||||
intersection;
|
||||
|
||||
|
||||
if (!this instanceof Editor) {
|
||||
return new Editor();
|
||||
}
|
||||
|
||||
selection = new Selection(side);
|
||||
highlights = new Highlights(side);
|
||||
handles = new Handles(side);
|
||||
|
@ -300,12 +295,13 @@
|
|||
function setReferences(inputs, editor) {
|
||||
hand = inputs.hand(); // Object.
|
||||
laser = inputs.laser(); // Object.
|
||||
getIntersection = inputs.getIntersection; // Function.
|
||||
getIntersection = inputs.intersection; // Function.
|
||||
otherEditor = editor; // Object.
|
||||
|
||||
laserOffset = laser.handOffset(); // Value.
|
||||
}
|
||||
|
||||
|
||||
function hoverHandle(overlayID) {
|
||||
// Highlights handle if overlayID is a handle, otherwise unhighlights currently highlighted handle if any.
|
||||
handles.hover(overlayID);
|
||||
|
@ -911,10 +907,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (!this instanceof Editor) {
|
||||
return new Editor();
|
||||
}
|
||||
|
||||
return {
|
||||
setReferences: setReferences,
|
||||
hoverHandle: hoverHandle,
|
||||
|
@ -1029,8 +1021,7 @@
|
|||
inputs[RIGHT_HAND] = new Inputs(RIGHT_HAND);
|
||||
|
||||
// UI object.
|
||||
ui = new UI(otherHand(dominantHand), setAppScaleWithHandles);
|
||||
ui.setReferences(inputs[LEFT_HAND], inputs[RIGHT_HAND]);
|
||||
ui = new UI(otherHand(dominantHand), inputs[LEFT_HAND], inputs[RIGHT_HAND], setAppScaleWithHandles);
|
||||
|
||||
// Editor objects.
|
||||
editors[LEFT_HAND] = new Editor(LEFT_HAND);
|
||||
|
|
Loading…
Reference in a new issue