Fix setting colors in ParticleExplorer without having the particle entity disappear. Handles Hex strings as well as color arrays.

This commit is contained in:
Thijs Wenker 2016-03-22 17:39:57 +01:00
parent cd802a6549
commit d47e8eb999

View file

@ -198,6 +198,16 @@ function createColorPicker(key) {
settings[key] = colorArray;
var controller = gui.addColor(settings, key);
controller.onChange(function(value) {
// Handle hex colors
if(_.isString(value) && value[0] === '#') {
const BASE_HEX = 16;
var colorRegExResult = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(value);
value = [
parseInt(colorRegExResult[1], BASE_HEX),
parseInt(colorRegExResult[2], BASE_HEX),
parseInt(colorRegExResult[3], BASE_HEX)
];
}
var obj = {};
obj[key] = convertColorArrayToObject(value);
writeVec3ToInterface(obj);