-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.lua
68 lines (52 loc) · 1.53 KB
/
main.lua
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
57
58
59
60
61
62
63
64
65
66
67
68
lastTouchPos = Vector2(0, 0)
scene = Scene()
camera = Camera(scene)
terrain = Shape(scene)
model = Model(scene)
sky = SkyBox(scene)
sun = Light(scene)
uiscene = Scene()
text = Text(uiscene)
function onKeyDown(key, rep, mods)
model:getAnimation(0):start()
end
function onTouchStart(pointer, x, y)
lastTouchPos = Vector2(x, y)
end
function onTouchMove(pointer, x, y)
difX = lastTouchPos.x - x
difY = lastTouchPos.y - y
lastTouchPos = Vector2(x, y)
camera:rotatePosition(0.1 * difX)
camera:elevatePosition(-0.1 * difY)
end
scene.ambientLightFactor = 0.2
scene.camera = camera.entity
text.text = "Press any key to start"
text.anchorPreset = AnchorPreset.CENTER_TOP
camera:setPosition(0, 7, -20)
camera:setView(0, 2, 0);
terrain:createPlane(200, 200)
terrain:setTexture("ground.png")
model:loadModel("CesiumMan.glb")
model:setScale(4)
model:setRotation(-90,0,0)
model:getAnimation(0).loop = true
sun.type = LightType.DIRECTIONAL
sun:setDirection(0,-0.7, 0.8)
sun:setIntensity(10)
sun:setShadows(true)
sky:setTextureFront("ely_hills/hills_lf.tga")
sky:setTextureBack("ely_hills/hills_rt.tga")
sky:setTextureLeft("ely_hills/hills_bk.tga")
sky:setTextureRight("ely_hills/hills_ft.tga")
sky:setTextureUp("ely_hills/hills_up.tga")
sky:setTextureDown("ely_hills/hills_dn.tga")
Engine.scalingMode = Scaling.FITWIDTH
Engine.setCanvasSize(1000, 480)
Engine.setScene(scene)
Engine.addSceneLayer(uiscene)
Engine.callTouchInMouseEvent = true
Engine.onKeyDown = onKeyDown
Engine.onTouchStart = onTouchStart
Engine.onTouchMove = onTouchMove