Babylon native on Ubuntu

If any other programmers from the BabylonNative project wants access to the code in the git, please leave me your github handle. I will also try to add some quickfixes.

I will update the git regularly with fresh code and problems.


So I ended up modifying bgfx for the ‘Invalid texture size (width 0, height 0)’ errors. Because it kept giving me this error when loading .babylon models.
I did a small workaround in bgfx.cpp to support 0x0 textures that it turns them into 1x1 textures. It still may cause some texture corruption where there are invalid textures, but it won’t crash anymore. The quickfix is available in my repositories.
I’m thinking of adding a default texture where there’s a 0x0 texture.

Another bug report :smiley:

CreateGroundFromHeightMap fails at ‘onSuccess’ of the LoadImage, I’ve tracked it back to LoadImage -> LoadFile -> createImageBitmap [right at onLoad(imgBmp)] in babylon.max.js .

I can confirm that the image is valid, also tried different formats and it always fails there.

By the way, the device is Samsung J3 (2017), but I don’t think it’s relevant to the bug.

Adding @bghgary FYI as well :slight_smile:

1 Like

Updated the code in the GIT, the code produces a black screen with no error whatsoever. CPU is ~30%, RAM 0.2/2GB, ~200 FPS.

It should display a skybox.

By the way, please don’t share the git with anyone but the Babylon developers yet as the game is still under development.

UPDATE : Made it work, but I had to send the app to the background and then back to foreground and everything worked. I’ll try to fix the terrain bug later…

Quick question : Is there any way to transfer a variable from JS to Java ?
Or pass a function created in java to JS ?

Yes, you can make a plugin.
In BN, the xmlhttprequest is java code and c++ glue.
For its core:

and the plugin declaration:

Thank you, I’ve been looking for an elegant solution all morning…

Sorry for the silly question, I’m tired, but do the plugins auto-enable or I need to do something ?

You have to initialize the plugin. All plugins are statically linked against the app.

Basically, initilization declares a JS object that can be use with the JS engine

And you initialize from the app itself:

Hello I keep getting ‘BabylonNative/Apps/Playground/Android/app/src/main/cpp/BabylonNativeJNI.cpp:20:10: fatal error: ‘Babylon/Polyfills/Mouse.h’ file not found’ even tho the paths are set in CMakeLists.txt :frowning:

Nevermind, I mad it work, now I’m having trouble importing them into Java.

Did you check the command line to see if the path is in a -i parameter?

Now I get this ld: error: undefined symbol: Babylon::Polyfills::mouse::getBuilding()
Android studio finds it but LD says it’s not there. Sorry for the silly questions but I’m new to this work environment.

Did you add the plugin dependency to the cmake link option?

Still not working … Here’s the code for reference :

Java_BabylonNative_Wrapper_getBuilding(JNIEnv *env, jclass clazz) {
const std::string s = Babylon::Polyfills::mouse::getBuilding().ToString().Utf8Value();
return env->NewStringUTF(s.c_str());}

Is your code available somewhere so I can take a look?

It’s the Mouse folder and CMakeLists.txt from Polyfills

“This invitation has expired.” Can you please send me another invitation?


1 Like

getBuilding is missing in Babylon::Polyfills::Mouse

Replace with something like this:

namespace Babylon::Polyfills::Mouse
    void Initialize(Napi::Env env)
    Napi::Value getBuilding() {
        return Babylon::Polyfills::Internal::getBuilding();

As it’s asking for a missing function in Babylon::Polyfills::Mouse namespace.

1 Like