Fixed color indicator position

This commit is contained in:
ericrius1 2015-10-14 16:17:57 -07:00
parent cfca0fe8c0
commit 4c709cba35
3 changed files with 50 additions and 4 deletions

View file

@ -0,0 +1,41 @@
//
// colorIndicatorEntityScript.js
// examples/painting/whiteboard
//
// Created by Eric Levin on 9/21/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/*global print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
/*global ColorIndicator */
(function() {
var _this;
ColorIndicator = function() {
_this = this;
};
ColorIndicator.prototype = {
changeColor: function() {
var newColor = Entities.getEntityProperties(this.whiteboard, "userData").currentColor;
Entities.editEntity(this.EntityID, {
color: newColor
});
},
preload: function(entityID) {
this.entityID = entityID;
var props = Entities.getEntityProperties(this.entityID, "userData");
this.position = props.position;
this.whiteboard = JSON.parse(props.userData).whiteboard;
},
};
// entity scripts always need to return a newly constructed object of our type
return new ColorIndicator();
});

View file

@ -210,7 +210,9 @@
this.painting = false;
this.strokes = [];
this.whitelist = [this.entityID];
this.strokeColor = JSON.parse(props.userData).currentColor;
var userData = JSON.parse(props.userData);
this.strokeColor = userData.currentColor;
this.colorIndicator = userData.colorIndicator;
this.laserPointer = Overlays.addOverlay("circle3d", {
color: this.strokeColor,
solid: true,

View file

@ -63,7 +63,7 @@ var colorIndicatorDimensions = {
z: 0.02
};
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
var colorIndicatorPosition = Vec3.sum(center, {x: 0, y: whiteboardDimensions.y/2, z: 0});
var colorIndicatorPosition = Vec3.sum(center, {x: 0, y: whiteboardDimensions.y/2 + colorIndicatorDimensions.y/2, z: 0});
var colorIndicatorBox = Entities.addEntity({
type: "Box",
color: colors[0],
@ -73,6 +73,8 @@ var colorIndicatorBox = Entities.addEntity({
script: scriptURL
});
Entities.editEntity(whiteboard, {userData: JSON.stringify({currentColor: colors[i], colorIndicator: colorIndicatorBox})} );
//COLOR BOXES
var direction = Quat.getRight(rotation);
var colorBoxPosition = Vec3.subtract(center, Vec3.multiply(direction, whiteboardDimensions.x / 2));
@ -82,7 +84,7 @@ var colorSquareDimensions = {
y: 0.1,
z: 0.05
};
colorBoxPosition.y += whiteboardDimensions.y / 2 + colorIndicatorDimensions.y/2 + colorSquareDimensions.y / 2 - 0.01;
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++) {
@ -117,7 +119,7 @@ var blackBox = Entities.addEntity({
userData: JSON.stringify({
whiteboard: whiteboard
})
})
});
var eraseBoxDimensions = {
@ -159,6 +161,7 @@ function cleanup() {
Entities.deleteEntity(whiteboard);
Entities.deleteEntity(eraseAllText);
Entities.deleteEntity(blackBox);
Entities.deleteEntity(colorIndicatorBox);
colorBoxes.forEach(function(colorBox) {
Entities.deleteEntity(colorBox);
});