hello there,
how do i rotate the skybox created in three.js on mouse click drag not the camera, or the using the orbital
got some parts working , would be a great help if i get this up and running,
basically i need to rotate the backround 360, on mouse drag
“renderer.domElement” and the “document” to point to the skybox on click ?
on clicking and draging the skybox , the skybox rotates, if mouse up revert to orriginal position with tansition, like in .js
const skyboxGeo = new THREE.BoxGeometry( 10000, 10000, 10000);
var skybox = new THREE.Mesh( skyboxGeo, materialArray );
scene.add(skybox);
/* */
var isDragging = false;
var previousMousePosition = {
x: 0,
y: 0
};
$(renderer.domElement).on('mousedown', function(e) {
isDragging = true;
})
.on('mousemove', function(e) {
//console.log(e);
var deltaMove = {
x: e.offsetX-previousMousePosition.x,
y: e.offsetY-previousMousePosition.y
};
if(isDragging) {
var deltaRotationQuaternion = new three.Quaternion()
.setFromEuler(new three.Euler(
toRadians(deltaMove.y * 1),
toRadians(deltaMove.x * 1),
0,
'XYZ'
));
skybox.quaternion.multiplyQuaternions(deltaRotationQuaternion, skybox.quaternion);
}
previousMousePosition = {
x: e.offsetX,
y: e.offsetY
};
});
/* */
$(document).on('mouseup', function(e) {
isDragging = false;
});