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

rotate

Syntax

    member(whichCastmember).node(whichNode).rotate(xAngle, yAngle, zAngle {, relativeTo})
    member(whichCastmember).node(whichNode).rotate(rotationVector {, relativeTo})
    member(whichCastmember).node(whichNode).rotate(position, axis, angle {, relativeTo})
    transform.rotate(xAngle, yAngle, zAngle {, relativeTo})
    transform.rotate(rotationVector {, relativeTo})
    transform.rotate(position, axis, angle {, relativeTo})

Description

3D command; applies a rotation after the current positional, rotational, and scale offsets held by the node's transform object or the directly referenced transform object. The rotation must be specified as a set of three angles, each of which specify an angle of rotation about the three corresponding axes. These angles may be specified explicitly in the form of `xAngle`, `yAngle`, and `zAngle`, or by a `rotationVector`, where the `x` component of the vector corresponds to the rotation about the X axis, `y` about Y axis, and`z` about Z axis. Alternatively, the rotation may also be specified as a rotation about an arbitrary axis passing through a point in space. This axis is defined in space by `position`, representing a position in space and `axis`, representing an axis passing through the specified position in space. The amount of rotation about this axis is specified by `angle`.

The optional `relativeTo` parameter determines which coordinate system axes are used to apply the desired rotational changes. The `relativeTo` parameter can have any of the following values:

| `#self` applies the increments relative to the node's local coordinate system (the X, Y and Z axes specified for the model during authoring). This value is used as the default if you use the `rotate` command with a node reference and the `relativeTo` parameter is not specified.
| `#parent` applies the increments relative to the node's parent's coordinate system. This value is used as the default if you use the `rotate` command with a transform reference and the `relativeTo` parameter is not specified.
| `#world` applies the increments relative to the world coordinate system. If a model's parent is the world, than this is equivalent to using `#parent`.
| `nodeReference` allows you to specify a node to base your rotation upon, the command applies the increments relative to the coordinate system of the specified node.

Examples

This example first rotates the model named Moon about its own Z axis (rotating it in place), then it rotates that same model about its parent node, the model named Earth (causing Moon to move orbitally about Earth).

    member("Scene").model("Moon").rotate(0,0,15)
    member("Scene").model("Moon").rotate(vector(0, 0, 5), member("Scene").model("Moon"))

This example rotates the model Ball around a position in space occupied by the model named Pole. The effect is that the model Ball moves orbitally about Pole in the x-y plane.

    polePos = member("3d Scene").model("Pole").worldPosition
    member("3d Scene").model("Ball").rotate(polePos, vector(0,0,1), 5, #world)

See also

`pointAt`, `preRotate`, `rotation (transform)`, `rotation (engraver shader)`, `rotation (backdrop and overlay)`, `preScale()`, `transform (property)`