r3-legacy/src/r3-gui.js

76 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-04-09 09:35:04 +02:00
/**
* GUI component
2019-10-06 21:11:18 +02:00
* @param apiComponent
2018-04-09 09:35:04 +02:00
* @constructor
*/
R3.GUI = function(
2019-10-06 21:11:18 +02:00
apiComponent
2018-04-09 09:35:04 +02:00
) {
2019-10-06 21:11:18 +02:00
__RUNTIME_COMPONENT__;
__UPGRADE_TO_RUNTIME__;
2018-04-09 09:35:04 +02:00
};
R3.GUI.prototype = Object.create(R3.Component.prototype);
R3.GUI.prototype.constructor = R3.GUI;
/**
* Creates a helper instance
*/
R3.GUI.prototype.createInstance = function() {
2019-10-06 21:11:18 +02:00
this.instance = new this.guiRuntime.instance( { autoPlace: false } );
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
__CREATE_INSTANCE__;
2018-04-09 09:35:04 +02:00
};
/**
2019-10-06 21:11:18 +02:00
* Updates the instance with the current state
2018-04-09 09:35:04 +02:00
*/
2019-10-06 21:11:18 +02:00
R3.GUI.prototype.updateInstance = function(property) {
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (property === 'domElement') {
console.warn('todo: update domElement for gui');
return;
}
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
__UPDATE_INSTANCE__;
2018-04-09 09:35:04 +02:00
};
/**
* Removes empty folders from instance
*/
R3.GUI.prototype.removeEmtpyFolders = function() {
this.instance.removeEmptyFolders();
};
/**
* Remove all folders from instance
*/
R3.GUI.prototype.removeAllFolders = function() {
this.instance.removeAllFolders();
};
/**
* Adds a folder to instance
* @param folderName
* @returns {*}
*/
R3.GUI.prototype.addFolder = function(folderName) {
try {
return this.instance.addFolder(folderName);
} catch (e) {
try {
folderName += ' duplicate (' + R3.Utils.RandomId() + ')';
return this.instance.addFolder(folderName);
} catch (e) {
console.log(e.message);
return null;
}
}
};