SquaresMaterial

SquaresMaterial

A material that display tilling of nested squares (or more generally parallelograms) It works with at most four colors. The given width correspond to the relative with of each squares. The constructor will renormalize these numbers so that their sum is one.

Constructor

new SquaresMaterial(dir1, dir2, widths, colors)

Source:

Constructor

Parameters:
Name Type Description
dir1 Vector2

first direction of the lattice

dir2 Vector2

second direction of the lattice

widths Array.<number>

a list of four numbers

colors Array.<Color>

a list of four colors

Extends

Classes

SquaresMaterial

Members

color0 :Color

Source:

first color

Type:
  • Color

color1 :Color

Source:

second color

Type:
  • Color

color2 :Color

Source:

third color

Type:
  • Color

color3 :Color

Source:

fourth color

Type:
  • Color

dir1 :Vector2

Source:

first direction of the checkerboard

Type:
  • Vector2

dir2 :Vector2

Source:

second direction of the checkerboard

Type:
  • Vector2

isMaterial :boolean

Source:
Overrides:

Says that the object inherits from Material

Type:
  • boolean

isReflecting

Source:
Overrides:

Says whether the material is reflecting Default is false.

lights

Source:
Overrides:

The light eventually affecting the material. If lights is not set up when the solid carrying the material is added to the scene, then lights is set up to the list of lights in the scene.

reflectivity :Color

Source:
Overrides:

Reflectivity of the material. Each channel (red, blue, green), interpreted as number between 0 and 1, is the reflectivity coefficient of the corresponding color (0 = no reflectivity, 1 = all light is reflected).

Type:
  • Color

usesLight

Source:
Overrides:

Says whether the material reacts to (certain) lights in the scene. Default is false.

usesNormal

Source:
Overrides:

Says whether the material requires the normal to the shape for its computation. Default is true.

usesUVMap

Source:
Overrides:

Says whether the material requires a UV map on the shape for its computation. Default is false.

Methods

glslInstance() → {string}

Source:
Overrides:

Compile all the function directly related to the object (e.g. render).

Returns:
Type
string

(abstract) glslRender() → {string}

Source:
Overrides:

Return the chunk of GLSL code used to compute the color of the material at the given point The render function on the GLSL side should have one of the following signatures

  • vec3 {{name}}_render(ExtVector v)
  • vec3 {{name}}_render(ExtVector v, RelVector normal)
  • vec3 {{name}}_render(ExtVector v, vec2 uv)
  • vec3 {{name}}_render(ExtVector v, RelVector normal, vec2 uv) The exact signature depends whether the material requires a normal or UV coordinates. Here v is the vector obtained when we hit the shape. It should return the color as a vec3 of the material at the given point, without taking into account reflections.
Returns:
Type
string