67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
/**
|
|
* Coder
|
|
* @param id
|
|
* @param name
|
|
* @param coderType
|
|
* @constructor
|
|
*/
|
|
GameLib.D3.Coder = function Coder(
|
|
id,
|
|
name,
|
|
coderType
|
|
) {
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
id = GameLib.Utils.RandomId();
|
|
}
|
|
this.id = id;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
name = 'Coder (' + id + ')';
|
|
}
|
|
this.name = name;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(coderType)) {
|
|
coderType = GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR;
|
|
}
|
|
this.coderType = coderType;
|
|
|
|
this.createInstance();
|
|
};
|
|
|
|
/**
|
|
* GameLib.D3.Coder Types
|
|
* @type {number}
|
|
*/
|
|
GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR = 0x1;
|
|
|
|
/**
|
|
* @returns {THREE.Coder}
|
|
*/
|
|
GameLib.D3.Coder.prototype.createInstance = function() {
|
|
this.instance = CodeMirror;
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
GameLib.D3.Coder.prototype.updateInstance = function() {
|
|
};
|
|
|
|
/**
|
|
* True if THREE physics
|
|
* @returns {boolean}
|
|
*/
|
|
GameLib.D3.Coder.prototype.isCodeMirror = function() {
|
|
return (this.coderType === GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR)
|
|
};
|
|
|
|
/**
|
|
* Logs a warning and throws an error if not cannon
|
|
*/
|
|
GameLib.D3.Coder.prototype.isNotCodeMirrorThrow = function() {
|
|
if (this.coderType !== GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR) {
|
|
console.warn('Only CodeMirror supported for this function');
|
|
throw new Error('Only CodeMirror supported for this function');
|
|
}
|
|
};
|