Jump to content

Server-side Babylon.js


ozRocker
 Share

Recommended Posts

This worked for me! (typescript) it requires https://github.com/stackgl/headless-gl 
Bit hackish but it works :) also with collision. 

GLOBAL.window = {};
GLOBAL.window.addEventListener = () => {};
GLOBAL.navigator = {};
GLOBAL.document = {};
GLOBAL.document.addEventListener = () => {};
GLOBAL.window.setTimeout = setTimeout;

export class HTMLElement {

}

var gl = require('gl')(10, 10, {})
var engine = new BABYLON.Engine({
    getContext: function() {
        return gl;
    },
    addEventListener: () => {}
});
var scene = new BABYLON.Scene(engine);
var scene.collisionsEnabled = true;
var camera = new BABYLON.FreeCamera('camera', BABYLON.Vector3.Zero(), scene);
var ground = BABYLON.Mesh.CreateGround('ground', 10, 10, 20, this.scene);

engine.runRenderLoop(function() { 
    scene.render(); 
});

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...