Make Simple Panorama images and view them in your browser!
This is a plugin for Mineflayer a high level Node.js API for creating Minecraft Bots. Mineflayer-panorama allows you to make pretty panorama images off the world the bot is in.
This plugin is built using Node and can be installed using:
git clone https://github.com/IceTank/mineflayer-panorama.git
cd mineflayer-panorama
npm install
For use as a plugin to make Panorama Images:
const panorama = require('./index')
const mineflayer = require('mineflayer')
const fs = require('fs')
const bot = mineflayer.createBot({
host: 'localhost'
})
bot.on('spawn', async () => {
console.info('Bot spawned')
bot.loadPlugin(panorama.image)
bot.on('camera_ready', async () => {
await bot.waitForChunksToLoad()
console.info('Ready to use')
let imageStream = await bot.panoramaImage.takePanoramaPictures()
let image = fs.createWriteStream('panorama1.jpeg')
imageStream.pipe(image)
image.on('finish', () => {
console.info('Wrote panorama image panorama1.jpeg')
})
})
})
This plugin also includes a webserver that can be used to view the generated images.
The webserver opens a website on a given port and serves the current panorama view of the bot and a Panorama viewer.
For an example see: example/browserCubeMap/index.js
.
Note: three.module.js has to be provided in public/js
. If npm install
did not download it, it has to be added manually.
The rendering is done by node-canvas-webgl which is tricky to install on Windows. I recommend using a unix based operating system or Docker to run this plugin.
Takes a panorama Image and resolves with a jpeg stream of that image on success.
camPos
- anull
,number
orVec3
like objectnull
- takes the panorama image from the bot current positionnumber
- takes the panorama image with a high offset at the bots current locationVec3
like - takes the panorama image at a given location. Note: the bot can only render chunks that are loaded. Taking images outside of the current render distance may result in a blank image off the current sky color.
Takes a picture of the current world at the bots current position looking at the point lookAt
lookAt
- aVec3
like object of the point the bot should look atname
- the name the jpeg image will be saved as
A class providing a express app to host the panorama viewer on.
When the page is opened the web server automatically calls bot.panoramaImage.takePanoramaImage
to take an up to date panorama image to display in the panorama viewer.
bot
- the mineflayer bot instancePORT
- the port the express app should listen on
Emitted when the express app is ready and running
Example Dockerfiles are provided in the examples. To build an example Dockerfile use this command:
docker build . -f .\example\<the example>\Dockerfile -t <image name>
For running the container read the README.md files in the example folders.
- Add panorama Video streaming/saving
- Add entitys to the panorama view
This project uses the MIT license.
This project is accepting PRs and Issues. See something you think can be improved? Go for it! Any and all help is highly appreciated!
For larger changes, it is recommended to discuss these changes in the issues tab before writing any code. It's also preferred to make many smaller PRs than one large one, where applicable.