require 'honey.std' return function(db) local capsule = db:createEntityWithComponents{ node = { matrix = Mat4() :identity() :translate(Vec3{0,10,0}) :rotateX(0.5*math.pi) }, collision = { class = "capsule", radius = 1, length = 2, category = 2, collide = bit.bxor(0xffffffff, 2) }, physics = { mass = { class = "capsule", mass = 10, direction = 3, radius = 1, length = 2, }, surface = true, maxAngularSpeed = 0, }, renderMesh = { mesh = { filename="assets/capsule.obj", index=1 }, shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, textures = { ourTexture = { filename = "assets/green-grass.jpg" }, }, }, script = { script = "scripts.capsuleMove" }, } local spring = db:createEntityWithComponents{ node = { name = "spring", parent = capsule, matrix = Mat4():identity() :translate(Vec3{0,-1,0}) }, collision = { class = "ray", length = 4, category = 2, collide = bit.bxor(0xffffffff, 2) }, onCollision = { script = "scripts.character.spring", }, spring = { F = 0, } } local pivotPivot = db:createEntityWithComponents{ node = { name = "p", parent = capsule, matrix = Mat4():identity():rotateX(-0.5*math.pi), }, } local capcamPivot = db:createEntityWithComponents{ node = { name = "pivot", parent = pivotPivot, matrix = Mat4():identity(), }, pitchyaw = { pitch = 0, yaw = 0, }, onCursorPos = { script = "scripts.cameraPivot" }, } local capcam = db:createEntityWithComponents{ camera = { projection = Mat4():perspective(math.rad(45), 640/480, 0.1, 1000), render="screen", }, node = { parent = capcamPivot, matrix = Mat4():identity():translate(Vec3{0,0,20}), }, onScroll = { script = "scripts.character.cameraDistance" }, onFramebufferSize = { script = "scripts.cameraHandleResize" }, } end