react-three-fiber icon indicating copy to clipboard operation
react-three-fiber copied to clipboard

Add Callbacks for Completion and Progress in `useLoader.preload`

Open sintanial opened this issue 1 year ago • 0 comments

First of all, I want to say that your library is fantastic and has saved me a lot of time and effort!

I encountered an issue where useLoader.preload does not support callbacks for completion and progress. This seems logical and feasible, considering that internally, THREE.Loader.load is used, which accepts callbacks for both completion and progress. While I am aware of useProgress, it doesn't suit my needs because I want to determine when a specific asset has successfully loaded, rather than all assets together.

I want to load all my assets as soon as the page opens and show a loading indicator during this time. useProgress can jump between states, making it unclear when the loading of all my assets is truly complete.

Here is an example of how I currently load my assets:

useGLTF.preload(assets.map(asset => asset.path));
useLoader.preload(THREE.AudioLoader, '/effects/firecracker.mp3');
useLoader.preload(QuarksLoader, '/effects/levelup.json');
useLoader.preload(QuarksLoader, '/effects/fireball.json');

Additional Information:

Adding callbacks to useLoader.preload would greatly enhance its functionality, allowing for more granular control over asset loading and improving the user experience by providing precise loading indicators.

sintanial avatar Aug 02 '24 22:08 sintanial

I think the code below can work for a tslFn() using as your example?

export const workgroupBarrier = () => expression( 'workgroupBarrier()' ).append();

sunag avatar May 29 '24 23:05 sunag

Also posting to see if barriers are possible for subsets of the compute shader? I.e. workers in a smaller workgroup subset all wait at a barrier together, but don't wait for other subsets. Ex:

tslFn( () => {
	const workgroup_idx = instanceIndex.mod(4); // 4 workers per group
        ...
	workgroupBarrier(workgroup_idx); // Only waits for the (4) workers in this group
	...
});

skywolf829 avatar Aug 26 '24 17:08 skywolf829

The workgroupBarrier() function does not take any arguments. As far as I know, there's also no way to directly specify the size of a subgroup in current implementations of WebGPU.

cmhhelgeson avatar Aug 27 '24 05:08 cmhhelgeson

I think the feature request has been implemented via #29192 🎉 .

Mugen87 avatar Feb 10 '25 09:02 Mugen87