Builds a scene containing only bond geometry from a PDB or SDF model.

generate_bond_scene(
  model,
  x = 0,
  y = 0,
  z = 0,
  scale = 1,
  center = TRUE,
  force_single_bonds = FALSE,
  material = rayrender::glossy,
  material_args = list(),
  material_vertex = material_list(diffuse = "grey33", ambient = "grey33", type = "phong",
    ambient_intensity = 0.3)
)

Arguments

model

Model extracted from a PDB or SDF file.

x

Default `0`. X offset, applied after centering.

y

Default `0`. Y offset, applied after centering.

z

Default `0`. Z offset, applied after centering.

scale

Default `1`. Amount to scale the interatom spacing.

center

Default `TRUE`. Centers the bounding box of the model.

force_single_bonds

Default `FALSE`. Whether to force all bonds to show as a single connection.

material

Default `rayrender::glossy`. Optional rayrender material used to initialize the mesh material when `material_vertex` is not supplied. Must be either `glossy`, `diffuse`, or `dielectric`.

material_args

Default `list()`. Named list of additional arguments passed to `material`. Arguments supplied by raymolecule for colors and textures override entries with the same names. For example, use `list(gloss = 0.35, reflectance = 0.12)` with `rayrender::glossy`, or `list(sigma = 0.4)` with `rayrender::diffuse`.

material_vertex

Default `material_list(diffuse="grey33",ambient="grey33",type="phong", ambient_intensity=0.3)`. Mesh material to use for the bonds.

Value

Raymesh scene containing only the connections between atoms in a molecule/protein.

Examples

bond_model = read_sdf(get_example_molecule("benzene"))

# Start with a centered bond scene using the molecule's recorded bond
# orders and default bond material.
bond_model |>
  generate_bond_scene() |>
  render_model(
    pathtrace = FALSE,
    width = 800,
    height = 800,
    background = "grey10"
  )


# This version reduces the spacing, forces every connection to a single
# bond, and lights the ligand from above and below while pathtracing.
bond_model |>
  generate_bond_scene(
    x = 0,
    y = 0,
    z = 0,
    scale = 0.7,
    center = TRUE,
    force_single_bonds = TRUE,
    material = rayrender::glossy,
    material_args = list(gloss = 0.35)
  ) |>
  render_model(
    pathtrace = TRUE,
    lights = "both",
    width = 800,
    height = 800,
    samples = 32
  )


# A custom rayvertex material changes the raster bond color and ambient
# contribution while keeping the same geometry.
bond_material = rayvertex::material_list(
  diffuse = "grey85",
  ambient = "grey25",
  type = "phong",
  ambient_intensity = 0.4
)
cinnemaldehyde_model = read_sdf(get_example_molecule("cinnemaldehyde"))
cinnemaldehyde_model |>
  generate_bond_scene(
    material_vertex = bond_material
  ) |>
  render_model(
    pathtrace = FALSE,
    width = 800,
    height = 800,
    background = "grey10"
  )