dat.gui/elements/shim.js

87 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2014-09-08 22:01:19 +00:00
// Use gui.shim.js in production when you want to use dat.gui to recall values without any of the interface.
( function( scope ) {
2014-09-09 20:18:15 +00:00
var Gui = function() {
2014-09-08 22:01:19 +00:00
this.vars = {};
2014-09-08 22:01:19 +00:00
this.$ = {
dockedContent: document.body
};
Object.defineProperties( this.$.dockedContent, {
offsetWidth: {
get: function() {
return window.innerWidth;
}
},
offsetHeight: {
get: function() {
return window.innerHeight;
}
}
} );
};
2014-09-08 22:01:19 +00:00
Gui.ready = function( fnc ) {
2014-09-08 22:01:19 +00:00
if ( window.Promise && arguments.length === 0 ) {
return new Promise( function( resolve ) {
resolve();
} );
}
fnc();
2014-09-08 22:01:19 +00:00
};
2014-09-08 22:01:19 +00:00
Gui.prototype.addEventListener = function( evt, fnc ) {
if ( evt == 'resize' ) {
window.addEventListener( evt, fnc );
}
};
Gui.prototype.var = function( name, value ) {
2014-09-08 22:01:19 +00:00
this.vars[ name ] = value;
return controllerShim;
2014-09-08 22:01:19 +00:00
};
2014-09-08 22:01:19 +00:00
2014-10-11 19:39:16 +00:00
Gui.prototype.folder = function( name ) {
return this;
};
Gui.prototype.add = function( object, path ) {
2014-09-09 20:18:15 +00:00
return controllerShim;
2014-09-08 22:01:19 +00:00
};
2014-09-08 22:01:19 +00:00
var identity = function() {
return this;
};
2014-09-08 22:01:19 +00:00
var controllerShim = {
2014-10-11 19:39:16 +00:00
on: identity,
onChange: identity,
disable: identity
};
2014-09-08 22:01:19 +00:00
scope.Gui = Gui;
2014-09-08 22:01:19 +00:00
})( this );