diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js
index 6878e9bd62a1f9ad351f6dc33d99e4bc2cbeebe9..78587542cd6b43674fc300184a13b1d16f5609e5 100644
--- a/examples/js/loaders/GLTFLoader.js
+++ b/examples/js/loaders/GLTFLoader.js
@@ -301,6 +301,7 @@ THREE.GLTFLoader = ( function () {
REPEAT: 10497,
SAMPLER_2D: 35678,
TRIANGLES: 4,
+ LINES: 1,
UNSIGNED_BYTE: 5121,
UNSIGNED_SHORT: 5123,
@@ -1227,14 +1228,76 @@ THREE.GLTFLoader = ( function () {
var meshNode = new THREE.Mesh( geometry, material );
meshNode.castShadow = true;
+
+ if ( primitive.extras ) meshNode.userData = primitive.extras;
+
+ group.add( meshNode );
+
+ }
+
+ else if ( primitive.mode === WEBGL_CONSTANTS.LINES) {
+
+ var geometry = new THREE.BufferGeometry();
+
+ var attributes = primitive.attributes;
+
+ _each( attributes, function( attributeEntry, attributeId ) {
+
+ if ( !attributeEntry ) {
+
+ return;
+
+ }
+
+ var bufferAttribute = dependencies.accessors[ attributeEntry ];
+
+ switch ( attributeId ) {
+
+ case 'POSITION':
+ geometry.addAttribute( 'position', bufferAttribute );
+ break;
+
+ case 'COLOR':
+ geometry.addAttribute( 'color', bufferAttribute );
+ break;
+
+ }
+
+ });
+
+ if ( primitive.indices ) {
+
+ var indexArray = dependencies.accessors[ primitive.indices ];
+
+ if(indexArray) {
+
+ geometry.setIndex(indexArray);
+
+ var offset = {
+ start: 0,
+ index: 0,
+ count: indexArray.count
+ };
+
+ geometry.groups.push(offset);
+ geometry.computeBoundingSphere();
+ }
+ }
+
+ var material = dependencies.materials[ primitive.material ];
+
+ var meshNode = new THREE.Line( geometry, material );
+ if ( primitive.indices ) meshNode = new THREE.LineSegments( geometry, material );
if ( primitive.extras ) meshNode.userData = primitive.extras;
group.add( meshNode );
- } else {
+ }
+
+ else {
- console.warn( "Non-triangular primitives are not supported" );
+ console.warn( "Only triangular and line primitives are supported" );
}
@@ -1474,8 +1537,13 @@ THREE.GLTFLoader = ( function () {
material = originalMaterial;
}
-
- child = new THREE.Mesh( originalGeometry, material );
+ if(child.type=="Line") {
+ child = new THREE.Line(originalGeometry, material);
+ }
+ else if(child.type=="LineSegments") {
+ child = new THREE.LineSegments(originalGeometry, material);
+ }
+ else child = new THREE.Mesh( originalGeometry, material );
child.castShadow = true;
child.userData = originalUserData;
diff --git a/examples/models/gltf/snowflake/line_frag.glsl b/examples/models/gltf/snowflake/line_frag.glsl
new file mode 100644
index 0000000000000000000000000000000000000000..b3b1579fd29caa681b52a1fd257f2ff9966f8cf1
--- /dev/null
+++ b/examples/models/gltf/snowflake/line_frag.glsl
@@ -0,0 +1,8 @@
+precision highp float;
+varying vec3 vertexColor;
+
+void main(void) {
+
+ gl_FragColor = vec4(vertexColor.r, vertexColor.g, vertexColor.b, 1.0);;
+
+}
diff --git a/examples/models/gltf/snowflake/line_vert.glsl b/examples/models/gltf/snowflake/line_vert.glsl
new file mode 100644
index 0000000000000000000000000000000000000000..f74e0094b086bcd0fa58145d4f639e817240c696
--- /dev/null
+++ b/examples/models/gltf/snowflake/line_vert.glsl
@@ -0,0 +1,17 @@
+precision highp float;
+
+attribute vec3 position;
+attribute vec3 color;
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+
+varying vec3 vertexColor;
+
+void main(void) {
+
+ vec4 pos = modelViewMatrix * vec4(position,1.0);
+ vertexColor = vec3(color.x, color.y, color.y);
+ gl_Position = projectionMatrix * pos;
+
+}
\ No newline at end of file
diff --git a/examples/models/gltf/snowflake/snowFlake.bin b/examples/models/gltf/snowflake/snowFlake.bin
new file mode 100644
index 0000000000000000000000000000000000000000..d71c78fb2c5976e1ed7ab43a20537cb294cd8170
Binary files /dev/null and b/examples/models/gltf/snowflake/snowFlake.bin differ
diff --git a/examples/models/gltf/snowflake/snowFlake.gltf b/examples/models/gltf/snowflake/snowFlake.gltf
new file mode 100644
index 0000000000000000000000000000000000000000..ff8ed60eb1f0a7665516cfd532178141e22b1ebd
--- /dev/null
+++ b/examples/models/gltf/snowflake/snowFlake.gltf
@@ -0,0 +1,133 @@
+{
+ "accessors": {
+ "VertexAccessor": {
+ "bufferView": "VertexBuffer",
+ "byteOffset": 0,
+ "byteStride": 12,
+ "componentType": 5126,
+ "count": 257,
+ "type": "VEC3",
+ "name": "VertexAccessor"
+ },
+ "ColorAccessor": {
+ "bufferView": "ColorView",
+ "byteOffset": 0,
+ "byteStride": 12,
+ "componentType": 5126,
+ "count": 257,
+ "type": "VEC3",
+ "name": "ColorAccessor"
+ }
+ },
+ "buffers": {
+ "Buffer": {
+ "uri": "snowFlake.bin",
+ "byteLength": 6168,
+ "type": "arraybuffer",
+ "name": "Buffer",
+ "extensions": {}
+ }
+ },
+ "bufferViews": {
+ "VertexBuffer": {
+ "buffer": "Buffer",
+ "byteOffset": 0,
+ "byteLength": 3084,
+ "target": 34962,
+ "name": "VertexBuffer"
+ },
+ "ColorView": {
+ "buffer": "Buffer",
+ "byteOffset": 3084,
+ "byteLength": 3084,
+ "target": 34962,
+ "name": "ColorView"
+ }
+ },
+ "images": {},
+ "materials": {
+ "meshMaterial": {
+ "technique": "meshTechnique",
+ "values": {},
+ "name": "meshMaterial"
+ }
+ },
+ "meshes": {
+ "mesh": {
+ "primitives": [
+ {
+ "attributes": {
+ "POSITION": "VertexAccessor",
+ "COLOR": "ColorAccessor"
+ },
+ "material": "meshMaterial",
+ "mode": 1
+ }
+ ],
+ "name": "mesh"
+ }
+ },
+ "nodes": {
+ "node1": {
+ "children": [],
+ "meshes": [
+ "mesh"
+ ],
+ "name": "node1"
+ }
+ },
+ "programs": {
+ "meshProgram": {
+ "attributes": [
+ "VertexAccessor",
+ "ColorAccessor"
+ ],
+ "fragmentShader": "fragmentShader",
+ "vertexShader": "vertexShader",
+ "name": "shader"
+ }
+ },
+ "samplers": {},
+ "scene": "default scene",
+ "scenes": {
+ "default scene": {
+ "nodes": [
+ "node1"
+ ],
+ "name": "default scene"
+ }
+ },
+ "shaders": {
+ "fragmentShader": {
+ "uri": "line_frag.glsl",
+ "type": 35632,
+ "name": "fragmentShader"
+ },
+ "vertexShader": {
+ "uri": "line_vert.glsl",
+ "type": 35633,
+ "name": "vertexShader"
+ }
+ },
+ "techniques": {
+ "meshTechnique": {
+ "parameters": {
+ "color": {
+ "type": 35665,
+ "semantic": "color"
+ }
+ },
+ "attributes": {},
+ "program": "meshProgram",
+ "uniforms": {},
+ "states": {
+ "enable": [
+ 3042,
+ 2929
+ ]
+ },
+ "name": "meshTechnique"
+ }
+ },
+ "textures": {}
+}
\ No newline at end of file
diff --git a/examples/models/gltf/snowflakes/line_frag.glsl b/examples/models/gltf/snowflakes/line_frag.glsl
new file mode 100644
index 0000000000000000000000000000000000000000..b3b1579fd29caa681b52a1fd257f2ff9966f8cf1
--- /dev/null
+++ b/examples/models/gltf/snowflakes/line_frag.glsl
@@ -0,0 +1,8 @@
+precision highp float;
+varying vec3 vertexColor;
+
+void main(void) {
+
+ gl_FragColor = vec4(vertexColor.r, vertexColor.g, vertexColor.b, 1.0);;
+
+}
diff --git a/examples/models/gltf/snowflakes/line_vert.glsl b/examples/models/gltf/snowflakes/line_vert.glsl
new file mode 100644
index 0000000000000000000000000000000000000000..f74e0094b086bcd0fa58145d4f639e817240c696
--- /dev/null
+++ b/examples/models/gltf/snowflakes/line_vert.glsl
@@ -0,0 +1,17 @@
+precision highp float;
+
+attribute vec3 position;
+attribute vec3 color;
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+
+varying vec3 vertexColor;
+
+void main(void) {
+
+ vec4 pos = modelViewMatrix * vec4(position,1.0);
+ vertexColor = vec3(color.x, color.y, color.y);
+ gl_Position = projectionMatrix * pos;
+
+}
\ No newline at end of file
diff --git a/examples/models/gltf/snowflakes/snowFlakes.bin b/examples/models/gltf/snowflakes/snowFlakes.bin
new file mode 100644
index 0000000000000000000000000000000000000000..13d5228418dddf41788ff719291d2ae164e4ad4f
Binary files /dev/null and b/examples/models/gltf/snowflakes/snowFlakes.bin differ
diff --git a/examples/models/gltf/snowflakes/snowFlakes.gltf b/examples/models/gltf/snowflakes/snowFlakes.gltf
new file mode 100644
index 0000000000000000000000000000000000000000..a7096a432619466a67dd1d79bc6359984d683ddf
--- /dev/null
+++ b/examples/models/gltf/snowflakes/snowFlakes.gltf
@@ -0,0 +1,150 @@
+{
+ "accessors": {
+ "VertexAccessor": {
+ "bufferView": "VertexBuffer",
+ "byteOffset": 0,
+ "byteStride": 12,
+ "componentType": 5126,
+ "count": 1376,
+ "type": "VEC3",
+ "name": "VertexAccessor"
+ },
+ "TriangleAccessor": {
+ "bufferView": "Lines",
+ "byteOffset": 0,
+ "byteStride": 2,
+ "componentType": 5123,
+ "count": 2720,
+ "type": "SCALAR",
+ "name": "TriangleAccessor"
+ },
+ "ColorAccessor": {
+ "bufferView": "ColorView",
+ "byteOffset": 0,
+ "byteStride": 12,
+ "componentType": 5126,
+ "count": 1376,
+ "type": "VEC3",
+ "name": "ColorAccessor"
+ }
+ },
+ "buffers": {
+ "Buffer": {
+ "uri": "snowFlakes.bin",
+ "byteLength": 38464,
+ "type": "arraybuffer",
+ "name": "Buffer",
+ "extensions": {}
+ }
+ },
+ "bufferViews": {
+ "VertexBuffer": {
+ "buffer": "Buffer",
+ "byteOffset": 0,
+ "byteLength": 16512,
+ "target": 34962,
+ "name": "VertexBuffer"
+ },
+ "Lines": {
+ "buffer": "Buffer",
+ "byteOffset": 16512,
+ "byteLength": 5440,
+ "target": 34962,
+ "name": "Lines"
+ },
+ "ColorView": {
+ "buffer": "Buffer",
+ "byteOffset": 21952,
+ "byteLength": 16512,
+ "target": 34962,
+ "name": "ColorView"
+ }
+ },
+ "images": {},
+ "materials": {
+ "meshMaterial": {
+ "technique": "meshTechnique",
+ "values": {},
+ "name": "meshMaterial"
+ }
+ },
+ "meshes": {
+ "mesh": {
+ "primitives": [
+ {
+ "attributes": {
+ "POSITION": "VertexAccessor",
+ "COLOR": "ColorAccessor"
+ },
+ "indices": "TriangleAccessor",
+ "material": "meshMaterial",
+ "mode": 1
+ }
+ ],
+ "name": "mesh"
+ }
+ },
+ "nodes": {
+ "node1": {
+ "children": [],
+ "meshes": [
+ "mesh"
+ ],
+ "name": "node1"
+ }
+ },
+ "programs": {
+ "meshProgram": {
+ "attributes": [
+ "VertexAccessor",
+ "ColorAccessor"
+ ],
+ "fragmentShader": "fragmentShader",
+ "vertexShader": "vertexShader",
+ "name": "shader"
+ }
+ },
+ "samplers": {},
+ "scene": "default scene",
+ "scenes": {
+ "default scene": {
+ "nodes": [
+ "node1"
+ ],
+ "name": "default scene"
+ }
+ },
+ "shaders": {
+ "fragmentShader": {
+ "uri": "line_frag.glsl",
+ "type": 35632,
+ "name": "fragmentShader"
+ },
+ "vertexShader": {
+ "uri": "line_vert.glsl",
+ "type": 35633,
+ "name": "vertexShader"
+ }
+ },
+ "techniques": {
+ "meshTechnique": {
+ "parameters": {
+ "color": {
+ "type": 35665,
+ "semantic": "color"
+ }
+ },
+ "attributes": {},
+ "program": "meshProgram",
+ "uniforms": {},
+ "states": {
+ "enable": [
+ 3042,
+ 2929
+ ]
+ },
+ "name": "meshTechnique"
+ }
+ },
+ "textures": {}
+}
\ No newline at end of file
diff --git a/examples/webgl_loader_gltf.html b/examples/webgl_loader_gltf.html
index 45589d3ca601ac7e5721acf51571f40511aeb8ae..0c7c524b30b024563a46ae371faccecab9f88ade 100644
--- a/examples/webgl_loader_gltf.html
+++ b/examples/webgl_loader_gltf.html
@@ -94,7 +94,7 @@
glTF loader -
monster by 3drt -
- COLLADA duck by Sony - other models courtesy Cesium
+ COLLADA duck by Sony - Cesium models courtesy Cesium