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

New and better state context provider #331

Closed
4 tasks done
alvarosabu opened this issue Jul 3, 2023 · 0 comments · Fixed by #333
Closed
4 tasks done

New and better state context provider #331

alvarosabu opened this issue Jul 3, 2023 · 0 comments · Fixed by #333
Assignees

Comments

@alvarosabu
Copy link
Member

alvarosabu commented Jul 3, 2023

Description

Based on https://github.com/orgs/Tresjs/discussions/321

As a plugin author, I will like to have a reactive state with the following characteristics:

  • Performant, (use of shallowRef where needed)
  • read-only
  • Strictly Typed
  • Reduce side effects on watchers
  • Needs to work on cientos and the rest of ecosystem via provide/inject

Suggested solution

Name Type Requirement Details
scene readonly, shallowRef essential
cameras readonly, shallowRef essential userData.TRES_IS_ACTIVE_CAMERA = true
const cameras = shallowRef([]) return { cameras: readonly(cameras)}
camera computed, readonly essential
pushCamera(newCamera: Camera, setActive: boolean) function essential cameras should be watched and removed from the cameras array if they got removed from the scene
removeCamera(camera: Camera) function essential
setCamera(cameraId string) function essential
renderer readonly, shallowRef essential setRenderer(renderer: Renderer)
maybe only callable once?
setRenderer(renderer: Renderer) function essential
sizes (height, width, aspectRatio) readonly handy sizes: {
    height: Ref
    width: Ref
    aspectRatio: Computed
}

Alternative

No response

Additional context

No response

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant