Skip to content

editor › Globals › ImageDrawable

Class: ImageDrawable

Hierarchy

↳ ImageDrawable

Index

Constructors

Properties

Methods

Constructors

constructor

+ new ImageDrawable(fileName?: string, dataUrl?: string, arrayBuffer?: ArrayBuffer, format?: string, assetData?: IAssetData): ImageDrawable

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:16

Parameters:

Name Type Description
fileName? string the url of the image file
dataUrl? string the dataUrl describing the image e.g. 'data:image/png;base64,…'
arrayBuffer? ArrayBuffer the arrayBuffer containing the image
format? string the image format (media type). 'image/jpeg' and 'image/png' definitely work, but others might work, too. But in the end it doesn't even matter, seems like the browser looks into the actual data.
assetData? IAssetData contains assetIdAndResourceName, kindOfResource and fileName

Returns: ImageDrawable

Properties

Private arrayBuffer

• arrayBuffer: any = null

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:14


Private assetData

• assetData: IAssetData | null = null

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:16


Private dataUrl

• dataUrl: any = null

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:10


Private fileName

• fileName: any = null

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:9


Private format

• format: string = null

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:13


Protected image

• image: HTMLImageElement = null

Inherited from Drawable.image

Defined in src/model/visualization/textures/drawables/Drawable.ts:25


Private loadingPromise

• loadingPromise: any = null

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:15

Methods

Private _createImageFromArrayBuffer

▸ _createImageFromArrayBuffer(arrayBuffer: any, format: any): Promise‹unknown›

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:95

Parameters:

Name Type
arrayBuffer any
format any

Returns: Promise‹unknown›


Private _createImageFromAssetData

▸ _createImageFromAssetData(assetData: any, format: any): Promise‹unknown›

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:84

Parameters:

Name Type
assetData any
format any

Returns: Promise‹unknown›


Private _createImageFromDataUrl

▸ _createImageFromDataUrl(dataUrl: string): Promise‹unknown›

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:101

Parameters:

Name Type
dataUrl string

Returns: Promise‹unknown›


Protected _createTexture

▸ _createTexture(): void

Inherited from Drawable._createTexture

Defined in src/model/visualization/textures/drawables/Drawable.ts:173

Subclasses must call this to ensure that the texture is set

Returns: void


Protected _initializeTexture

▸ _initializeTexture(texture: Texture): void

Inherited from Drawable._initializeTexture

Defined in src/model/visualization/textures/drawables/Drawable.ts:188

Parameters:

Name Type
texture Texture

Returns: void


canDrawSync

▸ canDrawSync(): boolean

Inherited from Drawable.canDrawSync

Defined in src/model/visualization/textures/drawables/Drawable.ts:79

Return whether drawSync can be called

Returns: boolean


drawAsync

▸ drawAsync(params: IDrawParameters): object

Inherited from Drawable.drawAsync

Defined in src/model/visualization/textures/drawables/Drawable.ts:64

Draw asynchronously. Return a promise that indicates when we are finished.

Parameters:

Name Type
params IDrawParameters

Returns: object

  • cancelFn(): function

  • (): void

  • drawPromise: Promise‹void›


drawSync

▸ drawSync(params: IDrawParameters): void

Inherited from Drawable.drawSync

Defined in src/model/visualization/textures/drawables/Drawable.ts:87

Renders the drawable into context, centered around dx, dy.

Parameters:

Name Type Description
params IDrawParameters {@see IDrawParameters} specifying the draw.

Returns: void


filledToCanvas

▸ filledToCanvas(): Promise‹HTMLCanvasElement›

Inherited from Drawable.filledToCanvas

Defined in src/model/visualization/textures/drawables/Drawable.ts:120

Used for cutouts: Draw the drawable to the canvas by filling the area it includes black. This will be used as a texture for the gpu to decide where the surface should be transparent. Mainly used with {@see SvgDrawable}

Returns: Promise‹HTMLCanvasElement›


getCutoutTexture

▸ getCutoutTexture(): Texture

Inherited from Drawable.getCutoutTexture

Defined in src/model/visualization/textures/drawables/Drawable.ts:50

Returns: Texture

THREE Texture of the drawable that's used for cutout-rendering. Should be black / white only, black means this spot should be transparent.


getImage

▸ getImage(): any

Overrides Drawable.getImage

Defined in src/model/visualization/textures/drawables/ImageDrawable.ts:56

Returns: any


getLoadedPromise

▸ getLoadedPromise(): Promise‹void›

Inherited from Drawable.getLoadedPromise

Defined in src/model/visualization/textures/drawables/Drawable.ts:42

Returns: Promise‹void›


getPhysicalSize

▸ getPhysicalSize(): Promise‹IDimensions2›

Inherited from Drawable.getPhysicalSize

Defined in src/model/visualization/textures/drawables/Drawable.ts:157

Returns: Promise‹IDimensions2›

the native physical size (in mm) of the drawable (override in subclasses if your data type knows this!). If not overwritten, tries to estimate the physical size by assuming a 72 dpi conversion factor


getSize

▸ getSize(): Promise‹IDimensions2›

Inherited from Drawable.getSize

Defined in src/model/visualization/textures/drawables/Drawable.ts:148

Return a promise that resolves to the natural size of the drawable. The natural size is in CSS pixel units.

Returns: Promise‹IDimensions2›


getTexture

▸ getTexture(): Texture

Inherited from Drawable.getTexture

Defined in src/model/visualization/textures/drawables/Drawable.ts:38

Returns: Texture

THREE Texture of the drawable


toCanvas

▸ toCanvas(): Promise‹HTMLCanvasElement›

Inherited from Drawable.toCanvas

Defined in src/model/visualization/textures/drawables/Drawable.ts:127

Create a canvas and draw own content to that.

Returns: Promise‹HTMLCanvasElement›