|
@@ -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;
|
|
|
|