-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (41 loc) · 1.64 KB
/
main.cpp
File metadata and controls
56 lines (41 loc) · 1.64 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <nodepp/nodepp.h>
#include <ungine/ungine.h>
#include <nodepp/http.h>
#include <nodepp/json.h>
#include <nodepp/bind.h>
using namespace nodepp;
#include "./controller/script/utils.cpp"
#include "./controller/scene/scene_0.cpp"
void onMain() {
auto width = EM_ASM_INT({ return window.screen.width; });
auto height = EM_ASM_INT({ return window.screen.height; });
EM_ASM({ (()=>{
if( screen.orientation ){
screen.orientation.addEventListener("change",()=>{ engine.refresh(); });
} else {
window.addEventListener( "resize", ()=>{ engine.refresh(); });
}
document.querySelector( "button" ).addEventListener( "click",()=>{
window.document.querySelector("canvas").requestFullscreen();
});
window.sensor = new Object({ x:"0", y:"0", z:"0", w:"0" });
try {
const sensor = new AbsoluteOrientationSensor({ frequency: 60 });
sensor.addEventListener( "reading", ()=>{
window.sensor.x = sensor.quaternion[0].toFixed(6);
window.sensor.y = sensor.quaternion[1].toFixed(6);
window.sensor.z = sensor.quaternion[2].toFixed(6);
window.sensor.w = sensor.quaternion[3].toFixed(6);
}); sensor.start();
} catch(err) { alert( "gyroscope not found" ); }
setTimeout(()=>{ start_ar_controller((ev)=>{
engine.marker(
ev.data.marker.idMatrix,
ev.data.matrix
);
}); },1000);
})(); }); srand( process::now() );
ungine::engine::start( width, height, "GAME" );
ungine::engine::set_fps( 60 );
ungine::scene ::scene_0();
}