Why? my originObject.position keep chaning?

Hi !!!
Using drag, I tried to reposition the conflicting between objects. (Swap)

The ‘originObject’ parameter was only initialized once in ‘dragstart’,
but it keeps changing in ‘drag’
Why originObject.position is changing???

three.dragcontrols.addEventListener( 'dragstart', function (event) { 
        dragStart = true;
        event.object.position.x = 0;
        event.object.position.z = 0;

        dragObject = event.object;

        //swap Init
        originObject = event.object;
        console.log("origindragObject.position at dragstart", originObject.position)
        three.orbitcontrols.enabled = false; 

    three.dragcontrols.addEventListener( 'drag', function (event) { 
        event.object.position.x = 0;
        event.object.position.z = 0;
        console.log("originObject.position at drag", originObject.position)

    three.dragcontrols.addEventListener( 'dragend', function () {
        dragStart = false;

        if(swapObject === undefined)

        console.log("originObject.position", originObject.position)
        console.log("swapObject.position", swapObject.position)

        let positionBuffer = originObject.position;
        console.log("positionBuffer", positionBuffer);

        three.orbitcontrols.enabled = true; 

and this is my log…

origindragObject.position at drastart and origindragObject.position at drag

Means dragObject , originObject and event.object are the same object. it’s not assigning the values, it’s assigning the object.

thank you very much.

It was very helpful to me!:smiley: