Getting Started

Transforms & Camera

Move, rotate, scale, and animate meshes in world space, then position and aim the perspective camera with direct controls or orbit composition.

Updated Publisher Alien_AlgorithmsPine Script v6

Mesh transforms

Transform methodspine
mesh.moveTo(0, -20, 0)
mesh.moveBy(5, 0, 0)
mesh.rotateTo(0, 45, 0)
mesh.rotateBy(0, 1.5, 0)
mesh.scaleTo(2.0, 1.0, 1.0)
mesh.scaleUniform(1.5)
MethodBehavior
moveTo()Sets absolute world position.
moveBy()Adds a relative world offset.
rotateTo()Sets absolute Euler rotation in degrees.
rotateBy()Adds relative rotation in degrees.
scaleTo()Sets independent axis scale.
scaleUniform()Sets equal scale on every axis.

Animation

Animation is ordinary state mutation before the frame render. Mesh transforms automatically invalidate cached world vertices.

Bar-driven animationpine
if barstate.islast
    float yaw = bar_index * 1.5
    mesh.rotateTo(0.0, yaw, 0.0)
    p3d.render(scene)
Degrees and radians differ
Mesh rotation methods accept degrees. Low-level Vec3.rotateX(), rotateY(), and rotateZ() accept radians.

Manual vertex edits and cache invalidation

Direct writes to mesh.vertices bypass transform mutators. Call mesh.invalidateCache() afterward, or use scene.invalidateAllCaches() when several scene structures changed.

Perspective camera

Camera controlspine
scene.camera.setPosition(0, 100, 300)
scene.camera.lookAt(0, 20, 0)
scene.camera.orbit(35.0, 25.0, 380.0)
scene.camera.setFov(700.0)
  • setPosition() places the camera in world space.
  • lookAt() aims at coordinates or a Vec3 target.
  • orbit() positions the camera by yaw, pitch, and distance around its target.
  • setFov() controls perspective scale.

Scene tag targeting

scene.lookAt("tag") targets a tagged mesh. To aim at arbitrary coordinates, use scene.camera.lookAt().

Vec3 math

Vec3 supports add, subtract, scale, negate, dot, cross, length, normalize, distance, linear interpolation, axis rotation, copying, and string output.

Use p3d.vec3(x, y, z) as the everyday constructor. Named Vec3.new() construction is also available where direct UDT fields are useful.

Pine3D is a graphical rendering library for Pine Script. TradingView drawing, execution, and publication limits still apply. © Alien_Algorithms.