Files
CavesOfSwift/Sources/Test/Objects/JolkCube.swift

34 lines
593 B
Swift
Raw Normal View History

2024-05-05 17:01:56 +10:00
import Foundation
import simd
import JolkEngine
2024-05-09 20:52:01 +10:00
struct JolkCube: Actor
2024-05-05 17:01:56 +10:00
{
private var _pos: Vec3f
private var theta: Float = 0.0
init(position: Vec3f)
{
_pos = position
}
var position: Vec3f { _pos }
2024-05-09 20:52:01 +10:00
mutating func update(deltaTime: Float, world: Collision)
2024-05-05 17:01:56 +10:00
{
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)
}
}