Need Help manipulating a <div> Transform with 2 Sliders.
Ok so you have a simple problem occuring here.
Basically when you run your function "document.getElementById('map').style.transform='rotate3d(1,0,0,'+ this.value +'deg)'" it replaces the old transform value.
So this means if you first move the first slider and rotate the z axis...
When you then move the next slider to rotate the other axis you are also setting the z axis to a value different then the slider.
The best way I can imagine to solve this problem in vanilla JS is to do as follows:
<input onchange="updateViewAngle"> <input onchange="updateCetnerRotation"> let ViewAngle = 0 let CenterRotation = 0 let canvasElem = document.getElementById('map') function updateViewAngle(event) { ViewAngle = event.value UpdateCanvas3d() } function updateCenterRotation(event) { CenterRotation = event.value UpdateCanvas3d() } function UpdateCanvas3d() { canvasElem.style.transform=.... }
Now there is a second way to go about this that potentially makes a lot more sense for what you are trying to do. Personally I would not use the rotate3D CSS transform, but instead use rotateX, rotateY, and rotateZ
When you use set rotate3d you are effectively setting a rotation around a fixed axis in 3d space every time.
Anyway I hope this helps.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now