( camera, lights, fog, material, object )
| 19486 | }; |
| 19487 | |
| 19488 | function setProgram( camera, lights, fog, material, object ) { |
| 19489 | |
| 19490 | if ( material.needsUpdate ) { |
| 19491 | |
| 19492 | if ( material.program ) _this.deallocateMaterial( material ); |
| 19493 | |
| 19494 | _this.initMaterial( material, lights, fog, object ); |
| 19495 | material.needsUpdate = false; |
| 19496 | |
| 19497 | } |
| 19498 | |
| 19499 | if ( material.morphTargets ) { |
| 19500 | |
| 19501 | if ( ! object.__webglMorphTargetInfluences ) { |
| 19502 | |
| 19503 | object.__webglMorphTargetInfluences = new Float32Array( _this.maxMorphTargets ); |
| 19504 | |
| 19505 | } |
| 19506 | |
| 19507 | } |
| 19508 | |
| 19509 | var refreshMaterial = false; |
| 19510 | |
| 19511 | var program = material.program, |
| 19512 | p_uniforms = program.uniforms, |
| 19513 | m_uniforms = material.uniforms; |
| 19514 | |
| 19515 | if ( program !== _currentProgram ) { |
| 19516 | |
| 19517 | _gl.useProgram( program ); |
| 19518 | _currentProgram = program; |
| 19519 | |
| 19520 | refreshMaterial = true; |
| 19521 | |
| 19522 | } |
| 19523 | |
| 19524 | if ( material.id !== _currentMaterialId ) { |
| 19525 | |
| 19526 | _currentMaterialId = material.id; |
| 19527 | refreshMaterial = true; |
| 19528 | |
| 19529 | } |
| 19530 | |
| 19531 | if ( refreshMaterial || camera !== _currentCamera ) { |
| 19532 | |
| 19533 | _gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, camera._projectionMatrixArray ); |
| 19534 | |
| 19535 | if ( camera !== _currentCamera ) _currentCamera = camera; |
| 19536 | |
| 19537 | } |
| 19538 | |
| 19539 | if ( refreshMaterial ) { |
| 19540 | |
| 19541 | // refresh uniforms common to several materials |
| 19542 | |
| 19543 | if ( fog && material.fog ) { |
| 19544 | |
| 19545 | refreshUniformsFog( m_uniforms, fog ); |
no test coverage detected