34 lines
593 B
Swift
34 lines
593 B
Swift
import Foundation
|
|
import simd
|
|
import JolkEngine
|
|
|
|
|
|
struct JolkCube: Actor
|
|
{
|
|
private var _pos: Vec3f
|
|
private var theta: Float = 0.0
|
|
|
|
init(position: Vec3f)
|
|
{
|
|
_pos = position
|
|
}
|
|
|
|
var position: Vec3f { _pos }
|
|
|
|
mutating 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)
|
|
}
|
|
}
|