Screen to Real World
Converts the position of the object in screen space to its corresponding position and rotation in real world space by performing a raycast.
note
- The selected AR camera must have a Device Tracker component in the Inspector panel and the Tracking Mode must be set to World. Otherwise, both the position and rotation will return 0, 0, 0.
- Effects that utilize this node cannot be previewed on desktop. To preview your effect, click Preview in TikTok and scan the QR code from the TikTok mobile app.
- Effects with this node can only run on mobile phones with gyroscopes, gravity sensors, acceleration sensors, and rotation sensors. If any of these sensors are missing, you will see a prompt that states your mobile phone does not support this effect.
- This node requires time for the camera to initialize. To ensure your effect runs smoothly, add a hint to prompt users to wait. For example, "Scanning space in 3...2...1."
- For best results, prompt users to click or focus on a plane with high contrast or bold textures.
- Deviation in the rotation returned by the node might occur in some cases. It is recommended to handle the rotation information separately to ensure that the object is always perpendicular to the plane.
Input
Name | Data Type | Description |
---|---|---|
Start | Exec | Starts the conversion from screen to world coordinates |
AR Camera | AR Camera | The camera to which the Device Tracker component is attached. Tracking mode must be set to World. |
Screen Position | Vec2 | The position of the object in screen space |
Max Ray Distance | Number | The maximum distance of a ray in meters. It can be 10 to 200 meters; the default is 100 meters. |
Output
Name | Data Type | Description |
---|---|---|
Hit Success | Exec | Executes the next node if an object is detected |
Hit Fail | Exec | Executes the next node if no object is detected |
Position | Vec3 | The position of the object in world space |
Rotation | Vec3 | The rotation angle of the object in world space |