# Use touch for three-dimensional interaction

This chapter mainly introduces how to use 2D touch components to control the movement of 3D/2D objects in the screen

touch3d

# Two-dimensional world touch control

Add a transparent touch node whose size is adapted to the two-dimensional world, and add touch event binding

const globalTouch = globalTouchTransform.entity.getComponent(engine.TouchInputComponent);
globalTouch.onTouchStart.add((sender: engine.TouchInputComponent, event: engine.TouchInputEvent) => {
  //..
});

# Get 3D world target element

const mainCamTransform = this.getChildByName(engine.game.activeScene.root.transform,'Main Camera');
const mainCam = mainCamTransform.entity.getComponent(engine.Camera) as engine.Camera;

const stoneTransform = this.getChildByName(engine.game.activeScene.root.transform,'stone_tallA');

# Convert 3D target element coordinates to homogeneous clipping coordinates

const stoneClipPos = mainCam.convertWorldPositionToClip(stoneTransform.worldPosition);

# Homogeneous clipping coordinates converted to UI coordinates

# The touch coordinates are compared with the converted 3D coordinates