Skip to contents

Converts the output of render_mesh() or render_scene() into a 3-dimensional R array of dimensions (height x width x 4) with RGBA channels.

Usage

image_to_array(image)

Arguments

image

An image list returned by render_mesh() or render_scene().

Value

A 3D array of dimensions (height, width, 4) with values in [0, 1].

Examples

mesh <- generate_cuboid(c(0, 0, 0), c(1, 1, 1))
img <- render_mesh(mesh$vertices, mesh$triangles)
arr <- image_to_array(img)
dim(arr)  # height x width x 4
#> [1] 600 800   4