feat: size

This commit is contained in:
TrèsAbhi committed 2024-01-28 20:56:49 -06:00
1 parent 72a24b2770
commit 4da4cf5259
5 files changed
+27 -3

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ export interface ModelArmor {
spaced?: number[];
}
interface BoundingBox {
export interface BoundingBox {
min: Vector3Tuple;
max: Vector3Tuple;
}
@@ -0,0 +1,8 @@
import { Vector3Tuple } from 'three';
import { BoundingBox } from './modelDefinitions';
export function normalizeBoundingBox(boundingBox: BoundingBox) {
return boundingBox.max.map(
(max, index) => max - boundingBox.min[index],
) as Vector3Tuple;
}
+9
View File
@@ -0,0 +1,9 @@
import { Vector3Tuple } from 'three';
import { BoundingBox } from './modelDefinitions';
export function unionBoundingBox(a: BoundingBox, b: BoundingBox) {
return {
min: a.min.map((a, index) => Math.min(a, b.min[index])) as Vector3Tuple,
max: a.max.map((a, index) => Math.max(a, b.max[index])) as Vector3Tuple,
} satisfies BoundingBox;
}