# Need Help with Y-Axis Drag and Drop Functionality in My Project

Hello everyone,

I am currently developing a functionality that allows dragging an object along the Y-axis. Upon release, the object should stop at the first object it encounters. I’ve tried a few solutions but none seem to work effectively.

Our current solution involves casting multiple Raycaster rays to find the exact position. However, this method isn’t very accurate unless we use a large number of rays, which significantly impacts the application’s performance.

Has anyone dealt with this before or have any suggestions on how to solve this problem? Any help would be greatly appreciated.

Thank you!

Hello. @felix-kami
I can’t understand correctly.
So you mean when release the object, then it is falling down and stop where it meets other object?

@Man Sorry my English is not good
What I mean is that when an object is dropped in the Y direction when it meets another object, it stops at the point of contact between the two objects,
Dropped objects come in many shapes such as stairs, roofs,…

I think the easiest method for this is, of course raycasting.
You can create number of Box3 to meet the meshes of the dropped object and fixed object, and while looping those Box3 , you can detect conflict by intersetsBox function, when they meet, you can stop dropped object.

This is simple code to implement this for the single mesh drop object.
const droppedMesh = new THREE.Mesh(geo1, mat1);
let Detect1 = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3);
Detect1.setFromObject(droppedMesh );

const fixedMesh = new THREE.Mesh(geo2, mat2);
let Detect2 = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3);
Detect2.setFromObject(fixedMesh);

if(Detect1.intersectsBox(Detect2)) return (‘stop’);
else return null

Hope this will help.
Thanks

@Man Thanks for the idea but it doesn’t meet my requirements, my objects can rotate and drag and drop so using BOX3 the contact point is not correct

My objects

You can add that Box3 to the group of the moving object.