浏览代码

Proper prefixing of uniforms and attributes. Add 'color' to the attribreplaceTHREEShaderAttributes.

bdysvik 8 年之前
父节点
当前提交
abf63b05ad

+ 8 - 1
examples/js/loaders/GLTFLoader.js

@@ -486,6 +486,13 @@ THREE.GLTFLoader = ( function () {
 					shaderText = shaderText.replace( regEx, 'uv' );
 					break;
 
+				case 'COLOR_0':
+				case 'COLOR0':
+				case 'COLOR':
+
+					shaderText = shaderText.replace( regEx, 'color' );
+					break;
+
 				case "WEIGHT":
 
 					shaderText = shaderText.replace( regEx, 'skinWeight' );
@@ -1758,4 +1765,4 @@ THREE.GLTFLoader = ( function () {
 
 	return GLTFLoader;
 
-} )();
+} )();

+ 7 - 7
examples/models/gltf/snowflake/line_vert.glsl

@@ -1,15 +1,15 @@
 precision highp float;
 
-attribute vec3 position;
-attribute vec3 color;
+attribute vec3 a_position;
+attribute vec3 a_color;
 
 varying vec3 v_color;
 
-uniform mat4 modelViewMatrix;
-uniform mat4 projectionMatrix;
+uniform mat4 u_modelViewMatrix;
+uniform mat4 u_projectionMatrix;
 
 void main(void) {
-	vec4 pos = modelViewMatrix * vec4(position,1.0);
-	v_color = color;
-	gl_Position = projectionMatrix * pos;
+	vec4 pos = u_modelViewMatrix * vec4(position,1.0);
+	v_color = a_color;
+	gl_Position = u_projectionMatrix * pos;
 }

+ 2 - 2
examples/models/gltf/snowflake/snowFlake.gltf

@@ -158,8 +158,8 @@
       },
       "program": "meshProgram",
       "uniforms": {
-        "modelViewMatrix": "modelViewMatrixParameter",
-        "projectionMatrix": "projectionMatrixParameter"
+        "u_modelViewMatrix": "modelViewMatrixParameter",
+        "u_projectionMatrix": "projectionMatrixParameter"
       },
       "states": {
         "enable": [

+ 7 - 7
examples/models/gltf/snowflakes/line_vert.glsl

@@ -1,15 +1,15 @@
 precision highp float;
 
-attribute vec3 position;
-attribute vec3 color;
+attribute vec3 a_position;
+attribute vec3 a_color;
 
 varying vec3 v_color;
 
-uniform mat4 modelViewMatrix;
-uniform mat4 projectionMatrix;
+uniform mat4 u_modelViewMatrix;
+uniform mat4 u_projectionMatrix;
 
 void main(void) {
-	vec4 pos = modelViewMatrix * vec4(position,1.0);
-	v_color = color;
-	gl_Position = projectionMatrix * pos;
+	vec4 pos = u_modelViewMatrix * vec4(a_position,1.0);
+	v_color = a_color;
+	gl_Position = u_projectionMatrix * pos;
 }

+ 2 - 2
examples/models/gltf/snowflakes/snowFlakes.gltf

@@ -181,8 +181,8 @@
       },
       "program": "meshProgram",
       "uniforms": {
-        "modelViewMatrix": "modelViewMatrixParameter",
-        "projectionMatrix": "projectionMatrixParameter"
+        "u_modelViewMatrix": "modelViewMatrixParameter",
+        "u_projectionMatrix": "projectionMatrixParameter"
       },
       "states": {
         "enable": [