Created
October 29, 2017 03:41
-
-
Save rhysburnie/a945c8bfca8ce704ee39d5d6280509c7 to your computer and use it in GitHub Desktop.
dat.GUI convert a field to a display instead of input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dat.GUI.prototype.convertToDisplay = function(owner, property) { | |
var field = this.__controllers.find(function(item){return item.property === property}); | |
var parent = field.domElement.parentElement; | |
var value = owner[property]; | |
delete owner[property]; | |
Object.defineProperty(owner, property, { | |
get: function() { | |
return value; | |
}, | |
set: function(newValue) { | |
value = newValue; | |
parent.innerText = newValue; | |
} | |
}); | |
} |
Author
rhysburnie
commented
Oct 29, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment