-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTexture.js
More file actions
34 lines (27 loc) · 798 Bytes
/
Texture.js
File metadata and controls
34 lines (27 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var Texture = {
mouseDown: false,
handleMouseDown: function (event) {
this.mouseDown = true;
this.lastMouseX = event.clientX;
this.lastMouseY = event.clientY;
},
handleMouseUp: function (event) {
this.mouseDown = false;
},
handleMouseMove: function (event) {
if (!this.mouseDown) {
return;
}
var newX = event.clientX;
var newY = event.clientY;
var deltaX = newX - this.lastMouseX;
var newRotationMatrix = mat4.create();
mat4.identity(newRotationMatrix);
mat4.rotate(newRotationMatrix, degToRad(deltaX / 10), [0, 1, 0]);
var deltaY = newY - this.lastMouseY;
mat4.rotate(newRotationMatrix, degToRad(deltaY / 10), [1, 0, 0]);
mat4.multiply(newRotationMatrix, moonRotationMatrix, moonRotationMatrix);
this.lastMouseX = newX
this.lastMouseY = newY;
}
}