Files
CavesOfSwift/Sources/Test/Objects/JolkCube.swift
2024-05-05 17:01:56 +10:00

34 lines
583 B
Swift

import Foundation
import simd
import JolkEngine
class JolkCube: Actor
{
private var _pos: Vec3f
private var theta: Float = 0.0
init(position: Vec3f)
{
_pos = position
}
var position: Vec3f { _pos }
func update(deltaTime: Float, world: Collision)
{
theta += 15 * deltaTime
_pos.y = 1 + sin(theta * 0.25) * 0.25
}
var transform: Mat4f
{
.translate(_pos) *
.rotate(x: theta * 0.25) *
.rotate(y: Float.rad(fromDeg: theta)) *
// .rotate(axis: .X, angle: theta * 0.25) *
// .rotate(axis: .Y, angle: Float.rad(fromDeg: theta)) *
.scale(scalar: 0.25)
}
}