spec/javascripts/jax/webgl/lighting_spec.js in jax-2.0.5 vs spec/javascripts/jax/webgl/lighting_spec.js in jax-2.0.6

- old
+ new

@@ -1,23 +1,35 @@ describe("LightManager", function() { var mgr; describe("when a light resource is defined with shadowcasting disabled", function() { beforeEach(function() { + LightSource.removeAllResources(); LightSource.addResources({"__test_shadowcast_disabled":{ shadowcaster:!1,enabled:!0, position:{x:-20,y:0,z:0}, - type:"POINT_LIGHT", - attenuation:{constant:0,linear:1,quadratic:0}, + type:"DIRECTIONAL_LIGHT", + attenuation:{constant:1,linear:0,quadratic:0}, color:{ambient:{red:.15,green:.15,blue:.15,alpha:1}, diffuse:{red:.33,green:.1843137254901961,blue:.12679738562091503,alpha:1}, specular:{red:0,green:0,blue:0,alpha:0}}}}); }); it("should not be a shadow caster", function() { expect(LightSource.find("__test_shadowcast_disabled").isShadowCaster()).toBeFalsy(); }); + + it("should not cause render errors with materials that have shadow mapping enabled", function() { + var model = new Jax.Model({position:[-20,0,0], lit: true, shadow_caster: false, mesh: new Jax.Mesh.Cube()}); + model.mesh.lit = true; + model.mesh.default_material = new Jax.Material({ layers:[ {type:"Lighting"} ] }); + model.mesh.default_material.addLayer(new Jax.Material.ShadowMap()); + + SPEC_CONTEXT.world.addLightSource("__test_shadowcast_disabled"); + SPEC_CONTEXT.world.addObject(model); + SPEC_CONTEXT.world.render(); + }); }); describe("when more than 1 light source is active", function() { beforeEach(function() { mgr = new Jax.Scene.LightManager(); @@ -64,10 +76,27 @@ return true; }); }); describe("by default", function() { + var model; beforeEach(function() { mgr = new Jax.Scene.LightManager(); }); + + describe("after adding an object", function() { + beforeEach(function() { mgr.addObject(model = new Jax.Model({shadow_caster:true})); }); + + it("should be in the shadowcasters list", function() { + expect(mgr.getShadowCasters().length).toEqual(1); + }); + + describe("removing the object", function() { + beforeEach(function() { mgr.removeObject(model); }); + + it("should be gone", function() { + expect(mgr.getShadowCasters().length).toEqual(0); + }); + }); + }); it("should not be enabled", function() { expect(mgr.isEnabled()).toBeFalsy(); });