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