1.
var mov2 = new THREE.Vector2();
? ? var planeGeometry = new THREE.PlaneBufferGeometry(window.innerWidth*2 , window.innerHeight, 2, 2);
? ? var planeMaterial = new THREE.MeshBasicMaterial({ visible: true, side: THREE.DoubleSide, color: 0x808000, transparent :true, opacity :0.5 });
? ? var planeXY = new THREE.Mesh(planeGeometry, planeMaterial); scene.add(planeXY);
? ? scene.add(planeXY)
2.
var clickOffsetX = 0;
? ? var isMovUp = false;
? ? function onMouseDown(e){
? ? ? ? if ( scope.enabled === false ) return;? ? ?
? ? ? ? var pointer = e.changedTouches ? e.changedTouches[0] : e;
? ? ? ? startPointer.x = pointer.clientX;
? ? ? ? startPointer.y = pointer.clientY;
? ? ? ? var entity = intersectObjects(startPointer.x, startPointer.y, arrBall)
? ? ? ? if(entity){
? ? ? ? ? ? selectBall = entity.object
? ? ? ? ? ? gl.selectBall(selectBall)
? ? ? ? ? ? planeXY.position.copy(selectBall.position)
? ? ? ? ? ? clickOffsetX = entity.point.x - selectBall.position.x;
? ? ? ? ? ? isMovUp = false;
? ? ? ? } else
? ? ? ? ? ? selectBall = null;
? ? }
? ? function onMouseMove(e){
? ? ? ? if ( scope.enabled === false ) return;
? ? ? ? if (!selectBall) return;
? ? ? ? var pointer = e.changedTouches ? e.changedTouches[0] : e;
? ? ? ? mov2.x = pointer.clientX - startPointer.x;
? ? ? ? mov2.y = startPointer.y - pointer.clientY;
? ? ? ? var entity = intersectObjects(pointer.x, pointer.y, [planeXY])
? ? ? ? if(entity)
? ? ? ? {
? ? ? ? ? ? console.log(entity.point)
? ? ? ? ? ? // console.log
? ? ? ? ? ? if (entity.point.y < selectBall.position.y + selectBall.scale.y
? ? ? ? ? ? ? ? && Math.abs(mov2.x) > 0.2 && mov2.y*5 < Math.abs(mov2.x)){
? ? ? ? ? ? ? ? if (selectBall.body)
? ? ? ? ? ? ? ? ? ? selectBall.body.setPosition( {x:entity.point.x - clickOffsetX, y:selectBall.body.position.y, z:selectBall.body.position.z});
? ? ? ? ? ? ? ? isMovUp = false;
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? if (!isMovUp){
? ? ? ? ? ? ? ? ? ? isMovUp = true;
? ? ? ? ? ? ? ? ? ? clock.getDelta();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? function onMouseUp(e) {
? ? ? ? if ( scope.enabled === false ) return;
? ? ? ? if (!selectBall) return;
? ? ? ? if (!isMovUp) {
? ? ? ? ? ? selectBall = null;
? ? ? ? ? ? return;
? ? ? ? }