Hi,
I have a model where I have two mesh red and green
i should be able to drag green mesh but the red mesh should not be moved.
i tried to identify the red mesh and used
DragControls.deactivate();
The red mesh is not moving but the model also got freezed
so if if try to drag a red box,it doesnt get dragged and later if i try to perfrom any action its not possible as screen is freezed.
can some one guide me through this.
i have attched the zip file of the proj demo
below is a snippet of the way i tried to control the drag operation
var dragControls = new THREE.DragControls( objects, camera, renderer.domElement
);
dragControls.addEventListener( 'drag', function ( event ) {
if ( event.object.position.y < (event.object.geometry.parameters.height /2) ) {
event.object.position.y = (event.object.geometry.parameters.height /2);
}
console.log(event.object.material.color.r);
console.log(event.object.material.color.g);
if (event.object.material.color.r == 1) {
dragControls.deactivate();
}
else if (event.object.material.color.r == 0) {
dragControls.activate();
}
if (event.object.material.color.g == 1) {
dragControls.activate();
}
event.object.userData.currentPosition.copy( event.object.position );
} );
dragControls.addEventListener( 'dragstart', function ( event ) {
if ( event.object.position.y < (event.object.geometry.parameters.height /2) ) {
event.object.position.y = (event.object.geometry.parameters.height /2);
}
console.log( 'new position ' + event.object.position.x );
controls.enabled = false;
} );
dragControls.addEventListener( 'dragend', function ( event ) {
controls.enabled = true;
} );
Can someone help me out with this.dragdemo.zip (1.9 MB)