Fixed issue with overlays disapearing on release grab

This commit is contained in:
ericrius1 2015-10-28 13:18:57 -07:00
parent 2f835b19fa
commit 4027782335
2 changed files with 40 additions and 52 deletions

View file

@ -47,6 +47,7 @@
if (this.painting) { if (this.painting) {
return; return;
} }
this.whichHand = this.hand;
if (this.hand === RIGHT_HAND) { if (this.hand === RIGHT_HAND) {
this.getHandPosition = MyAvatar.getRightPalmPosition; this.getHandPosition = MyAvatar.getRightPalmPosition;
this.getHandRotation = MyAvatar.getRightPalmRotation; this.getHandRotation = MyAvatar.getRightPalmRotation;
@ -183,6 +184,9 @@
}, },
releaseGrab: function() { releaseGrab: function() {
if(this.hand !== this.whichHand) {
return;
}
this.stopPainting(); this.stopPainting();
}, },

View file

@ -22,12 +22,14 @@ var modelURL = "http://localhost:8080/whiteboard.fbx?v1" + Math.random();
var colorIndicatorBorderModelURL = "http://localhost:8080/colorIndicatorBorder.fbx?v1" + Math.random(); var colorIndicatorBorderModelURL = "http://localhost:8080/colorIndicatorBorder.fbx?v1" + Math.random();
var eraseModelURL = "http://localhost:8080/eraser.fbx?v1" + Math.random();
var surfaceModelURL = "http://localhost:8080/boardSurface.fbx?v1" + Math.random(); var surfaceModelURL = "http://localhost:8080/boardSurface.fbx?v1" + Math.random();
var rotation = Quat.safeEulerAngles(Camera.getOrientation()); var rotation = Quat.safeEulerAngles(Camera.getOrientation());
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0); rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation))); var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation)));
var whiteboardDimensions, colorIndicatorBoxDimensions, colorIndicatorBox, eraseAllText var whiteboardDimensions, colorIndicatorBoxDimensions, colorIndicatorBox, eraser;
var colorBoxes = []; var colorBoxes = [];
var colors = [ var colors = [
@ -48,7 +50,11 @@ var whiteboard = Entities.addEntity({
rotation: rotation, rotation: rotation,
}); });
var colorIndicatorPosition = {x: center.x, y: center.y, z: center.z}; var colorIndicatorPosition = {
x: center.x,
y: center.y,
z: center.z
};
colorIndicatorPosition.y += 1.55; colorIndicatorPosition.y += 1.55;
colorIndicatorPosition = Vec3.sum(colorIndicatorPosition, Vec3.multiply(-0.1, Quat.getFront(rotation))); colorIndicatorPosition = Vec3.sum(colorIndicatorPosition, Vec3.multiply(-0.1, Quat.getFront(rotation)));
var colorIndicatorBorder = Entities.addEntity({ var colorIndicatorBorder = Entities.addEntity({
@ -60,27 +66,40 @@ var colorIndicatorBorder = Entities.addEntity({
}); });
var surfaceCenter = Vec3.sum(center, Vec3.multiply(-0.1, Quat.getFront(rotation))); var surfaceCenter = Vec3.sum(center, Vec3.multiply(-0.1, Quat.getFront(rotation)));
surfaceCenter.y += 0.6; surfaceCenter.y += 0.6;
var drawingSurface = Entities.addEntity({ var drawingSurface = Entities.addEntity({
type: "Model", type: "Model",
modelURL: surfaceModelURL, modelURL: surfaceModelURL,
shapeType: "box", shapeType: "box",
name: "whiteboard surface", name: "whiteboard surface",
position: surfaceCenter, position: surfaceCenter,
// dimensions: {x: 1.7, y: 1.3, z: 0.01},
script: scriptURL, script: scriptURL,
rotation: rotation, rotation: rotation,
userData: JSON.stringify({ userData: JSON.stringify({
color: { color: {
currentColor: colors[0] currentColor: colors[0]
} }
}) })
}) });
var eraseModelPosition = Vec3.sum(center, {x: 0, y: 2, z: 0 });
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
var eraser = Entities.addEntity({
type: "Model",
modelURL: eraseModelURL,
position: eraseModelPosition,
name: "Eraser",
script: scriptURL,
rotation: rotation,
userData: JSON.stringify({
whiteboard: drawingSurface
})
});
Script.setTimeout(function() { Script.setTimeout(function() {
whiteboardDimensions = Entities.getEntityProperties(whiteboard, "naturalDimensions").naturalDimensions; whiteboardDimensions = Entities.getEntityProperties(whiteboard, "naturalDimensions").naturalDimensions;
colorIndicatorDimensions = Entities.getEntityProperties(colorIndicatorBorder, "naturalDimensions").naturalDimensions; colorIndicatorBorderDimensions = Entities.getEntityProperties(colorIndicatorBorder, "naturalDimensions").naturalDimensions;
setUp(); setUp();
}, 1000) }, 1000)
@ -89,24 +108,25 @@ function setUp() {
// COLOR INDICATOR BOX // COLOR INDICATOR BOX
var colorIndicatorDimensions = { var eraseModelDimensions = Entities.getEntityProperties(eraser, "naturalDimensions").naturalDimensions;
x: whiteboardDimensions.x, Entities.editEntity(eraser, {dimensions: eraseModelDimensions});
y: 0.5, Entities.editEntity(colorIndicatorBorder, {dimensions: colorIndicatorBorderDimensions});
z: 0.02
};
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js"); scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
var colorIndicatorPosition = Vec3.sum(center, { var colorIndicatorPosition = Vec3.sum(center, {
x: 0, x: 0,
y: whiteboardDimensions.y / 2 + colorIndicatorDimensions.y / 2, y: whiteboardDimensions.y / 2 + colorIndicatorBorderDimensions.y / 2,
z: 0 z: 0
}); });
colorIndicatorPosition = Vec3.sum(colorIndicatorPosition, Vec3.multiply(-.1, Quat.getFront(rotation)));
var colorIndicatorBoxDimensions = Vec3.multiply(colorIndicatorBorderDimensions, 0.9);
colorIndicatorBox = Entities.addEntity({ colorIndicatorBox = Entities.addEntity({
type: "Box", type: "Box",
name: "Color Indicator", name: "Color Indicator",
color: colors[0], color: colors[0],
rotation: rotation, rotation: rotation,
position: colorIndicatorPosition, position: colorIndicatorPosition,
dimensions: colorIndicatorDimensions, dimensions: colorIndicatorBoxDimensions,
script: scriptURL, script: scriptURL,
userData: JSON.stringify({ userData: JSON.stringify({
whiteboard: drawingSurface whiteboard: drawingSurface
@ -158,49 +178,13 @@ function setUp() {
colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes); colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes);
} }
var eraseBoxDimensions = {
x: 0.5,
y: 0.1,
z: 0.01
};
var eraseBoxPosition = Vec3.sum(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + eraseBoxDimensions.x / 2 + 0.01));
eraseBoxPosition.y += 0.3;
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
eraseAllText = Entities.addEntity({
type: "Text",
position: eraseBoxPosition,
name: "Eraser",
script: scriptURL,
rotation: rotation,
dimensions: eraseBoxDimensions,
backgroundColor: {
red: 0,
green: 60,
blue: 0
},
textColor: {
red: 255,
green: 10,
blue: 10
},
text: "ERASE BOARD",
lineHeight: 0.07,
userData: JSON.stringify({
whiteboard: drawingSurface
})
});
} }
function cleanup() { function cleanup() {
Entities.deleteEntity(whiteboard); Entities.deleteEntity(whiteboard);
Entities.deleteEntity(drawingSurface); Entities.deleteEntity(drawingSurface);
Entities.deleteEntity(colorIndicatorBorder); Entities.deleteEntity(colorIndicatorBorder);
Entities.deleteEntity(eraseAllText); Entities.deleteEntity(eraser);
Entities.deleteEntity(colorIndicatorBox); Entities.deleteEntity(colorIndicatorBox);
colorBoxes.forEach(function(colorBox) { colorBoxes.forEach(function(colorBox) {
Entities.deleteEntity(colorBox); Entities.deleteEntity(colorBox);