diff --git a/examples/painting/whiteboard/colorIndicatorEntityScript.js b/examples/painting/whiteboard/colorIndicatorEntityScript.js index 326e9ab9c3..27b8ca01a1 100644 --- a/examples/painting/whiteboard/colorIndicatorEntityScript.js +++ b/examples/painting/whiteboard/colorIndicatorEntityScript.js @@ -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 }); diff --git a/examples/painting/whiteboard/colorSelectorEntityScript.js b/examples/painting/whiteboard/colorSelectorEntityScript.js index 8ad003035c..f1105604c7 100644 --- a/examples/painting/whiteboard/colorSelectorEntityScript.js +++ b/examples/painting/whiteboard/colorSelectorEntityScript.js @@ -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; }, diff --git a/examples/painting/whiteboard/whiteboardEntityScript.js b/examples/painting/whiteboard/whiteboardEntityScript.js index b03ab8f86c..f38073f389 100644 --- a/examples/painting/whiteboard/whiteboardEntityScript.js +++ b/examples/painting/whiteboard/whiteboardEntityScript.js @@ -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(); } }; diff --git a/examples/painting/whiteboard/whiteboardSpawner.js b/examples/painting/whiteboard/whiteboardSpawner.js index 51e4dee87d..13588d24a8 100644 --- a/examples/painting/whiteboard/whiteboardSpawner.js +++ b/examples/painting/whiteboard/whiteboardSpawner.js @@ -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,