Use different read-line library

This commit is contained in:
Sean Lilley 2016-06-23 22:35:07 -04:00
parent 139f473785
commit 388f9928c3
2 changed files with 8 additions and 15 deletions

View File

@ -1,8 +1,8 @@
"use strict";
var async = require('async');
var byline = require('byline');
var fs = require('fs-extra');
var path = require('path');
var readline = require('readline');
var loadImage = require('./image');
var Material = require('./mtl');
var Cesium = require('cesium');
@ -163,12 +163,8 @@ function processObj(objFile, info, materials, images, done) {
// f vertex//normal vertex//normal vertex//normal ...
var facePattern4 = /f( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))?/;
var stream = fs.createReadStream(objFile, 'utf8');
var reader = readline.createInterface({
input : stream
});
reader.on('line', function(line) {
var stream = byline(fs.createReadStream(objFile, {encoding: 'utf8'}));
stream.on('data', function(line) {
line = line.trim();
var result;
if ((line.length === 0) || (line.charAt(0) === '#')) {
@ -224,7 +220,7 @@ function processObj(objFile, info, materials, images, done) {
}
});
reader.on('close', function() {
stream.on('end', function() {
done({
vertexCount : vertexCount,
vertexArray : vertexArray,
@ -301,12 +297,8 @@ function getObjInfo(objFile, inputPath, done) {
var hasNormals = false;
var hasUVs = false;
var stream = fs.createReadStream(objFile, 'utf8');
var reader = readline.createInterface({
input : stream
});
reader.on('line', function(line) {
var stream = byline(fs.createReadStream(objFile, {encoding: 'utf8'}));
stream.on('data', function(line) {
if (!defined(mtlPath)) {
var mtllibMatches = line.match(/^mtllib.*/gm);
if (mtllibMatches !== null) {
@ -331,7 +323,7 @@ function getObjInfo(objFile, inputPath, done) {
}
});
reader.on('close', function() {
stream.on('end', function() {
if (!hasPositions) {
throw new Error('Could not process OBJ file, no positions.');
}

View File

@ -25,6 +25,7 @@
},
"dependencies": {
"async": "^1.4.2",
"byline": "^4.2.1",
"cesium": "^1.22.0",
"fs-extra": "^0.30.0",
"gltf-pipeline": "git://github.com/AnalyticalGraphicsInc/gltf-pipeline.git",