r3-legacy/src/game-lib-mouse.js

71 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-01-09 15:20:48 +01:00
/**
* Runtime mouse for updating instance objects
* @param graphics GameLib.D3.Graphics
* @param apiMouse GameLib.API.Mouse
* @constructor
*/
GameLib.Mouse = function (graphics, apiMouse) {
2017-01-09 15:20:48 +01:00
this.graphics = graphics;
this.graphics.isNotThreeThrow();
2017-01-09 15:20:48 +01:00
GameLib.API.Mouse.call(
this,
apiMouse.id,
apiMouse.name,
apiMouse.x,
apiMouse.y
);
this.parentObject = parentObject;
// this.instance = this.createInstance();
};
/**
* Creates an instance mouse
* @param update
* @returns {*}
*/
GameLib.Mouse.prototype.createInstance = function(update) {
//
// var instance = null;
//
// if (update) {
// instance = this.instance;
// instance.x = this.x;
// instance.y = this.y;
// } else {
// instance = new THREE.Mouse(this.x, this.y);
// }
//
// return instance;
};
/**
* Updates the instance vector, calls updateInstance on the parent object
*/
GameLib.Mouse.prototype.updateInstance = function() {
this.createInstance(true);
if (this.parentObject.updateInstance) {
this.parentObject.updateInstance();
}
};
/**
* Converts runtime vector to API Vector
* @returns {GameLib.API.Mouse}
*/
GameLib.Mouse.prototype.toApiMouse = function() {
return new GameLib.API.Mouse(
this.id,
this.name,
this.x,
this.y
);
};