Transforms & Camera
Move, rotate, scale, and animate meshes in world space, then position and aim the perspective camera with direct controls or orbit composition.
Mesh transforms
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)| Method | Behavior |
|---|---|
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.
if barstate.islast
float yaw = bar_index * 1.5
mesh.rotateTo(0.0, yaw, 0.0)
p3d.render(scene)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
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.