Formatting-only change.

This commit is contained in:
Par Winzell 2019-02-23 23:51:05 -08:00
parent e83d495fdc
commit a3841fe7cd
1 changed files with 62 additions and 62 deletions

View File

@ -1,76 +1,76 @@
import { readFileSync } from 'fs'; import {assert, expect} from 'chai';
import * as tmp from 'tmp';
import * as path from 'path';
import * as fbx2gltf from 'fbx2gltf'; import * as fbx2gltf from 'fbx2gltf';
import { assert, expect } from 'chai'; import {readFileSync} from 'fs';
import { validateBytes } from 'gltf-validator'; import {validateBytes} from 'gltf-validator';
import * as path from 'path';
import * as tmp from 'tmp';
interface Model { interface Model {
path: string; path: string;
ignoredIssues?: Array<string>; ignoredIssues?: Array<string>;
args?: Array<string>; args?: Array<string>;
} }
const MODELS :Array<Model> = [ const MODELS: Array<Model> = [
{ path: 'fromFacebook/Jon/jon_morph' }, {path : 'fromFacebook/Jon/jon_morph'},
{ {
path: 'fromFacebook/Jon/troll-final', path : 'fromFacebook/Jon/troll-final',
ignoredIssues: [ 'ACCESSOR_NON_UNIT' ], ignoredIssues : [ 'ACCESSOR_NON_UNIT' ],
}, },
{ path: 'fromFacebook/Natalie/GlitchRobot' }, {path : 'fromFacebook/Natalie/GlitchRobot'},
{ path: 'fromFacebook/Ocean/blackvan/blackvan_with_windows' }, {path : 'fromFacebook/Ocean/blackvan/blackvan_with_windows'},
{ path: 'fromFacebook/Ocean/zell_van_vertex_color' }, {path : 'fromFacebook/Ocean/zell_van_vertex_color'},
{ path: 'fromFacebook/RAZ/RAZ_ape' }, {path : 'fromFacebook/RAZ/RAZ_ape'},
{ path: 'fromFbxSDK/Box' }, {path : 'fromFbxSDK/Box'},
{ {
path: 'fromFbxSDK/Humanoid', path : 'fromFbxSDK/Humanoid',
ignoredIssues: [ 'UNSUPPORTED_EXTENSION' ], ignoredIssues : [ 'UNSUPPORTED_EXTENSION' ],
}, },
{ {
path: 'fromFbxSDK/Camera', path : 'fromFbxSDK/Camera',
ignoredIssues: [ 'UNSUPPORTED_EXTENSION' ], ignoredIssues : [ 'UNSUPPORTED_EXTENSION' ],
}, },
{ path: 'fromFbxSDK/Normals' }, {path : 'fromFbxSDK/Normals'},
{ path: 'fromGltfSamples/BoxVertexColors/BoxVertexColors' }, {path : 'fromGltfSamples/BoxVertexColors/BoxVertexColors'},
{ path: 'fromGltfSamples/WaterBottle/NewWaterBottle' }, {path : 'fromGltfSamples/WaterBottle/NewWaterBottle'},
]; ];
const CONVERSION_TIMEOUT_MS = 50000; const CONVERSION_TIMEOUT_MS = 50000;
describe('FBX2glTF', () => { describe('FBX2glTF', () => {
const tmpobj = tmp.dirSync(); const tmpobj = tmp.dirSync();
for(let model of MODELS) { for (let model of MODELS) {
const modelName = path.basename(model.path); const modelName = path.basename(model.path);
describe('Model: ' + modelName, () => { describe('Model: ' + modelName, () => {
const fbxPath = path.join('models', model.path + '.fbx'); const fbxPath = path.join('models', model.path + '.fbx');
let glbBytes; let glbBytes;
it('should convert fbx to glb', async () => { it('should convert fbx to glb', async () => {
const glbPath = path.join(tmpobj.name, modelName + '.glb'); const glbPath = path.join(tmpobj.name, modelName + '.glb');
try { try {
const destPath = await fbx2gltf(fbxPath, glbPath, model.args || []); const destPath = await fbx2gltf(fbxPath, glbPath, model.args || []);
assert.isNotNull(destPath); assert.isNotNull(destPath);
glbBytes = readFileSync(destPath); glbBytes = readFileSync(destPath);
} catch (err) { } catch (err) {
throw new Error('Conversion failed: ' + err); throw new Error('Conversion failed: ' + err);
} }
}).timeout(CONVERSION_TIMEOUT_MS); }).timeout(CONVERSION_TIMEOUT_MS);
it('resulting glb should be valid', async() => { it('resulting glb should be valid', async () => {
try { try {
let options = <any>{}; let options = <any>{};
if (model.ignoredIssues) { if (model.ignoredIssues) {
options.ignoredIssues = model.ignoredIssues; options.ignoredIssues = model.ignoredIssues;
} }
const report = await validateBytes(glbBytes, options); const report = await validateBytes(glbBytes, options);
expect(report.issues.numErrors).to.equal(0); expect(report.issues.numErrors).to.equal(0);
expect(report.issues.numWarnings).to.equal(0); expect(report.issues.numWarnings).to.equal(0);
} catch (err) { } catch (err) {
throw new Error('Validation failed: ' + err); throw new Error('Validation failed: ' + err);
} }
}); });
}); });
} }
console.log('GLB files may be inspected in: ' + tmpobj.name); console.log('GLB files may be inspected in: ' + tmpobj.name);
}); });