jscad.app seems to render twice as fast than openjscad.xyz, why? #94
Replies: 9 comments
-
@Hermann-SW if number of those utility spheres grows more, you could also see more benefits in jscad.app when creating a single sphere and placing it in different location via transform const utilSphere = sphere(...)
// in loops or elswhere needed use translate
translate([x,y,z], utilSphere) translate creates a new geometry object where mesh is the same but location info is different, and if not used in booleans, |
Beta Was this translation helpful? Give feedback.
-
we are working on that, and @platypii also agrees such setup similar to xyz is better, as it is also used in other CAD software because it is more practical. |
Beta Was this translation helpful? Give feedback.
-
Thank you, I will definitely use that in new application of my GP3D repo that generates JSCAD for 3D output. I cannot speed up current demo becuase of the "half vertex" handling, which is different for each sphere: In new demo I will have many spheres like in this OPenSCAD screen recording animation I will have many same radius spheres, but they will be colored differntly. |
Beta Was this translation helpful? Give feedback.
-
try this for comparison of what reuse instancing can give. const jscad = require('@jscad/modeling')
const { intersect, subtract } = jscad.booleans
const { colorize } = jscad.colors
const { cube, sphere } = jscad.primitives
const { translate } = jscad.transforms
module.exports = {main : ({// @jscad-params
multiplier = 4
}) => {
let reused = sphere({size:2})
let out = []
for(let x=0; x<multiplier; x ){
for(let y=0; y<multiplier; y ){
for(let z=0; z<multiplier; z ){
out.push(translate([x*10,y*10,z*10], reused))
}
}
}
return out
}
} |
Beta Was this translation helpful? Give feedback.
-
color should work like transform (translate, scale, rotate), so one utilSphere should be enough. |
Beta Was this translation helpful? Give feedback.
-
I am really impressed by that small model. I measured on Raspberry Pi5 with chromium browser rendering time for different multipliers:
It is OK having to wait for 25s for 8000 spheres — zooming and rotating afterwards is fast. |
Beta Was this translation helpful? Give feedback.
-
yeah, next step is to allow exporting currently edited script as gzipped data url. |
Beta Was this translation helpful? Give feedback.
-
That will be cool, I have "Share" button in my app for that:
They are already in URL, just base64 gzip encoded ;-) When using "drag&drop file change" method to work with jscad.app, I just change in dropped file, and jscad.app refreshes.
initially to view file in jscad.app. |
Beta Was this translation helpful? Give feedback.
-
@Hermann-SW declaring paramters and using them via form can allow for further optimizations, because you can cache things even more agressively. try this if you change view options, then boolean ops are skipped, and only previously calculated meshes are returned. They are returned with different transform. This may not be a perfect useful example, but show the benefits. (try "thow angle" slider it ahs |
Beta Was this translation helpful? Give feedback.
-
You can verify my numbers.
https://gist.github.com/Hermann-SW/b3e85c8fe6827cd29238c14f9da346be
I measured on Raspberry Pi5 with 64bit Raspberry PiOS (Debian based) 6s/12s refresh time for jscad.app/openjscad.xyz.
I measured on Intel Celeron j4125 with 64bit Ubuntu 22.04 9s/18s refresh time for jscad.app/openjscad.xyz.
While jscad.app has other cool features, like base64 data uri (and will have base64 gzipped data uri) compared to openjscad.xyz, twice the rendering performance is a killer argument for jscad.app ...
Only real jscad.app issue for me is the brightness issue (compared to openjscad.xyz): #83
Beta Was this translation helpful? Give feedback.
All reactions