PrismarineJS/prismarine-viewer

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


I have the same issue, any solution?

posted by alekitopi about 4 years ago

Can you try npm install prismarine-viewer@1.13.1 and see if that works?

posted by extremeheat about 4 years ago

Installing that version I had to install manually three and then when I tried to run the example again it appears the same error.

THREE.WebGLRenderer: Cannot read property 'getUniformLocation' of null
/root/cam/node_modules/minecraft-protocol/src/transforms/framing.js:67
          } else { throw e }
                   ^

TypeError: Cannot read property 'getUniformLocation' of null
    at NodeCanvasElement.getContext (/root/cam/node_modules/node-canvas-webgl/lib/canvas.js:88:39)
    at getContext (/root/cam/node_modules/prismarine-viewer/node_modules/three/build/three.js:17645:27)
    at new WebGLRenderer (/root/cam/node_modules/prismarine-viewer/node_modules/three/build/three.js:17676:11)
    at module.exports (/root/cam/node_modules/prismarine-viewer/lib/headless.js:13:20)
    at EventEmitter.<anonymous> (/root/cam/index.js:13:3)
    at Object.onceWrapper (events.js:421:28)
    at EventEmitter.emit (events.js:327:22)
    at Client.<anonymous> (/root/cam/node_modules/mineflayer/lib/plugins/health.js:13:11)
    at Object.onceWrapper (events.js:422:26)
    at Client.emit (events.js:327:22)
posted by alekitopi about 4 years ago

Try following the instructions here https://github.com/PrismarineJS/prismarine-viewer/tree/master/examples/exporter Your setup probably doesn't have an x server

posted by Karang about 4 years ago

I used xvfb-run -s "-ac -screen 0 1280x1024x24" node index.js and it worked. Now I can't stream that output to any server. I tried using ffmpeg to stream the file output to a RTMP server but didn't work. Any idea?

posted by alekitopi about 4 years ago

Fund this Issue

$0.00
Funded

Pull requests