Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use progress indicator instead of spinner #101

Merged
merged 9 commits into from
Mar 16, 2024
Merged

Conversation

eevleevs
Copy link
Contributor

@eevleevs eevleevs commented Mar 15, 2024

sample script to test is:

const jscad = require('@jscad/modeling')
const { intersect, subtract } = jscad.booleans
const { colorize } = jscad.colors
const { cube, sphere } = jscad.primitives

const sendProgress = (progress, note) => globalThis.postMessage?.({ method: 'onProgress', params: [ progress, note] })

async function main() {
  let _resolve
  setTimeout(()=>sendProgress(0.25,'first'), 500)
  setTimeout(()=>sendProgress(0.5,'second'), 1000)
  setTimeout(()=>sendProgress(0.75,'third'), 1500)
  setTimeout(()=>_resolve(), 2000,'DONE')
  
  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 }

@eevleevs
Copy link
Contributor Author

Not sure about the recent changes in main.js, will leave you to merge.

@hrgdavor
Copy link
Owner

hrgdavor commented Mar 15, 2024

ok, tweaked the onProgress method signature from const onProgress = ([value, note]) => { to const onProgress = (value, note) => { and the matching postMessage is postMessage({ method: 'onProgress', params: [ progress, note] })

@hrgdavor hrgdavor requested a review from platypii March 15, 2024 11:59
@eevleevs
Copy link
Contributor Author

ok, tweaked the onProgress method signature from const onProgress = ([value, note]) => { to const onProgress = (value, note) => { and the matching postMessage is postMessage({ method: 'onProgress', params: [ progress, note] })

Updated also the use of onProgress without parameters for reset.

Copy link
Collaborator

@platypii platypii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested loclally, looks good 👍

@hrgdavor hrgdavor merged commit bf70cb9 into hrgdavor:main Mar 16, 2024
@eevleevs eevleevs deleted the progress branch March 17, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants