Player rendering in the inventory
This commit is contained in:
@@ -3,11 +3,11 @@ 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 { push_box } from "./player_renderer.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
|
||||
// pixels, after the bones are turned, to the world. the texture is region of the atlas, stretched to the model's
|
||||
// texture size. only picks the bones drawn, all of them when not given
|
||||
// texture size. only picks the bones drawn, all of them when not given. emit gets the vertices, the batch by default
|
||||
export function push_model(
|
||||
model: EntityModelJson,
|
||||
pose: (bone: EntityBoneJson) => Matrix,
|
||||
@@ -16,6 +16,7 @@ export function push_model(
|
||||
to_world: (x: number, y: number, z: number) => Vec3,
|
||||
tint?: Vec3,
|
||||
only?: (bone: EntityBoneJson) => boolean,
|
||||
emit?: VertexSink,
|
||||
) {
|
||||
const to_uv = (u: number, v: number): [number, number] => [
|
||||
(region.x + u * region.width / model.texture_width) / atlas.width,
|
||||
@@ -33,7 +34,7 @@ export function push_model(
|
||||
// bedrock models are mirrored on x from the engine's, like blockbench shows them: +x is the model's right
|
||||
const low: Vec3 = [-(ox + w) - inflate, oy - inflate, oz - inflate];
|
||||
const high: Vec3 = [-ox + inflate, oy + h + inflate, oz + d + inflate];
|
||||
push_box(cube.size, low, high, cube.uv, to_uv, transform, tint);
|
||||
push_box(cube.size, low, high, cube.uv, to_uv, transform, tint, emit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user