Skip to content

Commit

Permalink
raymolecule v0.5.2: Fix CRAN issues and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermorganwall committed Feb 19, 2024
1 parent f5d65f9 commit 1e0c441
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 18 deletions.
14 changes: 8 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
Package: raymolecule
Type: Package
Title: Parse and Render Molecular Structures in 3D
Version: 0.5.1
Date: 2022-12-09
Version: 0.5.2
Date: 2024-2-18
Authors@R: c(person("Tyler", "Morgan-Wall", email = "[email protected]",
role = c("aut", "cph", "cre"), comment = c(ORCID = "0000-0002-3131-3814")))
Maintainer: Tyler Morgan-Wall <[email protected]>
Description: Downloads and parses 'SDF' (Structural Description Format) and 'PDB' (Protein Database) files for 3D rendering.
License: GPL-3
Encoding: UTF-8
Imports:
rayrender,
rayrender (>= 0.31.2),
magrittr,
PeriodicTable,
httr,
rayvertex
rayvertex (>= 0.10.4)
LazyData: true
RoxygenNote: 7.1.2
URL: http://www.raymolecule.com/
RoxygenNote: 7.3.0
URL: http://www.raymolecule.com/,
https://github.com/tylermorganwall/raymolecule
BugReports: https://github.com/tylermorganwall/raymolecule/issues
2 changes: 1 addition & 1 deletion R/convert_color.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' #none
convert_color = function(color, as_hex = FALSE) {
if(inherits(color,"character")) {
color = as.vector(col2rgb(color))/255
color = as.vector(grDevices::col2rgb(color))/255
}
stopifnot(all(color <= 1))
stopifnot(all(color >= 0))
Expand Down
7 changes: 4 additions & 3 deletions R/generate_atom_scene.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ generate_atom_scene = function(model, x=0, y=0, z=0, scale = 1, center = TRUE,
material = rayrender::glossy,
material_vertex = material_list(type="phong")) {
mat_info = material()
mat_info = mat_info[[1]]
if(!mat_info$type %in% c("glossy","diffuse", "dielectric")) {
stop("material() must be either `glossy`, `diffuse`, or `dielectric`")
}
Expand Down Expand Up @@ -78,7 +79,7 @@ generate_atom_scene = function(model, x=0, y=0, z=0, scale = 1, center = TRUE,
material=material(color=atomcol))
counter = counter + 1
}
return(do.call(rbind, scenelist))
return(do.call("rbind", scenelist))
} else {
scene = list()
for (i in 1:nrow(atoms)) {
Expand All @@ -89,8 +90,8 @@ generate_atom_scene = function(model, x=0, y=0, z=0, scale = 1, center = TRUE,
atomcol = "grey5"
}
material_atom = material_vertex
material_atom$diffuse = atomcol
material_atom$ambient = atomcol
material_atom$diffuse = as.numeric(grDevices::col2rgb(atomcol))/255
material_atom$ambient = as.numeric(grDevices::col2rgb(atomcol))/255
material_atom$ambient_intensity = 0.3
atomsize = (PeriodicTable::mass(atoms$type[i])/14)^(1/3)
scene = add_shape(scene, sphere_mesh(position = c(atoms$x[i],atoms$y[i], atoms$z[i]),
Expand Down
1 change: 1 addition & 0 deletions R/generate_bond_scene.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ generate_bond_scene = function(model, x=0, y=0, z=0, scale = 1, center = TRUE,
type = "phong",
ambient_intensity=0.3)) {
mat_info = material()
mat_info = mat_info[[1]]
if(!mat_info$type %in% c("glossy","diffuse", "dielectric")) {
stop("material() must be either `glossy`, `diffuse`, or `dielectric`")
}
Expand Down
1 change: 1 addition & 0 deletions R/generate_full_scene.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ generate_full_scene = function(model, x=0,y=0,z=0, scale = 1, center = TRUE, pat
force_single_bonds = FALSE, material = rayrender::glossy,
material_vertex = material_list(type="phong")) {
mat_info = material()
mat_info = mat_info[[1]]
if(!mat_info$type %in% c("glossy","diffuse", "dielectric")) {
stop("material() must be either `glossy`, `diffuse`, or `dielectric`")
}
Expand Down
6 changes: 4 additions & 2 deletions R/render_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ render_model = function(scene, fov = NULL, angle = c(0,0,0), order_rotation = c(
}
pathtraced = suppressWarnings(is.null(scene$vertices))
if(pathtraced) {
scene_model = scene[is.na(scene$lightintensity) &
is_not_light = unlist(lapply(scene$material, \(x) x$type)) != "light"

scene_model = scene[is_not_light &
(scene$shape == "cylinder" | scene$shape == "sphere"),]
bbox_x = range(scene_model$x,na.rm=TRUE)
bbox_y = range(scene_model$y,na.rm=TRUE)
bbox_z = range(scene_model$z,na.rm=TRUE)
spheresizes = scene[(scene$shape == "sphere" & scene$type != "light"),4]
spheresizes = unlist(lapply(scene$shape_info, \(x) x[[1]]$radius))[is_not_light]
if(length(spheresizes) > 0) {
max_sphere_radii = max(spheresizes,na.rm=TRUE)
} else {
Expand Down
1 change: 0 additions & 1 deletion R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ unit_vector = function(v) {

#'@title Create Orthonormal Basis from w (z)
#'
#'@param v Numeric vector.
#'@keywords internal
onb_from_w = function(n) {
a1 = unit_vector(n)
Expand Down
22 changes: 22 additions & 0 deletions man/convert_color.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/generate_bond_scene.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/onb_from_w.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e0c441

Please sign in to comment.