use array of colors

This commit is contained in:
Andrew Meadows 2016-04-26 11:23:05 -07:00
parent 6e28538063
commit 8a02a585f2

View file

@ -3,7 +3,14 @@ var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
Grid = function(opts) {
var that = {};
var gridColor = { red: 255, green: 255, blue: 255 };
var colors = [
{ red: 0, green: 0, blue: 0 },
{ red: 255, green: 255, blue: 255 },
{ red: 255, green: 0, blue: 0 },
{ red: 0, green: 255, blue: 0 },
{ red: 0, green: 0, blue: 255 },
];
var colorIndex = 0;
var gridAlpha = 0.6;
var origin = { x: 0, y: +MyAvatar.getJointPosition('LeftToeBase').y.toFixed(1) + 0.1, z: 0 };
var scale = 500;
@ -21,7 +28,7 @@ Grid = function(opts) {
position: origin,
visible: false,
drawInFront: false,
color: gridColor,
color: colors[0],
alpha: gridAlpha,
minorGridEvery: minorGridEvery,
majorGridEvery: majorGridEvery,
@ -45,6 +52,12 @@ Grid = function(opts) {
updateGrid();
};
that.getColorIndex = function() { return colorIndex; };
that.setColorIndex = function(value) {
colorIndex = value;
updateGrid();
};
that.getSnapToGrid = function() { return snapToGrid; };
that.setSnapToGrid = function(value) {
snapToGrid = value;
@ -162,8 +175,8 @@ Grid = function(opts) {
majorGridEvery = data.majorGridEvery;
}
if (data.gridColor !== undefined) {
gridColor = data.gridColor;
if (data.colorIndex !== undefined) {
colorIndex = data.colorIndex;
}
if (data.gridSize) {
@ -183,7 +196,7 @@ Grid = function(opts) {
visible: that.visible && that.enabled,
minorGridEvery: minorGridEvery,
majorGridEvery: majorGridEvery,
color: gridColor,
color: colors[colorIndex],
alpha: gridAlpha,
});