How to use the @bentley/imodeljs-common.TextureMapping.Params function in @bentley/imodeljs-common

To help you get started, we’ve selected a few @bentley/imodeljs-common 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
// We will only attempt to include the texture if material is undefined
      let textureMapping;
      if (!material) {
        const textureJson = json.texture;
        textureMapping = undefined !== textureJson ? this.textureMappingFromJson(textureJson) : undefined;

        if (undefined === textureMapping) {
          // Look for a gradient. If defined, create a texture mapping. No reason to pass the Gradient.Symb to the DisplayParams once we have the texture.
          const gradientProps = json.gradient as Gradient.SymbProps;
          const gradient = undefined !== gradientProps ? Gradient.Symb.fromJSON(gradientProps) : undefined;
          if (undefined !== gradient) {
            const texture = this._system.getGradientTexture(gradient, this._iModel);
            if (undefined !== texture) {
              // ###TODO: would be better if DisplayParams created the TextureMapping - but that requires an IModelConnection and a RenderSystem...
              textureMapping = new TextureMapping(texture, new TextureMapping.Params({ textureMat2x3: new TextureMapping.Trans2x3(0, 1, 0, 1, 0, 0) }));
            }
          }
        }
      }

      return new DisplayParams(type, lineColor, fillColor, width, linePixels, fillFlags, material, undefined, ignoreLighting, textureMapping);
    }
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
// We will only attempt to include the texture if material is undefined
      let textureMapping;
      if (!material) {
        const textureJson = json.texture;
        textureMapping = undefined !== textureJson ? this.textureMappingFromJson(textureJson) : undefined;

        if (undefined === textureMapping) {
          // Look for a gradient. If defined, create a texture mapping. No reason to pass the Gradient.Symb to the DisplayParams once we have the texture.
          const gradientProps = json.gradient as Gradient.SymbProps;
          const gradient = undefined !== gradientProps ? Gradient.Symb.fromJSON(gradientProps) : undefined;
          if (undefined !== gradient) {
            const texture = this._system.getGradientTexture(gradient, this._iModel);
            if (undefined !== texture) {
              // ###TODO: would be better if DisplayParams created the TextureMapping - but that requires an IModelConnection and a RenderSystem...
              textureMapping = new TextureMapping(texture, new TextureMapping.Params({ textureMat2x3: new TextureMapping.Trans2x3(0, 1, 0, 1, 0, 0) }));
            }
          }
        }
      }

      return new DisplayParams(type, lineColor, fillColor, width, linePixels, fillFlags, material, undefined, ignoreLighting, textureMapping);
    }
github imodeljs / imodeljs / core / frontend / src / render / primitives / DisplayParams.ts View on Github external
public static createForType(type: DisplayParams.Type, gf: GraphicParams, resolveGradient?: (grad: Gradient.Symb) => RenderTexture | undefined): DisplayParams {
    const lineColor = DisplayParams.adjustTransparencyInPlace(gf.lineColor.clone());
    switch (type) {
      case DisplayParams.Type.Mesh: {
        let gradientMapping: TextureMapping | undefined;
        if (undefined !== gf.gradient && undefined !== resolveGradient) {
          const gradientTexture = resolveGradient(gf.gradient);
          if (undefined !== gradientTexture)
            gradientMapping = new TextureMapping(gradientTexture, new TextureMapping.Params());
        }
        return new DisplayParams(type, lineColor, DisplayParams.adjustTransparencyInPlace(gf.fillColor.clone()), gf.rasterWidth, gf.linePixels, gf.fillFlags, gf.material, gf.gradient, false, gradientMapping);
      }
      case DisplayParams.Type.Linear:
        return new DisplayParams(type, lineColor, lineColor, gf.rasterWidth, gf.linePixels);
      default: // DisplayParams.Type.Text
        return new DisplayParams(type, lineColor, lineColor, 0, LinePixels.Solid, FillFlags.Always, undefined, undefined, true);
    }
  }
github imodeljs / imodeljs / core / frontend / src / tile / IModelTileIO.ts View on Github external
const texture = undefined !== namedTex ? namedTex.renderTexture as RenderTexture : undefined;
      if (undefined === texture) {
        assert(false, "bad texture mapping json");
        return undefined;
      }

      const paramsJson = json.params;
      const tf = paramsJson.transform;
      const paramProps: TextureMapping.ParamProps = {
        textureMat2x3: new TextureMapping.Trans2x3(tf[0][0], tf[0][1], tf[0][2], tf[1][0], tf[1][1], tf[1][2]),
        textureWeight: JsonUtils.asDouble(paramsJson.weight, 1.0),
        mapMode: JsonUtils.asInt(paramsJson.mode),
        worldMapping: JsonUtils.asBool(paramsJson.worldMapping),
      };

      return new TextureMapping(texture, new TextureMapping.Params(paramProps));
    }
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
const name = JsonUtils.asString(json.name);
      const namedTex = 0 !== name.length ? this._namedTextures[name] : undefined;
      const texture = undefined !== namedTex ? namedTex.renderTexture as RenderTexture : undefined;
      if (undefined === texture)
        return undefined;

      const paramsJson = json.params;
      const tf = paramsJson.transform;
      const paramProps: TextureMapping.ParamProps = {
        textureMat2x3: new TextureMapping.Trans2x3(tf[0][0], tf[0][1], tf[0][2], tf[1][0], tf[1][1], tf[1][2]),
        textureWeight: JsonUtils.asDouble(paramsJson.weight, 1.0),
        mapMode: JsonUtils.asInt(paramsJson.mode),
        worldMapping: JsonUtils.asBool(paramsJson.worldMapping),
      };

      return new TextureMapping(texture, new TextureMapping.Params(paramProps));
    }
github imodeljs / imodeljs / core / frontend / src / tile / BingElevation.ts View on Github external
public async getGraphic(latLongRange: Range2d, corners: Point3d[], groundBias: number, texture: RenderTexture, system: RenderSystem): Promise {
    const heights = await this.getHeights(latLongRange);
    if (undefined === heights)
      return undefined;

    const patch = new BilinearPatch(corners[0], corners[1], corners[2], corners[3]);
    const textureParams = new TextureMapping.Params({ mapMode: TextureMapping.Mode.Parametric });
    const textureMapping = new TextureMapping(texture!, textureParams);
    const displayParams = new DisplayParams(DisplayParams.Type.Mesh, ColorDef.white.clone(), ColorDef.white.clone(), 0.0, LinePixels.Solid, FillFlags.None, undefined, undefined, false, textureMapping);
    BingElevationProvider._scratchRange.setNull();
    BingElevationProvider._scratchRange.extendArray(corners);
    BingElevationProvider._scratchRange.low.z = 10E8;
    BingElevationProvider._scratchRange.high.z = -1.0E8;

    for (const height of heights) {
      BingElevationProvider._scratchRange.low.z = Math.min(BingElevationProvider._scratchRange.low.z, height);
      BingElevationProvider._scratchRange.high.z = Math.max(BingElevationProvider._scratchRange.high.z, height);
    }

    BingElevationProvider._scratchRange.low.z += groundBias;
    BingElevationProvider._scratchRange.high.z += groundBias;

    BingElevationProvider._scratchQParams.setFromRange(BingElevationProvider._scratchRange);