Rotation for cubes on entities

This commit is contained in:
2026-11-13 23:06:37 -03:00
parent c74ddedd6e
commit 9bf6b98953
5 changed files with 58 additions and 15 deletions
+12 -2
View File
@@ -501,6 +501,10 @@ const entity_cube = z.object({
uv: z.tuple([z.number(), z.number()], "must be [u, v], per face uvs aren't supported"),
// grows the box this many pixels each way without moving its texture
inflate: z.number().optional(),
// what rotation turns the box around, inside its bone
pivot: vec3.optional(),
// degrees around x, y then z
rotation: vec3.optional(),
});
export type EntityCubeJson = z.infer<typeof entity_cube>;
@@ -932,8 +936,14 @@ export function entity_model_from_geo(json: unknown, id: string): { model?: Enti
...(rotation === undefined ? {} : { rotation }),
cubes: cubes.map((cube) => {
if (!is_object(cube)) return cube;
const { origin, size, uv, inflate } = cube;
return { origin, size, uv, ...(inflate === undefined ? {} : { inflate }) };
const { origin, size, uv, inflate, pivot, rotation } = cube;
return {
origin,
size,
uv,
...(inflate === undefined ? {} : { inflate }),
...(rotation === undefined ? {} : { pivot: pivot ?? [0, 0, 0], rotation }),
};
}),
};
}),