Not exactly what I asked for, but OpenSCAD shows stack trace when right clicking on an object, here for "edge2()":
https://forums.raspberrypi.com/viewtopic.php?t=333342&start=50#p2022797
Has JSCAD similar functionality?
Posts made by HermannSW

RE: Are there JSCAD user callbacks?

Are there JSCAD user callbacks?
I have a JSCAD model of C36.10 fullerene graph embedded onto sphere:
https://openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/C36.10.concave.jscadI would like to be able to click on a vertex, and then that vertex should be moved to centroid polar coordinate of its neighbors, like vertex 7 here:
Since JSCAD is JavaScript in browser, it should be possible to add callback for mouse click event.
But is there some helper function that tells me which JSCAD object I have clicked on I can use in callback? 
JSCAD preview faster than "same" model OpenSCAD preview
I completed implentation of 6coloring for JSCAD, JSCAD_ and OpenSCAD today:
https://forums.raspberrypi.com/viewtopic.php?p=2032727#p2032727My planar graph playground tool "node.tetra.js" now creates planar graph sphere embeddings for JSCAD/OpenSCAD using the "same" spherical polygon and great circle arc (for graph edges) implementations:
When playing with both models, JSCAD preview mode is much faster than OpenSCAD preview for rotating the model, not sure whether it is a simpler preview or just better. Has anybody noticed similar?
Here is sample JSCAD model to play with online:
https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.C60.6coloring.vtype.js20KB JSCAD file:
https://stammwilbrandt.de/en/forum/JSCAD.C60.6coloring.vtype.jsHere is "same" sample OpenSCAD model (32KB) for download:
https://stammwilbrandt.de/en/forum/C60.6coloring.vtype.scad 
RE: How to generate JSCAD model in browser JS and display like demo.html?
@hrgdavor I tried that with openjscad.xyz and it did not work. But it does work with locally hosted demo.html !
Thanks, until now I had browser console open right, editor in middle and only half of 3D view left. After drag and drop, I can close the editor and see new graphs whenever I run node.tetra.js to produce a different x.jscad. So much easier to work now ... 
RE: How to generate JSCAD model in browser JS and display like demo.html?
@hrgdavor I follow up on graph algorithm work I stopped 28 years ago:
https://stammwilbrandt.de/en/TR/IAITR9310.ps.pdf
I built undirected graph library as basis already, it will grow over time. Currently output formats of the tools are SVG, PostScript, and OpenSCAD and JSCAD for sphere embeddings:
https://github.com/HermannSW/planar_graph_playgroundAll planar graphs can be 4colored (face as well as vertex, faces/vertices sharing an edge have to get different colors), there is a linear time algorithm for 5coloring, and I have built an even simpler 6coloring algorithm: https://github.com/HermannSW/planar_graph_playground/blob/main/undirected_graph.js#L311L332
Yesterday I made 6coloring work for JSCAD sphere embedding, 6coloring for embedding into the plane worked long ago:
https://forums.raspberrypi.com/viewtopic.php?p=2032214#p2032214
6coloring algorithm did use 5 colors only for sphere spherical face coloring (of C60 fullerene) left:
https://www.youtube.com/watch?v=ZlKumZDBbQ

RE: How to generate JSCAD model in browser JS and display like demo.html?
Thanks for the pointers, I will look into. Yesterday I found a solution myself, I just had incorrect mindset. Details of the (surprisingly small) diff needed in this posting:
https://forums.raspberrypi.com/viewtopic.php?p=2031648#p2031648This is new mode JSCAD_ running graph algorithms, system of linear equations solver and "main()" for viewing in browser:
https://openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD_.1.jsShould show like this browser with Autozoom enabled:
JSCAD_ takes longer than JSCAD mode, because running graph algorithms ...
Also JSCAD_ output is 36KB, JSCAD only 19KB. 
How to generate JSCAD model in browser JS and display like demo.html?
Creating JSCAD model with functionality inside works pretty well with NodeJS:
https://forums.raspberrypi.com/viewtopic.php?p=2030878#p2030878https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.C60_vtype_b.js
I can create planar embedding into plane in browser JS and display using SVG:
https://hermannsw.github.io/planar_graph_playground/Now I want to create new JSCAD model in browser JS and then display it as with "demo.html" in local webserver or openjscad.xyz.
Is that possible?
If so, where can I find doc or an example? 
RE: JSCAD for planar graph embeddings onto (unit) sphere
I implemented optional JSCAD output for planar graph playground "node.tetra.js", details here:
https://forums.raspberrypi.com/viewtopic.php?p=2030546#p2030546Until now I played with C20 hand edited for JSCAD, this is newly created C60 fullerene with 60 vertices and 90 edges:
https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.C60_vtype.jsMore vertices and edges than for C20, but design regeneration still done in less than 10 seconds on Intel it Linux Chrome!

RE: openscad.xyz support for "data:" URI scheme would be cool
@z3dev Thanks, I see your point wrt security.
But what is the difference of ...uri=data:... to this openscad.xyz link with model wrt security? In case you eval the uri= specified file (and that seems to be the case because the model gets rendered in browser) you break the same security rules ...
https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.minimal.js 
RE: JSCAD for planar graph embeddings onto (unit) sphere
I answered the question on whether JSCAD will be performant enough for low design regeneration with 12 spherical pentagons (it is, takes less than 5 seconds on Intel i7 Chrome, with carefully chosen values for gray points/segments), because all fullerenes have exactly 12 pentagons (
12*3*2=72
sp_tria2()
calls, ...), details here:
https://forums.raspberrypi.com/viewtopic.php?p=2029576#p2029576https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.C20_params.js

RE: JSCAD for planar graph embeddings onto (unit) sphere
Done, now "vertex()" optional 3rd parameter "half" works as well:
https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.vertex_half.jsGreen vertices 1, 2, 15 and 16 are forced as "half" vertices, that is a cube of right size gets subtracted from inside. Subtraction can be seen for vertex 1 at "look_inside" hole border. Vertex 2, 15 and 16 cannot be seen on inside anymore, unlike the other vertices with default "half=false":
... vertex(0, [1,0,0]) ,vertex(1, [0,1,0], true) ,vertex(2, [0,1,0], true) ... ,vertex(15, [0,1,0], true) ,vertex(16, [0,1,0], true) ...

RE: JSCAD for planar graph embeddings onto (unit) sphere
Not perfect, but "vtxt()" works now in JSCAD as well:
https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.vtxt.js 
RE: JSCAD for planar graph embeddings onto (unit) sphere
After a problem with spherical triangle implementation (my problem, not JSCAD problem) ...
https://openjscad.nodebb.com/topic/378/problemwithsubtractinghullisthisabug/3?_=1660487451987... now spherical triangle works. I called it three times to fill one spherical pentagon:
,sp_tria(2,1,15) ,sp_tria(2,15,16) ,sp_tria(2,16,3) ...
You can see spherical gray polygon from outside, and nothing of spherical polygon breaks into white sphere difference on the inside:
Click for view+rotate+zoom, design regeneration takes less than 3 seconds on Intel i7 Chrome
(normally I use chromiumbrowser on Raspberry Pi OS, will test that in 2 weeks):
https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.spherical_polygon.js
Clicking "Enable Auotozoom" and "Enable Autorotate" results in nice animation ...P.S:
Next step is to port "vtxt()" for adding text labels to vertex sphere, and "half()" for subtracting cube from inner side of vertex sphere, avoiding vertex to shine through to inside for 3Dprinting later.
After that is done, I will make "node.tetra.js" create JSCAD output as alternative to sofar OpenSCAD output. Creating C60 with 12 spherical pentagons JSCAD file and measuring design regeneration time for it will answer whether JSCAD is usable for great circle arc edge embedding of planar graphs onto sphere: 12 spherical pentagons is 12*3=36 spherical triangles, is 72 "sp_tria2()" and 36 differences with "hull()" of 6 points (mini cubes) ... 
openscad.xyz support for "data:" URI scheme would be cool
"https://openjscad.xyz?uri=..." is cool.
"data:" URI scheme does not work for openjscad.xyz:
https://en.wikipedia.org/wiki/Data_URI_scheme#SyntaxI use this working minimal JSCAD file:
https://www.openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/JSCAD.minimal.jsmodule.exports=function main(){return require('@jscad/modeling').primitives.sphere({radius: 50})}
This URI does not work:
https://openjscad.xyz/?uri=data:text/html;module.exports=function main(){return require('@jscad/modeling').primitives.sphere({radius: 50})}Base64 encoding and using application/json does not work either:
https://openjscad.xyz/?uri=data:application/json;base64,bW9kdWxlLmV4cG9ydHM9ZnVuY3Rpb24gbWFpbigpe3JldHVybiByZXF1aXJlKCdAanNjYWQvbW9kZWxpbmcnKS5wcmltaXRpdmVzLnNwaGVyZSh7cmFkaXVzOiA1MH0pfQo=It would be cool to have "data:" links working with openjscad.xyz, because that would allow to share JSCAD files without storing them anywhere — they are stored as part of the link ...
For looking where&how to add "data:" scheme: How is "dist/jscadweb.min.js" generated?

RE: Problem with "subtract()"ing "hull()", is this a bug?
Forgot to post the "answer" link for viewing in browser:
https://openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/A.JSCAD.vertex_edge2.sp_tria.js 
RE: Problem with "subtract()"ing "hull()", is this a bug?
Oops, too late/early, need to get more sleep.
 problem was bad indentation of brackets and placing ",h" at wrong level.
 problem was that I want "intersect()" and not "subtract()":
return colorize([0.5,0.5,0.5], intersect( translate([0,0,0], rotate([0,0,la1degToRad(180)], rotate([0,ph1degToRad(90),0], rotate([0,0,al13], sp_tria2(sc, s12, mpi(al13al12), 0.1, 40, 40) ) ) ) ), h ) )
Works like a charme now:

Problem with "subtract()"ing "hull()", is this a bug?
For drawing a spherical triangle I need to draw 2 "sp_tria2()"s in that triangle on the sphere. "sp_tria2()" might overshoot sphere triangle borders as here:
Next I create "hull()" from 6 points (found no way to do that, created "hull()" of 6 very small "cube()"s instead), the 3 triangle coordinates, and those coordinates scaled up to that "hull()" completely contains the wanted triangle part of "sp_tria2()":
Here is hull definition:
h = hull( cube({center: sv1, size: 0.01}) ,cube({center: sv2, size: 0.01}) ,cube({center: sv3, size: 0.01}) ,cube({center: s1, size: 0.01}) ,cube({center: s2, size: 0.01}) ,cube({center: s3, size: 0.01}) )
Why does "subtract()" not work when subtracting "h"?
(subtract does work for look_inside=yes, subtracting sphere and cube from outer sphere)
Here is link for you to play with:
https://openjscad.xyz/?uri=https://stammwilbrandt.de/en/forum/Q.JSCAD.vertex_edge2.sp_tria.js... return colorize([0.5,0.5,0.5], subtract( translate([0,0,0], rotate([0,0,la1degToRad(180)], rotate([0,ph1degToRad(90),0], rotate([0,0,al13], sp_tria2(sc, s12, mpi(al13al12), 0.1, 40, 40) ) ) ) ) ), h ) ...
"sp_tria(4,13,14)" call is in line 244 near the end.

RE: JSCAD for planar graph embeddings onto (unit) sphere
@z3dev said in JSCAD for planar graph embeddings onto (unit) sphere:
@HermannSW WOW! Very nice!
I'm very impressed with the speed of the algorithms! I was expecting to wait for minutes before viewing. But the design was viewable almost immediately!
Do you think that any 3D shape can be 'fitted' to a sphere? How about to a cylinder?
Sure, just calculate the correct (3D) coordinates and place whatever you like on sphere. For cylinder just 3D coordinate determination will be different [(theta, phi) polar coordinates for sphere, (h, phi) for cylinder coordinate at height h].
Here I placed text onto the vertex spheres on the sphere for debugging:
https://forums.raspberrypi.com/viewtopic.php?t=333342&start=50#p2023738

RE: JSCAD for planar graph embeddings onto (unit) sphere
Added debug feature "look_inside" for the white sphere:
https://forums.raspberrypi.com/viewtopic.php?p=2028520#p2028520
Learned that number of segments for white sphere is a problem when "subtract()" another sphere with radius reduced by 0.1. 180 segments was no problem for OpenSCAD, for JSCAD I did set parameter default to 30.