bg: Set up Background

Description Usage Arguments Details See Also Examples

Description

Set up the background of the scene.

Usage

1
2
3
bg3d(...) 
rgl.bg( sphere = FALSE, fogtype = "none", color = c("black", "white"), 
	back = "lines", fogScale = 1, ...)

Arguments

fogtype

fog type:

"none"

no fog

"linear"

linear fog function

"exp"

exponential fog function

"exp2"

squared exponential fog function

Fog only applies to objects with material3d property fog set to TRUE.

sphere

logical, if true, an environmental sphere geometry is used for the background decoration.

color

Primary color is used for background clearing and as fog color. Secondary color is used for background sphere geometry. See material3d for details.

back

Specifies the fill style of the sphere geometry. See material3d for details.

fogScale

Scaling for fog. See Details.

...

Material properties. See material3d for details.

Details

If sphere is set to TRUE, an environmental sphere enclosing the whole scene is drawn.

If not, but the material properties include a bitmap as a texture, the bitmap is drawn in the background of the scene. (The bitmap colors modify the general color setting.)

If neither a sphere nor a bitmap background is drawn, the background is filled with a solid color.

The fogScale parameter should be a positive value to change the density of the fog in the plot. For fogtype = "linear" it multiplies the density of the fog; for the exponential fog types it multiplies the density parameter used in the display.

See the OpenGL 2.1 reference for the formulas used in the fog calculations within R (though the "exp2" formula appears to be wrong, at least on my system). In WebGL displays, the following rules are used. They appear to match the rules used in R on my system.

See Also

material3d, bgplot3d to add a 2D plot as background.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
  open3d()
  
  # a simple white background
  
  bg3d("white")

  # the holo-globe (inspired by star trek):

  bg3d(sphere = TRUE, color = c("black", "green"), lit = FALSE, back = "lines" )

  # an environmental sphere with a nice texture.

  bg3d(sphere = TRUE, texture = system.file("textures/sunsleep.png", package = "rgl"), 
         back = "filled" )
         
  # The same texture as a fixed background
  
  open3d()
  bg3d(texture = system.file("textures/sunsleep.png", package = "rgl"), col = "white")

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'. 
null 
   1 
null 
   2 

rgl documentation built on Feb. 1, 2021, 3:01 a.m.