Add tests for transpiler
This commit is contained in:
parent
f0e0e1d96e
commit
11faf235d5
|
@ -14,7 +14,20 @@ EM_BOOL WebSocketOpen(int eventType, const EmscriptenWebSocketOpenEvent *e, void
|
||||||
camera.fovy = 60.0f;
|
camera.fovy = 60.0f;
|
||||||
camera.projection = 0;
|
camera.projection = 0;
|
||||||
|
|
||||||
emscripten_websocket_send_binary(e->socket, &camera, sizeof(camera));
|
Entity entity = (Entity){
|
||||||
|
"Zongor",
|
||||||
|
camera,
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,1,
|
||||||
|
1,1,1,1,
|
||||||
|
1,42,1,1,
|
||||||
|
1,1
|
||||||
|
};
|
||||||
|
|
||||||
|
emscripten_websocket_send_binary(e->socket, &entity, sizeof(entity));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,13 +52,15 @@ EM_BOOL WebSocketMessage(int eventType, const EmscriptenWebSocketMessageEvent *e
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera3D camera;
|
Entity entity;
|
||||||
memcpy(&camera, e->data, sizeof camera);
|
memcpy(&entity, e->data, sizeof entity);
|
||||||
|
|
||||||
printf("x: %f", camera.position.x);
|
printf("x: %f", entity.Camera.position.x);
|
||||||
printf(" y: %f", camera.position.y);
|
printf(" y: %f", entity.Camera.position.y);
|
||||||
printf(" z: %f", camera.position.z);
|
printf(" z: %f", entity.Camera.position.z);
|
||||||
printf(" fovy: %f", camera.fovy);
|
printf(" name: %s", entity.Name);
|
||||||
|
printf(" fovy: %f", entity.Camera.fovy);
|
||||||
|
printf(" luck: %d", entity.Luck);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
emscripten_websocket_close(e->socket, 0, 0);
|
emscripten_websocket_close(e->socket, 0, 0);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import Entity from "./out/Entity"
|
||||||
|
|
||||||
var decoder = new TextDecoder("utf-8");
|
var decoder = new TextDecoder("utf-8");
|
||||||
var port = 8089;
|
var port = 8089;
|
||||||
var ws = require("ws");
|
var ws = require("ws");
|
||||||
|
@ -11,15 +13,13 @@ wss.on("connection", function (ws) {
|
||||||
console.log("received TEXT: " + text.length + " characters:");
|
console.log("received TEXT: " + text.length + " characters:");
|
||||||
console.log(' "' + text + '"');
|
console.log(' "' + text + '"');
|
||||||
} else {
|
} else {
|
||||||
const camera = new Camera3D({}, new Uint8Array(message));
|
const entity = new Entity({}, new Uint8Array(message));
|
||||||
console.log(camera.position.x, camera.position.y, camera.position.z);
|
console.log(entity.Camera.position.x, entity.Camera.position.y, entity.Camera.position.z);
|
||||||
console.log(camera.target.x, camera.target.y, camera.target.z);
|
console.log(entity.Name);
|
||||||
console.log(camera.up.x, camera.up.y, camera.up.z);
|
console.log(entity.Luck);
|
||||||
console.log(camera.fovy);
|
console.log(entity.bytes);
|
||||||
console.log(camera.projection);
|
|
||||||
console.log(camera.bytes);
|
|
||||||
|
|
||||||
ws.send(camera.bytes, { binary: true }); // Echo back the received message
|
ws.send(entity.bytes, { binary: true }); // Echo back the received message
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue