Created
April 23, 2016 04:27
-
-
Save AndrewRayCode/15340499495afea654e45d9ace113d28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
var filename = path.resolve( __dirname, process.argv[ 2 ] ); | |
var contents = require( filename ); | |
// First delete the useless animations key that crashes the object loader | |
// https://github.com/mrdoob/three.js/issues/8723 | |
delete contents.animations; | |
contents.geometries = contents.geometries.map(function( geometry ) { | |
var morphTargets = geometry.data.morphTargets; | |
// Fix morphTargets, which are exported as [ [x,y,z], [x,y,z]... ] but | |
// should be [ x,y,z,x,y,z... ] | |
// see https://github.com/mrdoob/three.js/issues/7724 | |
if( morphTargets && morphTargets.length ) { | |
geometry.data.morphTargets = morphTargets.map(function( data ) { | |
var vertices = [].concat.apply( [], data.vertices ); | |
return { | |
name: data.name, | |
vertices: vertices | |
}; | |
}); | |
} | |
return geometry; | |
}); | |
fs.writeFile( filename, JSON.stringify( contents, null, 2 ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Warning this will overwrite the original file you pass in!!