Sha256: 8e07560c41e57fba5bdb1a5df2b1e6811f317c8bb17b4d32f0e844ff92d2b672

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

#= require "jax/material/illumination_layer"

class Jax.Material.Layer.LambertDiffuse extends Jax.Material.IlluminationLayer
  constructor: (options) ->
    @intensity = 1
    super options
    @meshDataMap =
      vertices: 'VERTEX_POSITION'
      normals:  'VERTEX_NORMAL'
    @eyeDir = vec3.create()
    @eyePos = vec3.create()
    
  illuminate: (context, mesh, model, vars, light) ->
    vars['LightDiffuseColor'] = light.color.diffuse
    vars['LightSpotExponent'] = light.spotExponent
    vars['LightSpotInnerCos'] = light.innerSpotAngleCos
    vars['LightSpotOuterCos'] = light.outerSpotAngleCos
    vars['LightType'] = light.type
    vars['EyeSpaceLightDirection'] = light.eyeDirection context.matrix_stack.getViewNormalMatrix(), @eyeDir
    vars['EyeSpaceLightPosition'] = light.eyePosition context.matrix_stack.getViewMatrix(), @eyePos

    vars.NormalMatrix = context.matrix_stack.getNormalMatrix()
    vars.MaterialDiffuseIntensity = @intensity
    vars.MaterialDiffuseColor = @color
    vars.ModelViewMatrix = context.matrix_stack.getModelViewMatrix()
    mesh.data.set vars, @meshDataMap

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jax-3.0.0.rc2 lib/assets/javascripts/shaders/lambert_diffuse/material.js.coffee
jax-3.0.0.rc1 lib/assets/javascripts/shaders/lambert_diffuse/material.js.coffee