Many thanks
@drgottjr for your detailed explanation, I need to study it better because my english is not so good.
Because you asked me I went to explain better what I do from begin, if it is a too long story for you, please, just past next where I explain what I do now and because I need to redirect JS console to a TextField.
I managed with threejs these days, because I wrote an app to control 3D printers, CNC machines, laser cutter machines and next I will add foam cutter machines.
The app can simulate work of these machines by loading gcode files created with various cad/cams, for printing are slicers like eg. slic3r, Cura, PrusaSlicer, Simplify3D, for CNC CAD/CAM like RhinoCam, ArtCam and others, and for laser various software like LaserGRBL, LaserWeb and others.
My app can load all these gcode files, in the Settings need to set what machine to use and after restart it load the selected layout for that machine.
All layouts are same, just have small needed changes for any different machine.
The app not only simulate, can control manually (with phone or tablet, touch) that machines over USB OTG cable or over local WiFi network or over Internet, this worked even without use WiFi on a Smartphone, just a Data Line (SIM).
I tried it many times with various Facebook litalian users and worked well, but for now only tested 3D printing part, these users with my app controlled my Creality Ender3 3D printer to my home from anyware, tested even 1000 Km, this not change, can be even from Sidney to NewYork, maybe just increase a bit the latency.
As server part ESP8266, ESP32, Rasperry Zero W, for ESPs I wrote a dedicated sketch capable ti receive commands and data, for Raspberry I used B4J.
On phone the user open a gcode file, just press PLAY button, the app want confirmation to send a file, by clicking OK B4 send a file in chunks and the server side save it on microsd card. I initially used PrefixMode with RPI but to adapt my app ti both ESPESP8266, ESP32 and RPI now I use TCP on Normal mode. Because this is a very big work I'm unable to port it to B4R and use Prefix.
After this the server side autonomaically start a print and read line by line all gcode file, it even send a log to my app any line by line, same lines that send to a printer, but over network and my app draw these.
At this point the app can even control some things over network and receive data like temperatures, that I draw in a graph and more more.
The app has PAUSE and RESUME buttons, dedicated page where show an IP Cam, receive over network photos, in 3D orint, one photo every layer, a layer is 0.2 0.4 mm hight, then at end of printing process have a page to create a timelapse video with various oarameters like resolution, FPS, Codec. The final video is MP4.
I can close the app, the Server side occupies to control all printing proces... even hours. It is connected just over USB, ESP or RPI can print on printer LCD, do beeps on beeper, move all axes.
This way I have even managed with long prints like 8-10 hours, but some days ago I touched the file transfer part on sebder and receiver, or better Client (my app) and Server (ESPs abd RPI) and I cannot send the file... but this is another question next I will post here requesting help.
---------------------------------------------------------
Returning on redirect console, as I said I managed with threejs because I want substitute a Canvas on my app with a full 3D view. I do not know OpenGL API, so searched some object oriented, threejs is very good.... so I managed with WebViewExtras, yes even managed initially with good
@Ivica Golubovic UltimateWebView that have a lots of great functionalities, but I had the problem that is not possible create istance of JSInterface on a Class. Ivica supposes it work only on Activity, I've used it in a Custom View Class. Ivica told me that check and try to fix it. iI tried with WebViewExtras that not require Me callback and it worked. Next I will use UltimateWebView library if Ivica fix the problem, just I commented for now.
Because I'm very new on threejs, I created a simple B4A app with 3 TABS to test inline:
- on first tab just a long scrollable vertical ScrollView, inside it a long TextField, here I print Javascript code
- by pressing second tab, there is a fullscreen WebView that render what i wrote in Javascript
- in last tab just there is another long scrollable TextField where next I want show a full HTML text and put a COPY, LOAD and SAVE buttons. This way it can manage with files, maybe load full HTML, extract JS and put in first TAB etc...
,- It has not colored syntax, just an EditText.
- It is like a sort of very simple jsFiddle but only for threejs.
- It permits to create 3D scenes live, add lights, put 3D objects, import 3D files (for this need to be tested, need path where load a file), rotate with touch, zoom with pinch, tranlate with 2 fingers, permits to set separate parameters for these eg dampingFactor, panSpeed, rotateSpeed, all floats, what uou write it render. Because imports are directly imported from DurAssets, it is not extensible, I only imported some JS, three.js, OrbitControl.js, Stats.js, more can be added, but by code.
Because I not yet managed to Load and Save files, for now I've created some Javascript templates that draw some scenes with some geometries, even I created a relatively long JS code that acts as small tutorial (introduction, I'm not expert) for threejs, in this code I've added some parst of threejs, geometries, lights, materials constructors with commented examples, to add to the scene just need to be uncommented.
The problem is that execute JS without a console is not a right way, if I just miss a semicolon, if I do some errors on code, by pressing the WebView is just Black, I cannot see where error is, WebView Extras show in the B4A log, but as you discussed need to be managed
I see that there are some consoles on github as Javascript that can be integrated, maybe this is a best option? What do you think on tools like Eruda or similars? I've no experience on this, tried Eruda on web and in one app from PlayStore and looks good.... maybe using code I can iteract and integrate it ?
For colored syntax I still provided to this by searching to port
@stevel05 CodeMirror Classes. It after more resolved issues worked on Android as CustomView, it is excellent on my Nexus 7, even on a phone, support 100+ language hilights Thanks to stevel even B4X, it support about 30 themes, lights and dark.
The problem is that this only works in Debug mode. For some strange reasons crash in Release mode, return an exception that a class cannot cast another class type. I suppose what is the problem, I initialize a CustomView Class inside another CustomView class, stevel do this on B4J, B4A maybe don't like it.
Next days I will post the project on the Forum, maybe someone can help to solve this.