Merge branch 'master' of https://github.com/highfidelity/hifi into brown
|
@ -225,10 +225,6 @@ void Web3DOverlay::setMaxFPS(uint8_t maxFPS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Web3DOverlay::render(RenderArgs* args) {
|
void Web3DOverlay::render(RenderArgs* args) {
|
||||||
if (!_visible || !getParentVisible()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QOpenGLContext * currentContext = QOpenGLContext::currentContext();
|
QOpenGLContext * currentContext = QOpenGLContext::currentContext();
|
||||||
QSurface * currentSurface = currentContext->surface();
|
QSurface * currentSurface = currentContext->surface();
|
||||||
if (!_webSurface) {
|
if (!_webSurface) {
|
||||||
|
@ -282,6 +278,10 @@ void Web3DOverlay::render(RenderArgs* args) {
|
||||||
_webSurface->resize(QSize(_resolution.x, _resolution.y));
|
_webSurface->resize(QSize(_resolution.x, _resolution.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_visible || !getParentVisible()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vec2 halfSize = getSize() / 2.0f;
|
vec2 halfSize = getSize() / 2.0f;
|
||||||
vec4 color(toGlm(getColor()), getAlpha());
|
vec4 color(toGlm(getColor()), getAlpha());
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,13 @@ void Head::calculateMouthShapes(float deltaTime) {
|
||||||
float trailingAudioJawOpenRatio = (100.0f - deltaTime * NORMAL_HZ) / 100.0f; // --> 0.99 at 60 Hz
|
float trailingAudioJawOpenRatio = (100.0f - deltaTime * NORMAL_HZ) / 100.0f; // --> 0.99 at 60 Hz
|
||||||
_trailingAudioJawOpen = glm::mix(_trailingAudioJawOpen, _audioJawOpen, trailingAudioJawOpenRatio);
|
_trailingAudioJawOpen = glm::mix(_trailingAudioJawOpen, _audioJawOpen, trailingAudioJawOpenRatio);
|
||||||
|
|
||||||
|
// truncate _mouthTime when mouth goes quiet to prevent floating point error on increment
|
||||||
|
const float SILENT_TRAILING_JAW_OPEN = 0.0002f;
|
||||||
|
const float MAX_SILENT_MOUTH_TIME = 10.0f;
|
||||||
|
if (_trailingAudioJawOpen < SILENT_TRAILING_JAW_OPEN && _mouthTime > MAX_SILENT_MOUTH_TIME) {
|
||||||
|
_mouthTime = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Advance time at a rate proportional to loudness, and move the mouth shapes through
|
// Advance time at a rate proportional to loudness, and move the mouth shapes through
|
||||||
// a cycle at differing speeds to create a continuous random blend of shapes.
|
// a cycle at differing speeds to create a continuous random blend of shapes.
|
||||||
_mouthTime += sqrtf(_averageLoudness) * TIMESTEP_CONSTANT * deltaTimeRatio;
|
_mouthTime += sqrtf(_averageLoudness) * TIMESTEP_CONSTANT * deltaTimeRatio;
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace controller {
|
||||||
for (int actionIndex = 0; actionIndex < actionArrayList.size(); actionIndex++) {
|
for (int actionIndex = 0; actionIndex < actionArrayList.size(); actionIndex++) {
|
||||||
QJsonArray actionState = actionArrayList[actionIndex].toArray();
|
QJsonArray actionState = actionArrayList[actionIndex].toArray();
|
||||||
for (int index = 0; index < actionState.size(); index++) {
|
for (int index = 0; index < actionState.size(); index++) {
|
||||||
_currentFrameActions[index] = actionState[index].toInt();
|
_currentFrameActions[index] = actionState[index].toDouble();
|
||||||
}
|
}
|
||||||
_actionStateList.push_back(_currentFrameActions);
|
_actionStateList.push_back(_currentFrameActions);
|
||||||
_currentFrameActions = ActionStates(toInt(Action::NUM_ACTIONS));
|
_currentFrameActions = ActionStates(toInt(Action::NUM_ACTIONS));
|
||||||
|
|
|
@ -96,7 +96,7 @@ function calcSpawnInfo(hand, height) {
|
||||||
* @param hand [number] -1 indicates no hand, Controller.Standard.RightHand or Controller.Standard.LeftHand
|
* @param hand [number] -1 indicates no hand, Controller.Standard.RightHand or Controller.Standard.LeftHand
|
||||||
* @param clientOnly [bool] true indicates tablet model is only visible to client.
|
* @param clientOnly [bool] true indicates tablet model is only visible to client.
|
||||||
*/
|
*/
|
||||||
WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
|
@ -107,6 +107,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
||||||
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
||||||
this.landscape = false;
|
this.landscape = false;
|
||||||
|
|
||||||
|
visible = visible === true;
|
||||||
|
|
||||||
if (dpi) {
|
if (dpi) {
|
||||||
this.dpi = dpi;
|
this.dpi = dpi;
|
||||||
} else {
|
} else {
|
||||||
|
@ -125,7 +127,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
||||||
"grabbableKey": {"grabbable": true}
|
"grabbableKey": {"grabbable": true}
|
||||||
}),
|
}),
|
||||||
dimensions: this.getDimensions(),
|
dimensions: this.getDimensions(),
|
||||||
parentID: AVATAR_SELF_ID
|
parentID: AVATAR_SELF_ID,
|
||||||
|
visible: visible
|
||||||
};
|
};
|
||||||
|
|
||||||
// compute position, rotation & parentJointIndex of the tablet
|
// compute position, rotation & parentJointIndex of the tablet
|
||||||
|
@ -158,7 +161,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
||||||
parentID: this.tabletEntityID,
|
parentID: this.tabletEntityID,
|
||||||
parentJointIndex: -1,
|
parentJointIndex: -1,
|
||||||
showKeyboardFocusHighlight: false,
|
showKeyboardFocusHighlight: false,
|
||||||
isAA: HMD.active
|
isAA: HMD.active,
|
||||||
|
visible: visible
|
||||||
});
|
});
|
||||||
|
|
||||||
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - (this.height / 20);
|
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - (this.height / 20);
|
||||||
|
@ -168,7 +172,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
||||||
localRotation: {x: 0, y: 1, z: 0, w: 0},
|
localRotation: {x: 0, y: 1, z: 0, w: 0},
|
||||||
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor},
|
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor},
|
||||||
alpha: 0.0,
|
alpha: 0.0,
|
||||||
visible: true,
|
visible: visible,
|
||||||
drawInFront: false,
|
drawInFront: false,
|
||||||
parentID: this.tabletEntityID,
|
parentID: this.tabletEntityID,
|
||||||
parentJointIndex: -1
|
parentJointIndex: -1
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// examples
|
// examples
|
||||||
//
|
//
|
||||||
// Created by Brad hefta-Gaub on 10/1/14.
|
// Created by Brad hefta-Gaub on 10/1/14.
|
||||||
|
// Modified by Daniela Fontes @DanielaFifo and Tiago Andrade @TagoWill on 4/7/2017
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// This script implements a class useful for building tools for editing entities.
|
// This script implements a class useful for building tools for editing entities.
|
||||||
|
@ -2592,6 +2593,16 @@ SelectionDisplay = (function() {
|
||||||
// pivot - point to use as a pivot
|
// pivot - point to use as a pivot
|
||||||
// offset - the position of the overlay tool relative to the selections center position
|
// offset - the position of the overlay tool relative to the selections center position
|
||||||
var makeStretchTool = function(stretchMode, direction, pivot, offset, customOnMove) {
|
var makeStretchTool = function(stretchMode, direction, pivot, offset, customOnMove) {
|
||||||
|
// directionFor3DStretch - direction and pivot for 3D stretch
|
||||||
|
// distanceFor3DStretch - distance from the intersection point and the handController
|
||||||
|
// used to increase the scale taking into account the distance to the object
|
||||||
|
// DISTANCE_INFLUENCE_THRESHOLD - constant that holds the minimum distance where the
|
||||||
|
// distance to the object will influence the stretch/resize/scale
|
||||||
|
var directionFor3DStretch = getDirectionsFor3DStretch(stretchMode);
|
||||||
|
var distanceFor3DStretch = 0;
|
||||||
|
var DISTANCE_INFLUENCE_THRESHOLD = 1.2;
|
||||||
|
|
||||||
|
|
||||||
var signs = {
|
var signs = {
|
||||||
x: direction.x < 0 ? -1 : (direction.x > 0 ? 1 : 0),
|
x: direction.x < 0 ? -1 : (direction.x > 0 ? 1 : 0),
|
||||||
y: direction.y < 0 ? -1 : (direction.y > 0 ? 1 : 0),
|
y: direction.y < 0 ? -1 : (direction.y > 0 ? 1 : 0),
|
||||||
|
@ -2604,17 +2615,22 @@ SelectionDisplay = (function() {
|
||||||
z: Math.abs(direction.z) > 0 ? 1 : 0,
|
z: Math.abs(direction.z) > 0 ? 1 : 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var numDimensions = mask.x + mask.y + mask.z;
|
var numDimensions = mask.x + mask.y + mask.z;
|
||||||
|
|
||||||
var planeNormal = null;
|
var planeNormal = null;
|
||||||
var lastPick = null;
|
var lastPick = null;
|
||||||
|
var lastPick3D = null;
|
||||||
var initialPosition = null;
|
var initialPosition = null;
|
||||||
var initialDimensions = null;
|
var initialDimensions = null;
|
||||||
var initialIntersection = null;
|
var initialIntersection = null;
|
||||||
var initialProperties = null;
|
var initialProperties = null;
|
||||||
var registrationPoint = null;
|
var registrationPoint = null;
|
||||||
var deltaPivot = null;
|
var deltaPivot = null;
|
||||||
|
var deltaPivot3D = null;
|
||||||
var pickRayPosition = null;
|
var pickRayPosition = null;
|
||||||
|
var pickRayPosition3D = null;
|
||||||
var rotation = null;
|
var rotation = null;
|
||||||
|
|
||||||
var onBegin = function(event) {
|
var onBegin = function(event) {
|
||||||
|
@ -2652,8 +2668,20 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
// Scaled offset in world coordinates
|
// Scaled offset in world coordinates
|
||||||
var scaledOffsetWorld = vec3Mult(initialDimensions, offsetRP);
|
var scaledOffsetWorld = vec3Mult(initialDimensions, offsetRP);
|
||||||
|
|
||||||
pickRayPosition = Vec3.sum(initialPosition, Vec3.multiplyQbyV(rotation, scaledOffsetWorld));
|
pickRayPosition = Vec3.sum(initialPosition, Vec3.multiplyQbyV(rotation, scaledOffsetWorld));
|
||||||
|
|
||||||
|
if (directionFor3DStretch) {
|
||||||
|
// pivot, offset and pickPlanePosition for 3D manipulation
|
||||||
|
var scaledPivot3D = Vec3.multiply(0.5, Vec3.multiply(1.0, directionFor3DStretch));
|
||||||
|
deltaPivot3D = Vec3.subtract(centeredRP, scaledPivot3D);
|
||||||
|
|
||||||
|
var scaledOffsetWorld3D = vec3Mult(initialDimensions,
|
||||||
|
Vec3.subtract(Vec3.multiply(0.5, Vec3.multiply(-1.0, directionFor3DStretch)),
|
||||||
|
centeredRP));
|
||||||
|
|
||||||
|
pickRayPosition3D = Vec3.sum(initialPosition, Vec3.multiplyQbyV(rotation, scaledOffsetWorld));
|
||||||
|
}
|
||||||
var start = null;
|
var start = null;
|
||||||
var end = null;
|
var end = null;
|
||||||
if (numDimensions == 1 && mask.x) {
|
if (numDimensions == 1 && mask.x) {
|
||||||
|
@ -2754,12 +2782,25 @@ SelectionDisplay = (function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
planeNormal = Vec3.multiplyQbyV(rotation, planeNormal);
|
planeNormal = Vec3.multiplyQbyV(rotation, planeNormal);
|
||||||
var pickRay = generalComputePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
lastPick = rayPlaneIntersection(pickRay,
|
lastPick = rayPlaneIntersection(pickRay,
|
||||||
pickRayPosition,
|
pickRayPosition,
|
||||||
planeNormal);
|
planeNormal);
|
||||||
|
|
||||||
|
var planeNormal3D = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
if (directionFor3DStretch) {
|
||||||
|
lastPick3D = rayPlaneIntersection(pickRay,
|
||||||
|
pickRayPosition3D,
|
||||||
|
planeNormal3D);
|
||||||
|
distanceFor3DStretch = Vec3.length(Vec3.subtract(pickRayPosition3D, pickRay.origin));
|
||||||
|
}
|
||||||
|
|
||||||
SelectionManager.saveProperties();
|
SelectionManager.saveProperties();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2791,7 +2832,31 @@ SelectionDisplay = (function() {
|
||||||
rotation = SelectionManager.worldRotation;
|
rotation = SelectionManager.worldRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var localDeltaPivot = deltaPivot;
|
||||||
|
var localSigns = signs;
|
||||||
|
|
||||||
var pickRay = generalComputePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
|
// Are we using handControllers or Mouse - only relevant for 3D tools
|
||||||
|
var controllerPose = getControllerWorldLocation(activeHand, true);
|
||||||
|
if (HMD.isHMDAvailable()
|
||||||
|
&& HMD.isHandControllerAvailable() && controllerPose.valid && that.triggered && directionFor3DStretch) {
|
||||||
|
localDeltaPivot = deltaPivot3D;
|
||||||
|
|
||||||
|
newPick = pickRay.origin;
|
||||||
|
|
||||||
|
var vector = Vec3.subtract(newPick, lastPick3D);
|
||||||
|
|
||||||
|
vector = Vec3.multiplyQbyV(Quat.inverse(rotation), vector);
|
||||||
|
|
||||||
|
if (distanceFor3DStretch > DISTANCE_INFLUENCE_THRESHOLD) {
|
||||||
|
// Range of Motion
|
||||||
|
vector = Vec3.multiply(distanceFor3DStretch , vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
localSigns = directionFor3DStretch;
|
||||||
|
|
||||||
|
} else {
|
||||||
newPick = rayPlaneIntersection(pickRay,
|
newPick = rayPlaneIntersection(pickRay,
|
||||||
pickRayPosition,
|
pickRayPosition,
|
||||||
planeNormal);
|
planeNormal);
|
||||||
|
@ -2801,13 +2866,15 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
vector = vec3Mult(mask, vector);
|
vector = vec3Mult(mask, vector);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (customOnMove) {
|
if (customOnMove) {
|
||||||
var change = Vec3.multiply(-1, vec3Mult(signs, vector));
|
var change = Vec3.multiply(-1, vec3Mult(localSigns, vector));
|
||||||
customOnMove(vector, change);
|
customOnMove(vector, change);
|
||||||
} else {
|
} else {
|
||||||
vector = grid.snapToSpacing(vector);
|
vector = grid.snapToSpacing(vector);
|
||||||
|
|
||||||
var changeInDimensions = Vec3.multiply(-1, vec3Mult(signs, vector));
|
var changeInDimensions = Vec3.multiply(-1, vec3Mult(localSigns, vector));
|
||||||
var newDimensions;
|
var newDimensions;
|
||||||
if (proportional) {
|
if (proportional) {
|
||||||
var absX = Math.abs(changeInDimensions.x);
|
var absX = Math.abs(changeInDimensions.x);
|
||||||
|
@ -2829,12 +2896,14 @@ SelectionDisplay = (function() {
|
||||||
} else {
|
} else {
|
||||||
newDimensions = Vec3.sum(initialDimensions, changeInDimensions);
|
newDimensions = Vec3.sum(initialDimensions, changeInDimensions);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
newDimensions.x = Math.max(newDimensions.x, MINIMUM_DIMENSION);
|
newDimensions.x = Math.max(newDimensions.x, MINIMUM_DIMENSION);
|
||||||
newDimensions.y = Math.max(newDimensions.y, MINIMUM_DIMENSION);
|
newDimensions.y = Math.max(newDimensions.y, MINIMUM_DIMENSION);
|
||||||
newDimensions.z = Math.max(newDimensions.z, MINIMUM_DIMENSION);
|
newDimensions.z = Math.max(newDimensions.z, MINIMUM_DIMENSION);
|
||||||
|
|
||||||
var changeInPosition = Vec3.multiplyQbyV(rotation, vec3Mult(deltaPivot, changeInDimensions));
|
var changeInPosition = Vec3.multiplyQbyV(rotation, vec3Mult(localDeltaPivot, changeInDimensions));
|
||||||
var newPosition = Vec3.sum(initialPosition, changeInPosition);
|
var newPosition = Vec3.sum(initialPosition, changeInPosition);
|
||||||
|
|
||||||
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
||||||
|
@ -2844,6 +2913,7 @@ SelectionDisplay = (function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var wantDebug = false;
|
var wantDebug = false;
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print(stretchMode);
|
print(stretchMode);
|
||||||
|
@ -2859,7 +2929,6 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectionManager._update();
|
SelectionManager._update();
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2871,6 +2940,75 @@ SelectionDisplay = (function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Direction for the stretch tool when using hand controller
|
||||||
|
var directionsFor3DGrab = {
|
||||||
|
LBN: {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
RBN: {
|
||||||
|
x: -1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
LBF: {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: -1
|
||||||
|
},
|
||||||
|
RBF: {
|
||||||
|
x: -1,
|
||||||
|
y: 1,
|
||||||
|
z: -1
|
||||||
|
},
|
||||||
|
LTN: {
|
||||||
|
x: 1,
|
||||||
|
y: -1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
RTN: {
|
||||||
|
x: -1,
|
||||||
|
y: -1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
LTF: {
|
||||||
|
x: 1,
|
||||||
|
y: -1,
|
||||||
|
z: -1
|
||||||
|
},
|
||||||
|
RTF: {
|
||||||
|
x: -1,
|
||||||
|
y: -1,
|
||||||
|
z: -1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns a vector with directions for the stretch tool in 3D using hand controllers
|
||||||
|
function getDirectionsFor3DStretch(mode) {
|
||||||
|
if (mode === "STRETCH_LBN") {
|
||||||
|
return directionsFor3DGrab.LBN;
|
||||||
|
} else if (mode === "STRETCH_RBN") {
|
||||||
|
return directionsFor3DGrab.RBN;
|
||||||
|
} else if (mode === "STRETCH_LBF") {
|
||||||
|
return directionsFor3DGrab.LBF;
|
||||||
|
} else if (mode === "STRETCH_RBF") {
|
||||||
|
return directionsFor3DGrab.RBF;
|
||||||
|
} else if (mode === "STRETCH_LTN") {
|
||||||
|
return directionsFor3DGrab.LTN;
|
||||||
|
} else if (mode === "STRETCH_RTN") {
|
||||||
|
return directionsFor3DGrab.RTN;
|
||||||
|
} else if (mode === "STRETCH_LTF") {
|
||||||
|
return directionsFor3DGrab.LTF;
|
||||||
|
} else if (mode === "STRETCH_RTF") {
|
||||||
|
return directionsFor3DGrab.RTF;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function addStretchTool(overlay, mode, pivot, direction, offset, handleMove) {
|
function addStretchTool(overlay, mode, pivot, direction, offset, handleMove) {
|
||||||
if (!pivot) {
|
if (!pivot) {
|
||||||
pivot = direction;
|
pivot = direction;
|
||||||
|
|
|
@ -111,7 +111,7 @@ function onMessage(message) {
|
||||||
case 'openSettings':
|
case 'openSettings':
|
||||||
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
||||||
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar", true))) {
|
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar", true))) {
|
||||||
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "General Preferences");
|
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog");
|
||||||
} else {
|
} else {
|
||||||
tablet.loadQMLOnTop("TabletGeneralPreferences.qml");
|
tablet.loadQMLOnTop("TabletGeneralPreferences.qml");
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
tabletScalePercentage = getTabletScalePercentageFromSettings();
|
tabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml",
|
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml",
|
||||||
DEFAULT_WIDTH * (tabletScalePercentage / 100),
|
DEFAULT_WIDTH * (tabletScalePercentage / 100),
|
||||||
null, activeHand, true);
|
null, activeHand, true, null, false);
|
||||||
UIWebTablet.register();
|
UIWebTablet.register();
|
||||||
HMD.tabletID = UIWebTablet.tabletEntityID;
|
HMD.tabletID = UIWebTablet.tabletEntityID;
|
||||||
HMD.homeButtonID = UIWebTablet.homeButtonID;
|
HMD.homeButtonID = UIWebTablet.homeButtonID;
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 5/2/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var thisEntityID;
|
||||||
|
|
||||||
|
this.preload = function (entityID) {
|
||||||
|
thisEntityID = entityID;
|
||||||
|
};
|
||||||
|
|
||||||
|
var SCAN_RATE = 100; //ms
|
||||||
|
var REFERENCE_FRAME_COUNT = 30;
|
||||||
|
var MAX_AUDIO_THRESHOLD = 16000;
|
||||||
|
|
||||||
|
var framePool = [];
|
||||||
|
|
||||||
|
function scanEngine() {
|
||||||
|
var avatarLoudnessPool = [];
|
||||||
|
|
||||||
|
function average(a) {
|
||||||
|
var sum = 0;
|
||||||
|
var total = a.length;
|
||||||
|
for (var i = 0; i < total; i++) {
|
||||||
|
sum += a[i];
|
||||||
|
}
|
||||||
|
return Math.round(sum / total);
|
||||||
|
}
|
||||||
|
|
||||||
|
function audioClamp(input) {
|
||||||
|
if (input > MAX_AUDIO_THRESHOLD) return MAX_AUDIO_THRESHOLD;
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var avatars = AvatarList.getAvatarIdentifiers();
|
||||||
|
avatars.forEach(function (id) {
|
||||||
|
var avatar = AvatarList.getAvatar(id);
|
||||||
|
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
framePool.push(average(avatarLoudnessPool));
|
||||||
|
if (framePool.length >= REFERENCE_FRAME_COUNT) {
|
||||||
|
framePool.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizedAverage(a) {
|
||||||
|
a = a.map(function (v) {
|
||||||
|
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||||
|
});
|
||||||
|
return average(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
var norm = normalizedAverage(framePool);
|
||||||
|
|
||||||
|
// we have a range of 55 to -53 degrees for the needle
|
||||||
|
|
||||||
|
var scaledDegrees = (norm / -.94) + 54.5; // shifting scale from 100 to 55 to -53 ish its more like -51 ;
|
||||||
|
|
||||||
|
Entities.setAbsoluteJointRotationInObjectFrame(thisEntityID, 0, Quat.fromPitchYawRollDegrees(0, 0, scaledDegrees));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.setInterval(function () {
|
||||||
|
scanEngine();
|
||||||
|
}, SCAN_RATE);
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,79 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 4/17/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var barID;
|
||||||
|
|
||||||
|
this.preload = function (entityID) {
|
||||||
|
var children = Entities.getChildrenIDs(entityID);
|
||||||
|
var childZero = Entities.getEntityProperties(children[0]);
|
||||||
|
barID = childZero.id;
|
||||||
|
};
|
||||||
|
|
||||||
|
var SCAN_RATE = 100; //ms
|
||||||
|
var REFERENCE_FRAME_COUNT = 30;
|
||||||
|
var MAX_AUDIO_THRESHOLD = 16000;
|
||||||
|
|
||||||
|
var framePool = [];
|
||||||
|
|
||||||
|
function scanEngine() {
|
||||||
|
var avatarLoudnessPool = [];
|
||||||
|
|
||||||
|
function average(a) {
|
||||||
|
var sum = 0;
|
||||||
|
var total = a.length;
|
||||||
|
for (var i = 0; i < total; i++) {
|
||||||
|
sum += a[i];
|
||||||
|
}
|
||||||
|
return Math.round(sum / total);
|
||||||
|
}
|
||||||
|
|
||||||
|
function audioClamp(input) {
|
||||||
|
if (input > MAX_AUDIO_THRESHOLD) return MAX_AUDIO_THRESHOLD;
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var avatars = AvatarList.getAvatarIdentifiers();
|
||||||
|
avatars.forEach(function (id) {
|
||||||
|
var avatar = AvatarList.getAvatar(id);
|
||||||
|
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
framePool.push(average(avatarLoudnessPool));
|
||||||
|
if (framePool.length >= REFERENCE_FRAME_COUNT) {
|
||||||
|
framePool.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizedAverage(a) {
|
||||||
|
a = a.map(function (v) {
|
||||||
|
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||||
|
});
|
||||||
|
return average(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
var norm = normalizedAverage(framePool);
|
||||||
|
|
||||||
|
|
||||||
|
var barProperties = Entities.getEntityProperties(barID);
|
||||||
|
|
||||||
|
var colorShift = 2.55 * norm; //shifting the scale to 0 - 255
|
||||||
|
var xShift = norm / 52; // changing scale from 0-100 to 0-1.9 ish
|
||||||
|
var normShift = xShift - 0.88; //shifting local displacement (-0.88)
|
||||||
|
var halfShift = xShift / 2;
|
||||||
|
Entities.editEntity(barID, {
|
||||||
|
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||||
|
localPosition: {x: normShift - (halfShift), y: -0.0625, z: -0.015},
|
||||||
|
color: {red: colorShift, green: barProperties.color.green, blue: barProperties.color.blue}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.setInterval(function () {
|
||||||
|
scanEngine();
|
||||||
|
}, SCAN_RATE);
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,92 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 4/17/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var barID, textID;
|
||||||
|
|
||||||
|
this.preload = function (entityID) {
|
||||||
|
|
||||||
|
var children = Entities.getChildrenIDs(entityID);
|
||||||
|
var childZero = Entities.getEntityProperties(children[0]);
|
||||||
|
var childOne = Entities.getEntityProperties(children[1]);
|
||||||
|
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
||||||
|
|
||||||
|
if (childZeroUserData.name === "bar") {
|
||||||
|
barID = childZero.id;
|
||||||
|
textID = childOne.id;
|
||||||
|
} else {
|
||||||
|
barID = childOne.id;
|
||||||
|
textID = childZero.id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var SCAN_RATE = 100; //ms
|
||||||
|
var REFERENCE_FRAME_COUNT = 30;
|
||||||
|
var MAX_AUDIO_THRESHOLD = 16000;
|
||||||
|
|
||||||
|
var framePool = [];
|
||||||
|
|
||||||
|
function scanEngine() {
|
||||||
|
var avatarLoudnessPool = [];
|
||||||
|
|
||||||
|
function average(a) {
|
||||||
|
var sum = 0;
|
||||||
|
var total = a.length;
|
||||||
|
for (var i = 0; i < total; i++) {
|
||||||
|
sum += a[i];
|
||||||
|
}
|
||||||
|
return Math.round(sum / total);
|
||||||
|
}
|
||||||
|
|
||||||
|
function audioClamp(input) {
|
||||||
|
if (input > MAX_AUDIO_THRESHOLD) return MAX_AUDIO_THRESHOLD;
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var avatars = AvatarList.getAvatarIdentifiers();
|
||||||
|
avatars.forEach(function (id) {
|
||||||
|
var avatar = AvatarList.getAvatar(id);
|
||||||
|
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
framePool.push(average(avatarLoudnessPool));
|
||||||
|
if (framePool.length >= REFERENCE_FRAME_COUNT) {
|
||||||
|
framePool.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizedAverage(a) {
|
||||||
|
a = a.map(function (v) {
|
||||||
|
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||||
|
});
|
||||||
|
return average(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
var norm = normalizedAverage(framePool);
|
||||||
|
|
||||||
|
Entities.editEntity(textID, {text: "Loudness: % " + norm});
|
||||||
|
|
||||||
|
var barProperties = Entities.getEntityProperties(barID);
|
||||||
|
|
||||||
|
|
||||||
|
var colorShift = 2.55 * norm; //shifting the scale to 0 - 255
|
||||||
|
var xShift = norm / 100; // changing scale from 0-100 to 0-1
|
||||||
|
var normShift = xShift - .5; //shifting scale form 0-1 to -.5 to .5
|
||||||
|
var halfShift = xShift / 2 ;
|
||||||
|
Entities.editEntity(barID, {
|
||||||
|
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||||
|
localPosition: {x: normShift - (halfShift), y: 0, z: 0.1},
|
||||||
|
color: {red: colorShift, green: barProperties.color.green, blue: barProperties.color.blue}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.setInterval(function () {
|
||||||
|
scanEngine();
|
||||||
|
}, SCAN_RATE);
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 5/2/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var pos = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||||
|
|
||||||
|
var meter = {
|
||||||
|
stand: {
|
||||||
|
type: 'Model',
|
||||||
|
modelURL: 'https://binaryrelay.com/files/public-docs/hifi/meter/applauseOmeter.fbx',
|
||||||
|
lifetime: '3600',
|
||||||
|
script: 'https://binaryrelay.com/files/public-docs/hifi/meter/applauseOmeter.js',
|
||||||
|
position: Vec3.sum(pos, {x: 0, y: 2.0, z: 0})
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Entities.addEntity(meter.stand);
|
||||||
|
|
||||||
|
})();
|
|
@ -0,0 +1,67 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 4/17/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
|
var pos = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||||
|
|
||||||
|
var graph = {
|
||||||
|
background: {
|
||||||
|
type: "Box",
|
||||||
|
dimensions: {x: 1, y: 1, z: .1},
|
||||||
|
color: {
|
||||||
|
red: 128,
|
||||||
|
green: 128,
|
||||||
|
blue: 128
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
script: "https://binaryrelay.com/files/public-docs/hifi/meter/basic/meter.js",
|
||||||
|
position: pos
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
type: "Box",
|
||||||
|
parentID: "",
|
||||||
|
userData: '{"name":"bar"}',
|
||||||
|
dimensions: {x: .05, y: .25, z: .1},
|
||||||
|
color: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
position: Vec3.sum(pos, {x: -0.495, y: 0, z: 0.1})
|
||||||
|
},
|
||||||
|
displayText: {
|
||||||
|
type: "Text",
|
||||||
|
parentID: "",
|
||||||
|
userData: '{"name":"displayText"}',
|
||||||
|
text: "Loudness: % ",
|
||||||
|
textColor: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
backgroundColor: {
|
||||||
|
red: 128,
|
||||||
|
green: 128,
|
||||||
|
blue: 128
|
||||||
|
},
|
||||||
|
visible: 0.5,
|
||||||
|
dimensions: {x: 0.70, y: 0.15, z: 0.1},
|
||||||
|
lifetime: "3600",
|
||||||
|
position: Vec3.sum(pos, {x: 0, y: 0.4, z: 0.06})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var background = Entities.addEntity(graph.background);
|
||||||
|
|
||||||
|
graph.bar.parentID = background;
|
||||||
|
graph.displayText.parentID = background;
|
||||||
|
|
||||||
|
var bar = Entities.addEntity(graph.bar);
|
||||||
|
var displayText = Entities.addEntity(graph.displayText);
|
||||||
|
|
||||||
|
|
||||||
|
})(); // END LOCAL_SCOPE
|
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 4/17/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var pos = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||||
|
|
||||||
|
var graph = {
|
||||||
|
background: {
|
||||||
|
type: "Model",
|
||||||
|
modelURL: "https://binaryrelay.com/files/public-docs/hifi/meter/plastic/meter-plastic.fbx",
|
||||||
|
color: {
|
||||||
|
red: 128,
|
||||||
|
green: 128,
|
||||||
|
blue: 128
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
script: "https://binaryrelay.com/files/public-docs/hifi/meter/plastic/meter.js",
|
||||||
|
position: pos
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
type: "Box",
|
||||||
|
parentID: "",
|
||||||
|
userData: '{"name":"bar"}',
|
||||||
|
dimensions: {x: .05, y: .245, z: .07},
|
||||||
|
color: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
position: Vec3.sum(pos, {x: -0.90, y: 0, z: -0.15})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
graph.bar.parentID = Entities.addEntity(graph.background);
|
||||||
|
Entities.addEntity(graph.bar);
|
||||||
|
|
||||||
|
|
||||||
|
})();
|
|
@ -0,0 +1,67 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 4/17/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var pos = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||||
|
|
||||||
|
var graph = {
|
||||||
|
background: {
|
||||||
|
type: "Model",
|
||||||
|
modelURL: "https://binaryrelay.com/files/public-docs/hifi/meter/text-entity/meter-text-entity.fbx",
|
||||||
|
color: {
|
||||||
|
red: 128,
|
||||||
|
green: 128,
|
||||||
|
blue: 128
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
script: "https://binaryrelay.com/files/public-docs/hifi/meter/text-entity/meter.js",
|
||||||
|
position: pos
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
type: "Box",
|
||||||
|
parentID: "",
|
||||||
|
userData: '{"name":"bar"}',
|
||||||
|
dimensions: {x: .05, y: .245, z: .07},
|
||||||
|
color: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
position: Vec3.sum(pos, {x: -0.88, y: 0, z: -0.15})
|
||||||
|
},
|
||||||
|
displayText: {
|
||||||
|
type: "Text",
|
||||||
|
parentID: "",
|
||||||
|
userData: '{"name":"displayText"}',
|
||||||
|
text: "Make Some Noise:",
|
||||||
|
textColor: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
backgroundColor: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
dimensions: {x: .82, y: 0.115, z: 0.15},
|
||||||
|
lifetime: "3600",
|
||||||
|
lineHeight: .08,
|
||||||
|
position: Vec3.sum(pos, {x: -0.2, y: 0.175, z: -0.035})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var background = Entities.addEntity(graph.background);
|
||||||
|
|
||||||
|
graph.bar.parentID = background;
|
||||||
|
graph.displayText.parentID = background;
|
||||||
|
|
||||||
|
var bar = Entities.addEntity(graph.bar);
|
||||||
|
var displayText = Entities.addEntity(graph.displayText);
|
||||||
|
|
||||||
|
|
||||||
|
})();
|
|
@ -0,0 +1,42 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 4/17/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var pos = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||||
|
|
||||||
|
var graph = {
|
||||||
|
background: {
|
||||||
|
type: "Model",
|
||||||
|
modelURL: "https://binaryrelay.com/files/public-docs/hifi/meter/wood/meter-wood.fbx",
|
||||||
|
color: {
|
||||||
|
red: 128,
|
||||||
|
green: 128,
|
||||||
|
blue: 128
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
script: "https://binaryrelay.com/files/public-docs/hifi/meter/wood/meter.js",
|
||||||
|
position: pos
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
type: "Box",
|
||||||
|
parentID: "",
|
||||||
|
userData: '{"name":"bar"}',
|
||||||
|
dimensions: {x: .05, y: .245, z: .07},
|
||||||
|
color: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
lifetime: "3600",
|
||||||
|
position: Vec3.sum(pos, {x: -0.88, y: 0, z: -0.15})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
graph.bar.parentID = Entities.addEntity(graph.background);
|
||||||
|
Entities.addEntity(graph.bar);
|
||||||
|
|
||||||
|
|
||||||
|
})();
|
|
@ -0,0 +1,89 @@
|
||||||
|
//
|
||||||
|
// Created by Alan-Michael Moody on 4/17/2017
|
||||||
|
//
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var barID, textID, originalText;
|
||||||
|
|
||||||
|
this.preload = function (entityID) {
|
||||||
|
|
||||||
|
var children = Entities.getChildrenIDs(entityID);
|
||||||
|
var childZero = Entities.getEntityProperties(children[0]);
|
||||||
|
var childOne = Entities.getEntityProperties(children[1]);
|
||||||
|
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
||||||
|
|
||||||
|
if (childZeroUserData.name === "bar") {
|
||||||
|
barID = childZero.id;
|
||||||
|
textID = childOne.id;
|
||||||
|
originalText = childOne.text
|
||||||
|
} else {
|
||||||
|
barID = childOne.id;
|
||||||
|
textID = childZero.id;
|
||||||
|
originalText = childZero.text;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var SCAN_RATE = 100; //ms
|
||||||
|
var REFERENCE_FRAME_COUNT = 30;
|
||||||
|
var MAX_AUDIO_THRESHOLD = 16000;
|
||||||
|
|
||||||
|
var framePool = [];
|
||||||
|
|
||||||
|
function scanEngine() {
|
||||||
|
var avatarLoudnessPool = [];
|
||||||
|
|
||||||
|
function average(a) {
|
||||||
|
var sum = 0;
|
||||||
|
var total = a.length;
|
||||||
|
for (var i = 0; i < total; i++) {
|
||||||
|
sum += a[i];
|
||||||
|
}
|
||||||
|
return Math.round(sum / total);
|
||||||
|
}
|
||||||
|
|
||||||
|
function audioClamp(input) {
|
||||||
|
if (input > MAX_AUDIO_THRESHOLD) return MAX_AUDIO_THRESHOLD;
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var avatars = AvatarList.getAvatarIdentifiers();
|
||||||
|
avatars.forEach(function (id) {
|
||||||
|
var avatar = AvatarList.getAvatar(id);
|
||||||
|
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
framePool.push(average(avatarLoudnessPool));
|
||||||
|
if (framePool.length >= REFERENCE_FRAME_COUNT) {
|
||||||
|
framePool.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizedAverage(a) {
|
||||||
|
a = a.map(function (v) {
|
||||||
|
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||||
|
});
|
||||||
|
return average(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
var norm = normalizedAverage(framePool);
|
||||||
|
Entities.editEntity(textID, {text: originalText + " % " + norm});
|
||||||
|
|
||||||
|
var barProperties = Entities.getEntityProperties(barID);
|
||||||
|
|
||||||
|
var colorShift = 2.55 * norm; //shifting the scale to 0 - 255
|
||||||
|
var xShift = norm / 52; // changing scale from 0-100 to 0-1.9 ish
|
||||||
|
var normShift = xShift - 0.88; //shifting local displacement (-0.88)
|
||||||
|
var halfShift = xShift / 2;
|
||||||
|
Entities.editEntity(barID, {
|
||||||
|
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||||
|
localPosition: {x: normShift - ( halfShift ), y: -0.0625, z: -0.015},
|
||||||
|
color: {red: colorShift, green: barProperties.color.green, blue: barProperties.color.blue}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.setInterval(function () {
|
||||||
|
scanEngine();
|
||||||
|
}, SCAN_RATE);
|
||||||
|
|
||||||
|
});
|
After Width: | Height: | Size: 399 KiB |
After Width: | Height: | Size: 410 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 2.1 MiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 651 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 528 KiB |