Rotate Model Around its Centre no Matter Pan Position #4917
-
Hey everyone. Not sure if any of the actual developers of model-viewer are here, but just in case - thanks for this tool. I've been having a lot of fun with it and it looks to work really well. My need is fairly simple and I have some Javascript skill, but I don't seem to be succeeding and hope someone can point me in the right direction. I have a model-viewer object which works perfectly. The model loads, I can examine it, and so on. I would like to modify the functionality a bit, though. Hopefully my description below makes sense. I want to be able to pan around the model, which is of course a default function and works fine. However, I'd like to prevent the default behaviour whereby the camera's focal point moves to a different position on the model. For instance, if our 3D model were a man, I would like the model rotation to always originate from the man's trunk and not reposition itself to his hands or feet, etc. The model should always spin on its own axis independent of camera panning placement. This feels like it's a really simple function that's not quite clicking for me yet. I've attempted to update both the camera-target and camera-orbit values with an event listener on the camera changing, but I'm not quite succeeding with this and it seems to just fix the camera in the centre of the model repeatedly - close to what I'm after, but not quite, as I want the panning position to be retained. If necessary I can show what I've attempted, but it's very crude and I feel like there's a very obvious solution to this that I'm not conceptualizing and seeing properly. Thanks for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
I understand what you mean, but I'm having a hard time understanding why you would want your UX to work that way. For instance, if you pan and zoom in on his toe, when dragging the camera the toe will fly off the screen and you'll likely be looking at nothing but white background until you manage to find the direction of the model again. Can you show an example of the kind of 3D UX you're imagining? We were very much intentional in not building ours that way. |
Beta Was this translation helpful? Give feedback.
Funny, that's the first time I've ever seen that done. It has exactly the problem I mentioned too. I would highly recommend using our default controls instead of copying that example. And believe it or not, you'd actually need to dig pretty deep into our code base / scene graph to accomplish that behavior. I have the feeling that UX was actually a coding shortcut someone made, possibly accidentally.