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

Devtools events structure and API #478

Closed
4 tasks done
alvarosabu opened this issue Dec 20, 2023 · 1 comment
Closed
4 tasks done

Devtools events structure and API #478

alvarosabu opened this issue Dec 20, 2023 · 1 comment

Comments

@alvarosabu
Copy link
Member

alvarosabu commented Dec 20, 2023

Description

As a maintainer of TresJS, I would like to be able to filter devtools cb events by type from dev tools solutions, having a more structured object than just sending the tres state ctx.

Atm we send the state on useTresContextProvider like this:

window.__TRES__DEVTOOLS__.cb(state)

Also, I would like to have an API to send actions from the devtools (for example edit properties of objects from the devtools Tresjs/nuxt#73)

Suggested solution

Events are sent to de devtools.cb with the following structure:

  • type: string identification of the type of event to be able to filter on the devtools
  • payload: container for the data to be sent
  • timestamp: performance.now for tracking
const event = {
   type: 'tres:ctx',
   payload: {
      scene,
      renderer,
      ....
   },
  timestamp: `performance.now()`
 }
window.__TRES__DEVTOOLS__.cb(event)

For the actions we could register an action hook on the core like this

window.__TRES__DEVTOOLS__.action = (event) => {
  if(event.type === 'tres:edit') {
     // logic for modifying the scene graph children
  }
}

then from the devtools

window.__TRES__DEVTOOLS__.action(
  {
     type: 'tres:edit'
     payload: {
        object: //obj uuid
        property: 'position.x'
        value: 2
     }
  }
)

Alternative

No response

Additional context

No response

Validations

@alvarosabu
Copy link
Member Author

@Tresjs/core This new feature will be a breaking change (we will need the v4 at the end 😛) for the nuxt devtools but is a necessary change to have a more robust event API for devtools.

Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

1 participant