skinview3d/README.md

139 lines
4.1 KiB
Markdown
Raw Permalink 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
* Ears
* 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");
2021-09-23 04:13:59 +02:00
// Load an 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
2021-09-23 04:13:59 +02:00
// Set the background color
skinViewer.background = 0x5a76f3;
// Set the background to a normal image
skinViewer.loadBackground("img/background.png");
// Set the background to a panoramic image
2021-09-23 04:13:59 +02:00
skinViewer.loadPanorama("img/panorama1.png");
2021-09-23 06:02:41 +02:00
// Change camera FOV
skinViewer.fov = 70;
// Zoom out
skinViewer.zoom = 0.5;
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`.
2021-09-23 04:13:59 +02:00
Note that FXAA is incompatible with transparent backgrounds.
So when FXAA is enabled, the default background color will be white instead of transparent.
2020-08-23 19:16:37 +02:00
2022-01-07 21:58:38 +01:00
## Lighting
By default, there are two lights on the scene. One is an ambient light, and the other is a point light from the camera.
To change the light intensity:
```js
skinViewer.cameraLight.intensity = 0.9;
skinViewer.globalLight.intensity = 0.1;
```
Setting `globalLight.intensity` to `1.0` and `cameraLight.intensity` to `0.0`
will completely disable shadows.
## Ears
skinview3d supports two types of ear texture:
* `standalone`: 14x7 image that contains the ear ([example](https://github.com/bs-community/skinview3d/blob/master/examples/img/ears.png))
* `skin`: Skin texture that contains the ear (e.g. [deadmau5's skin](https://minecraft.fandom.com/wiki/Easter_eggs#Deadmau5.27s_ears))
Usage:
```js
// You can specify ears in the constructor:
new skinview3d.SkinViewer({
skin: "img/deadmau5.png",
// Use ears drawn on the current skin (img/deadmau5.png)
ears: "current-skin",
// Or use ears from other textures
ears: {
textureType: "standalone", // "standalone" or "skin"
source: "img/ears.png"
}
});
// Show ears when loading skins:
skinViewer.loadSkin("img/deadmau5.png", { ears: true });
// Use ears from other textures:
skinViewer.loadEars("img/ears.png", { textureType: "standalone" });
skinViewer.loadEars("img/deadmau5.png", { textureType: "skin" });
```
2017-10-01 14:00:45 +02:00
# Build
2017-10-02 15:29:41 +02:00
`npm run build`