webgl/public/gl/core/Entity.js
2023-01-18 23:44:45 -05:00

28 lines
No EOL
626 B
JavaScript

import { Vec3 } from '../math/Vec3.js'
import { Mat4 } from '../math/Mat4.js'
export class Entity {
static #id = 0
constructor(mesh) {
this.mesh = mesh
this.position = new Vec3()
this.rotation = new Vec3()
this.scale = new Vec3(1, 1, 1)
this.id = Entity.#id
Entity.#id++
}
tran() {
this.rotation.x %= 360;
this.rotation.y %= 360;
this.rotation.z %= 360;
return new Mat4()
.identity()
.pos(this.position)
.rot(this.rotation.clone().multS(Math.PI/180))
.scale(this.scale)
}
}