3D Lingo Dictionary > O-S > spriteSpaceToWorldSpace |  |

spriteSpaceToWorldSpace

Syntax

    sprite(whichSprite).camera.spriteSpaceToWorldSpace(loc)
    sprite(whichSprite).camera(index).spriteSpaceToWorldSpace(loc)

Description

3D command; returns a world-space position that is found on the specified camera's projection plane that corresponds to a location within the referenced sprite. The location specified by `loc` should be a point relative to the sprite's upper-left corner.

The projection plane is defined by the camera's X and Y axes, and is at a distance in front of the camera such that one pixel represents one world unit of measurement. It is this projection plane that is used for the sprite display on stage.

The `camera.spriteSpaceToWorldSpace()` form of this command is a shortcut for using `camera(1).spriteSpaceToWorldSpace()`.

All cameras that are used by the referenced sprite will respond to the `spriteSpaceToWorldSpace` command as if their display rect is the same size as the sprite.

Example

This statement shows that the point (50, 50) within sprite 5 is equivalent to the vector (-1993.6699, 52.0773, 2263.7446) on the projection plane of the camera of sprite 5.

    put sprite(5).camera.spriteSpaceToWorldSpace(point(50, 50))
    -- vector(-1993.6699, 52.0773, 2263.7446)

See also

`worldSpaceToSpriteSpace`, `rect`, `camera`