Closed andretchen0 closed 2 weeks ago
Name | Link |
---|---|
Latest commit | 6789a3b169b18a0eea9520a6a25382f8fb67ba34 |
Latest deploy log | https://app.netlify.com/sites/tresjs-docs/deploys/666d60c2f6cc8b0008ab595d |
Deploy Preview | https://deploy-preview-712--tresjs-docs.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Features
This PR adds the following features via a private composable
useTresReady
:onTresReady
hook@ready
emit fromTresCanvas
onTresReady
Playground
... then open http://localhost:5173/basic/ready
Problem
useLoop
calls user callbacks before THREE can actually render to the screen, e.g., in the default setup,<canvas>
will have a height/width of 0 whenuseLoop
starts.For debugging, this means that the developer needs to wait for a few frames to pass before they get "real" values in their logs/debugger.
Solution
Start the loop and trigger
ready
callbacks when Tres is "ready".Use case
DX, particularly debugging.
Problem
572
Users had been asking for an easier way to get the context from a
TresCanvas
in a<script setup>
. It currently requires a few steps that users find non-obvious, as outlined in the issue above.Solution
@ready
emit that takes a callback and calls it withTresContext
when Tres is "ready"Use case
DX. Advanced users who want to write a bit less code in order to access
TresContext
.Problem
Child components can't take advantage of "ready" without registering a loop callback.
Solution
onTresReady
hookUse case
DX. Advanced users who want to be notified when Tres is "ready" in child components.
Meta
closes #595 – the present PR modifies
useLoop
notuseRenderLoop
as in the issue. ButuseRenderLoop
is no longer Tres' preferred looping method closes #572