How to use the @bentley/bentleyjs-core.JsonUtils.asDouble function in @bentley/bentleyjs-core

To help you get started, we’ve selected a few @bentley/bentleyjs-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / core / frontend / src / tile / IModelTileIO.ts View on Github external
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);
github imodeljs / imodeljs / core / frontend / src / tile / IModelTileIO.ts View on Github external
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);
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
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;
    }
github imodeljs / imodeljs / core / common / src / Lighting.ts View on Github external
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);
  }
github imodeljs / imodeljs / core / frontend / src / tile / IModelTileIO.ts View on Github external
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;
    }
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
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)
github imodeljs / imodeljs / core / common / src / Lighting.ts View on Github external
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);
  }
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
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;
    }
github imodeljs / imodeljs / core / common / src / Lighting.ts View on Github external
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);
  }
github imodeljs / imodeljs / core / backend / src / Element.ts View on Github external
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;
  }