skinview3d/README.md

90 lines
2.7 KiB
Markdown
Raw Normal View History

2017-10-01 14:17:34 +02:00
skinview3d
========
2020-01-07 07:15:01 +01:00
[![CI Status](https://img.shields.io/github/workflow/status/bs-community/skinview3d/CI?label=CI&logo=github&style=flat-square)](https://github.com/bs-community/skinview3d/actions?query=workflow:CI)
[![NPM Package](https://img.shields.io/npm/v/skinview3d.svg?style=flat-square)](https://www.npmjs.com/package/skinview3d)
[![MIT License](https://img.shields.io/badge/license-MIT-yellowgreen.svg?style=flat-square)](https://github.com/bs-community/skinview3d/blob/master/LICENSE)
[![Gitter Chat](https://img.shields.io/gitter/room/TechnologyAdvice/Stardust.svg?style=flat-square)](https://gitter.im/skinview3d/Lobby)
2017-10-01 14:17:34 +02:00
2017-10-01 09:47:40 +02:00
Three.js powered Minecraft skin viewer.
2016-01-10 18:28:54 +01:00
# Features
* 1.8 Skins
2017-09-02 14:39:01 +02:00
* HD Skins
2016-01-10 18:28:54 +01:00
* Capes
* Elytras
* Slim Arms
* Automatic model detection (Slim / Default)
2016-01-10 18:28:54 +01:00
2017-10-01 14:17:34 +02:00
# Usage
2020-08-23 19:16:37 +02:00
[Example of using skinview3d](https://bs-community.github.io/skinview3d/)
2017-10-01 14:17:34 +02:00
```html
<canvas id="skin_container"></canvas>
2017-10-01 14:17:34 +02:00
<script>
let skinViewer = new skinview3d.SkinViewer({
canvas: document.getElementById("skin_container"),
2020-06-14 10:05:47 +02:00
width: 300,
height: 400,
skin: "img/skin.png"
});
2017-10-01 14:17:34 +02:00
2020-06-14 10:05:47 +02:00
// Change viewer size
skinViewer.width = 600;
skinViewer.height = 800;
2017-10-01 14:17:34 +02:00
2020-06-14 10:05:47 +02:00
// Load another skin
skinViewer.loadSkin("img/skin2.png");
2020-05-29 10:46:19 +02:00
2020-06-14 10:05:47 +02:00
// Load a cape
skinViewer.loadCape("img/cape.png");
// Load a elytra (from a cape texture)
skinViewer.loadCape("img/cape.png", { backEquipment: "elytra" });
// Unload(hide) the cape / elytra
2020-06-14 10:05:47 +02:00
skinViewer.loadCape(null);
2020-05-29 10:46:19 +02:00
2018-02-11 16:39:33 +01:00
// Control objects with your mouse!
2018-02-12 02:46:07 +01:00
let control = skinview3d.createOrbitControls(skinViewer);
control.enableRotate = true;
control.enableZoom = false;
control.enablePan = false;
2018-01-06 15:01:12 +01:00
2018-02-11 16:39:33 +01:00
// Add an animation
2019-12-22 13:19:33 +01:00
let walk = skinViewer.animations.add(skinview3d.WalkingAnimation);
2018-02-11 16:39:33 +01:00
// Add another animation
2019-12-22 13:19:33 +01:00
let rotate = skinViewer.animations.add(skinview3d.RotatingAnimation);
2018-02-11 16:39:33 +01:00
// Remove an animation, stop walking dude
walk.remove();
2019-12-22 13:19:33 +01:00
// Remove the rotating animation, and make the player face forward
rotate.resetAndRemove();
2018-02-11 16:39:33 +01:00
// And run for now!
2019-12-22 13:19:33 +01:00
let run = skinViewer.animations.add(skinview3d.RunningAnimation);
2018-01-06 15:01:12 +01:00
2018-02-11 16:39:33 +01:00
// Set the speed of an animation
run.speed = 3;
// Pause single animation
run.paused = true;
// Pause all animations!
2019-12-22 13:19:33 +01:00
skinViewer.animations.paused = true;
2017-10-01 14:17:34 +02:00
</script>
```
2020-08-23 19:16:37 +02:00
## Anti-aliasing
skinview3d supports FXAA (fast approximate anti-aliasing).
To enable it, you need to replace `SkinViewer` with `FXAASkinViewer`.
You must use an **opaque** background when FXAA is enabled,
because FXAA is incompatible with transparent backgrounds.
2020-08-23 19:16:37 +02:00
By default, the background color is white.
To use a different color:
2020-08-23 19:16:37 +02:00
```javascript
let skinViewer = new skinview3d.FXAASkinViewer(...);
// Set the background color to blue
2020-08-23 19:16:37 +02:00
skinViewer.renderer.setClearColor(0x5a76f3);
```
2017-10-01 14:00:45 +02:00
# Build
2017-10-02 15:29:41 +02:00
`npm run build`