class Mittsu::ShaderMaterial

Attributes

attributes[RW]
defines[RW]
fog[RW]
fragment_shader[RW]
lights[RW]
morph_normals[RW]
morph_targets[RW]
shading[RW]
skinning[RW]
vertex_colors[RW]
vertex_shader[RW]
wireframe[RW]
wireframe_linewidth[RW]

Public Class Methods

new(parameters = {}) click to toggle source
Calls superclass method Mittsu::Material::new
# File lib/mittsu/materials/shader_material.rb, line 33
def initialize(parameters = {})
  super()

  @type = 'ShaderMaterial'
  @defines = {}
  @uniforms = {}
  @attributes = nil

  @vertex_shader = 'void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}'
  @fragment_shader = 'void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}'

  @shading = SmoothShading

  @line_width = 1

  @wireframe = false
  @wireframe_linewidth = 1

  @fog = false # set to use scene fog

  @lights = false # set to use scene lights

  @vertex_colors = NoColors # set to use "color" attribute stream

  @skinning = false # set to use skinning attribute streams

  @morph_targets = false # set to use morph targets
  @morph_normals = false # set to use morph normals

        # When rendered geometry doesn't include these attributes but the material does,
        # use these default values in WebGL. This avoids errors when buffer data is missing.
  @default_attributes_values = {
    'color' => [1.0, 1.0, 1.0],
    'uv' => [0, 0],
    'uv2' => [0, 0]
  }

  # TODO: necessary?
    # this.index0AttributeName = undefined;

  self.set_values(parameters)
end

Public Instance Methods

clone() click to toggle source
Calls superclass method Mittsu::Material#clone
# File lib/mittsu/materials/shader_material.rb, line 76
def clone
  material = ShaderMaterial.new

  super.clone(material)

    material.fragment_shader = @fragment_shader
    material.vertex_shader = @vertex_shader

    material.uniforms = UniformsUtils.clone(@uniforms)

    material.attributes = @attributes
    material.defines = @defines

    material.shading = @shading

    material.wireframe = @wireframe
    material.wireframe_linewidth = @wireframe_linewidth

    material.fog = @fog

    material.lights = @lights

    material.vertex_colors = @vertex_colors

    material.skinning = @skinning

    material.morph_targets = @morph_targets
    material.morph_normals = @morph_normals

        material
end