项目作者: bs-community

项目描述 :
Three.js powered Minecraft skin viewer.
高级语言: TypeScript
项目地址: git://github.com/bs-community/skinview3d.git
创建时间: 2017-10-01T07:16:35Z
项目社区:https://github.com/bs-community/skinview3d

开源协议:MIT License

下载


skinview3d

CI Status
NPM Package
MIT License
Gitter Chat

Three.js powered Minecraft skin viewer.

Features

  • 1.8 Skins
  • HD Skins
  • Capes
  • Ears
  • Elytras
  • Slim Arms
    • Automatic model detection (Slim / Default)
  • FXAA (fast approximate anti-aliasing)

Usage

Example of using skinview3d

CodeSandbox

  1. <canvas id="skin_container"></canvas>
  2. <script>
  3. let skinViewer = new skinview3d.SkinViewer({
  4. canvas: document.getElementById("skin_container"),
  5. width: 300,
  6. height: 400,
  7. skin: "img/skin.png"
  8. });
  9. // Change viewer size
  10. skinViewer.width = 600;
  11. skinViewer.height = 800;
  12. // Load another skin
  13. skinViewer.loadSkin("img/skin2.png");
  14. // Load a cape
  15. skinViewer.loadCape("img/cape.png");
  16. // Load an elytra (from a cape texture)
  17. skinViewer.loadCape("img/cape.png", { backEquipment: "elytra" });
  18. // Unload(hide) the cape / elytra
  19. skinViewer.loadCape(null);
  20. // Set the background color
  21. skinViewer.background = 0x5a76f3;
  22. // Set the background to a normal image
  23. skinViewer.loadBackground("img/background.png");
  24. // Set the background to a panoramic image
  25. skinViewer.loadPanorama("img/panorama1.png");
  26. // Change camera FOV
  27. skinViewer.fov = 70;
  28. // Zoom out
  29. skinViewer.zoom = 0.5;
  30. // Rotate the player
  31. skinViewer.autoRotate = true;
  32. // Apply an animation
  33. skinViewer.animation = new skinview3d.WalkingAnimation();
  34. // Set the speed of the animation
  35. skinViewer.animation.speed = 3;
  36. // Pause the animation
  37. skinViewer.animation.paused = true;
  38. // Remove the animation
  39. skinViewer.animation = null;
  40. </script>

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:

  1. skinViewer.cameraLight.intensity = 0.9;
  2. 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)
  • skin: Skin texture that contains the ear (e.g. deadmau5’s skin)

Usage:

  1. // You can specify ears in the constructor:
  2. new skinview3d.SkinViewer({
  3. skin: "img/deadmau5.png",
  4. // Use ears drawn on the current skin (img/deadmau5.png)
  5. ears: "current-skin",
  6. // Or use ears from other textures
  7. ears: {
  8. textureType: "standalone", // "standalone" or "skin"
  9. source: "img/ears.png"
  10. }
  11. });
  12. // Show ears when loading skins:
  13. skinViewer.loadSkin("img/deadmau5.png", { ears: true });
  14. // Use ears from other textures:
  15. skinViewer.loadEars("img/ears.png", { textureType: "standalone" });
  16. skinViewer.loadEars("img/deadmau5.png", { textureType: "skin" });

Name Tag

Usage:

  1. // Name tag with text "hello"
  2. skinViewer.nameTag = "hello";
  3. // Specify the text color
  4. skinViewer.nameTag = new skinview3d.NameTagObject("hello", { textStyle: "yellow" });
  5. // Unset the name tag
  6. skinViewer.nameTag = null;

In order to display name tags correctly, you need the Minecraft font from
South-Paw/typeface-minecraft.
This font is available at assets/minecraft.woff2.

To load this font, please add the @font-face rule to your CSS:

  1. @font-face {
  2. font-family: 'Minecraft';
  3. src: url('/path/to/minecraft.woff2') format('woff2');
  4. }

Build

npm run build