Color of gun sight change when hovering element
This commit is contained in:
parent
0ba03cdece
commit
ecee155751
10
js/Logger.js
10
js/Logger.js
|
@ -11,11 +11,11 @@ BD.Private.sendData = function(url, data) {
|
|||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
console.log("Done : " + xhr.responseText);
|
||||
}
|
||||
}
|
||||
// xhr.onreadystatechange = function() {
|
||||
// if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
// console.log("Done : " + xhr.responseText);
|
||||
// }
|
||||
// }
|
||||
|
||||
xhr.send(JSON.stringify(data));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var MousePointer = function(camera) {
|
||||
|
||||
this.domElement = document.createElement('canvas');
|
||||
this.domElement.style.position = 'absolute';
|
||||
this.domElement.style.cssFloat = 'top-left';
|
||||
|
@ -6,12 +7,41 @@ var MousePointer = function(camera) {
|
|||
this.size = 10;
|
||||
this.drawn = false;
|
||||
camera.mousePointer = this;
|
||||
this.style = MousePointer.NONE;
|
||||
}
|
||||
|
||||
MousePointer.prototype.render = function() {
|
||||
MousePointer.NONE = 0;
|
||||
MousePointer.BLACK = 1;
|
||||
MousePointer.RED = 2;
|
||||
|
||||
if (!this.drawn) {
|
||||
this.drawn = true;
|
||||
MousePointer.toColor = function(style) {
|
||||
|
||||
switch (style) {
|
||||
|
||||
case MousePointer.NONE:
|
||||
return null;
|
||||
case MousePointer.BLACK:
|
||||
return '#000000';
|
||||
case MousePointer.RED:
|
||||
return '#ff0000';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MousePointer.prototype.render = function(style) {
|
||||
|
||||
if (this.style !== style) {
|
||||
|
||||
if (style === MousePointer.NONE) {
|
||||
|
||||
// Clear canvas
|
||||
this.domElement.width = this.domElement.width;
|
||||
this.style = MousePointer.NONE;
|
||||
|
||||
} else {
|
||||
|
||||
this.domElement.width = this.domElement.width;
|
||||
|
||||
var i = container_size.width() / 2;
|
||||
var imin = i - this.size;
|
||||
|
@ -21,24 +51,32 @@ MousePointer.prototype.render = function() {
|
|||
var jmin = j - this.size;
|
||||
var jmax = j + this.size;
|
||||
|
||||
this.ctx.stokeStyle = "black";
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(imin, j);
|
||||
this.ctx.lineTo(imax, j);
|
||||
this.ctx.moveTo(i, jmin);
|
||||
this.ctx.lineTo(i, jmax);
|
||||
|
||||
this.ctx.closePath();
|
||||
|
||||
|
||||
this.ctx.lineWidth = 5;
|
||||
this.ctx.strokeStyle = '#ffffff';
|
||||
this.ctx.stroke();
|
||||
|
||||
this.ctx.lineWidth = 2;
|
||||
this.ctx.strokeStyle = MousePointer.toColor(style);
|
||||
this.ctx.stroke();
|
||||
|
||||
this.style = style;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MousePointer.prototype.clear = function() {
|
||||
|
||||
if (this.drawn) {
|
||||
this.drawn = false;
|
||||
this.domElement.width = this.domElement.width;
|
||||
}
|
||||
this.render(MousePointer.NONE);
|
||||
|
||||
}
|
||||
|
|
|
@ -276,10 +276,6 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
|||
|
||||
this.socket.on('disconnect', function() {
|
||||
console.log('Finished !');
|
||||
self.currentMesh.geometry.computeBoundingSphere();
|
||||
if (self.currentMesh.geometry.attributes.normal === undefined) {
|
||||
self.currentMesh.geometry.computeVertexNormals();
|
||||
}
|
||||
self.finished = true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -105,6 +105,10 @@ CameraSelecter.prototype.update = function(event, y) {
|
|||
}
|
||||
|
||||
document.getElementById('container').style.cursor = hovered ? "pointer" : "auto";
|
||||
|
||||
if (this.cameras.mainCamera().pointerLocked)
|
||||
this.cameras.mainCamera().mousePointer.render(hovered ? MousePointer.RED : MousePointer.BLACK);
|
||||
|
||||
}
|
||||
|
||||
CameraSelecter.prototype.click = function(event) {
|
||||
|
|
Loading…
Reference in New Issue