Improving VR grabscale

-Gizmo entities updated to avatar entities
-Added lifetime of 300 seconds for gizmo etities + interval updater
-Added righthand distance checker
-Changed renderLayer to front
This commit is contained in:
Basinsky 2020-05-20 00:01:40 +02:00 committed by GitHub
parent 91b83ab5ea
commit 8d4c93c424
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,7 +30,7 @@ var entityRotation;
var isDirectionFound = false; var isDirectionFound = false;
var handPositionLeft; var handPositionLeft;
var handPositionRight; var handPositionRight;
var SCALE_RATIO = 2.2; var SCALE_RATIO = 0.3;
var GIZMO_CYLINDER_LENGTH = 0.3; var GIZMO_CYLINDER_LENGTH = 0.3;
var GIZMO_CYLINDER_LENGTH_RATIO = 0.025; var GIZMO_CYLINDER_LENGTH_RATIO = 0.025;
var GIZMO_CYLINDER_DIAMETER = GIZMO_CYLINDER_LENGTH * GIZMO_CYLINDER_LENGTH_RATIO; var GIZMO_CYLINDER_DIAMETER = GIZMO_CYLINDER_LENGTH * GIZMO_CYLINDER_LENGTH_RATIO;
@ -38,6 +38,9 @@ var GIZMO_CENTER_DIAMETER = 0.05;
var GIZMO_END_DIAMETER = 0.02; var GIZMO_END_DIAMETER = 0.02;
var GIZMO_END_POSITION = GIZMO_CYLINDER_LENGTH * 0.5; var GIZMO_END_POSITION = GIZMO_CYLINDER_LENGTH * 0.5;
var GIZMO_DEFAULT_SCALE = 0.2; var GIZMO_DEFAULT_SCALE = 0.2;
var LIFETIME = 300; // sec
var EXPIRE_OFFSET = 10; // sec
var SEC_TO_MS = 1000;
var gizmoShapeIDs = []; var gizmoShapeIDs = [];
var DECIMAL_PRECISION = 4; var DECIMAL_PRECISION = 4;
var ENTITIES_TO_UPDATE; var ENTITIES_TO_UPDATE;
@ -65,6 +68,7 @@ var isScaleModeX = false;
var isScaleModeY = false; var isScaleModeY = false;
var isScaleModeZ = false; var isScaleModeZ = false;
var gizmoEndpointsDistanceLeft = []; var gizmoEndpointsDistanceLeft = [];
var gizmoEndpointsDistanceRight = [];
var rightGripState = 0; var rightGripState = 0;
var leftGripState = 0; var leftGripState = 0;
var LEFT_HAND_INDEX = MyAvatar.getJointIndex("LeftHand"); var LEFT_HAND_INDEX = MyAvatar.getJointIndex("LeftHand");
@ -79,7 +83,7 @@ var overlayID = Overlays.addOverlay("text3d", {
lineHeight: 0.05, lineHeight: 0.05,
dimensions: { x: 2, y: 0.5, z: 0.5 }, dimensions: { x: 2, y: 0.5, z: 0.5 },
drawInFront: true drawInFront: true
}, "local"); }, "local");
function createGizmo() { function createGizmo() {
gizmoCenterID = Entities.addEntity({ gizmoCenterID = Entities.addEntity({
@ -88,13 +92,14 @@ function createGizmo() {
name: "gizmoCenter", name: "gizmoCenter",
description: "", description: "",
position: { x: 0, y: 0, z: 0}, position: { x: 0, y: 0, z: 0},
lifetime: -1, lifetime: LIFETIME,
color: { r: 100, g: 100, b: 100 }, color: { r: 100, g: 100, b: 100 },
renderLayer: "front",
alpha: 0.5, alpha: 0.5,
dimensions: { x: GIZMO_CENTER_DIAMETER, y: GIZMO_CENTER_DIAMETER, z: GIZMO_CENTER_DIAMETER }, dimensions: { x: GIZMO_CENTER_DIAMETER, y: GIZMO_CENTER_DIAMETER, z: GIZMO_CENTER_DIAMETER },
collisionless: true, collisionless: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoCenterID); gizmoShapeIDs.push(gizmoCenterID);
var tempRotation = Quat.fromPitchYawRollRadians(0, 0, 0); var tempRotation = Quat.fromPitchYawRollRadians(0, 0, 0);
@ -106,13 +111,14 @@ function createGizmo() {
description: "", description: "",
localPosition: { x: 0, y: 0, z: 0 }, localPosition: { x: 0, y: 0, z: 0 },
localRotation: tempRotation, localRotation: tempRotation,
lifetime: -1, lifetime: LIFETIME,
color: { r: 100, g: 0, b: 0 }, color: { r: 100, g: 0, b: 0 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_CYLINDER_LENGTH, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER }, dimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH, z: GIZMO_CYLINDER_DIAMETER },
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false} }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false} }"
}); },"avatar");
gizmoShapeIDs.push(gizmoXaxisID); gizmoShapeIDs.push(gizmoXaxisID);
tempRotation = Quat.fromPitchYawRollRadians(0 , 0 ,-Math.PI/2); tempRotation = Quat.fromPitchYawRollRadians(0 , 0 ,-Math.PI/2);
@ -124,13 +130,14 @@ function createGizmo() {
description: "", description: "",
localPosition: { x: 0, y: 0, z: 0 }, localPosition: { x: 0, y: 0, z: 0 },
localRotation: tempRotation, localRotation: tempRotation,
lifetime: -1, lifetime: LIFETIME,
color: { r: 0, g: 100, b: 0 }, color: { r: 0, g: 100, b: 0 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_CYLINDER_LENGTH, z: GIZMO_END_DIAMETER }, dimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH, z: GIZMO_CYLINDER_DIAMETER },
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoYaxisID); gizmoShapeIDs.push(gizmoYaxisID);
tempRotation = Quat.fromPitchYawRollRadians(-Math.PI/2,0,0); tempRotation = Quat.fromPitchYawRollRadians(-Math.PI/2,0,0);
@ -142,13 +149,14 @@ function createGizmo() {
description: "", description: "",
localPosition: { x: 0, y: 0, z: 0 }, localPosition: { x: 0, y: 0, z: 0 },
localRotation: tempRotation, localRotation: tempRotation,
lifetime: -1, lifetime: LIFETIME,
color: { r: 0 ,g: 0, b: 100 }, color: { r: 0 ,g: 0, b: 100 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_CYLINDER_LENGTH }, dimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH, z: GIZMO_CYLINDER_DIAMETER },
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoZaxisID); gizmoShapeIDs.push(gizmoZaxisID);
gizmoXplusID = Entities.addEntity({ gizmoXplusID = Entities.addEntity({
@ -158,13 +166,14 @@ function createGizmo() {
parentID: gizmoXaxisID, parentID: gizmoXaxisID,
description: "", description: "",
localPosition: { x: 0, y: GIZMO_END_POSITION, z: 0 }, localPosition: { x: 0, y: GIZMO_END_POSITION, z: 0 },
lifetime: -1, lifetime: LIFETIME,
color: { r: 255, g: 0, b: 0 }, color: { r: 255, g: 0, b: 0 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER }, dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER },
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoXplusID); gizmoShapeIDs.push(gizmoXplusID);
gizmoXminusID = Entities.addEntity({ gizmoXminusID = Entities.addEntity({
@ -174,13 +183,14 @@ function createGizmo() {
parentID: gizmoXaxisID, parentID: gizmoXaxisID,
description: "", description: "",
localPosition: { x: 0, y: -GIZMO_END_POSITION, z: 0 }, localPosition: { x: 0, y: -GIZMO_END_POSITION, z: 0 },
lifetime: -1, lifetime: LIFETIME,
color: { r: 255, g: 0, b: 0}, color: { r: 255, g: 0, b: 0},
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: {x: GIZMO_END_DIAMETER,y: GIZMO_END_DIAMETER,z: GIZMO_END_DIAMETER}, dimensions: {x: GIZMO_END_DIAMETER,y: GIZMO_END_DIAMETER,z: GIZMO_END_DIAMETER},
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoXminusID); gizmoShapeIDs.push(gizmoXminusID);
gizmoYplusID = Entities.addEntity({ gizmoYplusID = Entities.addEntity({
@ -190,13 +200,14 @@ function createGizmo() {
parentID: gizmoYaxisID, parentID: gizmoYaxisID,
description: "", description: "",
localPosition: { x: 0, y: GIZMO_END_POSITION, z: 0 }, localPosition: { x: 0, y: GIZMO_END_POSITION, z: 0 },
lifetime: -1, lifetime: LIFETIME,
color: { r: 0, g: 255, b: 0 }, color: { r: 0, g: 255, b: 0 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER }, dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER },
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoYplusID); gizmoShapeIDs.push(gizmoYplusID);
gizmoYminusID = Entities.addEntity({ gizmoYminusID = Entities.addEntity({
@ -206,13 +217,14 @@ function createGizmo() {
parentID: gizmoYaxisID, parentID: gizmoYaxisID,
description: "", description: "",
localPosition: { x: 0, y: -GIZMO_END_POSITION, z: 0 }, localPosition: { x: 0, y: -GIZMO_END_POSITION, z: 0 },
lifetime: -1, lifetime: LIFETIME,
color: { r: 0, g: 255, b: 0 }, color: { r: 0, g: 255, b: 0 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER }, dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER },
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoYminusID); gizmoShapeIDs.push(gizmoYminusID);
gizmoZplusID = Entities.addEntity({ gizmoZplusID = Entities.addEntity({
@ -222,13 +234,14 @@ function createGizmo() {
parentID: gizmoZaxisID, parentID: gizmoZaxisID,
description: "", description: "",
localPosition: { x: 0, y: GIZMO_END_POSITION, z: 0 }, localPosition: { x: 0, y: GIZMO_END_POSITION, z: 0 },
lifetime: -1, lifetime: LIFETIME,
color: { r: 0, g: 0, b: 255 }, color: { r: 0, g: 0, b: 255 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER }, dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER },
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoZplusID); gizmoShapeIDs.push(gizmoZplusID);
gizmoZminusID = Entities.addEntity({ gizmoZminusID = Entities.addEntity({
@ -238,13 +251,14 @@ function createGizmo() {
parentID: gizmoZaxisID, parentID: gizmoZaxisID,
description: "", description: "",
localPosition: { x: 0, y: -GIZMO_END_POSITION, z: 0}, localPosition: { x: 0, y: -GIZMO_END_POSITION, z: 0},
lifetime: -1, lifetime: LIFETIME,
color: { r: 0, g: 0, b: 255 }, color: { r: 0, g: 0, b: 255 },
renderLayer: "front",
alpha: 1, alpha: 1,
dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER}, dimensions: { x: GIZMO_END_DIAMETER, y: GIZMO_END_DIAMETER, z: GIZMO_END_DIAMETER},
ignoreForCollisions: true, ignoreForCollisions: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(gizmoZminusID); gizmoShapeIDs.push(gizmoZminusID);
ENTITIES_TO_UPDATE = [gizmoXplusID, gizmoXminusID, gizmoYplusID, gizmoYminusID, gizmoZplusID, gizmoZminusID]; ENTITIES_TO_UPDATE = [gizmoXplusID, gizmoXminusID, gizmoYplusID, gizmoYminusID, gizmoZplusID, gizmoZminusID];
// add spheres at joint positions for debugging // add spheres at joint positions for debugging
@ -257,13 +271,14 @@ function createGizmo() {
parentJointIndex: LEFT_JOINT, parentJointIndex: LEFT_JOINT,
description: "", description: "",
localPosition: { x: 0, y: 0, z: 0}, localPosition: { x: 0, y: 0, z: 0},
lifetime: -1, lifetime: LIFETIME,
color: { r: 255, g: 100, b: 100 }, color: { r: 255, g: 100, b: 100 },
renderLayer: "front",
alpha: 0.5, alpha: 0.5,
localDimensions: { x: 0.05, y: 0.05, z: 0.05 }, localDimensions: { x: 0.05, y: 0.05, z: 0.05 },
collisionless: true, collisionless: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(debugLeftHandID); gizmoShapeIDs.push(debugLeftHandID);
debugRightHandID = Entities.addEntity({ debugRightHandID = Entities.addEntity({
type: "Shape", type: "Shape",
@ -273,13 +288,14 @@ function createGizmo() {
parentJointIndex: RIGHT_JOINT, parentJointIndex: RIGHT_JOINT,
description: "", description: "",
localPosition: { x: 0, y: 0, z: 0}, localPosition: { x: 0, y: 0, z: 0},
lifetime: -1, lifetime: LIFETIME,
color: { r: 100, g: 255, b: 100 }, color: { r: 100, g: 255, b: 100 },
renderLayer: "front",
alpha: 0.5, alpha: 0.5,
localDimensions: { x: 0.05, y: 0.05, z: 0.05 }, localDimensions: { x: 0.05, y: 0.05, z: 0.05 },
collisionless: true, collisionless: true,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }" userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false } }"
}); },"avatar");
gizmoShapeIDs.push(debugRightHandID); gizmoShapeIDs.push(debugRightHandID);
} }
} }
@ -345,13 +361,13 @@ function getJointIndex() {
function updateGizmoScale(scaleUpdateX, scaleUpdateY, scaleUpdateZ) { function updateGizmoScale(scaleUpdateX, scaleUpdateY, scaleUpdateZ) {
Entities.editEntity(gizmoXaxisID, { Entities.editEntity(gizmoXaxisID, {
dimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH*scaleUpdateX*2, z: GIZMO_CYLINDER_DIAMETER } localDimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH*scaleUpdateX*2, z: GIZMO_CYLINDER_DIAMETER }
}); });
Entities.editEntity(gizmoYaxisID, { Entities.editEntity(gizmoYaxisID, {
dimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH*scaleUpdateY*2, z: GIZMO_CYLINDER_DIAMETER } localDimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH*scaleUpdateY*2, z: GIZMO_CYLINDER_DIAMETER }
}); });
Entities.editEntity(gizmoZaxisID, { Entities.editEntity(gizmoZaxisID, {
dimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH*scaleUpdateZ*2, z: GIZMO_CYLINDER_DIAMETER } localDimensions: { x: GIZMO_CYLINDER_DIAMETER, y: GIZMO_CYLINDER_LENGTH*scaleUpdateZ*2, z: GIZMO_CYLINDER_DIAMETER }
}); });
Entities.editEntity(gizmoXplusID, { Entities.editEntity(gizmoXplusID, {
localPosition: {x: 0, y: GIZMO_END_POSITION*scaleUpdateX*2, z: 0 } localPosition: {x: 0, y: GIZMO_END_POSITION*scaleUpdateX*2, z: 0 }
@ -390,7 +406,7 @@ function isGizmo(id) {
} }
function startScaling() { function startScaling() {
if (!isScaling) { if (!isScaling) {
showGizmo(); showGizmo();
var startHandPositionLeft = MyAvatar.getJointPosition(LEFT_JOINT); var startHandPositionLeft = MyAvatar.getJointPosition(LEFT_JOINT);
var startHandPositionRight = MyAvatar.getJointPosition(RIGHT_JOINT); var startHandPositionRight = MyAvatar.getJointPosition(RIGHT_JOINT);
@ -414,12 +430,14 @@ function startScaling() {
if (isScaleModeZ) { if (isScaleModeZ) {
newDimensions = { x: oldDimensions.x, y: oldDimensions.y, z: oldDimensions.z* newScale }; newDimensions = { x: oldDimensions.x, y: oldDimensions.y, z: oldDimensions.z* newScale };
scaleZ = newScale; scaleZ = newScale;
} }
Entities.editEntity(entityToBeGrabbedID,{dimensions: newDimensions}); if (isScaleModeX || isScaleModeY || isScaleModeZ) {
updateGizmoScale( Entities.editEntity(entityToBeGrabbedID,{dimensions: newDimensions});
oldDimensions.x*scaleX*SCALE_RATIO, updateGizmoScale(
oldDimensions.y*scaleY*SCALE_RATIO, scaleX*SCALE_RATIO,
oldDimensions.z*scaleZ*SCALE_RATIO); scaleY*SCALE_RATIO,
scaleZ*SCALE_RATIO);
}
} }
@ -463,27 +481,35 @@ function startBuilding() {
startScaling(); startScaling();
} }
if (entityToBeGrabbedID) { if (entityToBeGrabbedID) {
handPositionLeft = MyAvatar.getJointPosition(LEFT_JOINT);
handPositionRight = MyAvatar.getJointPosition(RIGHT_JOINT);
var entityProperties = Entities.getEntityProperties(entityToBeGrabbedID,["position","rotation"]); var entityProperties = Entities.getEntityProperties(entityToBeGrabbedID,["position","rotation"]);
entityPosition = entityProperties.position; entityPosition = entityProperties.position;
entityRotation = entityProperties.rotation; entityRotation = entityProperties.rotation;
handPositionLeft = MyAvatar.getJointPosition(LEFT_JOINT);
handPositionRight = MyAvatar.getJointPosition(RIGHT_JOINT);
updateGizmoPositionRotation(entityPosition,entityRotation); updateGizmoPositionRotation(entityPosition,entityRotation);
var localPositions = Entities.getMultipleEntityProperties(ENTITIES_TO_UPDATE, "localPosition"); var localPositions = Entities.getMultipleEntityProperties(ENTITIES_TO_UPDATE, "localPosition");
for (var i = 0; i < localPositions.length; i++) { for (var i = 0; i < localPositions.length; i++) {
gizmoEndpointsDistanceLeft[i] = Vec3.distance(handPositionLeft, gizmoEndpointsDistanceLeft[i] = Vec3.distance(handPositionLeft,
Entities.localToWorldPosition(localPositions[i].localPosition, ENTITIES_TO_UPDATE[i], -1)); Entities.localToWorldPosition(localPositions[i].localPosition, ENTITIES_TO_UPDATE[i], -1));
gizmoEndpointsDistanceRight[i+6] = Vec3.distance(handPositionRight,
Entities.localToWorldPosition(localPositions[i].localPosition, ENTITIES_TO_UPDATE[i], -1));
} }
minimum = Math.min(gizmoEndpointsDistanceLeft[0], minimum = Math.min(gizmoEndpointsDistanceLeft[0],
gizmoEndpointsDistanceLeft[1], gizmoEndpointsDistanceLeft[1],
gizmoEndpointsDistanceLeft[2], gizmoEndpointsDistanceLeft[2],
gizmoEndpointsDistanceLeft[3], gizmoEndpointsDistanceLeft[3],
gizmoEndpointsDistanceLeft[4], gizmoEndpointsDistanceLeft[4],
gizmoEndpointsDistanceLeft[5]); gizmoEndpointsDistanceLeft[5],
gizmoEndpointsDistanceRight[6],
gizmoEndpointsDistanceRight[7],
gizmoEndpointsDistanceRight[8],
gizmoEndpointsDistanceRight[9],
gizmoEndpointsDistanceRight[10],
gizmoEndpointsDistanceRight[11]);
index = gizmoEndpointsDistanceLeft.indexOf(minimum); index = gizmoEndpointsDistanceLeft.indexOf(minimum);
if (index === 0 || index === 1) { if (index === 0 || index === 1 || index === 6 || index === 7) {
if (!isDirectionFound) { if (!isDirectionFound) {
isScaleModeX = true; isScaleModeX = true;
isScaleModeY = false; isScaleModeY = false;
@ -491,7 +517,7 @@ function startBuilding() {
isDirectionFound = true; isDirectionFound = true;
} }
} }
if (index === 2 || index === 3) { if (index === 2 || index === 3 || index === 8 || index === 9) {
if (!isDirectionFound) { if (!isDirectionFound) {
isScaleModeY = false; isScaleModeY = false;
isScaleModeY = true; isScaleModeY = true;
@ -499,7 +525,7 @@ function startBuilding() {
isDirectionFound = true; isDirectionFound = true;
} }
} }
if (index === 4 || index === 5) { if (index === 4 || index === 5 || index === 10 || index === 11) {
if (!isDirectionFound) { if (!isDirectionFound) {
isScaleModeZ = false; isScaleModeZ = false;
isScaleModeY = false; isScaleModeY = false;
@ -567,4 +593,12 @@ Messages.messageReceived.connect(onMessageReceived);
createGizmo(); createGizmo();
getJointIndex(); getJointIndex();
updateGizmoScale(GIZMO_DEFAULT_SCALE); updateGizmoScale(GIZMO_DEFAULT_SCALE);
var lifeTimeUpdater = Script.setInterval(function() {
if (gizmoCenterID) {
Entities.deleteEntity (gizmoCenterID);
createGizmo();
print("lifetimeupdater");
}
}, (LIFETIME - EXPIRE_OFFSET) * SEC_TO_MS);
Script.update.connect(startBuilding); Script.update.connect(startBuilding);