Attempting to utilize the functionality of "control.setRotationSnap" from the script "TransformControls.js", but unfortunately, it is not working as expected.
After conducting some research, I came across a forum post suggesting that the code might not be fully implemented yet ()
Here is my current code where I am trying to implement this feature:
let renderer, scene, camera, light1, light2, light3, orbit, control, texture, material, loader, mesh;
let renderer = new THREE.WebGLRenderer();
let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 1, 3000);
let light1 = new THREE.DirectionalLight(0xfffffe, 2);
let light2 = new THREE.DirectionalLight(0xfffeff, 1.75);
let light3 = new THREE.DirectionalLight(0xfeffff, 0.75);
let orbit = new THREE.OrbitControls(camera, renderer.domElement);
let control = new THREE.TransformControls(camera, renderer.domElement);
let material = new THREE.MeshPhongMaterial({ color: 0x888888, specular: 0x111111, shininess: 2 });
let loader = new THREE.STLLoader();
// Other initialization code...
// Code snippet where rotation snap functionality is supposed to be implemented:
if ( this.rotationSnap ) {
rotationAngle = Math.round( rotationAngle / this.rotationSnap ) * this.rotationSnap;
}
this.rotationAngle = rotationAngle;
// End of code snippet
// More code...
This section of code handles the rotation snap functionality in TransformControls.js:
// Apply rotation snap
if ( this.rotationSnap ) rotationAngle = Math.round( rotationAngle / this.rotationSnap ) * this.rotationSnap;
this.rotationAngle = rotationAngle;
My goal is to make the 3D object (STL) snap in 90-degree increments using "control.setRotationSnap". However, when attempting to do so, it does not work at all.
If anyone has encountered the same issue or has any insights, your help would be greatly appreciated.
Kind regards, Leon