Replies: 8 comments 8 replies
-
|
Unfortunately, not at the moment or near future. Script is executed directly, there is no csg to even know how many operations are left to do (even that would be inaccurate because one op can take minutes and second milliseconds, and it is not trivial to predict). |
Beta Was this translation helpful? Give feedback.
-
|
I was rather thinking that the script could actively report the progress to the UI, if there was a way for messaging. |
Beta Was this translation helpful? Give feedback.
-
|
As the developer prototyping, you can use Jscad app is meant to push user in the direction of a reusable module, so script communication with the environment is not something I would accept adding easily to jscad.app. On the other hand, if you want to create a page that runs a script with more user friendly UI, I am very interested to provide an easy way to do so in the long run. jscad.app is a prototype that should give us more insight what are the different components that are needed to create interesting things with jscad scripts. And jscad.app is also aimed to be the next playground for jscad scripts without those scripts being too dependent on the app, and that they also can be run with jscad-cli. |
Beta Was this translation helpful? Give feedback.
-
|
I think the playground will also be very useful in production for customising models by non developers, when using Not sure what would be the problem for reusability when messaging like the following. Would it not be just ignored on jscad-cli? this.postMessage?.({ method: 'progress', params: { progress: value } })I made a test on https://github.com/eevleevs/jscadui/tree/progress, seems to work quite well. |
Beta Was this translation helpful? Give feedback.
-
|
it has some potential. I tried with this script const jscad = require('@jscad/modeling')
const { intersect, subtract } = jscad.booleans
const { colorize } = jscad.colors
const { cube, sphere } = jscad.primitives
const sendProgress = progress => globalThis.postMessage?.({ method: 'progress', params: { progress } })
async function main() {
let _resolve
setTimeout(()=>sendProgress(0.25), 500)
setTimeout(()=>sendProgress(0.5), 1000)
setTimeout(()=>sendProgress(0.75), 1500)
setTimeout(()=>_resolve(), 2000)
await new Promise(resolve=>_resolve = resolve)
const outer = subtract(
cube({ size: 10 }),
sphere({ radius: 6.8 })
)
const inner = intersect(
sphere({ radius: 4 }),
cube({ size: 7 })
)
return [
colorize([0.65, 0.25, 0.8], outer),
colorize([0.7, 0.7, 0.1], inner),
]
}
module.exports = { main }The signature of the postMessage will likely change in the near future from example ts interface: export interface Agent {
// { method: 'progressV1', params: [{ progress:0.5, note:'drilling' }] }
progressV1(options: { progress: number, note:string }): void
// { method: 'progressV2', params: [0.5, 'drilling'] }
progressV2(progress: number, note:string): void
} |
Beta Was this translation helpful? Give feedback.
-
|
BTW @eevleevs, you can easily upload the version you are testing somewhere, and it will work ... for example I put your variant here: https://3d.hrg.hr/jscad/progress/ if you are testing with |
Beta Was this translation helpful? Give feedback.
-
|
@eevleevs after some deliberation I have made a choice how to discern messaging when response is expected (or at least info when the called method is done) and messaging when it is just a notification. Methods on the Proxy that start with ATM the target signature for the progress notification will be const sendProgress = progress => globalThis.postMessage?.({ method: 'onProgress', params: [progress] })I will let you know whet refactoring is done. |
Beta Was this translation helpful? Give feedback.
-
|
I could also use a failure indicator. Might be the same progress element with a 100% value and a red background, where the note explains the error. I could make it, are you ok with the following? globalThis.postMessage?.({ method: 'onError', params: [note] }) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have some large models that take minutes to generate, could use a way to display a progress indicator instead of the spinner.
Beta Was this translation helpful? Give feedback.
All reactions