Animators and coilhead animations

This commit is contained in:
2026-11-21 21:54:02 -03:00
parent 69ad4b80d0
commit 0c711b8163
21 changed files with 960 additions and 34 deletions
+20 -5
View File
@@ -12,7 +12,7 @@ import {
validate_entity,
} from "@/common/mod_data.ts";
import type { Texture } from "@/client/renderer/mod.ts";
import { IDENTITY } from "@/client/rendering/model_math.ts";
import { bone_matrices, IDENTITY } from "@/client/rendering/model_math.ts";
import { push_model } from "@/client/rendering/model_renderer.ts";
import { Mob } from "@/server/game/entity/mob.ts";
import { create_entity } from "@/server/game/entity/entity_types.ts";
@@ -54,7 +54,13 @@ function model_vertices(model: EntityModelJson, only?: (bone: EntityBoneJson) =>
const out: number[][] = [];
const atlas = { width: model.texture_width, height: model.texture_height } as Texture;
const region = { x: 0, y: 0, width: model.texture_width, height: model.texture_height };
push_model(model, () => IDENTITY, atlas, region, (x, y, z) => [x, y, z], undefined, only, (x, y, z, u, v) => {
push_model(model, bone_matrices(model, () => IDENTITY), atlas, region, (x, y, z) => [x, y, z], undefined, only, (
x,
y,
z,
u,
v,
) => {
out.push([x, y, z, u * model.texture_width, v * model.texture_height]);
});
return out;
@@ -114,9 +120,18 @@ Deno.test("a cube's rotation turns it around its pivot like the same rotation on
const atlas = { width: 16, height: 16 } as Texture;
const region = { x: 0, y: 0, width: 16, height: 16 };
const only = (bone: EntityBoneJson) => bone.name === name;
push_model(model!, () => IDENTITY, atlas, region, (x, y, z) => [x, y, z], undefined, only, (x, y, z) => {
out.push(x, y, z);
});
push_model(
model!,
bone_matrices(model!, () => IDENTITY),
atlas,
region,
(x, y, z) => [x, y, z],
undefined,
only,
(x, y, z) => {
out.push(x, y, z);
},
);
return out;
};
const turned = points("turned_cube");