Closed alvarosabu closed 5 months ago
This code logs state.controls null even if there is a Control in the scene (for example OrbitControls)
state.controls
const { onBeforeRender, pause, resume } = useLoop() const updateCallback = (state) => { if (!sphereRef.value) { return } console.log(state.controls) sphereRef.value.position.y += Math.sin(state.elapsed) * 0.01 }
The problem is here https://github.com/Tresjs/tres/blob/0720d186e92ca9faa9e5f4e51a3269504bed2a09/src/composables/useLoop/index.ts#L18C4-L27C5
We are creating an snapshot of the time the useLoop is used, which doesn't contain the updated controls.
useLoop
local playground
No response
System: OS: macOS 14.3.1 CPU: (8) arm64 Apple M1 Pro Memory: 69.00 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: 124.0.6367.208 Safari: 17.3.1 npmPackages: @tresjs/cientos: 3.8.0 => 3.8.0 @tresjs/core: workspace:^ => 4.0.0-rc.1 @tresjs/leches: 0.15.0-next.3 => 0.15.0-next.3
pnpm
For comparison, here's what R3F is passing to their useFrame callbacks.
useFrame
It's more or less the equivalent of TresContext, but without most of the refs.
TresContext
ref
https://github.com/pmndrs/react-three-fiber/blob/6b1029f8f54cc0951f8b8b912da8e792b663a73d/packages/fiber/src/core/store.ts#L92
Describe the bug
This code logs
state.controls
null even if there is a Control in the scene (for example OrbitControls)The problem is here https://github.com/Tresjs/tres/blob/0720d186e92ca9faa9e5f4e51a3269504bed2a09/src/composables/useLoop/index.ts#L18C4-L27C5
We are creating an snapshot of the time the
useLoop
is used, which doesn't contain the updated controls.Reproduction
local playground
Steps to reproduce
No response
System Info
Used Package Manager
pnpm
Code of Conduct