Rotation for cubes on entities
This commit is contained in:
+12
-2
@@ -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 }),
|
||||
};
|
||||
}),
|
||||
};
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user