Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected materialFromJson(key: string): RenderMaterial | undefined {
if (this._renderMaterials === undefined || this._renderMaterials[key] === undefined)
return undefined;
let material = this._system.findMaterial(key, this._iModel);
if (!material) {
const materialJson = this._renderMaterials[key];
const materialParams = new RenderMaterial.Params(key);
materialParams.diffuseColor = this.colorDefFromMaterialJson(materialJson.diffuseColor);
if (materialJson.diffuse !== undefined)
materialParams.diffuse = JsonUtils.asDouble(materialJson.diffuse);
materialParams.specularColor = this.colorDefFromMaterialJson(materialJson.specularColor);
if (materialJson.specular !== undefined)
materialParams.specular = JsonUtils.asDouble(materialJson.specular);
materialParams.reflectColor = this.colorDefFromMaterialJson(materialJson.reflectColor);
if (materialJson.reflect !== undefined)
materialParams.reflect = JsonUtils.asDouble(materialJson.reflect);
if (materialJson.specularExponent !== undefined)
materialParams.specularExponent = materialJson.specularExponent;
if (undefined !== materialJson.transparency)
materialParams.alpha = 1.0 - materialJson.transparency;
materialParams.refract = JsonUtils.asDouble(materialJson.refract);
materialParams.shadows = JsonUtils.asBool(materialJson.shadows);
materialParams.ambient = JsonUtils.asDouble(materialJson.ambient);
protected materialFromJson(key: string): RenderMaterial | undefined {
if (this._renderMaterials === undefined || this._renderMaterials[key] === undefined)
return undefined;
let material = this._system.findMaterial(key, this._iModel);
if (!material) {
const materialJson = this._renderMaterials[key];
const materialParams = new RenderMaterial.Params(key);
materialParams.diffuseColor = this.colorDefFromMaterialJson(materialJson.diffuseColor);
if (materialJson.diffuse !== undefined)
materialParams.diffuse = JsonUtils.asDouble(materialJson.diffuse);
materialParams.specularColor = this.colorDefFromMaterialJson(materialJson.specularColor);
if (materialJson.specular !== undefined)
materialParams.specular = JsonUtils.asDouble(materialJson.specular);
materialParams.reflectColor = this.colorDefFromMaterialJson(materialJson.reflectColor);
if (materialJson.reflect !== undefined)
materialParams.reflect = JsonUtils.asDouble(materialJson.reflect);
if (materialJson.specularExponent !== undefined)
materialParams.specularExponent = materialJson.specularExponent;
if (undefined !== materialJson.transparency)
materialParams.alpha = 1.0 - materialJson.transparency;
materialParams.refract = JsonUtils.asDouble(materialJson.refract);
materialParams.shadows = JsonUtils.asBool(materialJson.shadows);
materialParams.ambient = JsonUtils.asDouble(materialJson.ambient);
if (undefined !== materialJson.textureMapping)
materialParams.textureMapping = this.textureMappingFromJson(materialJson.textureMapping.texture);
const materialParams = new RenderMaterial.Params(key);
materialParams.diffuseColor = this.colorDefFromMaterialJson(materialJson.diffuseColor);
if (materialJson.diffuse !== undefined)
materialParams.diffuse = JsonUtils.asDouble(materialJson.diffuse);
materialParams.specularColor = this.colorDefFromMaterialJson(materialJson.specularColor);
if (materialJson.specular !== undefined)
materialParams.specular = JsonUtils.asDouble(materialJson.specular);
materialParams.reflectColor = this.colorDefFromMaterialJson(materialJson.reflectColor);
if (materialJson.reflect !== undefined)
materialParams.reflect = JsonUtils.asDouble(materialJson.reflect);
if (materialJson.specularExponent !== undefined)
materialParams.specularExponent = materialJson.specularExponent;
if (materialJson.transparency !== undefined)
materialParams.transparency = materialJson.transparency;
materialParams.refract = JsonUtils.asDouble(materialJson.refract);
materialParams.shadows = JsonUtils.asBool(materialJson.shadows);
materialParams.ambient = JsonUtils.asDouble(materialJson.ambient);
if (undefined !== materialJson.textureMapping)
materialParams.textureMapping = this.textureMappingFromJson(materialJson.textureMapping.texture);
material = this._system.createMaterial(materialParams, this._iModel);
}
return material;
}
constructor(opts?: LightProps) {
opts = opts ? opts : {};
this.lightType = JsonUtils.asInt(opts.lightType);
this.intensity = JsonUtils.asDouble(opts.intensity);
this.kelvin = JsonUtils.asDouble(opts.kelvin);
this.shadows = JsonUtils.asDouble(opts.shadows);
this.bulbs = JsonUtils.asInt(opts.bulbs);
this.lumens = JsonUtils.asDouble(opts.lumens);
this.color = ColorDef.fromJSON(opts.color);
if (opts.intensity2)
this.intensity2 = JsonUtils.asDouble(opts.intensity2);
if (opts.color2)
this.color2 = ColorDef.fromJSON(opts.color2);
}
materialParams.specularColor = this.colorDefFromMaterialJson(materialJson.specularColor);
if (materialJson.specular !== undefined)
materialParams.specular = JsonUtils.asDouble(materialJson.specular);
materialParams.reflectColor = this.colorDefFromMaterialJson(materialJson.reflectColor);
if (materialJson.reflect !== undefined)
materialParams.reflect = JsonUtils.asDouble(materialJson.reflect);
if (materialJson.specularExponent !== undefined)
materialParams.specularExponent = materialJson.specularExponent;
if (undefined !== materialJson.transparency)
materialParams.alpha = 1.0 - materialJson.transparency;
materialParams.refract = JsonUtils.asDouble(materialJson.refract);
materialParams.shadows = JsonUtils.asBool(materialJson.shadows);
materialParams.ambient = JsonUtils.asDouble(materialJson.ambient);
if (undefined !== materialJson.textureMapping)
materialParams.textureMapping = this.textureMappingFromJson(materialJson.textureMapping.texture);
material = this._system.createMaterial(materialParams, this._iModel);
}
return material;
}
protected materialFromJson(key: string): RenderMaterial | undefined {
if (this._renderMaterials === undefined || this._renderMaterials[key] === undefined)
return undefined;
let material = this._system.findMaterial(key, this._iModel);
if (!material) {
const materialJson = this._renderMaterials[key];
const materialParams = new RenderMaterial.Params(key);
materialParams.diffuseColor = this.colorDefFromMaterialJson(materialJson.diffuseColor);
if (materialJson.diffuse !== undefined)
materialParams.diffuse = JsonUtils.asDouble(materialJson.diffuse);
materialParams.specularColor = this.colorDefFromMaterialJson(materialJson.specularColor);
if (materialJson.specular !== undefined)
materialParams.specular = JsonUtils.asDouble(materialJson.specular);
materialParams.reflectColor = this.colorDefFromMaterialJson(materialJson.reflectColor);
if (materialJson.reflect !== undefined)
materialParams.reflect = JsonUtils.asDouble(materialJson.reflect);
if (materialJson.specularExponent !== undefined)
materialParams.specularExponent = materialJson.specularExponent;
if (materialJson.transparency !== undefined)
materialParams.transparency = materialJson.transparency;
materialParams.refract = JsonUtils.asDouble(materialJson.refract);
materialParams.shadows = JsonUtils.asBool(materialJson.shadows);
materialParams.ambient = JsonUtils.asDouble(materialJson.ambient);
if (undefined !== materialJson.textureMapping)
constructor(opts?: LightProps) {
opts = opts ? opts : {};
this.lightType = JsonUtils.asInt(opts.lightType);
this.intensity = JsonUtils.asDouble(opts.intensity);
this.kelvin = JsonUtils.asDouble(opts.kelvin);
this.shadows = JsonUtils.asDouble(opts.shadows);
this.bulbs = JsonUtils.asInt(opts.bulbs);
this.lumens = JsonUtils.asDouble(opts.lumens);
this.color = ColorDef.fromJSON(opts.color);
if (opts.intensity2)
this.intensity2 = JsonUtils.asDouble(opts.intensity2);
if (opts.color2)
this.color2 = ColorDef.fromJSON(opts.color2);
}
if (materialJson.diffuse !== undefined)
materialParams.diffuse = JsonUtils.asDouble(materialJson.diffuse);
materialParams.specularColor = this.colorDefFromMaterialJson(materialJson.specularColor);
if (materialJson.specular !== undefined)
materialParams.specular = JsonUtils.asDouble(materialJson.specular);
materialParams.reflectColor = this.colorDefFromMaterialJson(materialJson.reflectColor);
if (materialJson.reflect !== undefined)
materialParams.reflect = JsonUtils.asDouble(materialJson.reflect);
if (materialJson.specularExponent !== undefined)
materialParams.specularExponent = materialJson.specularExponent;
if (materialJson.transparency !== undefined)
materialParams.transparency = materialJson.transparency;
materialParams.refract = JsonUtils.asDouble(materialJson.refract);
materialParams.shadows = JsonUtils.asBool(materialJson.shadows);
materialParams.ambient = JsonUtils.asDouble(materialJson.ambient);
if (undefined !== materialJson.textureMapping)
materialParams.textureMapping = this.textureMappingFromJson(materialJson.textureMapping.texture);
material = this._system.createMaterial(materialParams, this._iModel);
}
return material;
}
constructor(opts?: LightProps) {
opts = opts ? opts : {};
this.lightType = JsonUtils.asInt(opts.lightType);
this.intensity = JsonUtils.asDouble(opts.intensity);
this.kelvin = JsonUtils.asDouble(opts.kelvin);
this.shadows = JsonUtils.asDouble(opts.shadows);
this.bulbs = JsonUtils.asInt(opts.bulbs);
this.lumens = JsonUtils.asDouble(opts.lumens);
this.color = ColorDef.fromJSON(opts.color);
if (opts.intensity2)
this.intensity2 = JsonUtils.asDouble(opts.intensity2);
if (opts.color2)
this.color2 = ColorDef.fromJSON(opts.color2);
}
constructor(props: SheetProps, iModel: IModelDb) {
super(props, iModel);
this.height = JsonUtils.asDouble(props.height);
this.width = JsonUtils.asDouble(props.width);
this.scale = props.scale;
this.sheetTemplate = props.sheetTemplate ? Id64.fromJSON(props.sheetTemplate) : undefined;
}