How to use the @bentley/imodeljs-common.RenderTexture.Type 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 / render / webgl / SolarShadowMap.ts View on Github external
// shadowMap texture is 1/4 size the depth texture (and averaged down when converting)
    const shadowMapTextureHandle = TextureHandle.createForAttachment(evsmWidth, evsmHeight, GL.Texture.Format.Rgba, pixelDataType);
    if (undefined === shadowMapTextureHandle)
      return undefined;

    const fboSM = FrameBuffer.create([shadowMapTextureHandle]);
    if (undefined === fboSM)
      return undefined;

    const depthTexture = new Texture(new RenderTexture.Params(undefined, RenderTexture.Type.TileSection, true), depthTextureHandle);
    const evsmGeom = EVSMGeometry.createGeometry(depthTexture.texture.getHandle()!, shadowMapWidth, shadowMapHeight);
    if (undefined === evsmGeom)
      return undefined;

    const shadowMapTexture = new Texture(new RenderTexture.Params(undefined, RenderTexture.Type.Normal, true), shadowMapTextureHandle);
    const renderCommands = new RenderCommands(target, stack, batch);
    return new Bundle(depthTexture, shadowMapTexture, fbo, fboSM, evsmGeom, renderCommands);
  }
github imodeljs / imodeljs / core / frontend / src / render / webgl / SolarShadowMap.ts View on Github external
}
      /* falls through */
      default:
        return undefined;
    }

    // shadowMap texture is 1/4 size the depth texture (and averaged down when converting)
    const shadowMapTextureHandle = TextureHandle.createForAttachment(evsmWidth, evsmHeight, GL.Texture.Format.Rgba, pixelDataType);
    if (undefined === shadowMapTextureHandle)
      return undefined;

    const fboSM = FrameBuffer.create([shadowMapTextureHandle]);
    if (undefined === fboSM)
      return undefined;

    const depthTexture = new Texture(new RenderTexture.Params(undefined, RenderTexture.Type.TileSection, true), depthTextureHandle);
    const evsmGeom = EVSMGeometry.createGeometry(depthTexture.texture.getHandle()!, shadowMapWidth, shadowMapHeight);
    if (undefined === evsmGeom)
      return undefined;

    const shadowMapTexture = new Texture(new RenderTexture.Params(undefined, RenderTexture.Type.Normal, true), shadowMapTextureHandle);
    const renderCommands = new RenderCommands(target, stack, batch);
    return new Bundle(depthTexture, shadowMapTexture, fbo, fboSM, evsmGeom, renderCommands);
  }
github imodeljs / imodeljs / core / frontend / src / render / webgl / System.ts View on Github external
public getGradient(grad: Gradient.Symb): RenderTexture | undefined {
    const existingGrad = this.gradients.get(grad);
    if (existingGrad)
      return existingGrad;

    const image: ImageBuffer = grad.getImage(0x100, 0x100);

    const textureHandle = TextureHandle.createForImageBuffer(image, RenderTexture.Type.Normal);
    if (!textureHandle)
      return undefined;

    const params = new Texture.Params(undefined, Texture.Type.Normal, true); // gradient textures are unnamed, but owned by this IdMap.
    const texture = new Texture(params, textureHandle);
    this.addGradient(grad, texture);
    return texture;
  }
github imodeljs / imodeljs / core / frontend / src / render / webgl / PlanarClassifier.ts View on Github external
const useMRT = System.instance.capabilities.supportsDrawBuffers;

    if (undefined === this._fbo) {
      const colorTextureHandle = TextureHandle.createForAttachment(this._width, this._height, GL.Texture.Format.Rgba, GL.Texture.DataType.UnsignedByte);
      const featureTextureHandle = TextureHandle.createForAttachment(this._width, this._height, GL.Texture.Format.Rgba, GL.Texture.DataType.UnsignedByte);
      const combinedTextureHandle = TextureHandle.createForAttachment(this._width, 2 * this._height, GL.Texture.Format.Rgba, GL.Texture.DataType.UnsignedByte);
      if (undefined === colorTextureHandle ||
        undefined === featureTextureHandle ||
        undefined === combinedTextureHandle) {
        assert(false, "Failed to create planar classifier texture");
        return;
      }

      this._colorTexture = new Texture(new RenderTexture.Params(undefined, RenderTexture.Type.TileSection, true), colorTextureHandle);
      this._featureTexture = new Texture(new RenderTexture.Params(undefined, RenderTexture.Type.TileSection, true), featureTextureHandle);
      this._combinedTexture = new Texture(new RenderTexture.Params(undefined, RenderTexture.Type.TileSection, true), combinedTextureHandle);
      if (useMRT)
        this._fbo = FrameBuffer.create([colorTextureHandle, featureTextureHandle]);
      else {
        this._fbo = FrameBuffer.create([colorTextureHandle]);
        this._featureFbo = FrameBuffer.create([featureTextureHandle]);
      }
      this._combinedFbo = FrameBuffer.create([combinedTextureHandle]);
    }

    if (undefined === this._fbo || (!useMRT && undefined === this._featureFbo)) {
      assert(false, "unable to create frame buffer objects");
      return;
    }

    const prevState = System.instance.currentRenderState.clone();
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
return imageElementFromImageSource(imageSource).then((image) => {
        if (this._isCanceled)
          return undefined;

        let textureType = RenderTexture.Type.Normal;
        if (JsonUtils.asBool(namedTex.isGlyph))
          textureType = RenderTexture.Type.Glyph;
        else if (JsonUtils.asBool(namedTex.isTileSection))
          textureType = RenderTexture.Type.TileSection;

        const params = new RenderTexture.Params(name, textureType);
        return this._system.createTextureFromImage(image, ImageSourceFormat.Png === format, this._iModel, params);
      });
    }
github imodeljs / imodeljs / core / frontend / src / tile / IModelTileIO.ts View on Github external
return imageElementFromImageSource(imageSource).then((image) => {
        if (this._isCanceled)
          return undefined;

        let textureType = RenderTexture.Type.Normal;
        if (JsonUtils.asBool(namedTex.isGlyph))
          textureType = RenderTexture.Type.Glyph;
        else if (JsonUtils.asBool(namedTex.isTileSection))
          textureType = RenderTexture.Type.TileSection;

        const params = new RenderTexture.Params(namedTex.isGlyph ? undefined : name, textureType);
        return this._system.createTextureFromImage(image, ImageSourceFormat.Png === format, this._iModel, params);
      });
    }
github imodeljs / imodeljs / core / frontend / src / tile / IModelTileIO.ts View on Github external
return imageElementFromImageSource(imageSource).then((image) => {
        if (this._isCanceled)
          return undefined;

        let textureType = RenderTexture.Type.Normal;
        if (JsonUtils.asBool(namedTex.isGlyph))
          textureType = RenderTexture.Type.Glyph;
        else if (JsonUtils.asBool(namedTex.isTileSection))
          textureType = RenderTexture.Type.TileSection;

        const params = new RenderTexture.Params(namedTex.isGlyph ? undefined : name, textureType);
        return this._system.createTextureFromImage(image, ImageSourceFormat.Png === format, this._iModel, params);
      });
    }
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
return imageElementFromImageSource(imageSource).then((image) => {
        if (this._isCanceled)
          return undefined;

        let textureType = RenderTexture.Type.Normal;
        if (JsonUtils.asBool(namedTex.isGlyph))
          textureType = RenderTexture.Type.Glyph;
        else if (JsonUtils.asBool(namedTex.isTileSection))
          textureType = RenderTexture.Type.TileSection;

        const params = new RenderTexture.Params(name, textureType);
        return this._system.createTextureFromImage(image, ImageSourceFormat.Png === format, this._iModel, params);
      });
    }
github imodeljs / imodeljs / core / frontend / src / tile / DgnTileIO.ts View on Github external
return imageElementFromImageSource(imageSource).then((image) => {
        if (this._isCanceled)
          return undefined;

        let textureType = RenderTexture.Type.Normal;
        if (JsonUtils.asBool(namedTex.isGlyph))
          textureType = RenderTexture.Type.Glyph;
        else if (JsonUtils.asBool(namedTex.isTileSection))
          textureType = RenderTexture.Type.TileSection;

        const params = new RenderTexture.Params(name, textureType);
        return this._system.createTextureFromImage(image, ImageSourceFormat.Png === format, this._iModel, params);
      });
    }