Jump to content

BABYLON not defined on node server?


Recommended Posts

Hi everyone, 

I'm new to node and babylon, but I've spent hours googling and can't find an explanation for my problem, so I decided to post here.

I am working on a game using node and babylon, and written in TypeScript using atom. The game has a server and client. When using the BABYLON.Vector3 class in my server file no errors show in atom, however once i start the server with the command 'node server' it throws an error saying: 'BABYLON is not defined'. I have tried doing 'npm install babylonjs' however the error still remains. Is it not possible to use BABYLON.Vector3 in my server? Everything works fine on the client.

I have attached the error.


Link to comment
Share on other sites

Hi and welcome to the forum. Nodejs and servers and stuff are beyond my capabilities but there are experts about that may be able to do so. There are certainly others working with servers on the forum. So lets give yoyr question a quick bump up.

Link to comment
Share on other sites

Hi, @Melancholix,

You don't really need babylon server-side,
you can't use it for very much anyhow, since babylon requires a canvas & webGL to work correctly, neither of which are available out-of-the-box on nodeJs,

vector3's can be made by an array "var v3 = {x:0, y:0, z:0};"  and simply used v3.x === 0.

Anyways, on-topic;

it sounds like it either isn't required correctly or you are calling it wrong.

// I believe it should be something like this.. but I'm not 100% sure, worth a try though.

var bblon = require('./ pathToBabylon / babylonFileNameWithoutExtention'); //added spaces at the slashes ( / ) for readability.

var v3 = new bblon.BABYLON.Vector3( 0, 0, 0);

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.

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.


  • Recently Browsing   0 members

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