-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_wasm.nelua
48 lines (36 loc) · 1.22 KB
/
main_wasm.nelua
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
## pragmas.nogc = true
local World = require "entropy.world"
local world: World
local Render = require 'entropy.render'
local Context = require 'entropy.render.context.wasm'
local Renderer = require "entropy.render.renderer"
local MeshImpl = require "entropy.render.impl.mesh"
require "entropy.render.impl.compose"
local Camera = require "entropy.scene.camera"
local Mesh = require "entropy.scene.mesh"
local Event = require "entropy.defs.event"
-- local function print(s: cstring): void <cimport> end
local render: Render
local context: Context
local renderer: Renderer(MeshImpl)
local function onInit() <cexport, codename 'onInit'>
print("onInit")
render:init_default()
context:init(".entropy-canvas", 512, 512, true, render)
renderer:init(context.device, context.format, context.width, context.height)
-- setup camera
local cameras = world:s("entropy.scene.cameras", Camera)
local camera_idx = cameras:create({
pos = { 10, 10, 10 },
rot = { 0, 0, 0 },
fov = 90,
z_near = 0.1,
z_far = 10000,
})
cameras[camera_idx]:look_at({ 0, 0, 0 })
end
local function onAnimationFrame() <cexport, codename 'onAnimationFrame'>
local view = context:view()
renderer:render(view, &world)
context:present()
end