Determine how to convert between the rotation system of the Three.js camera and openscad camera #235

Closed
opened 2021-03-10 11:11:24 +01:00 by Irev-Dev · 0 comments
Irev-Dev commented 2021-03-10 11:11:24 +01:00 (Migrated from github.com)

https://user-images.githubusercontent.com/29681384/110612478-5562d880-81e4-11eb-85eb-2df257151c4c.mov

The recording above demos the UI we're going for, that basically a reference Three.js shape can be used to rotate in real time so the user can keep track of the orientation, once they stop draging we fetch an image of the openscad shape from that same perspective.

However obvious from the video is the shapes are not in sync, and I'm not sure how to convert between the two rotation systems. Openscads camera is quiet simple, as the Y axis is always 0, and X and Z change to give view around the object.

However Three.js rotation system seems more sophisticated, and I haven't wrapped my head around it. I probably need to learn a bit more 3d maths.

Code for what I've got so far [is here]( at https://github.com/Irev-Dev/cadhub/pull/232/files#diff-909a21548e3b050a91a1970b45ba5cc77079d52397f01a5d5e87e658f48cdd95R25)
And it can be played with live at https://cadhub.xyz/dev-ide (though often the first image load is quiet slow due to lambda cold start)

Bit more background. Openscad can be very slow to render how 3d outputs (stl) but is quick to output images (preview) so we're leveraging that as best we can to give a "Live" like experience in the browser.

https://user-images.githubusercontent.com/29681384/110612478-5562d880-81e4-11eb-85eb-2df257151c4c.mov The recording above demos the UI we're going for, that basically a reference Three.js shape can be used to rotate in real time so the user can keep track of the orientation, once they stop draging we fetch an image of the openscad shape from that same perspective. However obvious from the video is the shapes are not in sync, and I'm not sure how to convert between the two rotation systems. Openscads camera is quiet simple, as the Y axis is always 0, and X and Z change to give view around the object. However Three.js rotation system seems more sophisticated, and I haven't wrapped my head around it. I probably need to learn a bit more 3d maths. Code for what I've got so far [is here]( at https://github.com/Irev-Dev/cadhub/pull/232/files#diff-909a21548e3b050a91a1970b45ba5cc77079d52397f01a5d5e87e658f48cdd95R25) And it can be played with live at https://cadhub.xyz/dev-ide (though often the first image load is quiet slow due to lambda cold start) Bit more background. Openscad can be very slow to render how 3d outputs (stl) but is quick to output images (preview) so we're leveraging that as best we can to give a "Live" like experience in the browser.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: h3n3/cadhub#235