"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ig_utilities_1 = require("@intelligentgraphics/ig.utilities");
var PreviewPrefix = "PREVIEW_";
exports.createIGXC = function (igxc) {
    var e_1, _a;
    var materials = {};
    for (var materialName in igxc.Materials) {
        var material = igxc.Materials[materialName];
        if (!ig_utilities_1.isNullOrUndefined(material)) {
            materials[materialName] = exports.createMaterial(material);
        }
    }
    var geometries = {};
    for (var geometryName in igxc.GeometryPreviews) {
        var previewGeometryName = exports.createResourceName(geometryName);
        var geometry = igxc.GeometryPreviews[geometryName];
        geometries[previewGeometryName] = geometry;
    }
    var objects = [];
    try {
        for (var _b = tslib_1.__values(igxc.Objects), _c = _b.next(); !_c.done; _c = _b.next()) {
            var object = _c.value;
            objects.push(tslib_1.__assign(tslib_1.__assign({}, object), { Geometry: ig_utilities_1.isNullOrUndefined(object.Geometry)
                    ? undefined
                    : exports.createResourceName(object.Geometry), AOTransform: undefined }));
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
        }
        finally { if (e_1) throw e_1.error; }
    }
    return tslib_1.__assign(tslib_1.__assign({}, igxc), { Objects: objects, Materials: materials, GeometryNormalMaps: {}, GeometryPreviews: {}, Geometries: geometries, GeometryDeformations: {}, Scripts: [], ObjectAmbientOcclusionMaps: {} });
};
exports.createMaterial = function (material) { return ({
    name: undefined,
    Texture: undefined,
    Mapping: undefined,
    Shininess: 0,
    SpecularR: 0,
    SpecularG: 0,
    SpecularB: 0,
    GeoNormalScaleU: material.GeoNormalScaleU,
    GeoNormalScaleV: material.GeoNormalScaleV,
    Transparency: material.Transparency,
    EmissiveB: material.EmissiveB,
    EmissiveG: material.EmissiveG,
    EmissiveR: material.EmissiveR,
    DiffuseR: material.DiffuseR,
    DiffuseG: material.DiffuseG,
    DiffuseB: material.DiffuseB,
    Ambient: material.Ambient,
    Diffuse: undefined,
    Normal: undefined,
    Specular: undefined,
    Alpha: undefined,
    Roughness: undefined,
    Metalness: undefined,
    Bump: undefined,
    AO: undefined,
    Meta: { Taxonomy: {} },
}); };
exports.createResourceName = function (name) { return PreviewPrefix + name; };
