提交 c1df1730 编写于 作者: B Ben Houston

ways to define ThreeJS "uniforms" for structs and struct arrays. ways to set...

ways to define ThreeJS "uniforms" for structs and struct arrays.  ways to set those values.  still missing some glue code.
上级 e889e6b9
......@@ -2140,6 +2140,82 @@ THREE.WebGLRenderer = function ( parameters ) {
break;
case 'fs':
_gl.uniform1f( location[ uniform.property ], value );
break;
case 'v2s':
_gl.uniform2f( location[ uniform.property ], value.x, value.y );
break;
case 'v3s':
_gl.uniform3f( location[ uniform.property ], value.x, value.y, value.z );
break;
case 'v4s':
_gl.uniform4f( location[ uniform.property ], value.x, value.y, value.z, value.w );
break;
case 'cs':
_gl.uniform3f( location[ uniform.property ], value.r, value.g, value.b );
break;
case 'fsa':
for( var i = 0; i < value.length; i ++ ) {
_gl.uniform1f( location[ i ][ uniform.property ], value );
}
break;
case 'v2sa':
for( var i = 0; i < value.length; i ++ ) {
_gl.uniform2f( location[ i ][ uniform.property ], value.x, value.y );
}
break;
case 'v3sa':
for( var i = 0; i < value.length; i ++ ) {
_gl.uniform3f( location[ i ][ uniform.property ], value.x, value.y, value.z );
}
break;
case 'v4sa':
for( var i = 0; i < value.length; i ++ ) {
_gl.uniform4f( location[ i ][ uniform.property ], value.x, value.y, value.z, value.w );
}
break;
case 'csa':
for( var i = 0; i < value.length; i ++ ) {
_gl.uniform3f( location[ i ][ uniform.property ], value.r, value.g, value.b );
}
break;
case 'iv1':
// flat array of integers (JS or typed array)
......
......@@ -77,25 +77,25 @@ THREE.UniformsLib = {
"ambientLightColor" : { type: "fv", value: [] },
"directionalLightDirection" : { type: "fv", value: [] },
"directionalLightColor" : { type: "fv", value: [] },
"hemisphereLightDirection" : { type: "fv", value: [], array: 'hemisphereLights', property: 'direction' },
"hemisphereLightSkyColor" : { type: "fv", value: [], array: 'hemisphereLights', property: 'skyColor' },
"hemisphereLightGroundColor" : { type: "fv", value: [], array: 'hemisphereLights', property: 'groundColor' },
"pointLightColor" : { type: "fv", value: [], array: 'pointLights', property: 'color' },
"pointLightPosition" : { type: "fv", value: [], array: 'pointLights', property: 'position' },
"pointLightDistance" : { type: "fv1", value: [], array: 'pointLights', property: 'distance' },
"pointLightDecay" : { type: "fv1", value: [], array: 'pointLights', property: 'decay' },
"spotLightColor" : { type: "fv", value: [], array: 'spotLights', property: 'color' },
"spotLightPosition" : { type: "fv", value: [], array: 'spotLights', property: 'position' },
"spotLightDirection" : { type: "fv", value: [], array: 'spotLights', property: 'direction' },
"spotLightDistance" : { type: "fv1", value: [], array: 'spotLights', property: 'distance' },
"spotLightAngleCos" : { type: "fv1", value: [], array: 'spotLights', property: 'angleCos' },
"spotLightExponent" : { type: "fv1", value: [], array: 'spotLights', property: 'exponent' },
"spotLightDecay" : { type: "fv1", value: [], array: 'spotLights', property: 'decay' }
"directionalLightDirection" : { type: "v3sa", value: [], name: 'hemisphereLights', property: 'direction' },
"directionalLightColor" : { type: "csa", value: [], name: 'hemisphereLights', property: 'direction' },
"hemisphereLightDirection" : { type: "v3sa", value: [], name: 'hemisphereLights', property: 'direction' },
"hemisphereLightSkyColor" : { type: "csa", value: [], name: 'hemisphereLights', property: 'skyColor' },
"hemisphereLightGroundColor" : { type: "csa", value: [], name: 'hemisphereLights', property: 'groundColor' },
"pointLightColor" : { type: "csa", value: [], name: 'pointLights', property: 'color' },
"pointLightPosition" : { type: "v3sa", value: [], name: 'pointLights', property: 'position' },
"pointLightDistance" : { type: "fsa", value: [], name: 'pointLights', property: 'distance' },
"pointLightDecay" : { type: "fsa", value: [], name: 'pointLights', property: 'decay' },
"spotLightColor" : { type: "csa", value: [], name: 'spotLights', property: 'color' },
"spotLightPosition" : { type: "v3sa", value: [], name: 'spotLights', property: 'position' },
"spotLightDirection" : { type: "v3sa", value: [], name: 'spotLights', property: 'direction' },
"spotLightDistance" : { type: "fsa", value: [], name: 'spotLights', property: 'distance' },
"spotLightAngleCos" : { type: "fsa", value: [], name: 'spotLights', property: 'angleCos' },
"spotLightExponent" : { type: "fsa", value: [], name: 'spotLights', property: 'exponent' },
"spotLightDecay" : { type: "fsa", value: [], name: 'spotLights', property: 'decay' }
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册