Closed zkobrinsky closed 1 year ago
Start a new pull request in StackBlitz Codeflow.
@zkobrinsky Thanks for the issue with the reproduction link.
Cientos' <OrbitControls />
doesn't currently expose a camera or the update method from the underlying three component, as far as I can see. Unlike a lot of other Cientos' components, <OrbitControls />
doesn't use Vue's defineExpose
to expose a ref. Doing so would allow the camera and update() to be accessed like this:
[... in setup]
const controls = ref(null);
onMounted(() => {
// Three's OrbitControls' camera is on the 'object' field:
// https://threejs.org/docs/?q=camera#examples/en/controls/OrbitControls.object
console.log(controls.value.value.object.isCamera) // true
console.log(controls.value.value.update) // function update()
}
@alvarosabu @JaimeTorrealba
To be consistent with other Cientos' components, we should expose a ref using defineExpose
. I'll submit a PR shortly.
Feel free to ignore if you'd like to go a different direction here.
@JaimeTorrealba was wondering about an alternative to using value.value
, but there hasn't been any follow up.
@alvarosabu
I've submitted a PR exposing the camera and update in Cientos' <OrbitControls />
.
There's a separate TresJS issue here: useTresContext().controls
is null. Can we transfer that to TresJS?
Yes we should open it on the core package, thanks for taking care of it
Thanks for looking into this.
Describe the bug
I'm trying to enableDamping on my OrbitControls and I'm unable to call controls.update in the render loop for two reasons: When using the Cientos OrbitControls, if I expose it with a ref it has no update function, and if I access it from context it returns null.
There's also a separate issue where orbitControls has no camera attached to it when you expose it unless you explicitly v-bind one to the component (also in stackBlitz attached).
Reproduction
https://stackblitz.com/edit/tresjs-basic-nj82xh?file=src%2Fcomponents%2FTheScene.vue
Steps to reproduce
No response
System Info
No response
Used Package Manager
npm
Code of Conduct