|
@@ -1452,7 +1452,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
this.initMaterial = function ( material, lights, fog, object ) {
|
|
this.initMaterial = function ( material, lights, fog, object ) {
|
|
|
|
|
|
- var u, identifiers, i, parameters, maxLightCount, maxBones;
|
|
|
|
|
|
+ var u, a, identifiers, i, parameters, maxLightCount, maxBones;
|
|
|
|
|
|
if ( material instanceof THREE.MeshDepthMaterial ) {
|
|
if ( material instanceof THREE.MeshDepthMaterial ) {
|
|
|
|
|
|
@@ -1499,18 +1499,23 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters );
|
|
material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters );
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // load uniforms
|
|
|
|
+
|
|
identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition',
|
|
identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition',
|
|
'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences'
|
|
'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences'
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+
|
|
for( u in material.uniforms ) {
|
|
for( u in material.uniforms ) {
|
|
|
|
|
|
identifiers.push(u);
|
|
identifiers.push(u);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
cacheUniformLocations( material.program, identifiers );
|
|
cacheUniformLocations( material.program, identifiers );
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // load attributes
|
|
|
|
|
|
identifiers = [ "position", "normal", "uv", "uv2", "tangent", "color",
|
|
identifiers = [ "position", "normal", "uv", "uv2", "tangent", "color",
|
|
"skinVertexA", "skinVertexB", "skinIndex", "skinWeight" ];
|
|
"skinVertexA", "skinVertexB", "skinIndex", "skinWeight" ];
|
|
@@ -1520,6 +1525,11 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
identifiers.push( "morphTarget" + i );
|
|
identifiers.push( "morphTarget" + i );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ for( a in material.attributes ) {
|
|
|
|
+
|
|
|
|
+ identifiers.push( a );
|
|
|
|
+ }
|
|
|
|
+
|
|
cacheAttributeLocations( material.program, identifiers );
|
|
cacheAttributeLocations( material.program, identifiers );
|
|
|
|
|
|
|
|
|
|
@@ -1704,26 +1714,32 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
// set base
|
|
// set base
|
|
|
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLMorphTargetsBuffers[ object.morphTargetBase ] );
|
|
|
|
- _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
|
|
|
|
|
|
+ if( object.morphTargetBase !== -1 ) {
|
|
|
|
+
|
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLMorphTargetsBuffers[ object.morphTargetBase ] );
|
|
|
|
+ _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer );
|
|
|
|
+ _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
// find most influencing
|
|
// find most influencing
|
|
|
|
|
|
- var used = [];
|
|
|
|
var candidateInfluence = -1;
|
|
var candidateInfluence = -1;
|
|
var candidate = 0;
|
|
var candidate = 0;
|
|
var influences = object.morphTargetInfluences;
|
|
var influences = object.morphTargetInfluences;
|
|
var i, il = influences.length;
|
|
var i, il = influences.length;
|
|
var m = 0;
|
|
var m = 0;
|
|
|
|
|
|
- used[ object.morphTargetBase ] = 1;
|
|
|
|
-
|
|
|
|
while( m < material.numSupportedMorphTargets ) {
|
|
while( m < material.numSupportedMorphTargets ) {
|
|
|
|
|
|
for( i = 0; i < il; i++ ) {
|
|
for( i = 0; i < il; i++ ) {
|
|
|
|
|
|
- if( !used[ i ] && candidateInfluence < influences[ i ] ) {
|
|
|
|
|
|
+ if( i != object.morphTargetBase && influences[ i ] > candidateInfluence ) {
|
|
|
|
|
|
candidate = i;
|
|
candidate = i;
|
|
candidateInfluence = influences[ candidate ];
|
|
candidateInfluence = influences[ candidate ];
|
|
@@ -1735,9 +1751,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
object.__webGLMorphTargetInfluences[ m ] = candidateInfluence;
|
|
object.__webGLMorphTargetInfluences[ m ] = candidateInfluence;
|
|
|
|
|
|
- used[ candidate ] = 1;
|
|
|
|
candidateInfluence = -1;
|
|
candidateInfluence = -1;
|
|
-
|
|
|
|
m++;
|
|
m++;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3865,6 +3879,7 @@ THREE.Snippets = {
|
|
"morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];",
|
|
"morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];",
|
|
"morphed *= 0.25;",
|
|
"morphed *= 0.25;",
|
|
"morphed += position;",
|
|
"morphed += position;",
|
|
|
|
+
|
|
"gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );",
|
|
"gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );",
|
|
|
|
|
|
"#else",
|
|
"#else",
|
|
@@ -3873,7 +3888,7 @@ THREE.Snippets = {
|
|
|
|
|
|
"#endif"
|
|
"#endif"
|
|
|
|
|
|
- ].join("\n")
|
|
|
|
|
|
+ ].join("\n")
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -4256,6 +4271,5 @@ THREE.ShaderLib = {
|
|
].join("\n")
|
|
].join("\n")
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
};
|
|
};
|