vujadin / BabylonHx

Port of Babylon.js 3D engine to Haxe.
http:/paradoxplay.com/babylonhx
Apache License 2.0
189 stars 43 forks source link

Errors with Haxe 3.4.0-rc.2, Lime 3.5.2, hxcpp 3.4.2 #139

Open dpavicic opened 7 years ago

dpavicic commented 7 years ago

Hey, I'm trying out Babylon.hx but I got stuck when building the examples ( Lime build ). First I got lots of missing assets errors but I managed to solve that by downloading them from Babylon.js web and put them into the assets directory. I tried to build to HTML and Windows native, so here's what happened:

HTML ( Materials test scene ) Assets fail to load, 'engine' reference is undefinged( null ) Build passes fine, no error but when dev server is started, web page is cyan screen and there's lot's of errors in console. First it says that it cannot read the __renderLoop() function ... it cannot read because at that time 'engine' reference is underfined and it's been called before assets are loaded. From that point assets will never get loaded/displayed. The 'render' function has been called before assets are loaded and 'onPreloadComplete' callback's been called. If I put check for engine null reference in ;render' function it works fine. : override public function render(renderer:Renderer) { if ( engine == null ) return; engine._renderLoop(); } So, this is just a minor issue.

2) After that fix the scene loads and displays fine but there's a lot WebGL shader related errors in the console and the red semi-transparent sphere acts weirdly when moving around. See screenshot here: https://www.dropbox.com/s/izjzaebtl3xgpzq/babylon_html_002.png?dl=0

WINDOWS target Same issues, red semi-transparent sphere acts weirdly when moving around. So I guess same shader issues applies on hxcpp windows target.

Any thoughts how to deal with those issues?

BTW, Cheers from Croatia

vujadin commented 7 years ago

Hi, its probably because of 2D stuff as it collides sometimes with 3D depending on complexity of 3D scene, shaders used GL state enabled/disables ets... 2D api is new and still in experimental stage. Its basically a quick and dirty Haxe port of this http://lib.ivank.net/ with some tweaks I've done to make it work with BHx... but it still doesn't work 100%, I just needed basic 2D stuff for a project I worked on.

To disable 2D stuff you need to remove/comment out following lines: https://github.com/vujadin/BabylonHx/blob/master/src/MainLime.hx#L197 https://github.com/vujadin/BabylonHx/blob/master/src/MainLime.hx#L217

and these too: https://github.com/vujadin/BabylonHx/blob/master/src/MainLime.hx#L226 https://github.com/vujadin/BabylonHx/blob/master/src/MainLime.hx#L234 https://github.com/vujadin/BabylonHx/blob/master/src/MainLime.hx#L242 https://github.com/vujadin/BabylonHx/blob/master/src/MainLime.hx#L273 https://github.com/vujadin/BabylonHx/blob/master/src/MainLime.hx#L280

dpavicic commented 7 years ago

Thanks man, that was fast. It was indeed 2D stuff. Btw, do you plan maybe to make the Kha backend also?

vujadin commented 7 years ago

I've updated lime template, they have changed lime api again... Kha support was planned from the beginning but its not possible right now because of how kha handles shaders. I've had a chance to meed Robert (kha author) at haxe conference this year and he promised me to implement features I need to make bhx work with kha... there should be and issue opened in kha repo by me, about runtime shader compilation (Robert told me to open that issue as a remainder for him), but I guess he gave up the idea...

dpavicic commented 7 years ago

Too bad ... Haxe is really missing a good 3D engine ( for all possible backends ).