mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:41:02 +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() {
|
changeColor: function() {
|
||||||
var userData = JSON.parse(Entities.getEntityProperties(this.whiteboard, "userData").userData);
|
var userData = JSON.parse(Entities.getEntityProperties(this.whiteboard, "userData").userData);
|
||||||
var newColor = userData.currentColor;
|
var newColor = userData.color.currentColor;
|
||||||
Entities.editEntity(this.entityID, {
|
Entities.editEntity(this.entityID, {
|
||||||
color: newColor
|
color: newColor
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
/*global ColorSelector */
|
/*global ColorSelector */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
Script.include("../../libraries/utils.js");
|
||||||
var _this;
|
var _this;
|
||||||
ColorSelector = function() {
|
ColorSelector = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
|
@ -29,9 +29,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
selectColor: function() {
|
selectColor: function() {
|
||||||
Entities.editEntity(this.whiteboard, {
|
setEntityCustomData(this.colorKey, this.whiteboard, {currentColor: this.color});
|
||||||
userData: JSON.stringify({currentColor: this.color})
|
|
||||||
});
|
|
||||||
Entities.callEntityMethod(this.whiteboard, "changeColor");
|
Entities.callEntityMethod(this.whiteboard, "changeColor");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -40,6 +38,7 @@
|
||||||
var props = Entities.getEntityProperties(this.entityID, ["position, color, userData"]);
|
var props = Entities.getEntityProperties(this.entityID, ["position, color, userData"]);
|
||||||
this.position = props.position;
|
this.position = props.position;
|
||||||
this.color = props.color;
|
this.color = props.color;
|
||||||
|
this.colorKey = "color";
|
||||||
this.whiteboard = JSON.parse(props.userData).whiteboard;
|
this.whiteboard = JSON.parse(props.userData).whiteboard;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -188,11 +188,14 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
changeColor: function() {
|
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, {
|
Overlays.editOverlay(this.laserPointer, {
|
||||||
color: this.strokeColor
|
color: this.strokeColor
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Entities.callEntityMethod(this.colorIndicator, "changeColor");
|
Entities.callEntityMethod(this.colorIndicator, "changeColor");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -223,20 +226,20 @@
|
||||||
this.painting = false;
|
this.painting = false;
|
||||||
this.strokes = [];
|
this.strokes = [];
|
||||||
this.whitelist = [this.entityID];
|
this.whitelist = [this.entityID];
|
||||||
var userData = JSON.parse(props.userData);
|
|
||||||
this.strokeColor = userData.currentColor;
|
|
||||||
this.colorIndicator = userData.colorIndicator;
|
|
||||||
this.laserPointer = Overlays.addOverlay("circle3d", {
|
this.laserPointer = Overlays.addOverlay("circle3d", {
|
||||||
color: this.strokeColor,
|
color: this.strokeColor,
|
||||||
solid: true,
|
solid: true,
|
||||||
rotation: this.rotation
|
rotation: this.rotation
|
||||||
});
|
});
|
||||||
this.forwardOffset = 0.0005;
|
this.forwardOffset = 0.0005;
|
||||||
|
|
||||||
|
this.changeColor();
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
|
|
||||||
Overlays.deleteOverlay(this.laserPointer);
|
Overlays.deleteOverlay(this.laserPointer);
|
||||||
|
// this.eraseBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,10 +49,7 @@ var whiteboard = Entities.addEntity({
|
||||||
red: 255,
|
red: 255,
|
||||||
green: 255,
|
green: 255,
|
||||||
blue: 255
|
blue: 255
|
||||||
},
|
}
|
||||||
userData: JSON.stringify({
|
|
||||||
currentColor: colors[0]
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +67,7 @@ var colorIndicatorPosition = Vec3.sum(center, {
|
||||||
});
|
});
|
||||||
var colorIndicatorBox = Entities.addEntity({
|
var colorIndicatorBox = Entities.addEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
|
name: "Color Indicator",
|
||||||
color: colors[0],
|
color: colors[0],
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
position: colorIndicatorPosition,
|
position: colorIndicatorPosition,
|
||||||
|
@ -82,7 +80,9 @@ var colorIndicatorBox = Entities.addEntity({
|
||||||
|
|
||||||
Entities.editEntity(whiteboard, {
|
Entities.editEntity(whiteboard, {
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
currentColor: colors[0],
|
color: {
|
||||||
|
currentColor: colors[0],
|
||||||
|
},
|
||||||
colorIndicator: colorIndicatorBox
|
colorIndicator: colorIndicatorBox
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -102,6 +102,7 @@ var scriptURL = Script.resolvePath("colorSelectorEntityScript.js");
|
||||||
for (var i = 0; i < colors.length; i++) {
|
for (var i = 0; i < colors.length; i++) {
|
||||||
var colorBox = Entities.addEntity({
|
var colorBox = Entities.addEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
|
name: "Color Selector",
|
||||||
position: colorBoxPosition,
|
position: colorBoxPosition,
|
||||||
dimensions: colorSquareDimensions,
|
dimensions: colorSquareDimensions,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
|
@ -127,6 +128,7 @@ colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDime
|
||||||
colorBoxPosition.y += 0.3;
|
colorBoxPosition.y += 0.3;
|
||||||
var blackBox = Entities.addEntity({
|
var blackBox = Entities.addEntity({
|
||||||
type: 'Box',
|
type: 'Box',
|
||||||
|
name: "Black Color",
|
||||||
position: colorBoxPosition,
|
position: colorBoxPosition,
|
||||||
dimensions: blackBoxDimensions,
|
dimensions: blackBoxDimensions,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
|
@ -155,6 +157,7 @@ scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
||||||
var eraseAllText = Entities.addEntity({
|
var eraseAllText = Entities.addEntity({
|
||||||
type: "Text",
|
type: "Text",
|
||||||
position: eraseBoxPosition,
|
position: eraseBoxPosition,
|
||||||
|
name: "Eraser",
|
||||||
script: scriptURL,
|
script: scriptURL,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
dimensions: eraseBoxDimensions,
|
dimensions: eraseBoxDimensions,
|
||||||
|
|
Loading…
Reference in a new issue