Description
Bug
NodeOps accidentally shares scene
across multiple TresCanvas
s.
See the StackBlitz reproduction for details.
Problem
NodeOps's let scene
is set whenever a new Scene
is added to any TresCanvas
– i.e., the variable points to the last Scene
added to a TresCanvas
. If elements from another TresCanvas
read scene
in nodeOps, the code expects that they will find their Scene
, but they do not.
Solution?
Solution A
We could refactor nodeOps as (context: TresContext) => NodeOps
.
Every new instance of TresCanvas
could create a new nodeOps instance which contains a unique TresContext
(i.e., with the appropriate Scene
) within its scope.
Solution B
Otherwise, we could simply recurse up the parent chain until we reach a Scene
or run out of parents.
Reproduction
https://stackblitz.com/edit/tresjs-basic-e6uzmm?file=src%2FApp.vue
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.14.0 - /usr/local/bin/pnpm
npmPackages:
@tresjs/cientos: ^3.5.1 => 3.5.1
@tresjs/core: ^3.4.1 => 3.4.1
@tresjs/eslint-config-vue: ^0.2.1 => 0.2.1
vite: ^4.5.0 => 4.5.0
Used Package Manager
npm
Code of Conduct
- I agree to follow this project's Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status
Activity