I all,
for my 3D printing host app I had necessity to add a 3D view and found a good start point, I started from here:
https://www.b4x.com/android/forum/threads/b4x-using-three-js-webgl-in-a-webview.127277/
Many Thanks to user @roumei for posting it, this library is quite impressive and works very well even on my old phone a full HW accelleration is archived, just need a browser that support WebGL. Now I'm able to create a full 60 fps GL accelerated 3D view and construct my 3D scene in a way I've in mind.
Starting from @roumei example I studied it and extended a bit the class to create more geometries and add more functionalities.
To Learn fast THREEJS I've decided to make a simple app to interact with it in realtime. This app use a TabHost and have 3 tabs I've created two releases of this app, one with Javascript injected using WebViewExtras.executeJavascript in realtime, and other that collect a full HTML string then send it to a WebView.
- in the first Tab I put a ScrollView with a long EditText, here I write directly the Javascript code to be executed in a webview, this code is then added to an HTML template that import three.js and orbitcontrols.js. In the EditText I do not see the HTML file, just the Javascript to put inside the HTML <script> tag.
- in the second tab I put a WebView in fullscreen, when I press the Tab the app pack all HTML string with Javascript too and load it in the WebView, this work very well and just by changing the JS code in the EditText the final result change.
- in the last Tab (not implemented yet) I want to show a full HTML string with scripts, then add a button to Save and another to Load. This way, by just click on the created Index.html file it launches on the browser.
All these worked well, just I do not have the console, if I only miss a semicolon or there are some JS errors, executing it just do not show nothing in a WebView.... Next If I've success I try to integrate a console like Eruda.
Now my problem is that I want integrate this inside my app and call from B4A the Javascript functions to draw lines, cylinders that simulate a real plastic filament, and much more.... so definitely, I need to replace my old View.
The big problem I found is that some functions expets 5-8-10 arguments and working with WebViewExtras I've read that can be used max 3 arguments.
Is there a way to solve this limitation or maybe use some JavaObject or Reflection code to pass more arguments to a JS function ?
Maybe is possible to send an Object like a Type or maybe an array of parameters or other ways ?
Many thanks for your suggestions
for my 3D printing host app I had necessity to add a 3D view and found a good start point, I started from here:
https://www.b4x.com/android/forum/threads/b4x-using-three-js-webgl-in-a-webview.127277/
Many Thanks to user @roumei for posting it, this library is quite impressive and works very well even on my old phone a full HW accelleration is archived, just need a browser that support WebGL. Now I'm able to create a full 60 fps GL accelerated 3D view and construct my 3D scene in a way I've in mind.
Starting from @roumei example I studied it and extended a bit the class to create more geometries and add more functionalities.
To Learn fast THREEJS I've decided to make a simple app to interact with it in realtime. This app use a TabHost and have 3 tabs I've created two releases of this app, one with Javascript injected using WebViewExtras.executeJavascript in realtime, and other that collect a full HTML string then send it to a WebView.
- in the first Tab I put a ScrollView with a long EditText, here I write directly the Javascript code to be executed in a webview, this code is then added to an HTML template that import three.js and orbitcontrols.js. In the EditText I do not see the HTML file, just the Javascript to put inside the HTML <script> tag.
- in the second tab I put a WebView in fullscreen, when I press the Tab the app pack all HTML string with Javascript too and load it in the WebView, this work very well and just by changing the JS code in the EditText the final result change.
- in the last Tab (not implemented yet) I want to show a full HTML string with scripts, then add a button to Save and another to Load. This way, by just click on the created Index.html file it launches on the browser.
All these worked well, just I do not have the console, if I only miss a semicolon or there are some JS errors, executing it just do not show nothing in a WebView.... Next If I've success I try to integrate a console like Eruda.
Now my problem is that I want integrate this inside my app and call from B4A the Javascript functions to draw lines, cylinders that simulate a real plastic filament, and much more.... so definitely, I need to replace my old View.
The big problem I found is that some functions expets 5-8-10 arguments and working with WebViewExtras I've read that can be used max 3 arguments.
Is there a way to solve this limitation or maybe use some JavaObject or Reflection code to pass more arguments to a JS function ?
Maybe is possible to send an Object like a Type or maybe an array of parameters or other ways ?
Many thanks for your suggestions
Last edited: