ShadowMaterial.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { ShaderMaterial } from './ShaderMaterial';
  2. import { ShaderChunk } from '../renderers/shaders/ShaderChunk';
  3. import { UniformsLib } from '../renderers/shaders/UniformsLib';
  4. import { UniformsUtils } from '../renderers/shaders/UniformsUtils';
  5. /**
  6. * @author mrdoob / http://mrdoob.com/
  7. *
  8. * parameters = {
  9. * opacity: <float>
  10. * }
  11. */
  12. function ShadowMaterial( parameters ) {
  13. ShaderMaterial.call( this, {
  14. uniforms: UniformsUtils.merge( [
  15. UniformsLib.lights,
  16. {
  17. opacity: { value: 1.0 }
  18. }
  19. ] ),
  20. vertexShader: ShaderChunk[ 'shadow_vert' ],
  21. fragmentShader: ShaderChunk[ 'shadow_frag' ]
  22. } );
  23. this.lights = true;
  24. this.transparent = true;
  25. Object.defineProperties( this, {
  26. opacity: {
  27. enumerable: true,
  28. get: function () {
  29. return this.uniforms.opacity.value;
  30. },
  31. set: function ( value ) {
  32. this.uniforms.opacity.value = value;
  33. }
  34. }
  35. } );
  36. this.setValues( parameters );
  37. }
  38. ShadowMaterial.prototype = Object.create( ShaderMaterial.prototype );
  39. ShadowMaterial.prototype.constructor = ShadowMaterial;
  40. ShadowMaterial.prototype.isShadowMaterial = true;
  41. export { ShadowMaterial };
粤ICP备19079148号