New sql files and improved Logger.js
This commit is contained in:
parent
ad0b759e5e
commit
df04a1bbfb
|
@ -1,10 +1,37 @@
|
||||||
DROP TABLE IF EXISTS users CASCADE;
|
DROP TABLE IF EXISTS users CASCADE;
|
||||||
DROP TABLE IF EXISTS arrowclicked CASCADE;
|
DROP TABLE IF EXISTS arrowclicked CASCADE;
|
||||||
DROP TABLE IF EXISTS coinclicked CASCADE;
|
DROP TABLE IF EXISTS coinclicked CASCADE;
|
||||||
|
DROP TABLE IF EXISTS keyboardevent CASCADE;
|
||||||
|
|
||||||
|
DROP TYPE IF EXISTS VECTOR3 CASCADE;
|
||||||
|
DROP TYPE IF EXISTS CAMERA CASCADE;
|
||||||
|
DROP TYPE IF EXISTS DIRECTION CASCADE;
|
||||||
|
|
||||||
|
CREATE TYPE VECTOR3 AS(
|
||||||
|
x FLOAT,
|
||||||
|
y FLOAT,
|
||||||
|
z FLOAT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TYPE CAMERA AS(
|
||||||
|
position VECTOR3,
|
||||||
|
target VECTOR3
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TYPE DIRECTION AS ENUM(
|
||||||
|
'n',
|
||||||
|
'ne',
|
||||||
|
'e',
|
||||||
|
'se',
|
||||||
|
's',
|
||||||
|
'sw',
|
||||||
|
'w',
|
||||||
|
'nw'
|
||||||
|
);
|
||||||
|
|
||||||
CREATE TABLE users(
|
CREATE TABLE users(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
name char(50)
|
name CHAR(50)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE arrowclicked(
|
CREATE TABLE arrowclicked(
|
||||||
|
@ -20,3 +47,11 @@ CREATE TABLE coinclicked(
|
||||||
time TIMESTAMP DEFAULT NOW(),
|
time TIMESTAMP DEFAULT NOW(),
|
||||||
coin_id INTEGER
|
coin_id INTEGER
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE keyboardevent(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
user_id SERIAL REFERENCES users (id),
|
||||||
|
time TIMESTAMP DEFAULT NOW(),
|
||||||
|
direction DIRECTION,
|
||||||
|
camera CAMERA
|
||||||
|
);
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
INSERT INTO users(name) VALUES('Thomas');
|
||||||
|
INSERT INTO keyboardevent(user_id, direction, camera) VALUES(
|
||||||
|
1,
|
||||||
|
NULL,
|
||||||
|
ROW(ROW(0,0,0), ROW(0,0,0))
|
||||||
|
);
|
||||||
|
|
||||||
|
SELECT ((camera).position).x FROM keyboardevent;
|
|
@ -24,3 +24,23 @@ BD.Event.CoinClicked.prototype.send = function() {
|
||||||
BD.Private.sendData(url, data);
|
BD.Private.sendData(url, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BD.Event.KeyboardEvent = function() {};
|
||||||
|
BD.Event.KeyboardEvent.prototype.send = function() {
|
||||||
|
var url = "/keyboard-event";
|
||||||
|
var data = {
|
||||||
|
camera: {
|
||||||
|
// Compact camera
|
||||||
|
position: {
|
||||||
|
x: this.camera.position.x,
|
||||||
|
y: this.camera.position.y,
|
||||||
|
z: this.camera.position.z
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
x: this.camera.target.x,
|
||||||
|
y: this.camera.target.y,
|
||||||
|
z: this.camera.target.z
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
BD.Private.sendData(url, data);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue