Skip to content

Armor Rendering - #212

Open
Vatten wants to merge 6 commits into
bs-community:masterfrom
Vatten:master
Open

Armor Rendering#212
Vatten wants to merge 6 commits into
bs-community:masterfrom
Vatten:master

Conversation

@Vatten

@Vatten Vatten commented Mar 8, 2026

Copy link
Copy Markdown

Hello everyone! Stemming from #210, I've gone ahead and opened this PR with my armor implementation. This is mainly for comparing and merging ideas and getting the best of both worlds.

It's complete with an api, controls on the example page, some offscreen render examples (although I just realized one of them is covering up hacksore's skin so do tell me if you'd want that changed lol)

My solution was to have an ArmorType object that takes in paths to both the layer1 and layer2 textures, and "compiles" them into an armor type. You would then use skinview3d.loadArmor with the armor types to place them on different armor slots.
You would initialize these armor types once, and reuse them everywhere, essentially only loading the textures once.
This is the example from the README:

// Initialize armor types using their layer textures (as found in resource packs)
let diamondArmor = new skinview3d.ArmorType("img/armor/diamond_layer_1.png", "img/armor/diamond_layer_2.png");
let turtleHelmet = new skinview3d.ArmorType("img/armor/turtle_layer_1.png");
// Load the armor types on armor slots (in this case, a turtle helmet with diamond armor)
skinViewer.loadArmor({
	helmet: turtleHelmet,
	chestplate: diamondArmor,
	leggings: diamondArmor,
	boots: diamondArmor
});

// Short-hand for applying an armor type on all slots
skinViewer.loadArmor(diamondArmor);

// Unload(hide) the armor
skinViewer.loadArmor();

From #210 I've also implemented @undefined303's idea of fallback armor with skinview3d.fallbackArmor()

// Specify fallback armor that will always be applied if there is no other armor set
skinViewer.fallbackArmor(diamondArmor);
// Or you can specify slots
skinViewer.fallbackArmor({
	helmet: diamondArmor,
	chestplate: diamondArmor
});

This PR is dependent on changes in skinview-utils, a PR will open there as well

Adds armor models, with the exact dimensions as in minecraft. Also adds a way to load armor textures in the vanilla minecraft way, which allows for all armor from both vanilla minecraft and from any resource pack (even high resolution ones) to be loaded and rendered.
This adds configurable armor examples to the examples page as well as some examples on the offscreen render.
@vercel

vercel Bot commented Mar 8, 2026

Copy link
Copy Markdown

@Vatten is attempting to deploy a commit to the Hacksore's Team Team on Vercel.

A member of the Team first needs to authorize it.

@undefined303

undefined303 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

I don't think we need to upload the leather material, since leather can be dyed, and the original materials all require an overlay (which we don't support yet), so we can skip that.Also, could you upload the material for the bronze armor? (I have files with the bronze armor material in my PR, or you can just bring them over directly)

@undefined303

Copy link
Copy Markdown
Contributor

Screenshot_20260308_181823_mark_via_Shell
I see that other recreate-related code has a texture.dispose() method, so I'm not sure if we need to add that here as well

@undefined303

undefined303 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Screenshot_20260308_182607_mark_via_Shell
Screenshot_20260308_182743_mark_via_Shell
When creating materials, maybe we can check if they meet the requirements (like using the main material instead of legs) and display a warning

@Vatten

Vatten commented Mar 9, 2026

Copy link
Copy Markdown
Author

Alright, I've added the dispose. As for the warning, loadArmorToCanvas in skinview-utils does warn if the texture's dimensions are wrong. It doesn't check if the texture is a layer1 or layer2 texture though, but I feel like that's up to the user to provide the correct textures

@undefined303

Copy link
Copy Markdown
Contributor

I'll close my pr #210 when it merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants