Player model

This commit is contained in:
2026-09-27 11:50:08 -03:00
parent eada67de13
commit edf4b72dc4
6 changed files with 212 additions and 42 deletions
+4 -15
View File
@@ -8,12 +8,12 @@ import type { Entity } from "$/client/entity/entity.ts";
import { RemotePlayer } from "$/client/entity/remote_player.ts";
import { ItemEntity } from "$/client/entity/item_entity.ts";
import { render_item_entity } from "./item_renderer.ts";
import { render_player } from "./player_renderer.ts";
import {
draw_terrain,
flush_batch,
push_back_face,
push_bottom_face,
push_box,
push_front_face,
push_left_face,
push_right_face,
@@ -21,7 +21,6 @@ import {
set_current_texture,
Texture,
view_projection,
white_tex,
} from "$/client/renderer/mod.ts";
import type { RenderLayer } from "$/common/everything_registry.ts";
import { FACE_GROUPS, UNALIGNED_GROUP } from "$/client/workers/chunk_messages.ts";
@@ -95,11 +94,12 @@ export class LevelRenderer {
// every entity but the one the camera is in
render_entities(level: ClientLevel, camera_entity: Entity, partial_tick: number) {
flush_batch();
set_current_texture(white_tex!);
const skin = AssetManager.instance.get<Texture>("bworld:skin");
set_current_texture(skin.tex);
for (const entity of level.entities.values()) {
if (entity !== camera_entity && entity instanceof RemotePlayer) {
render_player(entity, partial_tick);
render_player(entity, skin, partial_tick);
}
}
flush_batch();
@@ -180,14 +180,3 @@ export function group_faces_camera(
const position = axis === 0 ? camera.x : axis === 1 ? camera.y : camera.z;
return FACE_NORMALS[group][axis] > 0 ? position > min : position < max;
}
// a box body and head in the player's color
function render_player(player: RemotePlayer, partial_tick: number) {
const [r, g, b] = player.color;
const { x, y, z } = player.render_position(partial_tick);
// body
push_box(x - 0.3, y, z - 0.15, 0.6, 1.3, 0.3, r, g, b);
// head
push_box(x - 0.25, y + 1.3, z - 0.25, 0.5, 0.5, 0.5, 0.95, 0.8, 0.65);
}