https://github.com/lizainslie/mc-three
Three.js utilities for Minecraft models
https://github.com/lizainslie/mc-three
minecraft model
Last synced: 8 months ago
JSON representation
Three.js utilities for Minecraft models
- Host: GitHub
- URL: https://github.com/lizainslie/mc-three
- Owner: LizAinslie
- Created: 2020-01-08T19:05:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T13:31:49.000Z (over 2 years ago)
- Last Synced: 2024-12-27T20:33:54.705Z (9 months ago)
- Topics: minecraft, model
- Language: TypeScript
- Size: 814 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MCThree - Minecraft for Three.js
This repository wouldn't be possible without [this work](https://github.com/vberlier/three-mcmodel). I just expanded on it and made it more stable!
## Basic Usage
**index.html:**
```html```
**main.js:**
```js
// ...new MinecraftModelLoader().load('/path/to/model.json', mesh => {
const textureLoader = new MinecraftTextureLoader();
mesh.resolveTextures(path =>
textureLoader.load(`/path/to/assets/minecraft/${path}.png`),
);
scene.add(mesh); // scene defined by three.js earlier in code
});// ...
```## Advanced Usage
First you will want to extract the Minecraft assets from the latest Minecraft jar. Go ahead and do that then come back. Place them in a subdirectory of your static files root.**index.html:**
```html```
**main.js:**
```js
// ...new MinecraftModelLoader().load('/path/to/model.json', mesh => {
const textureLoader = new MinecraftTextureLoader();
mesh.resolveTextures(path => {
let namespace, texture;// Check for namespace and default to minecraft: namespace if none is provided.
if (path.indexOf(':') === -1) {
namespace = 'minecraft';
texture = path;
} else {
const pathPieces = path.split(/\:/g);
namespace = pathPieces[0];
texture = pathPieces[1];
}return textureLoader.load(`/path/to/static/root/mcassets/${namespace}/textures/${texture}.png`),
});
scene.add(mesh); // scene defined by three.js earlier in code
});// ...
```