mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #6208 from ericrius1/closePaintModel
Added to the whiteboard model, and some bug fixes
This commit is contained in:
commit
846310f9fb
2 changed files with 150 additions and 135 deletions
|
@ -47,6 +47,7 @@
|
|||
if (this.painting) {
|
||||
return;
|
||||
}
|
||||
this.whichHand = this.hand;
|
||||
if (this.hand === RIGHT_HAND) {
|
||||
this.getHandPosition = MyAvatar.getRightPalmPosition;
|
||||
this.getHandRotation = MyAvatar.getRightPalmRotation;
|
||||
|
@ -183,6 +184,9 @@
|
|||
},
|
||||
|
||||
releaseGrab: function() {
|
||||
if(this.hand !== this.whichHand) {
|
||||
return;
|
||||
}
|
||||
this.stopPainting();
|
||||
|
||||
},
|
||||
|
@ -241,10 +245,8 @@
|
|||
Overlays.deleteOverlay(this.laserPointer);
|
||||
// this.eraseBoard();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new Whiteboard();
|
||||
});
|
|
@ -16,186 +16,199 @@
|
|||
|
||||
Script.include("../../libraries/utils.js");
|
||||
var scriptURL = Script.resolvePath("whiteboardEntityScript.js");
|
||||
var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/whiteboard.fbx";
|
||||
|
||||
var colorIndicatorBorderModelURL = "https://s3.amazonaws.com/hifi-public/eric/models/colorIndicatorBorder.fbx";
|
||||
var eraserModelURL = "https://s3.amazonaws.com/hifi-public/eric/models/eraser.fbx";
|
||||
var surfaceModelURL = "https://s3.amazonaws.com/hifi-public/eric/models/boardSurface.fbx";
|
||||
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
||||
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(rotation)));
|
||||
center.y += 0.4;
|
||||
|
||||
var whiteboardDimensions, colorIndicatorBoxDimensions, colorIndicatorBox, eraser, blocker;
|
||||
var colorBoxes = [];
|
||||
|
||||
var colors = [
|
||||
hexToRgb("#2F8E84"),
|
||||
hexToRgb("#66CCB3"),
|
||||
hexToRgb("#A43C37"),
|
||||
hexToRgb("#491849"),
|
||||
hexToRgb("#6AB03B"),
|
||||
hexToRgb("#993369"),
|
||||
hexToRgb("#9B47C2")
|
||||
hexToRgb("#000000")
|
||||
];
|
||||
|
||||
//WHITEBOARD
|
||||
var whiteboardDimensions = {
|
||||
x: 2,
|
||||
y: 1.5,
|
||||
z: 0.08
|
||||
};
|
||||
var whiteboard = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: "https://hifi-public.s3.amazonaws.com/ozan/support/for_eric/whiteboard/whiteboard.fbx",
|
||||
name: "whiteboard",
|
||||
shapeType: "box",
|
||||
modelURL: modelURL,
|
||||
name: "whiteboard base",
|
||||
position: center,
|
||||
rotation: rotation,
|
||||
script: scriptURL,
|
||||
dimensions: whiteboardDimensions,
|
||||
color: {
|
||||
red: 255,
|
||||
green: 255,
|
||||
blue: 255
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// COLOR INDICATOR BOX
|
||||
var colorIndicatorDimensions = {
|
||||
x: whiteboardDimensions.x,
|
||||
y: 0.05,
|
||||
z: 0.02
|
||||
var colorIndicatorPosition = {
|
||||
x: center.x,
|
||||
y: center.y,
|
||||
z: center.z
|
||||
};
|
||||
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
|
||||
var colorIndicatorPosition = Vec3.sum(center, {
|
||||
x: 0,
|
||||
y: whiteboardDimensions.y / 2 + colorIndicatorDimensions.y / 2,
|
||||
z: 0
|
||||
});
|
||||
var colorIndicatorBox = Entities.addEntity({
|
||||
type: "Box",
|
||||
name: "Color Indicator",
|
||||
color: colors[0],
|
||||
rotation: rotation,
|
||||
colorIndicatorPosition.y += 1.55;
|
||||
colorIndicatorPosition = Vec3.sum(colorIndicatorPosition, Vec3.multiply(-0.1, Quat.getFront(rotation)));
|
||||
var colorIndicatorBorder = Entities.addEntity({
|
||||
type: "Model",
|
||||
position: colorIndicatorPosition,
|
||||
dimensions: colorIndicatorDimensions,
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
whiteboard: whiteboard
|
||||
})
|
||||
modelURL: colorIndicatorBorderModelURL,
|
||||
rotation: rotation,
|
||||
shapeType: "box"
|
||||
});
|
||||
|
||||
Entities.editEntity(whiteboard, {
|
||||
var surfaceCenter = Vec3.sum(center, Vec3.multiply(-0.1, Quat.getFront(rotation)));
|
||||
surfaceCenter.y += 0.6;
|
||||
var drawingSurface = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: surfaceModelURL,
|
||||
shapeType: "box",
|
||||
name: "whiteboard surface",
|
||||
position: surfaceCenter,
|
||||
script: scriptURL,
|
||||
rotation: rotation,
|
||||
userData: JSON.stringify({
|
||||
color: {
|
||||
currentColor: colors[0]
|
||||
},
|
||||
colorIndicator: colorIndicatorBox
|
||||
})
|
||||
});
|
||||
|
||||
//COLOR BOXES
|
||||
var direction = Quat.getRight(rotation);
|
||||
var colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2));
|
||||
var colorBoxes = [];
|
||||
var colorSquareDimensions = {
|
||||
x: (whiteboardDimensions.x / 2) / (colors.length - 1),
|
||||
y: 0.1,
|
||||
z: 0.05
|
||||
};
|
||||
colorBoxPosition.y += whiteboardDimensions.y / 2 + colorIndicatorDimensions.y + colorSquareDimensions.y / 2;
|
||||
var spaceBetweenColorBoxes = Vec3.multiply(direction, colorSquareDimensions.x * 2);
|
||||
var scriptURL = Script.resolvePath("colorSelectorEntityScript.js");
|
||||
for (var i = 0; i < colors.length; i++) {
|
||||
var colorBox = Entities.addEntity({
|
||||
type: "Box",
|
||||
name: "Color Selector",
|
||||
position: colorBoxPosition,
|
||||
dimensions: colorSquareDimensions,
|
||||
rotation: rotation,
|
||||
color: colors[i],
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
whiteboard: whiteboard,
|
||||
colorIndicator: colorIndicatorBox
|
||||
})
|
||||
});
|
||||
colorBoxes.push(colorBox);
|
||||
colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes);
|
||||
}
|
||||
|
||||
|
||||
// BLACK BOX
|
||||
var blackBoxDimensions = {
|
||||
x: 0.3,
|
||||
y: 0.3,
|
||||
z: 0.01
|
||||
};
|
||||
|
||||
colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2 + blackBoxDimensions.x / 2 - 0.01));
|
||||
colorBoxPosition.y += 0.3;
|
||||
var fragShaderURL = Script.resolvePath('blackInk.fs?v1' + Math.random());
|
||||
var blackBox = Entities.addEntity({
|
||||
type: 'Box',
|
||||
name: "Black Color",
|
||||
position: colorBoxPosition,
|
||||
dimensions: blackBoxDimensions,
|
||||
rotation: rotation,
|
||||
color: {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0
|
||||
},
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
whiteboard: whiteboard,
|
||||
version: 2,
|
||||
ProceduralEntity: {
|
||||
shaderUrl: fragShaderURL
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
var lightPosition = Vec3.sum(center, Vec3.multiply(-3, Quat.getFront(rotation)));
|
||||
var light = Entities.addEntity({
|
||||
type: 'Light',
|
||||
name: 'whiteboard light',
|
||||
position: lightPosition,
|
||||
dimensions: {x: 10, y: 10, z: 10},
|
||||
intensity: 2,
|
||||
color: {red: 255, green: 255, blue: 255}
|
||||
});
|
||||
|
||||
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;
|
||||
var eraserPosition = Vec3.sum(center, {x: 0, y: 2.05, z: 0 });
|
||||
eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.1, rotation));
|
||||
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
||||
var eraseAllText = Entities.addEntity({
|
||||
type: "Text",
|
||||
position: eraseBoxPosition,
|
||||
var eraser = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: eraserModelURL,
|
||||
position: eraserPosition,
|
||||
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: whiteboard
|
||||
whiteboard: drawingSurface
|
||||
})
|
||||
});
|
||||
|
||||
Script.setTimeout(function() {
|
||||
whiteboardDimensions = Entities.getEntityProperties(whiteboard, "naturalDimensions").naturalDimensions;
|
||||
colorIndicatorBorderDimensions = Entities.getEntityProperties(colorIndicatorBorder, "naturalDimensions").naturalDimensions;
|
||||
setUp();
|
||||
}, 2000)
|
||||
|
||||
|
||||
function setUp() {
|
||||
var blockerPosition = Vec3.sum(center, {x: 0, y: -1, z: 0 });
|
||||
blockerPosition = Vec3.sum(blockerPosition, Vec3.multiply(-1, Quat.getFront(rotation)));
|
||||
blocker = Entities.addEntity({
|
||||
type: "Box",
|
||||
rotation: rotation,
|
||||
position: blockerPosition,
|
||||
dimensions: {x: whiteboardDimensions.x, y: 1, z: 0.1},
|
||||
shapeType: "box",
|
||||
visible: false
|
||||
});
|
||||
|
||||
var eraseModelDimensions = Entities.getEntityProperties(eraser, "naturalDimensions").naturalDimensions;
|
||||
Entities.editEntity(eraser, {dimensions: eraseModelDimensions});
|
||||
Entities.editEntity(colorIndicatorBorder, {dimensions: colorIndicatorBorderDimensions});
|
||||
|
||||
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
|
||||
var colorIndicatorPosition = Vec3.sum(center, {
|
||||
x: 0,
|
||||
y: whiteboardDimensions.y / 2 + colorIndicatorBorderDimensions.y / 2,
|
||||
z: 0
|
||||
});
|
||||
colorIndicatorPosition = Vec3.sum(colorIndicatorPosition, Vec3.multiply(-.1, Quat.getFront(rotation)));
|
||||
var colorIndicatorBoxDimensions = Vec3.multiply(colorIndicatorBorderDimensions, 0.9);
|
||||
colorIndicatorBox = Entities.addEntity({
|
||||
type: "Box",
|
||||
name: "Color Indicator",
|
||||
color: colors[0],
|
||||
rotation: rotation,
|
||||
position: colorIndicatorPosition,
|
||||
dimensions: colorIndicatorBoxDimensions,
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
whiteboard: drawingSurface
|
||||
})
|
||||
});
|
||||
|
||||
Entities.editEntity(drawingSurface, {
|
||||
userData: JSON.stringify({
|
||||
color: {
|
||||
currentColor: colors[0]
|
||||
},
|
||||
colorIndicator: colorIndicatorBox
|
||||
})
|
||||
});
|
||||
|
||||
//COLOR BOXES
|
||||
var direction = Quat.getRight(rotation);
|
||||
var colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2));
|
||||
var colorSquareDimensions = {
|
||||
x: 0.13,
|
||||
y: 0.13,
|
||||
z: 0.002
|
||||
};
|
||||
|
||||
var palleteDepthOffset = -0.07;
|
||||
var palleteHeightOffset = -0.28;
|
||||
|
||||
colorBoxPosition = Vec3.sum(colorBoxPosition, Vec3.multiply(palleteDepthOffset, Quat.getFront(rotation)));
|
||||
colorBoxPosition.y += palleteHeightOffset;
|
||||
var spaceBetweenColorBoxes = Vec3.multiply(direction, colorSquareDimensions.x * 1.76);
|
||||
var palleteXOffset = Vec3.multiply(direction, 0.43);
|
||||
colorBoxPosition = Vec3.sum(colorBoxPosition, palleteXOffset);
|
||||
var scriptURL = Script.resolvePath("colorSelectorEntityScript.js");
|
||||
for (var i = 0; i < colors.length; i++) {
|
||||
var colorBox = Entities.addEntity({
|
||||
type: "Box",
|
||||
name: "Color Selector",
|
||||
position: colorBoxPosition,
|
||||
dimensions: colorSquareDimensions,
|
||||
rotation: rotation,
|
||||
color: colors[i],
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
whiteboard: drawingSurface,
|
||||
colorIndicator: colorIndicatorBox
|
||||
})
|
||||
});
|
||||
colorBoxes.push(colorBox);
|
||||
colorBoxPosition = Vec3.sum(colorBoxPosition, spaceBetweenColorBoxes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
Entities.deleteEntity(whiteboard);
|
||||
Entities.deleteEntity(eraseAllText);
|
||||
Entities.deleteEntity(blackBox);
|
||||
Entities.deleteEntity(drawingSurface);
|
||||
Entities.deleteEntity(colorIndicatorBorder);
|
||||
Entities.deleteEntity(eraser);
|
||||
Entities.deleteEntity(colorIndicatorBox);
|
||||
Entities.deleteEntity(blocker);
|
||||
Entities.deleteEntity(light);
|
||||
colorBoxes.forEach(function(colorBox) {
|
||||
Entities.deleteEntity(colorBox);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Uncomment this line to delete whiteboard and all associated entity on script close
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
// Script.scriptEnding.connect(cleanup);
|
Loading…
Reference in a new issue