Melancholix Posted August 16, 2016 Share Posted August 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 18, 2016 Share Posted August 18, 2016 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. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted August 18, 2016 Share Posted August 18, 2016 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); Quote Link to comment Share on other sites More sharing options...
Melancholix Posted August 19, 2016 Author Share Posted August 19, 2016 Thanks @aWeirdo, I tried what you suggested but it still didn't work. I'll just follow your other piece of advice and make my own server side vector class. I only wanted babylon server side for the vector class to keep things consistent, I guess it doesn't really matter though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.