Tresjs / cientos

Collection of useful helpers and fully functional, ready-made abstractions for TresJS
https://cientos.tresjs.org/
MIT License
281 stars 40 forks source link

useSurfaceSampler is not a composable #440

Open alvarosabu opened 3 months ago

alvarosabu commented 3 months ago

Describe the bug

While adding on-demand invalidation on the useSurfaceSampler and Sampler on #436 I noticed that useSurfaceSampler is not a vue composable per definition (it doesn't deal with any type of reactivity or state), is just a function. See why here https://vuejs.org/guide/reusability/composables#what-is-a-composable

Since we are providing to our users as it was a composable, I would expect that the options are reactive.

https://github.com/Tresjs/cientos/blob/9e17559fc98066db79b02b7ea0c98ae3037ac906/src/core/abstractions/useSurfaceSampler/index.ts#L81-L143

Reproduction

Local playground, run useSurfaceSampler

Steps to reproduce

No response

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 89.09 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 8.15.4 - ~/Library/pnpm/pnpm
    bun: 1.0.2 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 120.1.61.116
    Chrome: 125.0.6422.142
    Safari: 17.5
  npmPackages:
    @tresjs/core: 4.0.2 => 4.0.2 
    @tresjs/leches: ^0.14.0 => 0.14.0

Used Package Manager

pnpm

Code of Conduct

alvarosabu commented 3 months ago

Hi @andretchen0 could you please help me out with this one? It's blocking full support of the on-demand for the sampler #436

andretchen0 commented 3 months ago

Hey @alvarosabu ,

Since we are providing to our users as it was a composable, I would expect that the options are reactive.

Which options are you referring to? The arguments to the function?

   mesh: Mesh, 
   count: number = 16, 
   instanceMesh?: InstancedMesh | null, 
   weight?: string, 
   transform?: TransformFn, 

E.g.: https://vuejs.org/guide/reusability/composables.html#input-arguments