Archived
Private
Public Access
1
0
This repository has been archived on 2026-02-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ProjectBackup/C#/TSEngine/Core/Math/transform.ts
2022-09-04 12:45:01 +02:00

31 lines
1.1 KiB
TypeScript

namespace TSE {
export class Transform {
public position: Vector3 = Vector3.zero;
public rotation: Vector3 = Vector3.zero;
public scale: Vector3 = Vector3.one;
public copyFrom(transform: Transform): void {
this.position.copyFrom(transform.position);
this.rotation.copyFrom(transform.rotation);
this.scale.copyFrom(transform.scale);
}
public get transformationMatrix(): Matrix4x4 {
let translation = Matrix4x4.translation(this.position);
let rotation = Matrix4x4.rotationXYZ(this.rotation.x, this.rotation.y, this.rotation.z);
let scale = Matrix4x4.scale(this.scale);
return Matrix4x4.multiply3(translation, rotation, scale);
}
public setFromJson(json: any): void {
if (json.position !== undefined) this.position.setFromJson(json.position);
if (json.rotation !== undefined) this.rotation.setFromJson(json.rotation);
if (json.scale !== undefined) this.scale.setFromJson(json.scale);
}
}
}