PrismarineJS/prismarine-viewer





The issue has been closed
headless.js example doesn't work #128
mehmetahsen posted onGitHub
Hi,
Couldn't get examples/headless.js -slightly changed version of it- to work. I'm suspecting a missing dependency or config issue. Server my bot is connecting is Cuberite, but I also tried on vanilla servers, with different versions with no luck.
Bot:
const mineflayer = require('mineflayer')
const mineflayerViewer = require('prismarine-viewer').headless
const bot = mineflayer.createBot({
host: '127.0.0.1',
port: 25565,
username: 'testbot',
version: '1.12.2',
viewDistance: 'tiny',
})
let show = true
function toggleSkin () {
show = !show
bot.setSettings({
skinParts: {
showJacket: show,
showHat: show,
showRightPants: show,
showLeftPants: show,
showLeftSleeve: show,
showRightSleeve: show
}
})
}
bot.once('spawn', () => {
// Record 200 frames, 512x512 pixels, and save
bot.chat(bot.spawnPoint.toString())
mineflayerViewer(bot, { output: '/bot/videos/save0.mp4', frames: 200, width: 512, height: 512 })
bot.setControlState('jump', true)
})
bot.on('spawn', () => {
setInterval(toggleSkin, 500)
})
Error I am getting:
root@d84a189c4823:/bot# node _bot.js
THREE.WebGLRenderer: Cannot read property 'getUniformLocation' of null
/bot/node_modules/minecraft-protocol/src/transforms/framing.js:67
} else { throw e }
^
TypeError: Cannot read property 'getUniformLocation' of null
at NodeCanvasElement.getContext (/bot/node_modules/node-canvas-webgl/lib/canvas.js:88:39)
at getContext (/bot/node_modules/three/build/three.js:17645:27)
at new WebGLRenderer (/bot/node_modules/three/build/three.js:17676:11)
at module.exports (/bot/node_modules/prismarine-viewer/lib/headless.js:19:20)
at EventEmitter.<anonymous> (/bot/_bot.js:31:3)
at Object.onceWrapper (events.js:421:28)
at EventEmitter.emit (events.js:327:22)
at Client.<anonymous> (/bot/node_modules/mineflayer/lib/plugins/health.js:13:11)
at Object.onceWrapper (events.js:422:26)
at Client.emit (events.js:327:22)
I have node-convas-webgl
installed.
Apologies in advance if I missed something.
Best, Mehmet