diff --git a/utils/converters/fbx2three.js b/utils/converters/fbx2three.js index 72300aa910fc0c87b25e3aafb7d2460ff124f1d0..9d0375724e890abc1fd4b9827353c36c7edaa89d 100644 --- a/utils/converters/fbx2three.js +++ b/utils/converters/fbx2three.js @@ -28,9 +28,13 @@ global.window = { innerWidth: 1024, innerHeight: 768, URL: { + createObjectURL: function () { + throw new Error( 'fbx2three: Images in binary format not yet supported.' ); + } + } }; @@ -40,7 +44,7 @@ THREE.ImageLoader.prototype.load = function ( url, onLoad ) { if ( this.path !== undefined ) url = this.path + url; // If image isn't found, try to ignore it. - if ( !fs.existsSync( url ) ) { + if ( ! fs.existsSync( url ) ) { onLoad( new Buffer( '' ) ); return; @@ -54,7 +58,7 @@ THREE.ImageLoader.prototype.load = function ( url, onLoad ) { // Convert image buffer to data URL. THREE.ImageUtils.getDataURL = function ( image ) { - if ( !( image instanceof Buffer ) ) { + if ( ! ( image instanceof Buffer ) ) { throw new Error( 'fbx2three: Image should be loaded as Buffer.' ); diff --git a/utils/servers/simplehttpserver.js b/utils/servers/simplehttpserver.js index bc38202bedb5cdbb4584309b1b73bb7989e11f3f..df67bcd1d83c3962eb4731a697bfe808d4314977 100644 --- a/utils/servers/simplehttpserver.js +++ b/utils/servers/simplehttpserver.js @@ -13,10 +13,10 @@ */ var port = 8000, - http = require('http'), - urlParser = require('url'), - fs = require('fs'), - path = require('path'), + http = require( 'http' ), + urlParser = require( 'url' ), + fs = require( 'fs' ), + path = require( 'path' ), currentDir = process.cwd(), mimeTypes = { "html": "text/html", @@ -32,88 +32,103 @@ var port = 8000, "bin": "application/octet-stream" }; -port = process.argv[2] ? parseInt(process.argv[2], 0) : port; +port = process.argv[ 2 ] ? parseInt( process.argv[ 2 ], 0 ) : port; -function handleRequest(request, response) { +function handleRequest( request, response ) { - var urlObject = urlParser.parse(request.url, true); - var pathname = decodeURIComponent(urlObject.pathname); + var urlObject = urlParser.parse( request.url, true ); + var pathname = decodeURIComponent( urlObject.pathname ); - console.log('[' + (new Date()).toUTCString() + '] ' + '"' + request.method + ' ' + pathname + '"'); + console.log( '[' + ( new Date() ).toUTCString() + '] ' + '"' + request.method + ' ' + pathname + '"' ); - var filePath = path.join(currentDir, pathname); + var filePath = path.join( currentDir, pathname ); - fs.stat(filePath, function(err, stats) { + fs.stat( filePath, function ( err, stats ) { - if (err) { - response.writeHead(404, {}); - response.end('File not found!'); + if ( err ) { + + response.writeHead( 404, {} ); + response.end( 'File not found!' ); return; + } - if (stats.isFile()) { + if ( stats.isFile() ) { - fs.readFile(filePath, function(err, data) { + fs.readFile( filePath, function ( err, data ) { - if (err) { - response.writeHead(404, {}); - response.end('Opps. Resource not found'); + if ( err ) { + + response.writeHead( 404, {} ); + response.end( 'Opps. Resource not found' ); return; + } - var fileType = filePath.split('.').pop().toLowerCase(); + var fileType = filePath.split( '.' ).pop().toLowerCase(); - response.writeHead(200, { - "Content-Type": mimeTypes[fileType] || mimeTypes['bin'] + response.writeHead( 200, { + "Content-Type": mimeTypes[ fileType ] || mimeTypes[ 'bin' ] } ); - response.write(data); + response.write( data ); response.end(); - }); + } ); - } else if (stats.isDirectory()) { + } else if ( stats.isDirectory() ) { - fs.readdir(filePath, function(error, files) { + fs.readdir( filePath, function ( error, files ) { - if (error) { - response.writeHead(500, {}); + if ( error ) { + + response.writeHead( 500, {} ); response.end(); return; + } var l = pathname.length; - if (pathname.substring(l-1)!='/') pathname += '/'; + if ( pathname.substring( l - 1 ) != '/' ) pathname += '/'; - response.writeHead(200, {'Content-Type': 'text/html'}); - response.write('\n