mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 11:46:34 +02:00
Remembering whiteboards last color between sessions
This commit is contained in:
parent
dc6875f5b5
commit
e8b6b32572
4 changed files with 19 additions and 14 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
changeColor: function() {
|
||||
var userData = JSON.parse(Entities.getEntityProperties(this.whiteboard, "userData").userData);
|
||||
var newColor = userData.currentColor;
|
||||
var newColor = userData.color.currentColor;
|
||||
Entities.editEntity(this.entityID, {
|
||||
color: newColor
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
/*global ColorSelector */
|
||||
|
||||
(function() {
|
||||
|
||||
Script.include("../../libraries/utils.js");
|
||||
var _this;
|
||||
ColorSelector = function() {
|
||||
_this = this;
|
||||
|
@ -29,9 +29,7 @@
|
|||
},
|
||||
|
||||
selectColor: function() {
|
||||
Entities.editEntity(this.whiteboard, {
|
||||
userData: JSON.stringify({currentColor: this.color})
|
||||
});
|
||||
setEntityCustomData(this.colorKey, this.whiteboard, {currentColor: this.color});
|
||||
Entities.callEntityMethod(this.whiteboard, "changeColor");
|
||||
},
|
||||
|
||||
|
@ -40,6 +38,7 @@
|
|||
var props = Entities.getEntityProperties(this.entityID, ["position, color, userData"]);
|
||||
this.position = props.position;
|
||||
this.color = props.color;
|
||||
this.colorKey = "color";
|
||||
this.whiteboard = JSON.parse(props.userData).whiteboard;
|
||||
},
|
||||
|
||||
|
|
|
@ -188,11 +188,14 @@
|
|||
},
|
||||
|
||||
changeColor: function() {
|
||||
this.strokeColor = JSON.parse(Entities.getEntityProperties(this.entityID, ["userData"]).userData).currentColor;
|
||||
var userData = JSON.parse(Entities.getEntityProperties(this.entityID, ["userData"]).userData);
|
||||
this.strokeColor = userData.color.currentColor;
|
||||
this.colorIndicator = userData.colorIndicator;
|
||||
Overlays.editOverlay(this.laserPointer, {
|
||||
color: this.strokeColor
|
||||
});
|
||||
|
||||
|
||||
Entities.callEntityMethod(this.colorIndicator, "changeColor");
|
||||
},
|
||||
|
||||
|
@ -223,20 +226,20 @@
|
|||
this.painting = false;
|
||||
this.strokes = [];
|
||||
this.whitelist = [this.entityID];
|
||||
var userData = JSON.parse(props.userData);
|
||||
this.strokeColor = userData.currentColor;
|
||||
this.colorIndicator = userData.colorIndicator;
|
||||
this.laserPointer = Overlays.addOverlay("circle3d", {
|
||||
color: this.strokeColor,
|
||||
solid: true,
|
||||
rotation: this.rotation
|
||||
});
|
||||
this.forwardOffset = 0.0005;
|
||||
|
||||
this.changeColor();
|
||||
},
|
||||
|
||||
unload: function() {
|
||||
|
||||
Overlays.deleteOverlay(this.laserPointer);
|
||||
// this.eraseBoard();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -49,10 +49,7 @@ var whiteboard = Entities.addEntity({
|
|||
red: 255,
|
||||
green: 255,
|
||||
blue: 255
|
||||
},
|
||||
userData: JSON.stringify({
|
||||
currentColor: colors[0]
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -70,6 +67,7 @@ var colorIndicatorPosition = Vec3.sum(center, {
|
|||
});
|
||||
var colorIndicatorBox = Entities.addEntity({
|
||||
type: "Box",
|
||||
name: "Color Indicator",
|
||||
color: colors[0],
|
||||
rotation: rotation,
|
||||
position: colorIndicatorPosition,
|
||||
|
@ -82,7 +80,9 @@ var colorIndicatorBox = Entities.addEntity({
|
|||
|
||||
Entities.editEntity(whiteboard, {
|
||||
userData: JSON.stringify({
|
||||
currentColor: colors[0],
|
||||
color: {
|
||||
currentColor: colors[0],
|
||||
},
|
||||
colorIndicator: colorIndicatorBox
|
||||
})
|
||||
});
|
||||
|
@ -102,6 +102,7 @@ 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,
|
||||
|
@ -127,6 +128,7 @@ colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDime
|
|||
colorBoxPosition.y += 0.3;
|
||||
var blackBox = Entities.addEntity({
|
||||
type: 'Box',
|
||||
name: "Black Color",
|
||||
position: colorBoxPosition,
|
||||
dimensions: blackBoxDimensions,
|
||||
rotation: rotation,
|
||||
|
@ -155,6 +157,7 @@ scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
|||
var eraseAllText = Entities.addEntity({
|
||||
type: "Text",
|
||||
position: eraseBoxPosition,
|
||||
name: "Eraser",
|
||||
script: scriptURL,
|
||||
rotation: rotation,
|
||||
dimensions: eraseBoxDimensions,
|
||||
|
|
Loading…
Reference in a new issue