提交 7eef51a2 编写于 作者: B bdysvik

updating the snowflake example so that it is compatible with latest glTF specification

上级 e4a46ae5
...@@ -1241,7 +1241,9 @@ THREE.GLTFLoader = ( function () { ...@@ -1241,7 +1241,9 @@ THREE.GLTFLoader = ( function () {
var attributes = primitive.attributes; var attributes = primitive.attributes;
_each( attributes, function( attributeEntry, attributeId ) { for ( var attributeId in attributes ) {
var attributeEntry = attributes[ attributeId ];
if ( !attributeEntry ) { if ( !attributeEntry ) {
...@@ -1257,13 +1259,15 @@ THREE.GLTFLoader = ( function () { ...@@ -1257,13 +1259,15 @@ THREE.GLTFLoader = ( function () {
geometry.addAttribute( 'position', bufferAttribute ); geometry.addAttribute( 'position', bufferAttribute );
break; break;
case 'COLOR_0':
case 'COLOR0':
case 'COLOR': case 'COLOR':
geometry.addAttribute( 'color', bufferAttribute ); geometry.addAttribute( 'color', bufferAttribute );
break; break;
} }
}); };
if ( primitive.indices ) { if ( primitive.indices ) {
......
precision highp float; precision highp float;
varying vec3 vertexColor; varying vec3 v_color;
void main(void) { void main(void) {
gl_FragColor = vec4(vertexColor.r, vertexColor.g, vertexColor.b, 1.0);; gl_FragColor = vec4(v_color.r, v_color.g, v_color.b, 1.0);;
} }
...@@ -3,15 +3,13 @@ precision highp float; ...@@ -3,15 +3,13 @@ precision highp float;
attribute vec3 position; attribute vec3 position;
attribute vec3 color; attribute vec3 color;
varying vec3 v_color;
uniform mat4 modelViewMatrix; uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix; uniform mat4 projectionMatrix;
varying vec3 vertexColor;
void main(void) { void main(void) {
vec4 pos = modelViewMatrix * vec4(position,1.0); vec4 pos = modelViewMatrix * vec4(position,1.0);
vertexColor = vec3(color.x, color.y, color.y); v_color = color;
gl_Position = projectionMatrix * pos; gl_Position = projectionMatrix * pos;
} }
\ No newline at end of file
...@@ -7,6 +7,16 @@ ...@@ -7,6 +7,16 @@
"componentType": 5126, "componentType": 5126,
"count": 257, "count": 257,
"type": "VEC3", "type": "VEC3",
"max": [
250.0,
250.0,
0.0
],
"min": [
-250.0,
-250.0,
0.0
],
"name": "VertexAccessor" "name": "VertexAccessor"
}, },
"ColorAccessor": { "ColorAccessor": {
...@@ -16,9 +26,22 @@ ...@@ -16,9 +26,22 @@
"componentType": 5126, "componentType": 5126,
"count": 257, "count": 257,
"type": "VEC3", "type": "VEC3",
"max": [
0.999963164,
0.99640733,
1.0
],
"min": [
0.500137746,
0.5041365,
1.0
],
"name": "ColorAccessor" "name": "ColorAccessor"
} }
}, },
"asset": {
"version": "1.1"
},
"buffers": { "buffers": {
"Buffer": { "Buffer": {
"uri": "snowFlake.bin", "uri": "snowFlake.bin",
...@@ -58,7 +81,7 @@ ...@@ -58,7 +81,7 @@
{ {
"attributes": { "attributes": {
"POSITION": "VertexAccessor", "POSITION": "VertexAccessor",
"COLOR": "ColorAccessor" "COLOR_0": "ColorAccessor"
}, },
"material": "meshMaterial", "material": "meshMaterial",
"mode": 1 "mode": 1
...@@ -79,8 +102,8 @@ ...@@ -79,8 +102,8 @@
"programs": { "programs": {
"meshProgram": { "meshProgram": {
"attributes": [ "attributes": [
"VertexAccessor", "a_position",
"ColorAccessor" "a_color"
], ],
"fragmentShader": "fragmentShader", "fragmentShader": "fragmentShader",
"vertexShader": "vertexShader", "vertexShader": "vertexShader",
...@@ -112,14 +135,32 @@ ...@@ -112,14 +135,32 @@
"techniques": { "techniques": {
"meshTechnique": { "meshTechnique": {
"parameters": { "parameters": {
"modelViewMatrixParameter": {
"type": 35676,
"semantic": "MODELVIEW"
},
"projectionMatrixParameter": {
"type": 35676,
"semantic": "PROJECTION"
},
"position": {
"type": 35665,
"semantic": "POSITION"
},
"color": { "color": {
"type": 35665, "type": 35665,
"semantic": "color" "semantic": "COLOR_0"
} }
}, },
"attributes": {}, "attributes": {
"a_position": "position",
"a_color": "color"
},
"program": "meshProgram", "program": "meshProgram",
"uniforms": {}, "uniforms": {
"modelViewMatrix": "modelViewMatrixParameter",
"projectionMatrix": "projectionMatrixParameter"
},
"states": { "states": {
"enable": [ "enable": [
3042, 3042,
......
precision highp float; precision highp float;
varying vec3 vertexColor; varying vec3 v_color;
void main(void) { void main(void) {
gl_FragColor = vec4(vertexColor.r, vertexColor.g, vertexColor.b, 1.0);; gl_FragColor = vec4(v_color.r, v_color.g, v_color.b, 1.0);;
} }
...@@ -3,15 +3,13 @@ precision highp float; ...@@ -3,15 +3,13 @@ precision highp float;
attribute vec3 position; attribute vec3 position;
attribute vec3 color; attribute vec3 color;
varying vec3 v_color;
uniform mat4 modelViewMatrix; uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix; uniform mat4 projectionMatrix;
varying vec3 vertexColor;
void main(void) { void main(void) {
vec4 pos = modelViewMatrix * vec4(position,1.0); vec4 pos = modelViewMatrix * vec4(position,1.0);
vertexColor = vec3(color.x, color.y, color.y); v_color = color;
gl_Position = projectionMatrix * pos; gl_Position = projectionMatrix * pos;
} }
\ No newline at end of file
...@@ -7,16 +7,32 @@ ...@@ -7,16 +7,32 @@
"componentType": 5126, "componentType": 5126,
"count": 1376, "count": 1376,
"type": "VEC3", "type": "VEC3",
"max": [
2300.0,
2450.0,
0.0
],
"min": [
0.0,
0.0,
0.0
],
"name": "VertexAccessor" "name": "VertexAccessor"
}, },
"TriangleAccessor": { "LineAccessor": {
"bufferView": "Lines", "bufferView": "LineView",
"byteOffset": 0, "byteOffset": 0,
"byteStride": 2, "byteStride": 2,
"componentType": 5123, "componentType": 5123,
"count": 2720, "count": 2720,
"type": "SCALAR", "type": "SCALAR",
"name": "TriangleAccessor" "max": [
1374.0
],
"min": [
0.0
],
"name": "LineAccessor"
}, },
"ColorAccessor": { "ColorAccessor": {
"bufferView": "ColorView", "bufferView": "ColorView",
...@@ -25,9 +41,22 @@ ...@@ -25,9 +41,22 @@
"componentType": 5126, "componentType": 5126,
"count": 1376, "count": 1376,
"type": "VEC3", "type": "VEC3",
"max": [
0.999963164,
0.999615431,
1.0
],
"min": [
0.500137746,
0.5002869,
1.0
],
"name": "ColorAccessor" "name": "ColorAccessor"
} }
}, },
"asset": {
"version": "1.1"
},
"buffers": { "buffers": {
"Buffer": { "Buffer": {
"uri": "snowFlakes.bin", "uri": "snowFlakes.bin",
...@@ -45,12 +74,12 @@ ...@@ -45,12 +74,12 @@
"target": 34962, "target": 34962,
"name": "VertexBuffer" "name": "VertexBuffer"
}, },
"Lines": { "LineView": {
"buffer": "Buffer", "buffer": "Buffer",
"byteOffset": 16512, "byteOffset": 16512,
"byteLength": 5440, "byteLength": 5440,
"target": 34962, "target": 34963,
"name": "Lines" "name": "LineView"
}, },
"ColorView": { "ColorView": {
"buffer": "Buffer", "buffer": "Buffer",
...@@ -74,9 +103,9 @@ ...@@ -74,9 +103,9 @@
{ {
"attributes": { "attributes": {
"POSITION": "VertexAccessor", "POSITION": "VertexAccessor",
"COLOR": "ColorAccessor" "COLOR_0": "ColorAccessor"
}, },
"indices": "TriangleAccessor", "indices": "LineAccessor",
"material": "meshMaterial", "material": "meshMaterial",
"mode": 1 "mode": 1
} }
...@@ -96,8 +125,8 @@ ...@@ -96,8 +125,8 @@
"programs": { "programs": {
"meshProgram": { "meshProgram": {
"attributes": [ "attributes": [
"VertexAccessor", "a_position",
"ColorAccessor" "a_color"
], ],
"fragmentShader": "fragmentShader", "fragmentShader": "fragmentShader",
"vertexShader": "vertexShader", "vertexShader": "vertexShader",
...@@ -129,14 +158,32 @@ ...@@ -129,14 +158,32 @@
"techniques": { "techniques": {
"meshTechnique": { "meshTechnique": {
"parameters": { "parameters": {
"modelViewMatrixParameter": {
"type": 35676,
"semantic": "MODELVIEW"
},
"projectionMatrixParameter": {
"type": 35676,
"semantic": "PROJECTION"
},
"position": {
"type": 35665,
"semantic": "POSITION"
},
"color": { "color": {
"type": 35665, "type": 35665,
"semantic": "color" "semantic": "COLOR_0"
} }
}, },
"attributes": {}, "attributes": {
"a_position": "position",
"a_color": "color"
},
"program": "meshProgram", "program": "meshProgram",
"uniforms": {}, "uniforms": {
"modelViewMatrix": "modelViewMatrixParameter",
"projectionMatrix": "projectionMatrixParameter"
},
"states": { "states": {
"enable": [ "enable": [
3042, 3042,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册