|
@@ -21934,6 +21934,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
// reset caching for this frame
|
|
|
|
|
|
_currentMaterialId = - 1;
|
|
|
+ _currentCamera = null;
|
|
|
_lightsNeedUpdate = true;
|
|
|
|
|
|
// update scene graph
|
|
@@ -22957,6 +22958,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ var refreshProgram = false;
|
|
|
var refreshMaterial = false;
|
|
|
|
|
|
var program = material.program,
|
|
@@ -22968,6 +22970,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
_gl.useProgram( program.program );
|
|
|
_currentProgram = program.id;
|
|
|
|
|
|
+ refreshProgram = true;
|
|
|
refreshMaterial = true;
|
|
|
|
|
|
}
|
|
@@ -22979,7 +22982,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( refreshMaterial || camera !== _currentCamera ) {
|
|
|
+ if ( refreshProgram || camera !== _currentCamera ) {
|
|
|
|
|
|
_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, camera.projectionMatrix.elements );
|
|
|
|
|
@@ -22992,6 +22995,35 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( camera !== _currentCamera ) _currentCamera = camera;
|
|
|
|
|
|
+ // load material specific uniforms
|
|
|
+ // (shader material also gets them for the sake of genericity)
|
|
|
+
|
|
|
+ if ( material instanceof THREE.ShaderMaterial ||
|
|
|
+ material instanceof THREE.MeshPhongMaterial ||
|
|
|
+ material.envMap ) {
|
|
|
+
|
|
|
+ if ( p_uniforms.cameraPosition !== null ) {
|
|
|
+
|
|
|
+ _vector3.setFromMatrixPosition( camera.matrixWorld );
|
|
|
+ _gl.uniform3f( p_uniforms.cameraPosition, _vector3.x, _vector3.y, _vector3.z );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material instanceof THREE.MeshPhongMaterial ||
|
|
|
+ material instanceof THREE.MeshLambertMaterial ||
|
|
|
+ material instanceof THREE.ShaderMaterial ||
|
|
|
+ material.skinning ) {
|
|
|
+
|
|
|
+ if ( p_uniforms.viewMatrix !== null ) {
|
|
|
+
|
|
|
+ _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, camera.matrixWorldInverse.elements );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// skinning uniforms must be set even if material didn't change
|
|
@@ -23113,35 +23145,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
loadUniformsGeneric( program, material.uniformsList );
|
|
|
|
|
|
- // load material specific uniforms
|
|
|
- // (shader material also gets them for the sake of genericity)
|
|
|
-
|
|
|
- if ( material instanceof THREE.ShaderMaterial ||
|
|
|
- material instanceof THREE.MeshPhongMaterial ||
|
|
|
- material.envMap ) {
|
|
|
-
|
|
|
- if ( p_uniforms.cameraPosition !== null ) {
|
|
|
-
|
|
|
- _vector3.setFromMatrixPosition( camera.matrixWorld );
|
|
|
- _gl.uniform3f( p_uniforms.cameraPosition, _vector3.x, _vector3.y, _vector3.z );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( material instanceof THREE.MeshPhongMaterial ||
|
|
|
- material instanceof THREE.MeshLambertMaterial ||
|
|
|
- material instanceof THREE.ShaderMaterial ||
|
|
|
- material.skinning ) {
|
|
|
-
|
|
|
- if ( p_uniforms.viewMatrix !== null ) {
|
|
|
-
|
|
|
- _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, camera.matrixWorldInverse.elements );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
loadUniformsMatrices( p_uniforms, object );
|