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

Trigger transform event for model position or rotation #1631

Open
hamza-hajji opened this issue Aug 15, 2024 · 2 comments
Open

Trigger transform event for model position or rotation #1631

hamza-hajji opened this issue Aug 15, 2024 · 2 comments
Labels
feature-suggestion Suggestion for how to extend xeokit

Comments

@hamza-hajji
Copy link
Contributor

hamza-hajji commented Aug 15, 2024

Is your feature request related to a problem? Please describe.
I often want to listen to transform (position, rotation...) change for a model, but I don't find a triggered event for that

Describe the solution you'd like
Maybe an event, like eye for camera that listens to eye property change, for example

const sceneModel = xktLoader.load({
  id: "myModel",
  src: "./models/whatever.xkt",
  saoEnabled: true,
  edges: true,
  dtxEnabled: true,
});

sceneModel.on('position', (newPos) => {
// do my thing
})
sceneModel.on('rotation', (newPos) => {
// do my thing
})
sceneModel.on('scale', (newPos) => {
// do my thing
})

Describe alternatives you've considered
I make it work currentyl with rendered event

viewer.scene.on('rendered', () => {
  // sync models with their position and rotation
});

But it causes a lot of lagging even after debounce

Thank you

@hamza-hajji hamza-hajji added the feature-suggestion Suggestion for how to extend xeokit label Aug 15, 2024
hamza-hajji pushed a commit to hamza-hajji/xeokit-sdk that referenced this issue Aug 16, 2024
@MichalDybizbanskiCreoox
Copy link
Collaborator

Hi @hamza-hajji , Michał from Creoox here.
Thank you for your feature request, we'd like to understand the motivation better.
What would be a use-case for this user-initiated state change broadcast?

@hamza-hajji
Copy link
Contributor Author

hamza-hajji commented Aug 23, 2024

Hi Michał, thanks for your response, about the motivation: based on your linkedin post (https://www.linkedin.com/posts/xeolabs_testing-xeokits-upcoming-dynamic-model-realign[…]tm_content=feedcontent&utm_medium=g_dt_web&utm_campaign=copy) we would like to listen the event when a user moves a model to align it in order to display for example arrow the direction the user move the model

If we align the models every time we move a model with model.position = [...], we have to copy paste it all over the codebase, it's better to listen to that change once, and align all the time

model.on('position', (newPos) => {
  alignedModel.position = newPos;
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-suggestion Suggestion for how to extend xeokit
Projects
None yet
Development

No branches or pull requests

2 participants