@itwin/core-frontend
Version:
iTwin.js frontend components
85 lines • 4.97 kB
TypeScript
/** @packageDocumentation
* @module Rendering
*/
import { TransientIdSequence } from "@itwin/core-bentley";
import { _implementationProhibited, _textures } from "../internal/Symbols";
import { Gradient, ImageBuffer, ImageSource, RenderMaterial, RenderTexture, TextureTransparency } from "@itwin/core-common";
import { MaterialParams } from "./MaterialParams";
/** Parameters describing a [[RenderTexture]] to be created on a Worker by [[WorkerGraphicDescriptionContext.createTexture]].
* @beta
*/
export interface WorkerTextureParams {
/** The type of texture to create. */
type?: RenderTexture.Type;
/** Describes the image used by the texture. */
source: ImageBuffer | ImageSource | URL;
/** Describes the transparency of the image. If this information can be supplied, it can improve performance. Otherwise,
* an attempt will be made to infer it.
*/
transparency?: TextureTransparency;
}
/** An opaque representation of a [[WorkerGraphicDescriptionContext]] that can be passed from the main thread to a [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker).
* @see [[RenderSystem.createWorkerGraphicDescriptionContextProps]] to obtain an implementation of this type.
* @see [[WorkerGraphicDescriptionContext.fromProps]] to instantiate the context on a Worker from this representation.
* @beta
*/
export interface WorkerGraphicDescriptionContextProps {
/** @internal */
readonly [_implementationProhibited]: unknown;
}
/** Context allocated on a [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker) to enable it to create [[GraphicDescription]]s.
* When the Worker returns one or more GraphicDescriptions to the main thread, it should also return this context as a [[GraphicDescriptionContextProps]].
* @see [[WorkerGraphicDescriptionContext.fromProps]] to instantiate this type.
* @beta
*/
export interface WorkerGraphicDescriptionContext {
/** @internal */
readonly [_implementationProhibited]: unknown;
/** A "fork" of the iModel's transient Id sequence obtained from the main thread. New Ids generated by this sequence on the Worker will be
* merged into the original sequence by [[RenderSystem.resolveGraphicDescriptionContext]].
*/
readonly transientIds: TransientIdSequence;
/** Converts this context to a representation that can be passed back to the main thread.
* @param transferables A set of [transferable objects](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects) that
* can be efficiently copied to the main thread.
*/
toProps(transferables: Set<Transferable>): GraphicDescriptionContextProps;
/** Create a RenderMaterial. */
createMaterial(params: MaterialParams): RenderMaterial;
/** Create a texture. */
createTexture(params: WorkerTextureParams): RenderTexture;
/** Create a texture from a gradient. If a texture was previously created using the same gradient settings, it will be reused. */
createGradientTexture(gradient: Gradient.Symb): RenderTexture;
}
/** @beta */
export declare namespace WorkerGraphicDescriptionContext {
/** Instantiate a context from its opaque representation. */
function fromProps(props: WorkerGraphicDescriptionContextProps): WorkerGraphicDescriptionContext;
}
/** Describes a [[GraphicDescriptionContext]] returned from a [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker) to the main thread, holding resources like
* transient Ids, textures, and materials that were allocated on the Worker for use by [[GraphicDescription]]s.
* @see [[WorkerGraphicDescriptionContext.toProps]] to obtain an implementation of this type.
* @see [[RenderSystem.resolveGraphicDescriptionContext]] to instantiate the context from this representation.
* @beta
*/
export interface GraphicDescriptionContextProps {
/** @internal */
readonly [_implementationProhibited]: unknown;
}
/** Context holding resources like transient Ids, textures, and materials that were allocated on a [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker) by a
* [[WorkerGraphicDescriptionContext]] for use in [[GraphicDescription]]s. This context must be supplied to [[RenderSystem.createGraphicFromDescription]] when converting a
* GraphicDescription to a [[RenderGraphic]].
* @see [[RenderSystem.resolveGraphicDescriptionContext]] to obtain an implementation of this type.
* @beta
*/
export interface GraphicDescriptionContext {
/** @internal */
readonly [_implementationProhibited]: unknown;
/** A function that remaps the local Id portion of an [Id64String]($bentley) allocated by [[WorkerGraphicDescriptionContext.transientIds]], to that of the corresponding
* Id allocated by [[IModelConnection.transientIds]].
*/
remapTransientLocalId(sourceLocalId: number): number;
/** @internal */
[_textures]: Map<string, RenderTexture>;
}
//# sourceMappingURL=GraphicDescriptionContext.d.ts.map