Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(OrbitControls): expose ref #250

Conversation

andretchen0
Copy link
Contributor

@andretchen0 andretchen0 commented Oct 11, 2023

Closes #249

Problem

In Cientos' <OrbitControls />, the camera and update functions aren't exposed.

Solution

Expose a ref to the component using Vue's defineExpose. This is the approach taken by other Cientos' components, e.g., Levioso:

With this PR, the camera is accessible via [refName].value.value.object. Update() is available via [refName].value.value.update.

@stackblitz
Copy link

stackblitz bot commented Oct 11, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Oct 11, 2023

Deploy Preview for cientos-tresjs ready!

Name Link
🔨 Latest commit 71a783a
🔍 Latest deploy log https://app.netlify.com/sites/cientos-tresjs/deploys/6527069153165d0008c56e84
😎 Deploy Preview https://deploy-preview-250--cientos-tresjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -315,6 +315,8 @@ onUnmounted(() => {
controlsRef.value.dispose()
}
})

defineExpose({ value: controlsRef })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call expose defineExpose({ control: controlsRef })?

The value.value makes me uncomfortable

Copy link
Contributor Author

@andretchen0 andretchen0 Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we stick with value.value for the moment. Even if it's weird, it's consistent with the other Cientos components.

Problem

value.value is bad DX, but it's the established pattern in Cientos at the moment.

value: boxRef,

Solution

@JaimeTorrealba opened an issue to discuss value.value a little while ago, but there wasn't any feedback.

I suggest we discuss there and then apply the decision to all components. Jaime is on vacation starting on the 14th and we'll want his input before moving forward.

In the meantime, I suggest we merge here to keep the components consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andretchen0 you are totally right, let's merge this one as it is, and then let's discuss the value.value here #160 ✌️

@alvarosabu alvarosabu merged commit 0f1d162 into main Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OrbitControls has no update function, also shows null when accessed from context
2 participants