style fixes and fix for grid color changes not applying

This commit is contained in:
Liv Erickson 2018-03-23 11:39:44 -07:00
parent e90c051744
commit 9dd91ea31e

View file

@ -2,15 +2,7 @@ var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
Grid = function (opts) {
var that = {};
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 gridColor = { red: 0, green: 0, blue: 0 };
var gridAlpha = 0.6;
var origin = { x: 0, y: +MyAvatar.getJointPosition('LeftToeBase').y.toFixed(1) + 0.1, z: 0 };
var scale = 500;
@ -28,10 +20,10 @@ Grid = function(opts) {
position: origin,
visible: false,
drawInFront: false,
color: colors[0],
color: gridColor,
alpha: gridAlpha,
minorGridEvery: minorGridEvery,
majorGridEvery: majorGridEvery,
majorGridEvery: majorGridEvery
});
that.visible = false;
@ -39,26 +31,38 @@ Grid = function(opts) {
that.getOrigin = function () {
return origin;
}
};
that.getMinorIncrement = function () {
return minorGridEvery;
};
that.getMinorIncrement = function() { return minorGridEvery; };
that.setMinorIncrement = function (value) {
minorGridEvery = value;
updateGrid();
}
that.getMajorIncrement = function() { return majorGridEvery; };
};
that.getMajorIncrement = function () {
return majorGridEvery;
};
that.setMajorIncrement = function (value) {
majorGridEvery = value;
updateGrid();
};
that.getColorIndex = function() { return colorIndex; };
that.setColorIndex = function(value) {
colorIndex = value;
that.getColor = function () {
return gridColor;
};
that.setColor = function (value) {
gridColor = value;
updateGrid();
};
that.getSnapToGrid = function() { return snapToGrid; };
that.getSnapToGrid = function () {
return snapToGrid;
};
that.setSnapToGrid = function (value) {
snapToGrid = value;
that.emitUpdate();
@ -67,7 +71,7 @@ Grid = function(opts) {
that.setEnabled = function (enabled) {
that.enabled = enabled;
updateGrid();
}
};
that.getVisible = function () { return that.visible; };
that.setVisible = function (visible, noUpdate) {
@ -77,7 +81,7 @@ Grid = function(opts) {
if (!noUpdate) {
that.emitUpdate();
}
}
};
that.snapToSurface = function (position, dimensions, registration) {
if (!snapToGrid) {
@ -97,7 +101,7 @@ Grid = function(opts) {
y: origin.y + (registration.y * dimensions.y),
z: position.z
};
}
};
that.snapToGrid = function (position, majorOnly, dimensions, registration) {
if (!snapToGrid) {
@ -133,11 +137,11 @@ Grid = function(opts) {
var snappedDelta = {
x: Math.round(delta.x / spacing) * spacing,
y: Math.round(delta.y / spacing) * spacing,
z: Math.round(delta.z / spacing) * spacing,
z: Math.round(delta.z / spacing) * spacing
};
return snappedDelta;
}
};
that.setPosition = function (newPosition, noUpdate) {
@ -157,7 +161,7 @@ Grid = function(opts) {
majorGridEvery: majorGridEvery,
gridSize: halfSize,
visible: that.visible,
snapToGrid: snapToGrid,
snapToGrid: snapToGrid
});
}
};
@ -183,8 +187,8 @@ Grid = function(opts) {
majorGridEvery = data.majorGridEvery;
}
if (data.colorIndex !== undefined) {
colorIndex = data.colorIndex;
if (data.gridColor) {
gridColor = data.gridColor;
}
if (data.gridSize) {
@ -196,7 +200,7 @@ Grid = function(opts) {
}
updateGrid(true);
}
};
function updateGrid(noUpdate) {
Overlays.editOverlay(gridOverlay, {
@ -204,8 +208,8 @@ Grid = function(opts) {
visible: that.visible && that.enabled,
minorGridEvery: minorGridEvery,
majorGridEvery: majorGridEvery,
color: colors[colorIndex],
alpha: gridAlpha,
color: gridColor,
alpha: gridAlpha
});
if (!noUpdate) {
@ -260,7 +264,7 @@ GridTool = function(opts) {
} else if (data.type == "update") {
horizontalGrid.update(data);
for (var i = 0; i < listeners.length; i++) {
listeners[i] && listeners[i](data);
[i] && listeners[i](data);
}
} else if (data.type == "action") {
var action = data.action;