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
+3 -3
View File
@@ -5,7 +5,7 @@
import type { Texture } from "@/client/renderer/mod.ts";
import type { SpriteRegion } from "@/common/constants.ts";
import type { EntityBoneJson, EntityModelJson } from "@/common/mod_data.ts";
import { apply, bone_matrices, type Matrix, type Vec3 } from "./model_math.ts";
import { apply, bone_matrices, type Matrix, multiply, own_matrix, type Vec3 } from "./model_math.ts";
import { push_box, type VertexSink } from "./player_renderer.ts";
// pose is each bone's turn before its parent's, like a head looking or a limb swinging. to_world takes the model's
@@ -28,9 +28,9 @@ export function push_model(
const matrices = bone_matrices(model, pose);
for (const bone of model.bones) {
if (only && !only(bone)) continue;
const matrix = matrices.get(bone.name)!;
const transform = (px: number, py: number, pz: number) => to_world(...apply(matrix, px, py, pz));
for (const cube of bone.cubes) {
const matrix = multiply(matrices.get(bone.name)!, own_matrix(cube));
const transform = (px: number, py: number, pz: number) => to_world(...apply(matrix, px, py, pz));
const inflate = cube.inflate ?? 0;
const [ox, oy, oz] = cube.origin;
const [w, h, d] = cube.size;