Visuak break progress !
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ export class PlayerComponent extends Component {
|
||||
screens: GuiScreen[] = [];
|
||||
render_distance = 6;
|
||||
|
||||
breaking_block = false;
|
||||
breaking_block?: { x: number; y: number; z: number };
|
||||
break_progress = 0;
|
||||
break_progress_max = 0;
|
||||
|
||||
|
||||
+37
-86
@@ -1,36 +1,9 @@
|
||||
import { push_vertex } from "./core.ts";
|
||||
import type { Texture } from "./types.ts";
|
||||
|
||||
const pad = 0.5;
|
||||
|
||||
function push_vertex(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
px: number,
|
||||
py: number,
|
||||
pz: number,
|
||||
u: number,
|
||||
v: number,
|
||||
r: number,
|
||||
g: number,
|
||||
b: number,
|
||||
a: number,
|
||||
) {
|
||||
vertices[i++] = px;
|
||||
vertices[i++] = py;
|
||||
vertices[i++] = pz;
|
||||
vertices[i++] = u;
|
||||
vertices[i++] = v;
|
||||
vertices[i++] = r;
|
||||
vertices[i++] = g;
|
||||
vertices[i++] = b;
|
||||
vertices[i++] = a;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
export function push_front_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -53,20 +26,16 @@ export function push_front_face(
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z2, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y, z2, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y, z2, u1, v1, r, g, b, a);
|
||||
push_vertex(x2, y2, z2, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z2, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
push_vertex(x, y, z2, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y2, z2, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y2, z2, u0, v0, r, g, b, a);
|
||||
}
|
||||
|
||||
export function push_back_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -88,20 +57,16 @@ export function push_back_face(
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y, z, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u1, v0, r, g, b, a);
|
||||
push_vertex(x2, y, z, u0, v1, r, g, b, a);
|
||||
push_vertex(x, y, z, u1, v1, r, g, b, a);
|
||||
push_vertex(x, y2, z, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
push_vertex(x2, y, z, u0, v1, r, g, b, a);
|
||||
push_vertex(x, y2, z, u1, v0, r, g, b, a);
|
||||
push_vertex(x2, y2, z, u0, v0, r, g, b, a);
|
||||
}
|
||||
|
||||
export function push_left_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -123,20 +88,16 @@ export function push_left_face(
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y, z2, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z2, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y, z, u0, v1, r, g, b, a);
|
||||
push_vertex(x, y, z2, u1, v1, r, g, b, a);
|
||||
push_vertex(x, y2, z2, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z2, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
push_vertex(x, y, z, u0, v1, r, g, b, a);
|
||||
push_vertex(x, y2, z2, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y2, z, u0, v0, r, g, b, a);
|
||||
}
|
||||
|
||||
export function push_right_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -159,20 +120,16 @@ export function push_right_face(
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
push_vertex(x2, y, z2, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y, z, u1, v1, r, g, b, a);
|
||||
push_vertex(x2, y2, z, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
push_vertex(x2, y, z2, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y2, z, u1, v0, r, g, b, a);
|
||||
push_vertex(x2, y2, z2, u0, v0, r, g, b, a);
|
||||
}
|
||||
|
||||
export function push_top_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -195,20 +152,16 @@ export function push_top_face(
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y2, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y2, z2, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y2, z2, u1, v1, r, g, b, a);
|
||||
push_vertex(x2, y2, z, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y2, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
push_vertex(x, y2, z2, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y2, z, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y2, z, u0, v0, r, g, b, a);
|
||||
}
|
||||
|
||||
export function push_bottom_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -230,13 +183,11 @@ export function push_bottom_face(
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z2, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y, z, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y, z, u1, v1, r, g, b, a);
|
||||
push_vertex(x2, y, z2, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z2, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y, z2, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
push_vertex(x, y, z, u0, v1, r, g, b, a);
|
||||
push_vertex(x2, y, z2, u1, v0, r, g, b, a);
|
||||
push_vertex(x, y, z2, u0, v0, r, g, b, a);
|
||||
}
|
||||
|
||||
@@ -111,9 +111,9 @@ export class PlayerControlsSystem extends System {
|
||||
InputManager.set_mouse_grabbed(player_component.screens.length === 0);
|
||||
|
||||
if (InputManager.is_mouse_down(0) && player_component.screens.length === 0) {
|
||||
player_component.breaking_block = true;
|
||||
player_component.breaking_block = { x: 0, y: 9999, z: 0 };
|
||||
} else {
|
||||
player_component.breaking_block = false;
|
||||
player_component.breaking_block = undefined;
|
||||
player_component.break_progress_max = 0;
|
||||
player_component.break_progress = 0;
|
||||
}
|
||||
@@ -123,6 +123,7 @@ export class PlayerControlsSystem extends System {
|
||||
if (block && player_component.screens.length === 0) {
|
||||
const block_info = EverythingRegistry.get_by_id<BlockRegistry>("blocks", block.block)!;
|
||||
if (player_component.breaking_block) {
|
||||
player_component.breaking_block = { x: block.x, y: block.y, z: block.z };
|
||||
player_component.break_progress_max = block_info.toughness ?? 9999;
|
||||
player_component.break_progress += delta;
|
||||
if (player_component.break_progress >= player_component.break_progress_max) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Camera } from "$/client/components/camera.ts";
|
||||
|
||||
import { render_animated_sprite, render_sprite } from "./rendering/sprites.ts";
|
||||
import { render_dimension } from "./rendering/dimension.ts";
|
||||
import { render_player_crosshair, render_player_hotbar } from "./rendering/player.ts";
|
||||
import { render_player_breaking, render_player_crosshair, render_player_hotbar } from "./rendering/player.ts";
|
||||
import { PlayerComponent } from "../player.ts";
|
||||
import { begin_mode_3d, end_mode_3d } from "../renderer/core.ts";
|
||||
|
||||
@@ -32,6 +32,11 @@ export class RenderSystem extends System {
|
||||
if (dimension) {
|
||||
render_dimension(dimension, camera);
|
||||
}
|
||||
|
||||
const player_component = entity.get(PlayerComponent);
|
||||
if (player_component) {
|
||||
render_player_breaking(player_component);
|
||||
}
|
||||
}
|
||||
|
||||
end_mode_3d();
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
import { SLOT_SIZE } from "$/common/constants.ts";
|
||||
import { SLOT_SIZE, TEXTURE_SIZE } from "$/common/constants.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import { PlayerInventory } from "../../inventory.ts";
|
||||
import { draw_item, draw_nine_slice } from "./render_utils.ts";
|
||||
import { canvas, draw_rect_stroke, push_back_face, Texture } from "$/client/renderer/mod.ts";
|
||||
import {
|
||||
canvas,
|
||||
draw_rect_stroke,
|
||||
push_back_face,
|
||||
push_bottom_face,
|
||||
push_front_face,
|
||||
push_left_face,
|
||||
push_right_face,
|
||||
push_top_face,
|
||||
Texture,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
import { PlayerComponent } from "../../player.ts";
|
||||
import { get_sprite_region } from "../../../common/utils.ts";
|
||||
|
||||
const PADDING = 10;
|
||||
|
||||
@@ -68,3 +79,42 @@ export function render_player_crosshair() {
|
||||
[0, 0, 0, 0.6],
|
||||
);
|
||||
}
|
||||
|
||||
const FACE_FUNCTIONS = [
|
||||
push_back_face,
|
||||
push_bottom_face,
|
||||
push_front_face,
|
||||
push_left_face,
|
||||
push_right_face,
|
||||
push_top_face,
|
||||
];
|
||||
export function render_player_breaking(player_component: PlayerComponent) {
|
||||
const block = player_component.breaking_block;
|
||||
if (block) {
|
||||
const tex = AssetManager.instance.get<Texture>("bworld:textures");
|
||||
|
||||
const progress = Math.max(
|
||||
0,
|
||||
Math.min(1, player_component.break_progress / player_component.break_progress_max),
|
||||
);
|
||||
const break_sprite = Math.round(progress * 8);
|
||||
|
||||
if (Number.isNaN(break_sprite)) {
|
||||
return;
|
||||
}
|
||||
const region = get_sprite_region(`bworld:break_${break_sprite}`);
|
||||
|
||||
for (const fn of FACE_FUNCTIONS) {
|
||||
fn(
|
||||
tex,
|
||||
block.x,
|
||||
block.y,
|
||||
block.z,
|
||||
region.x * TEXTURE_SIZE,
|
||||
region.y * TEXTURE_SIZE,
|
||||
TEXTURE_SIZE,
|
||||
TEXTURE_SIZE,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,249 @@
|
||||
|
||||
import type { BlockRegistry } from "$/common/everything_registry.ts";
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
import {
|
||||
push_back_face,
|
||||
push_bottom_face,
|
||||
push_front_face,
|
||||
push_left_face,
|
||||
push_right_face,
|
||||
push_top_face,
|
||||
} from "../renderer/models.ts";
|
||||
import type { Texture } from "../renderer/types.ts";
|
||||
|
||||
const pad = 0.5;
|
||||
|
||||
function push_vertex(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
px: number,
|
||||
py: number,
|
||||
pz: number,
|
||||
u: number,
|
||||
v: number,
|
||||
r: number,
|
||||
g: number,
|
||||
b: number,
|
||||
a: number,
|
||||
) {
|
||||
vertices[i++] = px;
|
||||
vertices[i++] = py;
|
||||
vertices[i++] = pz;
|
||||
vertices[i++] = u;
|
||||
vertices[i++] = v;
|
||||
vertices[i++] = r;
|
||||
vertices[i++] = g;
|
||||
vertices[i++] = b;
|
||||
vertices[i++] = a;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
export function push_front_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
sx: number,
|
||||
sy: number,
|
||||
sw: number,
|
||||
sh: number,
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1,
|
||||
a = 1,
|
||||
) {
|
||||
const x2 = x + 1;
|
||||
const y2 = y + 1;
|
||||
const z2 = z + 1;
|
||||
|
||||
const u0 = (sx + pad) / texture.width;
|
||||
const v0 = (sy + pad) / texture.height;
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z2, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z2, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
export function push_back_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
sx: number,
|
||||
sy: number,
|
||||
sw: number,
|
||||
sh: number,
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1,
|
||||
a = 1,
|
||||
) {
|
||||
const x2 = x + 1;
|
||||
const y2 = y + 1;
|
||||
|
||||
const u0 = (sx + pad) / texture.width;
|
||||
const v0 = (sy + pad) / texture.height;
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y, z, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
export function push_left_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
sx: number,
|
||||
sy: number,
|
||||
sw: number,
|
||||
sh: number,
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1,
|
||||
a = 1,
|
||||
) {
|
||||
const y2 = y + 1;
|
||||
const z2 = z + 1;
|
||||
|
||||
const u0 = (sx + pad) / texture.width;
|
||||
const v0 = (sy + pad) / texture.height;
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y, z2, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z2, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z2, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
export function push_right_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
sx: number,
|
||||
sy: number,
|
||||
sw: number,
|
||||
sh: number,
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1,
|
||||
a = 1,
|
||||
) {
|
||||
const x2 = x + 1;
|
||||
const y2 = y + 1;
|
||||
const z2 = z + 1;
|
||||
|
||||
const u0 = (sx + pad) / texture.width;
|
||||
const v0 = (sy + pad) / texture.height;
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x2, y, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
export function push_top_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
sx: number,
|
||||
sy: number,
|
||||
sw: number,
|
||||
sh: number,
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1,
|
||||
a = 1,
|
||||
) {
|
||||
const x2 = x + 1;
|
||||
const z2 = z + 1;
|
||||
const y2 = y + 1;
|
||||
|
||||
const u0 = (sx + pad) / texture.width;
|
||||
const v0 = (sy + pad) / texture.height;
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y2, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z2, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y2, z2, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y2, z, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y2, z, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
export function push_bottom_face(
|
||||
vertices: Float32Array,
|
||||
i: number,
|
||||
texture: Texture,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
sx: number,
|
||||
sy: number,
|
||||
sw: number,
|
||||
sh: number,
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1,
|
||||
a = 1,
|
||||
) {
|
||||
const x2 = x + 1;
|
||||
const z2 = z + 1;
|
||||
|
||||
const u0 = (sx + pad) / texture.width;
|
||||
const v0 = (sy + pad) / texture.height;
|
||||
const u1 = (sx + sw - pad) / texture.width;
|
||||
const v1 = (sy + sh - pad) / texture.height;
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z, u1, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z2, u1, v0, r, g, b, a);
|
||||
|
||||
i = push_vertex(vertices, i, x, y, z, u0, v1, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x2, y, z2, u1, v0, r, g, b, a);
|
||||
i = push_vertex(vertices, i, x, y, z2, u0, v0, r, g, b, a);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
type TexturesInfo = Record<string, SpriteRegion>;
|
||||
|
||||
const CHUNK_SIZE = 16;
|
||||
|
||||
Reference in New Issue
Block a user