prendy
Version:
Make games with prerendered backdrops using babylonjs and repond
20 lines (16 loc) • 603 B
text/typescript
import { Point3D } from "chootils/dist/points3d";
import { Vector3 } from "@babylonjs/core";
import { shortenDecimals } from "chootils/dist/numbers";
export function point3dToVector3(thePoint: Point3D) {
return new Vector3(thePoint.x, thePoint.y, thePoint.z);
}
export function vector3ToPoint3d(theVector3: Vector3) {
return { x: theVector3.x, y: theVector3.y, z: theVector3.z } as Point3D;
}
export function vector3ToSafePoint3d(theVector3: Vector3) {
return {
x: shortenDecimals(theVector3.x),
y: shortenDecimals(theVector3.y),
z: shortenDecimals(theVector3.z),
} as Point3D;
}