r3-legacy/src/game-lib-d3-graphics.js

68 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-10-25 17:57:32 +02:00
/**
2017-01-13 16:19:51 +01:00
* Graphics
* @param id
* @param name
* @param graphicsType
2016-10-25 17:57:32 +02:00
* @constructor
*/
2016-11-21 16:08:39 +01:00
GameLib.D3.Graphics = function Graphics(
2017-01-13 16:19:51 +01:00
id,
name,
graphicsType
2016-10-25 17:57:32 +02:00
) {
2017-01-13 16:19:51 +01:00
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
2017-01-12 17:40:17 +01:00
}
2017-01-13 16:19:51 +01:00
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Graphics (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(graphicsType)) {
graphicsType = GameLib.D3.Graphics.GRAPHICS_TYPE_THREE;
}
this.graphicsType = graphicsType;
2017-01-12 17:40:17 +01:00
this.instance = this.createInstance();
};
/**
* GameLib.D3.Graphics Types
* @type {number}
*/
GameLib.D3.Graphics.GRAPHICS_TYPE_THREE = 0x1;
/**
* @returns {THREE.Graphics}
*/
2017-06-25 13:31:24 +02:00
GameLib.D3.Graphics.prototype.createInstance = function() {
var instance = THREE;
2017-01-12 17:40:17 +01:00
return instance;
};
/**
* Updates the instance with the current state
*/
GameLib.D3.Graphics.prototype.updateInstance = function() {
};
2016-10-25 17:57:32 +02:00
/**
* True if THREE physics
* @returns {boolean}
*/
GameLib.D3.Graphics.prototype.isThree = function() {
2017-06-25 13:31:24 +02:00
return (this.graphicsType === GameLib.D3.Graphics.GRAPHICS_TYPE_THREE)
2016-10-25 17:57:32 +02:00
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.D3.Graphics.prototype.isNotThreeThrow = function() {
2017-06-25 13:31:24 +02:00
if (this.graphicsType !== GameLib.D3.Graphics.GRAPHICS_TYPE_THREE) {
2016-10-25 17:57:32 +02:00
console.warn('Only THREE supported for this function');
throw new Error('Only THREE supported for this function');
}
};