@babylonjs/gui 7.14.0 → 7.15.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -407,10 +407,13 @@ export class Image extends Control {
407
407
  this._domImage = engine.createCanvasImage();
408
408
  // need to add to enforce rendering
409
409
  const imgElement = this._domImage;
410
- if (imgElement.style) {
410
+ let addedToDom = false;
411
+ if (imgElement.style && this._source?.endsWith(".svg")) {
411
412
  imgElement.style.visibility = "hidden";
412
413
  imgElement.style.position = "absolute";
414
+ imgElement.style.top = "0";
413
415
  engine.getRenderingCanvas()?.parentNode?.appendChild(imgElement);
416
+ addedToDom = true;
414
417
  }
415
418
  if (value) {
416
419
  Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1, loaded: false, waitingForLoadCallback: [this._onImageLoaded.bind(this)] });
@@ -424,10 +427,12 @@ export class Image extends Control {
424
427
  waitingCallback();
425
428
  }
426
429
  cachedData.waitingForLoadCallback.length = 0;
430
+ addedToDom && imgElement.remove();
427
431
  return;
428
432
  }
429
433
  }
430
434
  this._onImageLoaded();
435
+ addedToDom && imgElement.remove();
431
436
  };
432
437
  if (value) {
433
438
  Tools.SetCorsBehavior(value, this._domImage);
@@ -441,7 +446,7 @@ export class Image extends Control {
441
446
  * @returns the svg
442
447
  */
443
448
  _svgCheck(value) {
444
- if (window.SVGSVGElement && value.search(/.svg#/gi) !== -1 && value.indexOf("#") === value.lastIndexOf("#")) {
449
+ if (window.SVGSVGElement && value.search(/(\.svg|\.svg?[?|#].*)$/gi) !== -1 && value.indexOf("#") === value.lastIndexOf("#")) {
445
450
  this._isSVG = true;
446
451
  const svgsrc = value.split("#")[0];
447
452
  const elemid = value.split("#")[1];
@@ -1 +1 @@
1
- {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/image.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE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";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nimport { Control } from \"./control\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvas, ICanvasRenderingContext, IImage } from \"core/Engines/ICanvas\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\n\r\n/**\r\n * Class used to create 2D images\r\n */\r\nexport class Image extends Control {\r\n /**\r\n * Specifies an alternate text for the image, if the image for some reason cannot be displayed.\r\n */\r\n public alt?: string;\r\n\r\n private _workingCanvas: Nullable<ICanvas> = null;\r\n\r\n private _domImage: IImage;\r\n private _imageWidth: number;\r\n private _imageHeight: number;\r\n private _loaded = false;\r\n private _stretch = Image.STRETCH_FILL;\r\n private _source: Nullable<string>;\r\n private _autoScale = false;\r\n\r\n private _sourceLeft = 0;\r\n private _sourceTop = 0;\r\n private _sourceWidth = 0;\r\n private _sourceHeight = 0;\r\n private _svgAttributesComputationCompleted: boolean = false;\r\n private _isSVG: boolean = false;\r\n\r\n private _cellWidth: number = 0;\r\n private _cellHeight: number = 0;\r\n private _cellId: number = -1;\r\n\r\n private _sliceLeft: number;\r\n private _sliceRight: number;\r\n private _sliceTop: number;\r\n private _sliceBottom: number;\r\n\r\n private _populateNinePatchSlicesFromImage = false;\r\n\r\n private _detectPointerOnOpaqueOnly: boolean;\r\n\r\n private _imageDataCache: {\r\n data: Uint8ClampedArray | null;\r\n key: string;\r\n } = { data: null, key: \"\" };\r\n\r\n /**\r\n * Cache of images to avoid loading the same image multiple times\r\n */\r\n public static SourceImgCache = new Map<string, { img: IImage; timesUsed: number; loaded: boolean; waitingForLoadCallback: Array<() => void> }>();\r\n\r\n /**\r\n * Observable notified when the content is loaded\r\n */\r\n public onImageLoadedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed\r\n */\r\n public onSVGAttributesComputedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Gets or sets the referrer policy to apply on the img element load request.\r\n * You should set referrerPolicy before set the source of the image if you want to ensure the header will be present on the xhr loading request\r\n */\r\n public referrerPolicy: Nullable<ReferrerPolicy>;\r\n\r\n /**\r\n * Gets a boolean indicating that the content is loaded\r\n */\r\n public get isLoaded(): boolean {\r\n return this._loaded;\r\n }\r\n\r\n public override isReady(): boolean {\r\n return this.isLoaded;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.\r\n * Beware using this as this will consume more memory as the image has to be stored twice\r\n */\r\n @serialize()\r\n public get detectPointerOnOpaqueOnly(): boolean {\r\n return this._detectPointerOnOpaqueOnly;\r\n }\r\n\r\n public set detectPointerOnOpaqueOnly(value: boolean) {\r\n if (this._detectPointerOnOpaqueOnly === value) {\r\n return;\r\n }\r\n\r\n this._detectPointerOnOpaqueOnly = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the left value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceLeft(): number {\r\n return this._sliceLeft;\r\n }\r\n\r\n public set sliceLeft(value: number) {\r\n if (this._sliceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sliceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the right value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceRight(): number {\r\n return this._sliceRight;\r\n }\r\n\r\n public set sliceRight(value: number) {\r\n if (this._sliceRight === value) {\r\n return;\r\n }\r\n\r\n this._sliceRight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceTop(): number {\r\n return this._sliceTop;\r\n }\r\n\r\n public set sliceTop(value: number) {\r\n if (this._sliceTop === value) {\r\n return;\r\n }\r\n\r\n this._sliceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the bottom value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceBottom(): number {\r\n return this._sliceBottom;\r\n }\r\n\r\n public set sliceBottom(value: number) {\r\n if (this._sliceBottom === value) {\r\n return;\r\n }\r\n\r\n this._sliceBottom = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the left coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceLeft(): number {\r\n return this._sourceLeft;\r\n }\r\n\r\n public set sourceLeft(value: number) {\r\n if (this._sourceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sourceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceTop(): number {\r\n return this._sourceTop;\r\n }\r\n\r\n public set sourceTop(value: number) {\r\n if (this._sourceTop === value) {\r\n return;\r\n }\r\n\r\n this._sourceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the width to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceWidth(): number {\r\n return this._sourceWidth;\r\n }\r\n\r\n public set sourceWidth(value: number) {\r\n if (this._sourceWidth === value) {\r\n return;\r\n }\r\n\r\n this._sourceWidth = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceHeight(): number {\r\n return this._sourceHeight;\r\n }\r\n\r\n public set sourceHeight(value: number) {\r\n if (this._sourceHeight === value) {\r\n return;\r\n }\r\n\r\n this._sourceHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image width\r\n */\r\n public get imageWidth(): number {\r\n return this._imageWidth;\r\n }\r\n\r\n /**\r\n * Gets the image height\r\n */\r\n public get imageHeight(): number {\r\n return this._imageHeight;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data\r\n */\r\n @serialize()\r\n public get populateNinePatchSlicesFromImage(): boolean {\r\n return this._populateNinePatchSlicesFromImage;\r\n }\r\n\r\n public set populateNinePatchSlicesFromImage(value: boolean) {\r\n if (this._populateNinePatchSlicesFromImage === value) {\r\n return;\r\n }\r\n\r\n this._populateNinePatchSlicesFromImage = value;\r\n\r\n if (this._populateNinePatchSlicesFromImage && this._loaded) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n }\r\n\r\n /** Indicates if the format of the image is SVG */\r\n public get isSVG(): boolean {\r\n return this._isSVG;\r\n }\r\n\r\n /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */\r\n public get svgAttributesComputationCompleted(): boolean {\r\n return this._svgAttributesComputationCompleted;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the image can force its container to adapt its size\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n public get autoScale(): boolean {\r\n return this._autoScale;\r\n }\r\n\r\n public set autoScale(value: boolean) {\r\n if (this._autoScale === value) {\r\n return;\r\n }\r\n\r\n this._autoScale = value;\r\n\r\n if (value && this._loaded) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n }\r\n\r\n /** Gets or sets the stretching mode used by the image */\r\n @serialize()\r\n public get stretch(): number {\r\n return this._stretch;\r\n }\r\n\r\n public set stretch(value: number) {\r\n if (this._stretch === value) {\r\n return;\r\n }\r\n\r\n this._stretch = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _rotate90(n: number, preserveProperties: boolean = false): Image {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n const canvas = engine.createCanvas(height, width);\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.translate(canvas.width / 2, canvas.height / 2);\r\n context.rotate((n * Math.PI) / 2);\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);\r\n\r\n const dataUrl: string = canvas.toDataURL(\"image/jpg\");\r\n const rotatedImage = new Image(this.name + \"rotated\", dataUrl);\r\n\r\n if (preserveProperties) {\r\n rotatedImage._stretch = this._stretch;\r\n rotatedImage._autoScale = this._autoScale;\r\n rotatedImage._cellId = this._cellId;\r\n rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;\r\n rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;\r\n }\r\n\r\n this._handleRotationForSVGImage(this, rotatedImage, n);\r\n\r\n this._imageDataCache.data = null;\r\n\r\n return rotatedImage;\r\n }\r\n\r\n private _handleRotationForSVGImage(srcImage: Image, dstImage: Image, n: number): void {\r\n if (!srcImage._isSVG) {\r\n return;\r\n }\r\n\r\n if (srcImage._svgAttributesComputationCompleted) {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n } else {\r\n srcImage.onSVGAttributesComputedObservable.addOnce(() => {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n });\r\n }\r\n }\r\n\r\n private _rotate90SourceProperties(srcImage: Image, dstImage: Image, n: number): void {\r\n let srcLeft = srcImage.sourceLeft,\r\n srcTop = srcImage.sourceTop,\r\n srcWidth = srcImage.domImage.width,\r\n srcHeight = srcImage.domImage.height;\r\n\r\n let dstLeft = srcLeft,\r\n dstTop = srcTop,\r\n dstWidth = srcImage.sourceWidth,\r\n dstHeight = srcImage.sourceHeight;\r\n\r\n if (n != 0) {\r\n const mult = n < 0 ? -1 : 1;\r\n n = n % 4;\r\n for (let i = 0; i < Math.abs(n); ++i) {\r\n dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;\r\n dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;\r\n [dstWidth, dstHeight] = [dstHeight, dstWidth];\r\n if (n < 0) {\r\n dstTop -= dstHeight;\r\n } else {\r\n dstLeft -= dstWidth;\r\n }\r\n srcLeft = dstLeft;\r\n srcTop = dstTop;\r\n [srcWidth, srcHeight] = [srcHeight, srcWidth];\r\n }\r\n }\r\n\r\n dstImage.sourceLeft = dstLeft;\r\n dstImage.sourceTop = dstTop;\r\n dstImage.sourceWidth = dstWidth;\r\n dstImage.sourceHeight = dstHeight;\r\n }\r\n\r\n private _extractNinePatchSliceDataFromImage() {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height);\r\n const imageData = context.getImageData(0, 0, width, height);\r\n\r\n // Left and right\r\n this._sliceLeft = -1;\r\n this._sliceRight = -1;\r\n for (let x = 0; x < width; x++) {\r\n const alpha = imageData.data[x * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceLeft === -1) {\r\n this._sliceLeft = x;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceLeft > -1) {\r\n this._sliceRight = x;\r\n break;\r\n }\r\n }\r\n\r\n // top and bottom\r\n this._sliceTop = -1;\r\n this._sliceBottom = -1;\r\n for (let y = 0; y < height; y++) {\r\n const alpha = imageData.data[y * width * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceTop === -1) {\r\n this._sliceTop = y;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceTop > -1) {\r\n this._sliceBottom = y;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the internal DOM image used to render the control\r\n */\r\n public set domImage(value: IImage) {\r\n this._domImage = value;\r\n this._loaded = false;\r\n this._imageDataCache.data = null;\r\n\r\n if (this._domImage.width) {\r\n this._onImageLoaded();\r\n } else {\r\n this._domImage.onload = () => {\r\n this._onImageLoaded();\r\n };\r\n }\r\n }\r\n\r\n public get domImage(): IImage {\r\n return this._domImage;\r\n }\r\n\r\n private _onImageLoaded(): void {\r\n this._imageDataCache.data = null;\r\n this._imageWidth = this._domImage.width;\r\n this._imageHeight = this._domImage.height;\r\n this._loaded = true;\r\n\r\n if (this._populateNinePatchSlicesFromImage) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n\r\n this.onImageLoadedObservable.notifyObservers(this);\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image source url\r\n */\r\n @serialize()\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Resets the internal Image Element cache. Can reduce memory usage.\r\n */\r\n public static ResetImageCache() {\r\n Image.SourceImgCache.clear();\r\n }\r\n\r\n private _removeCacheUsage(source: Nullable<string>) {\r\n const value = source && Image.SourceImgCache.get(source);\r\n if (value) {\r\n value.timesUsed -= 1;\r\n\r\n // Remove from DOM\r\n const htmlElement = value.img as HTMLImageElement;\r\n if (htmlElement.parentNode) {\r\n htmlElement.parentNode.removeChild(htmlElement);\r\n }\r\n\r\n // Since the image isn't being used anymore, we can clean it from the cache\r\n if (value.timesUsed === 0) {\r\n Image.SourceImgCache.delete(source);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets image source url\r\n */\r\n public set source(value: Nullable<string>) {\r\n if (this._urlRewriter && value) {\r\n value = this._urlRewriter(value);\r\n }\r\n\r\n if (this._source === value) {\r\n return;\r\n }\r\n\r\n this._removeCacheUsage(this._source);\r\n\r\n this._loaded = false;\r\n this._source = value;\r\n this._imageDataCache.data = null;\r\n\r\n if (value) {\r\n value = this._svgCheck(value);\r\n }\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n if (value && Image.SourceImgCache.has(value)) {\r\n const cachedData = Image.SourceImgCache.get(value)!;\r\n this._domImage = cachedData.img;\r\n cachedData.timesUsed += 1;\r\n if (cachedData.loaded) {\r\n this._onImageLoaded();\r\n } else {\r\n cachedData.waitingForLoadCallback.push(this._onImageLoaded.bind(this));\r\n }\r\n return;\r\n }\r\n this._domImage = engine.createCanvasImage();\r\n // need to add to enforce rendering\r\n const imgElement = this._domImage as HTMLImageElement;\r\n if (imgElement.style) {\r\n imgElement.style.visibility = \"hidden\";\r\n imgElement.style.position = \"absolute\";\r\n engine.getRenderingCanvas()?.parentNode?.appendChild(imgElement);\r\n }\r\n\r\n if (value) {\r\n Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1, loaded: false, waitingForLoadCallback: [this._onImageLoaded.bind(this)] });\r\n }\r\n\r\n this._domImage.onload = () => {\r\n if (value) {\r\n const cachedData = Image.SourceImgCache.get(value);\r\n if (cachedData) {\r\n cachedData.loaded = true;\r\n for (const waitingCallback of cachedData.waitingForLoadCallback) {\r\n waitingCallback();\r\n }\r\n cachedData.waitingForLoadCallback.length = 0;\r\n return;\r\n }\r\n }\r\n this._onImageLoaded();\r\n };\r\n if (value) {\r\n Tools.SetCorsBehavior(value, this._domImage);\r\n Tools.SetReferrerPolicyBehavior(this.referrerPolicy, this._domImage);\r\n this._domImage.src = value;\r\n }\r\n }\r\n\r\n /**\r\n * Checks for svg document with icon id present\r\n * @param value the source svg\r\n * @returns the svg\r\n */\r\n private _svgCheck(value: string): string {\r\n if (window.SVGSVGElement && value.search(/.svg#/gi) !== -1 && value.indexOf(\"#\") === value.lastIndexOf(\"#\")) {\r\n this._isSVG = true;\r\n const svgsrc = value.split(\"#\")[0];\r\n const elemid = value.split(\"#\")[1];\r\n // check if object alr exist in document\r\n const svgExist = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgExist) {\r\n const svgDoc = svgExist.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n const elem = <SVGGraphicsElement>(<unknown>svgDoc.getElementById(elemid));\r\n if (elem && vb && docwidth && docheight) {\r\n this._getSVGAttribs(svgExist, elemid);\r\n return value;\r\n }\r\n }\r\n\r\n // wait for object to load\r\n svgExist.addEventListener(\"load\", () => {\r\n this._getSVGAttribs(svgExist, elemid);\r\n });\r\n } else {\r\n // create document object\r\n const svgImage = document.createElement(\"object\");\r\n svgImage.data = svgsrc;\r\n svgImage.type = \"image/svg+xml\";\r\n svgImage.width = \"0%\";\r\n svgImage.height = \"0%\";\r\n document.body.appendChild(svgImage);\r\n // when the object has loaded, get the element attribs\r\n svgImage.onload = () => {\r\n const svgobj = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgobj) {\r\n this._getSVGAttribs(svgobj, elemid);\r\n }\r\n };\r\n }\r\n return svgsrc;\r\n } else {\r\n return value;\r\n }\r\n }\r\n\r\n /**\r\n * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically\r\n * given external svg file and icon id\r\n * @param svgsrc\r\n * @param elemid\r\n */\r\n private _getSVGAttribs(svgsrc: HTMLObjectElement, elemid: string) {\r\n const svgDoc = svgsrc.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n // get element bbox and matrix transform\r\n const elem = svgDoc.getElementById(elemid) as Nullable<SVGGraphicsElement>;\r\n if (vb && docwidth && docheight && elem) {\r\n const vb_width = Number(vb.split(\" \")[2]);\r\n const vb_height = Number(vb.split(\" \")[3]);\r\n const elem_bbox = elem.getBBox();\r\n let elem_matrix_a = 1;\r\n let elem_matrix_d = 1;\r\n let elem_matrix_e = 0;\r\n let elem_matrix_f = 0;\r\n const mainMatrix = elem.transform.baseVal.consolidate()!.matrix;\r\n if (elem.transform && elem.transform.baseVal.consolidate()) {\r\n elem_matrix_a = mainMatrix.a;\r\n elem_matrix_d = mainMatrix.d;\r\n elem_matrix_e = mainMatrix.e;\r\n elem_matrix_f = mainMatrix.f;\r\n }\r\n\r\n // compute source coordinates and dimensions\r\n this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;\r\n this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;\r\n this.sourceWidth = elem_bbox.width * elem_matrix_a * (docwidth / vb_width);\r\n this.sourceHeight = elem_bbox.height * elem_matrix_d * (docheight / vb_height);\r\n this._svgAttributesComputationCompleted = true;\r\n this.onSVGAttributesComputedObservable.notifyObservers(this);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the cell width to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellWidth(): number {\r\n return this._cellWidth;\r\n }\r\n set cellWidth(value: number) {\r\n if (this._cellWidth === value) {\r\n return;\r\n }\r\n\r\n this._cellWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell height to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellHeight(): number {\r\n return this._cellHeight;\r\n }\r\n set cellHeight(value: number) {\r\n if (this._cellHeight === value) {\r\n return;\r\n }\r\n\r\n this._cellHeight = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell id to use (this will turn on the animation sheet mode)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellId(): number {\r\n return this._cellId;\r\n }\r\n set cellId(value: number) {\r\n if (this._cellId === value) {\r\n return;\r\n }\r\n\r\n this._cellId = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Image\r\n * @param name defines the control name\r\n * @param url defines the image url\r\n */\r\n constructor(\r\n public override name?: string,\r\n url: Nullable<string> = null\r\n ) {\r\n super(name);\r\n this.source = url;\r\n }\r\n\r\n /**\r\n * Tests if a given coordinates belong to the current control\r\n * @param x defines x coordinate to test\r\n * @param y defines y coordinate to test\r\n * @returns true if the coordinates are inside the control\r\n */\r\n public override contains(x: number, y: number): boolean {\r\n if (!super.contains(x, y)) {\r\n return false;\r\n }\r\n\r\n if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {\r\n return true;\r\n }\r\n\r\n const width = this._currentMeasure.width | 0;\r\n const height = this._currentMeasure.height | 0;\r\n const key = width + \"_\" + height;\r\n\r\n let imageData = this._imageDataCache.data;\r\n\r\n if (!imageData || this._imageDataCache.key !== key) {\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n this._imageDataCache.data = imageData = context.getImageData(0, 0, width, height).data;\r\n this._imageDataCache.key = key;\r\n }\r\n\r\n x = (x - this._currentMeasure.left) | 0;\r\n y = (y - this._currentMeasure.top) | 0;\r\n\r\n const pickedPixel = imageData[(x + y * width) * 4 + 3];\r\n\r\n return pickedPixel > 0;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"Image\";\r\n }\r\n\r\n /** Force the control to synchronize with its content */\r\n public synchronizeSizeWithContent() {\r\n if (!this._loaded) {\r\n return;\r\n }\r\n\r\n this.width = this._domImage.width + \"px\";\r\n this.height = this._domImage.height + \"px\";\r\n }\r\n\r\n protected override _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n break;\r\n case Image.STRETCH_FILL:\r\n break;\r\n case Image.STRETCH_UNIFORM:\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n break;\r\n case Image.STRETCH_EXTEND:\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n if (this.parent && this.parent.parent) {\r\n // Will update root size if root is not the top root\r\n this.parent.adaptWidthToChildren = true;\r\n this.parent.adaptHeightToChildren = true;\r\n }\r\n break;\r\n }\r\n }\r\n\r\n super._processMeasures(parentMeasure, context);\r\n }\r\n\r\n private _prepareWorkingCanvasForOpaqueDetection() {\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const width = this._currentMeasure.width;\r\n const height = this._currentMeasure.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.clearRect(0, 0, width, height);\r\n }\r\n\r\n private _drawImage(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number, tx: number, ty: number, tw: number, th: number) {\r\n context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);\r\n\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const transform = context.getTransform();\r\n\r\n const canvas = this._workingCanvas!;\r\n const workingCanvasContext = canvas.getContext(\"2d\")!;\r\n workingCanvasContext.save();\r\n const ttx = tx - this._currentMeasure.left;\r\n const tty = ty - this._currentMeasure.top;\r\n workingCanvasContext.setTransform(transform.a, transform.b, transform.c, transform.d, (ttx + tw) / 2, (tty + th) / 2);\r\n workingCanvasContext.translate(-(ttx + tw) / 2, -(tty + th) / 2);\r\n\r\n workingCanvasContext.drawImage(this._domImage, sx, sy, sw, sh, ttx, tty, tw, th);\r\n workingCanvasContext.restore();\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n let x, y, width, height;\r\n if (this.cellId == -1) {\r\n x = this._sourceLeft;\r\n y = this._sourceTop;\r\n\r\n width = this._sourceWidth ? this._sourceWidth : this._imageWidth;\r\n height = this._sourceHeight ? this._sourceHeight : this._imageHeight;\r\n } else {\r\n const rowCount = this._domImage.naturalWidth / this.cellWidth;\r\n const column = (this.cellId / rowCount) >> 0;\r\n const row = this.cellId % rowCount;\r\n\r\n x = this.cellWidth * row;\r\n y = this.cellHeight * column;\r\n width = this.cellWidth;\r\n height = this.cellHeight;\r\n }\r\n\r\n this._prepareWorkingCanvasForOpaqueDetection();\r\n\r\n this._applyStates(context);\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_FILL:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_UNIFORM: {\r\n const hRatio = this._currentMeasure.width / width;\r\n const vRatio = this._currentMeasure.height / height;\r\n const ratio = Math.min(hRatio, vRatio);\r\n const centerX = (this._currentMeasure.width - width * ratio) / 2;\r\n const centerY = (this._currentMeasure.height - height * ratio) / 2;\r\n\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);\r\n break;\r\n }\r\n case Image.STRETCH_EXTEND:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n this._renderNinePatch(context, x, y, width, height);\r\n break;\r\n }\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n private _renderNinePatch(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number): void {\r\n const idealRatio = this.host.idealWidth\r\n ? this._width.getValue(this.host) / this.host.idealWidth\r\n : this.host.idealHeight\r\n ? this._height.getValue(this.host) / this.host.idealHeight\r\n : 1;\r\n const leftWidth = this._sliceLeft;\r\n const topHeight = this._sliceTop;\r\n const bottomHeight = sh - this._sliceBottom;\r\n const rightWidth = sw - this._sliceRight;\r\n const centerWidth = this._sliceRight - this._sliceLeft;\r\n const centerHeight = this._sliceBottom - this._sliceTop;\r\n const leftWidthAdjusted = Math.round(leftWidth * idealRatio);\r\n const topHeightAdjusted = Math.round(topHeight * idealRatio);\r\n const bottomHeightAdjusted = Math.round(bottomHeight * idealRatio);\r\n const rightWidthAdjusted = Math.round(rightWidth * idealRatio);\r\n const targetCenterWidth = Math.round(this._currentMeasure.width) - rightWidthAdjusted - leftWidthAdjusted + 2;\r\n const targetCenterHeight = Math.round(this._currentMeasure.height) - bottomHeightAdjusted - topHeightAdjusted + 2;\r\n const centerLeftOffset = Math.round(this._currentMeasure.left) + leftWidthAdjusted - 1;\r\n const centerTopOffset = Math.round(this._currentMeasure.top) + topHeightAdjusted - 1;\r\n const rightOffset = Math.round(this._currentMeasure.left + this._currentMeasure.width) - rightWidthAdjusted;\r\n const bottomOffset = Math.round(this._currentMeasure.top + this._currentMeasure.height) - bottomHeightAdjusted;\r\n\r\n //Top Left\r\n this._drawImage(context, sx, sy, leftWidth, topHeight, this._currentMeasure.left, this._currentMeasure.top, leftWidthAdjusted, topHeightAdjusted);\r\n //Top\r\n this._drawImage(context, sx + this._sliceLeft, sy, centerWidth, topHeight, centerLeftOffset + 1, this._currentMeasure.top, targetCenterWidth - 2, topHeightAdjusted);\r\n //Top Right\r\n this._drawImage(context, sx + this._sliceRight, sy, rightWidth, topHeight, rightOffset, this._currentMeasure.top, rightWidthAdjusted, topHeightAdjusted);\r\n //Left\r\n this._drawImage(context, sx, sy + this._sliceTop, leftWidth, centerHeight, this._currentMeasure.left, centerTopOffset + 1, leftWidthAdjusted, targetCenterHeight - 2);\r\n // Center\r\n this._drawImage(\r\n context,\r\n sx + this._sliceLeft,\r\n sy + this._sliceTop,\r\n centerWidth,\r\n centerHeight,\r\n centerLeftOffset + 1,\r\n centerTopOffset + 1,\r\n targetCenterWidth - 2,\r\n targetCenterHeight - 2\r\n );\r\n //Right\r\n this._drawImage(\r\n context,\r\n sx + this._sliceRight,\r\n sy + this._sliceTop,\r\n rightWidth,\r\n centerHeight,\r\n rightOffset,\r\n centerTopOffset + 1,\r\n rightWidthAdjusted,\r\n targetCenterHeight - 2\r\n );\r\n //Bottom Left\r\n this._drawImage(context, sx, sy + this._sliceBottom, leftWidth, bottomHeight, this._currentMeasure.left, bottomOffset, leftWidthAdjusted, bottomHeightAdjusted);\r\n //Bottom\r\n this._drawImage(\r\n context,\r\n sx + this.sliceLeft,\r\n sy + this._sliceBottom,\r\n centerWidth,\r\n bottomHeight,\r\n centerLeftOffset + 1,\r\n bottomOffset,\r\n targetCenterWidth - 2,\r\n bottomHeightAdjusted\r\n );\r\n //Bottom Right\r\n this._drawImage(context, sx + this._sliceRight, sy + this._sliceBottom, rightWidth, bottomHeight, rightOffset, bottomOffset, rightWidthAdjusted, bottomHeightAdjusted);\r\n }\r\n\r\n public override dispose() {\r\n super.dispose();\r\n this.onImageLoadedObservable.clear();\r\n this.onSVGAttributesComputedObservable.clear();\r\n this._removeCacheUsage(this._source);\r\n }\r\n\r\n // Static\r\n /** STRETCH_NONE */\r\n public static readonly STRETCH_NONE = 0;\r\n /** STRETCH_FILL */\r\n public static readonly STRETCH_FILL = 1;\r\n /** STRETCH_UNIFORM */\r\n public static readonly STRETCH_UNIFORM = 2;\r\n /** STRETCH_EXTEND */\r\n public static readonly STRETCH_EXTEND = 3;\r\n /** NINE_PATCH */\r\n public static readonly STRETCH_NINE_PATCH = 4;\r\n}\r\nRegisterClass(\"BABYLON.GUI.Image\", Image);\r\n"]}
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/image.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AACpD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAEjD,OAAO,EAAE,WAAW,EAAE,+CAAiC;AAEvD;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,OAAO;IA8D9B;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEe,OAAO;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IAEH,IAAW,yBAAyB;QAChC,OAAO,IAAI,CAAC,0BAA0B,CAAC;IAC3C,CAAC;IAED,IAAW,yBAAyB,CAAC,KAAc;QAC/C,IAAI,IAAI,CAAC,0BAA0B,KAAK,KAAK,EAAE;YAC3C,OAAO;SACV;QAED,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC;IAC5C,CAAC;IAED;;OAEG;IAEH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE;YAC3B,OAAO;SACV;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAExB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IAEH,IAAW,UA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,CAAK;AAC1C,iBAAiB;AACM,wBAAkB,GAAG,CAAC,AAAJ,CAAK;AA/7B9C;IADC,SAAS,EAAE;sDAGX;AAcD;IADC,SAAS,EAAE;sCAGX;AAgBD;IADC,SAAS,EAAE;uCAGX;AAgBD;IADC,SAAS,EAAE;qCAGX;AAgBD;IADC,SAAS,EAAE;wCAGX;AAgBD;IADC,SAAS,EAAE;uCAGX;AAgBD;IADC,SAAS,EAAE;sCAGX;AAgBD;IADC,SAAS,EAAE;wCAGX;AAgBD;IADC,SAAS,EAAE;yCAGX;AA8BD;IADC,SAAS,EAAE;6DAGX;AA6BD;IADC,SAAS,EAAE;sCAGX;AAgBD;IADC,SAAS,EAAE;oCAGX;AAsMD;IADC,SAAS,EAAE;mCAGX;AA2MD;IADC,SAAS,EAAE;sCAGX;AAeD;IADC,SAAS,EAAE;uCAGX;AAeD;IADC,SAAS,EAAE;mCAGX;AAySL,aAAa,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nimport { Control } from \"./control\";\r\nimport type { Measure } from \"../measure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport type { ICanvas, ICanvasRenderingContext, IImage } from \"core/Engines/ICanvas\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\n\r\n/**\r\n * Class used to create 2D images\r\n */\r\nexport class Image extends Control {\r\n /**\r\n * Specifies an alternate text for the image, if the image for some reason cannot be displayed.\r\n */\r\n public alt?: string;\r\n\r\n private _workingCanvas: Nullable<ICanvas> = null;\r\n\r\n private _domImage: IImage;\r\n private _imageWidth: number;\r\n private _imageHeight: number;\r\n private _loaded = false;\r\n private _stretch = Image.STRETCH_FILL;\r\n private _source: Nullable<string>;\r\n private _autoScale = false;\r\n\r\n private _sourceLeft = 0;\r\n private _sourceTop = 0;\r\n private _sourceWidth = 0;\r\n private _sourceHeight = 0;\r\n private _svgAttributesComputationCompleted: boolean = false;\r\n private _isSVG: boolean = false;\r\n\r\n private _cellWidth: number = 0;\r\n private _cellHeight: number = 0;\r\n private _cellId: number = -1;\r\n\r\n private _sliceLeft: number;\r\n private _sliceRight: number;\r\n private _sliceTop: number;\r\n private _sliceBottom: number;\r\n\r\n private _populateNinePatchSlicesFromImage = false;\r\n\r\n private _detectPointerOnOpaqueOnly: boolean;\r\n\r\n private _imageDataCache: {\r\n data: Uint8ClampedArray | null;\r\n key: string;\r\n } = { data: null, key: \"\" };\r\n\r\n /**\r\n * Cache of images to avoid loading the same image multiple times\r\n */\r\n public static SourceImgCache = new Map<string, { img: IImage; timesUsed: number; loaded: boolean; waitingForLoadCallback: Array<() => void> }>();\r\n\r\n /**\r\n * Observable notified when the content is loaded\r\n */\r\n public onImageLoadedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed\r\n */\r\n public onSVGAttributesComputedObservable = new Observable<Image>();\r\n\r\n /**\r\n * Gets or sets the referrer policy to apply on the img element load request.\r\n * You should set referrerPolicy before set the source of the image if you want to ensure the header will be present on the xhr loading request\r\n */\r\n public referrerPolicy: Nullable<ReferrerPolicy>;\r\n\r\n /**\r\n * Gets a boolean indicating that the content is loaded\r\n */\r\n public get isLoaded(): boolean {\r\n return this._loaded;\r\n }\r\n\r\n public override isReady(): boolean {\r\n return this.isLoaded;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.\r\n * Beware using this as this will consume more memory as the image has to be stored twice\r\n */\r\n @serialize()\r\n public get detectPointerOnOpaqueOnly(): boolean {\r\n return this._detectPointerOnOpaqueOnly;\r\n }\r\n\r\n public set detectPointerOnOpaqueOnly(value: boolean) {\r\n if (this._detectPointerOnOpaqueOnly === value) {\r\n return;\r\n }\r\n\r\n this._detectPointerOnOpaqueOnly = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the left value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceLeft(): number {\r\n return this._sliceLeft;\r\n }\r\n\r\n public set sliceLeft(value: number) {\r\n if (this._sliceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sliceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the right value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceRight(): number {\r\n return this._sliceRight;\r\n }\r\n\r\n public set sliceRight(value: number) {\r\n if (this._sliceRight === value) {\r\n return;\r\n }\r\n\r\n this._sliceRight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceTop(): number {\r\n return this._sliceTop;\r\n }\r\n\r\n public set sliceTop(value: number) {\r\n if (this._sliceTop === value) {\r\n return;\r\n }\r\n\r\n this._sliceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the bottom value for slicing (9-patch)\r\n */\r\n @serialize()\r\n public get sliceBottom(): number {\r\n return this._sliceBottom;\r\n }\r\n\r\n public set sliceBottom(value: number) {\r\n if (this._sliceBottom === value) {\r\n return;\r\n }\r\n\r\n this._sliceBottom = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the left coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceLeft(): number {\r\n return this._sourceLeft;\r\n }\r\n\r\n public set sourceLeft(value: number) {\r\n if (this._sourceLeft === value) {\r\n return;\r\n }\r\n\r\n this._sourceLeft = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the top coordinate in the source image\r\n */\r\n @serialize()\r\n public get sourceTop(): number {\r\n return this._sourceTop;\r\n }\r\n\r\n public set sourceTop(value: number) {\r\n if (this._sourceTop === value) {\r\n return;\r\n }\r\n\r\n this._sourceTop = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the width to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceWidth(): number {\r\n return this._sourceWidth;\r\n }\r\n\r\n public set sourceWidth(value: number) {\r\n if (this._sourceWidth === value) {\r\n return;\r\n }\r\n\r\n this._sourceWidth = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the height to capture in the source image\r\n */\r\n @serialize()\r\n public get sourceHeight(): number {\r\n return this._sourceHeight;\r\n }\r\n\r\n public set sourceHeight(value: number) {\r\n if (this._sourceHeight === value) {\r\n return;\r\n }\r\n\r\n this._sourceHeight = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image width\r\n */\r\n public get imageWidth(): number {\r\n return this._imageWidth;\r\n }\r\n\r\n /**\r\n * Gets the image height\r\n */\r\n public get imageHeight(): number {\r\n return this._imageHeight;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data\r\n */\r\n @serialize()\r\n public get populateNinePatchSlicesFromImage(): boolean {\r\n return this._populateNinePatchSlicesFromImage;\r\n }\r\n\r\n public set populateNinePatchSlicesFromImage(value: boolean) {\r\n if (this._populateNinePatchSlicesFromImage === value) {\r\n return;\r\n }\r\n\r\n this._populateNinePatchSlicesFromImage = value;\r\n\r\n if (this._populateNinePatchSlicesFromImage && this._loaded) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n }\r\n\r\n /** Indicates if the format of the image is SVG */\r\n public get isSVG(): boolean {\r\n return this._isSVG;\r\n }\r\n\r\n /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */\r\n public get svgAttributesComputationCompleted(): boolean {\r\n return this._svgAttributesComputationCompleted;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the image can force its container to adapt its size\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n public get autoScale(): boolean {\r\n return this._autoScale;\r\n }\r\n\r\n public set autoScale(value: boolean) {\r\n if (this._autoScale === value) {\r\n return;\r\n }\r\n\r\n this._autoScale = value;\r\n\r\n if (value && this._loaded) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n }\r\n\r\n /** Gets or sets the stretching mode used by the image */\r\n @serialize()\r\n public get stretch(): number {\r\n return this._stretch;\r\n }\r\n\r\n public set stretch(value: number) {\r\n if (this._stretch === value) {\r\n return;\r\n }\r\n\r\n this._stretch = value;\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _rotate90(n: number, preserveProperties: boolean = false): Image {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n const canvas = engine.createCanvas(height, width);\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.translate(canvas.width / 2, canvas.height / 2);\r\n context.rotate((n * Math.PI) / 2);\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);\r\n\r\n const dataUrl: string = canvas.toDataURL(\"image/jpg\");\r\n const rotatedImage = new Image(this.name + \"rotated\", dataUrl);\r\n\r\n if (preserveProperties) {\r\n rotatedImage._stretch = this._stretch;\r\n rotatedImage._autoScale = this._autoScale;\r\n rotatedImage._cellId = this._cellId;\r\n rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;\r\n rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;\r\n }\r\n\r\n this._handleRotationForSVGImage(this, rotatedImage, n);\r\n\r\n this._imageDataCache.data = null;\r\n\r\n return rotatedImage;\r\n }\r\n\r\n private _handleRotationForSVGImage(srcImage: Image, dstImage: Image, n: number): void {\r\n if (!srcImage._isSVG) {\r\n return;\r\n }\r\n\r\n if (srcImage._svgAttributesComputationCompleted) {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n } else {\r\n srcImage.onSVGAttributesComputedObservable.addOnce(() => {\r\n this._rotate90SourceProperties(srcImage, dstImage, n);\r\n this._markAsDirty();\r\n });\r\n }\r\n }\r\n\r\n private _rotate90SourceProperties(srcImage: Image, dstImage: Image, n: number): void {\r\n let srcLeft = srcImage.sourceLeft,\r\n srcTop = srcImage.sourceTop,\r\n srcWidth = srcImage.domImage.width,\r\n srcHeight = srcImage.domImage.height;\r\n\r\n let dstLeft = srcLeft,\r\n dstTop = srcTop,\r\n dstWidth = srcImage.sourceWidth,\r\n dstHeight = srcImage.sourceHeight;\r\n\r\n if (n != 0) {\r\n const mult = n < 0 ? -1 : 1;\r\n n = n % 4;\r\n for (let i = 0; i < Math.abs(n); ++i) {\r\n dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;\r\n dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;\r\n [dstWidth, dstHeight] = [dstHeight, dstWidth];\r\n if (n < 0) {\r\n dstTop -= dstHeight;\r\n } else {\r\n dstLeft -= dstWidth;\r\n }\r\n srcLeft = dstLeft;\r\n srcTop = dstTop;\r\n [srcWidth, srcHeight] = [srcHeight, srcWidth];\r\n }\r\n }\r\n\r\n dstImage.sourceLeft = dstLeft;\r\n dstImage.sourceTop = dstTop;\r\n dstImage.sourceWidth = dstWidth;\r\n dstImage.sourceHeight = dstHeight;\r\n }\r\n\r\n private _extractNinePatchSliceDataFromImage() {\r\n const width = this._domImage.width;\r\n const height = this._domImage.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.drawImage(this._domImage, 0, 0, width, height);\r\n const imageData = context.getImageData(0, 0, width, height);\r\n\r\n // Left and right\r\n this._sliceLeft = -1;\r\n this._sliceRight = -1;\r\n for (let x = 0; x < width; x++) {\r\n const alpha = imageData.data[x * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceLeft === -1) {\r\n this._sliceLeft = x;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceLeft > -1) {\r\n this._sliceRight = x;\r\n break;\r\n }\r\n }\r\n\r\n // top and bottom\r\n this._sliceTop = -1;\r\n this._sliceBottom = -1;\r\n for (let y = 0; y < height; y++) {\r\n const alpha = imageData.data[y * width * 4 + 3];\r\n\r\n if (alpha > 127 && this._sliceTop === -1) {\r\n this._sliceTop = y;\r\n continue;\r\n }\r\n\r\n if (alpha < 127 && this._sliceTop > -1) {\r\n this._sliceBottom = y;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the internal DOM image used to render the control\r\n */\r\n public set domImage(value: IImage) {\r\n this._domImage = value;\r\n this._loaded = false;\r\n this._imageDataCache.data = null;\r\n\r\n if (this._domImage.width) {\r\n this._onImageLoaded();\r\n } else {\r\n this._domImage.onload = () => {\r\n this._onImageLoaded();\r\n };\r\n }\r\n }\r\n\r\n public get domImage(): IImage {\r\n return this._domImage;\r\n }\r\n\r\n private _onImageLoaded(): void {\r\n this._imageDataCache.data = null;\r\n this._imageWidth = this._domImage.width;\r\n this._imageHeight = this._domImage.height;\r\n this._loaded = true;\r\n\r\n if (this._populateNinePatchSlicesFromImage) {\r\n this._extractNinePatchSliceDataFromImage();\r\n }\r\n\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n\r\n this.onImageLoadedObservable.notifyObservers(this);\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the image source url\r\n */\r\n @serialize()\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Resets the internal Image Element cache. Can reduce memory usage.\r\n */\r\n public static ResetImageCache() {\r\n Image.SourceImgCache.clear();\r\n }\r\n\r\n private _removeCacheUsage(source: Nullable<string>) {\r\n const value = source && Image.SourceImgCache.get(source);\r\n if (value) {\r\n value.timesUsed -= 1;\r\n\r\n // Remove from DOM\r\n const htmlElement = value.img as HTMLImageElement;\r\n if (htmlElement.parentNode) {\r\n htmlElement.parentNode.removeChild(htmlElement);\r\n }\r\n\r\n // Since the image isn't being used anymore, we can clean it from the cache\r\n if (value.timesUsed === 0) {\r\n Image.SourceImgCache.delete(source);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets image source url\r\n */\r\n public set source(value: Nullable<string>) {\r\n if (this._urlRewriter && value) {\r\n value = this._urlRewriter(value);\r\n }\r\n\r\n if (this._source === value) {\r\n return;\r\n }\r\n\r\n this._removeCacheUsage(this._source);\r\n\r\n this._loaded = false;\r\n this._source = value;\r\n this._imageDataCache.data = null;\r\n\r\n if (value) {\r\n value = this._svgCheck(value);\r\n }\r\n\r\n // Should abstract platform instead of using LastCreatedEngine\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n if (value && Image.SourceImgCache.has(value)) {\r\n const cachedData = Image.SourceImgCache.get(value)!;\r\n this._domImage = cachedData.img;\r\n cachedData.timesUsed += 1;\r\n if (cachedData.loaded) {\r\n this._onImageLoaded();\r\n } else {\r\n cachedData.waitingForLoadCallback.push(this._onImageLoaded.bind(this));\r\n }\r\n return;\r\n }\r\n this._domImage = engine.createCanvasImage();\r\n // need to add to enforce rendering\r\n const imgElement = this._domImage as HTMLImageElement;\r\n let addedToDom = false;\r\n if (imgElement.style && this._source?.endsWith(\".svg\")) {\r\n imgElement.style.visibility = \"hidden\";\r\n imgElement.style.position = \"absolute\";\r\n imgElement.style.top = \"0\";\r\n engine.getRenderingCanvas()?.parentNode?.appendChild(imgElement);\r\n addedToDom = true;\r\n }\r\n\r\n if (value) {\r\n Image.SourceImgCache.set(value, { img: this._domImage, timesUsed: 1, loaded: false, waitingForLoadCallback: [this._onImageLoaded.bind(this)] });\r\n }\r\n\r\n this._domImage.onload = () => {\r\n if (value) {\r\n const cachedData = Image.SourceImgCache.get(value);\r\n if (cachedData) {\r\n cachedData.loaded = true;\r\n for (const waitingCallback of cachedData.waitingForLoadCallback) {\r\n waitingCallback();\r\n }\r\n cachedData.waitingForLoadCallback.length = 0;\r\n addedToDom && imgElement.remove();\r\n return;\r\n }\r\n }\r\n this._onImageLoaded();\r\n addedToDom && imgElement.remove();\r\n };\r\n if (value) {\r\n Tools.SetCorsBehavior(value, this._domImage);\r\n Tools.SetReferrerPolicyBehavior(this.referrerPolicy, this._domImage);\r\n this._domImage.src = value;\r\n }\r\n }\r\n\r\n /**\r\n * Checks for svg document with icon id present\r\n * @param value the source svg\r\n * @returns the svg\r\n */\r\n private _svgCheck(value: string): string {\r\n if (window.SVGSVGElement && value.search(/(\\.svg|\\.svg?[?|#].*)$/gi) !== -1 && value.indexOf(\"#\") === value.lastIndexOf(\"#\")) {\r\n this._isSVG = true;\r\n const svgsrc = value.split(\"#\")[0];\r\n const elemid = value.split(\"#\")[1];\r\n // check if object alr exist in document\r\n const svgExist = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgExist) {\r\n const svgDoc = svgExist.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n const elem = <SVGGraphicsElement>(<unknown>svgDoc.getElementById(elemid));\r\n if (elem && vb && docwidth && docheight) {\r\n this._getSVGAttribs(svgExist, elemid);\r\n return value;\r\n }\r\n }\r\n\r\n // wait for object to load\r\n svgExist.addEventListener(\"load\", () => {\r\n this._getSVGAttribs(svgExist, elemid);\r\n });\r\n } else {\r\n // create document object\r\n const svgImage = document.createElement(\"object\");\r\n svgImage.data = svgsrc;\r\n svgImage.type = \"image/svg+xml\";\r\n svgImage.width = \"0%\";\r\n svgImage.height = \"0%\";\r\n document.body.appendChild(svgImage);\r\n // when the object has loaded, get the element attribs\r\n svgImage.onload = () => {\r\n const svgobj = <HTMLObjectElement>document.body.querySelector('object[data=\"' + svgsrc + '\"]');\r\n if (svgobj) {\r\n this._getSVGAttribs(svgobj, elemid);\r\n }\r\n };\r\n }\r\n return svgsrc;\r\n } else {\r\n return value;\r\n }\r\n }\r\n\r\n /**\r\n * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically\r\n * given external svg file and icon id\r\n * @param svgsrc\r\n * @param elemid\r\n */\r\n private _getSVGAttribs(svgsrc: HTMLObjectElement, elemid: string) {\r\n const svgDoc = svgsrc.contentDocument;\r\n // get viewbox width and height, get svg document width and height in px\r\n if (svgDoc && svgDoc.documentElement) {\r\n const vb = svgDoc.documentElement.getAttribute(\"viewBox\");\r\n const docwidth = Number(svgDoc.documentElement.getAttribute(\"width\"));\r\n const docheight = Number(svgDoc.documentElement.getAttribute(\"height\"));\r\n // get element bbox and matrix transform\r\n const elem = svgDoc.getElementById(elemid) as Nullable<SVGGraphicsElement>;\r\n if (vb && docwidth && docheight && elem) {\r\n const vb_width = Number(vb.split(\" \")[2]);\r\n const vb_height = Number(vb.split(\" \")[3]);\r\n const elem_bbox = elem.getBBox();\r\n let elem_matrix_a = 1;\r\n let elem_matrix_d = 1;\r\n let elem_matrix_e = 0;\r\n let elem_matrix_f = 0;\r\n const mainMatrix = elem.transform.baseVal.consolidate()!.matrix;\r\n if (elem.transform && elem.transform.baseVal.consolidate()) {\r\n elem_matrix_a = mainMatrix.a;\r\n elem_matrix_d = mainMatrix.d;\r\n elem_matrix_e = mainMatrix.e;\r\n elem_matrix_f = mainMatrix.f;\r\n }\r\n\r\n // compute source coordinates and dimensions\r\n this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;\r\n this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;\r\n this.sourceWidth = elem_bbox.width * elem_matrix_a * (docwidth / vb_width);\r\n this.sourceHeight = elem_bbox.height * elem_matrix_d * (docheight / vb_height);\r\n this._svgAttributesComputationCompleted = true;\r\n this.onSVGAttributesComputedObservable.notifyObservers(this);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the cell width to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellWidth(): number {\r\n return this._cellWidth;\r\n }\r\n set cellWidth(value: number) {\r\n if (this._cellWidth === value) {\r\n return;\r\n }\r\n\r\n this._cellWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell height to use when animation sheet is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellHeight(): number {\r\n return this._cellHeight;\r\n }\r\n set cellHeight(value: number) {\r\n if (this._cellHeight === value) {\r\n return;\r\n }\r\n\r\n this._cellHeight = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets the cell id to use (this will turn on the animation sheet mode)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#image\r\n */\r\n @serialize()\r\n get cellId(): number {\r\n return this._cellId;\r\n }\r\n set cellId(value: number) {\r\n if (this._cellId === value) {\r\n return;\r\n }\r\n\r\n this._cellId = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new Image\r\n * @param name defines the control name\r\n * @param url defines the image url\r\n */\r\n constructor(\r\n public override name?: string,\r\n url: Nullable<string> = null\r\n ) {\r\n super(name);\r\n this.source = url;\r\n }\r\n\r\n /**\r\n * Tests if a given coordinates belong to the current control\r\n * @param x defines x coordinate to test\r\n * @param y defines y coordinate to test\r\n * @returns true if the coordinates are inside the control\r\n */\r\n public override contains(x: number, y: number): boolean {\r\n if (!super.contains(x, y)) {\r\n return false;\r\n }\r\n\r\n if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {\r\n return true;\r\n }\r\n\r\n const width = this._currentMeasure.width | 0;\r\n const height = this._currentMeasure.height | 0;\r\n const key = width + \"_\" + height;\r\n\r\n let imageData = this._imageDataCache.data;\r\n\r\n if (!imageData || this._imageDataCache.key !== key) {\r\n const canvas = this._workingCanvas;\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n this._imageDataCache.data = imageData = context.getImageData(0, 0, width, height).data;\r\n this._imageDataCache.key = key;\r\n }\r\n\r\n x = (x - this._currentMeasure.left) | 0;\r\n y = (y - this._currentMeasure.top) | 0;\r\n\r\n const pickedPixel = imageData[(x + y * width) * 4 + 3];\r\n\r\n return pickedPixel > 0;\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"Image\";\r\n }\r\n\r\n /** Force the control to synchronize with its content */\r\n public synchronizeSizeWithContent() {\r\n if (!this._loaded) {\r\n return;\r\n }\r\n\r\n this.width = this._domImage.width + \"px\";\r\n this.height = this._domImage.height + \"px\";\r\n }\r\n\r\n protected override _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n break;\r\n case Image.STRETCH_FILL:\r\n break;\r\n case Image.STRETCH_UNIFORM:\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n break;\r\n case Image.STRETCH_EXTEND:\r\n if (this._autoScale) {\r\n this.synchronizeSizeWithContent();\r\n }\r\n if (this.parent && this.parent.parent) {\r\n // Will update root size if root is not the top root\r\n this.parent.adaptWidthToChildren = true;\r\n this.parent.adaptHeightToChildren = true;\r\n }\r\n break;\r\n }\r\n }\r\n\r\n super._processMeasures(parentMeasure, context);\r\n }\r\n\r\n private _prepareWorkingCanvasForOpaqueDetection() {\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const width = this._currentMeasure.width;\r\n const height = this._currentMeasure.height;\r\n\r\n if (!this._workingCanvas) {\r\n const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n throw new Error(\"Invalid engine. Unable to create a canvas.\");\r\n }\r\n this._workingCanvas = engine.createCanvas(width, height);\r\n }\r\n const canvas = this._workingCanvas;\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n\r\n context.clearRect(0, 0, width, height);\r\n }\r\n\r\n private _drawImage(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number, tx: number, ty: number, tw: number, th: number) {\r\n context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);\r\n\r\n if (!this._detectPointerOnOpaqueOnly) {\r\n return;\r\n }\r\n\r\n const transform = context.getTransform();\r\n\r\n const canvas = this._workingCanvas!;\r\n const workingCanvasContext = canvas.getContext(\"2d\")!;\r\n workingCanvasContext.save();\r\n const ttx = tx - this._currentMeasure.left;\r\n const tty = ty - this._currentMeasure.top;\r\n workingCanvasContext.setTransform(transform.a, transform.b, transform.c, transform.d, (ttx + tw) / 2, (tty + th) / 2);\r\n workingCanvasContext.translate(-(ttx + tw) / 2, -(tty + th) / 2);\r\n\r\n workingCanvasContext.drawImage(this._domImage, sx, sy, sw, sh, ttx, tty, tw, th);\r\n workingCanvasContext.restore();\r\n }\r\n\r\n public override _draw(context: ICanvasRenderingContext): void {\r\n context.save();\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n let x, y, width, height;\r\n if (this.cellId == -1) {\r\n x = this._sourceLeft;\r\n y = this._sourceTop;\r\n\r\n width = this._sourceWidth ? this._sourceWidth : this._imageWidth;\r\n height = this._sourceHeight ? this._sourceHeight : this._imageHeight;\r\n } else {\r\n const rowCount = this._domImage.naturalWidth / this.cellWidth;\r\n const column = (this.cellId / rowCount) >> 0;\r\n const row = this.cellId % rowCount;\r\n\r\n x = this.cellWidth * row;\r\n y = this.cellHeight * column;\r\n width = this.cellWidth;\r\n height = this.cellHeight;\r\n }\r\n\r\n this._prepareWorkingCanvasForOpaqueDetection();\r\n\r\n this._applyStates(context);\r\n if (this._loaded) {\r\n switch (this._stretch) {\r\n case Image.STRETCH_NONE:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_FILL:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_UNIFORM: {\r\n const hRatio = this._currentMeasure.width / width;\r\n const vRatio = this._currentMeasure.height / height;\r\n const ratio = Math.min(hRatio, vRatio);\r\n const centerX = (this._currentMeasure.width - width * ratio) / 2;\r\n const centerY = (this._currentMeasure.height - height * ratio) / 2;\r\n\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);\r\n break;\r\n }\r\n case Image.STRETCH_EXTEND:\r\n this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);\r\n break;\r\n case Image.STRETCH_NINE_PATCH:\r\n this._renderNinePatch(context, x, y, width, height);\r\n break;\r\n }\r\n }\r\n\r\n context.restore();\r\n }\r\n\r\n private _renderNinePatch(context: ICanvasRenderingContext, sx: number, sy: number, sw: number, sh: number): void {\r\n const idealRatio = this.host.idealWidth\r\n ? this._width.getValue(this.host) / this.host.idealWidth\r\n : this.host.idealHeight\r\n ? this._height.getValue(this.host) / this.host.idealHeight\r\n : 1;\r\n const leftWidth = this._sliceLeft;\r\n const topHeight = this._sliceTop;\r\n const bottomHeight = sh - this._sliceBottom;\r\n const rightWidth = sw - this._sliceRight;\r\n const centerWidth = this._sliceRight - this._sliceLeft;\r\n const centerHeight = this._sliceBottom - this._sliceTop;\r\n const leftWidthAdjusted = Math.round(leftWidth * idealRatio);\r\n const topHeightAdjusted = Math.round(topHeight * idealRatio);\r\n const bottomHeightAdjusted = Math.round(bottomHeight * idealRatio);\r\n const rightWidthAdjusted = Math.round(rightWidth * idealRatio);\r\n const targetCenterWidth = Math.round(this._currentMeasure.width) - rightWidthAdjusted - leftWidthAdjusted + 2;\r\n const targetCenterHeight = Math.round(this._currentMeasure.height) - bottomHeightAdjusted - topHeightAdjusted + 2;\r\n const centerLeftOffset = Math.round(this._currentMeasure.left) + leftWidthAdjusted - 1;\r\n const centerTopOffset = Math.round(this._currentMeasure.top) + topHeightAdjusted - 1;\r\n const rightOffset = Math.round(this._currentMeasure.left + this._currentMeasure.width) - rightWidthAdjusted;\r\n const bottomOffset = Math.round(this._currentMeasure.top + this._currentMeasure.height) - bottomHeightAdjusted;\r\n\r\n //Top Left\r\n this._drawImage(context, sx, sy, leftWidth, topHeight, this._currentMeasure.left, this._currentMeasure.top, leftWidthAdjusted, topHeightAdjusted);\r\n //Top\r\n this._drawImage(context, sx + this._sliceLeft, sy, centerWidth, topHeight, centerLeftOffset + 1, this._currentMeasure.top, targetCenterWidth - 2, topHeightAdjusted);\r\n //Top Right\r\n this._drawImage(context, sx + this._sliceRight, sy, rightWidth, topHeight, rightOffset, this._currentMeasure.top, rightWidthAdjusted, topHeightAdjusted);\r\n //Left\r\n this._drawImage(context, sx, sy + this._sliceTop, leftWidth, centerHeight, this._currentMeasure.left, centerTopOffset + 1, leftWidthAdjusted, targetCenterHeight - 2);\r\n // Center\r\n this._drawImage(\r\n context,\r\n sx + this._sliceLeft,\r\n sy + this._sliceTop,\r\n centerWidth,\r\n centerHeight,\r\n centerLeftOffset + 1,\r\n centerTopOffset + 1,\r\n targetCenterWidth - 2,\r\n targetCenterHeight - 2\r\n );\r\n //Right\r\n this._drawImage(\r\n context,\r\n sx + this._sliceRight,\r\n sy + this._sliceTop,\r\n rightWidth,\r\n centerHeight,\r\n rightOffset,\r\n centerTopOffset + 1,\r\n rightWidthAdjusted,\r\n targetCenterHeight - 2\r\n );\r\n //Bottom Left\r\n this._drawImage(context, sx, sy + this._sliceBottom, leftWidth, bottomHeight, this._currentMeasure.left, bottomOffset, leftWidthAdjusted, bottomHeightAdjusted);\r\n //Bottom\r\n this._drawImage(\r\n context,\r\n sx + this.sliceLeft,\r\n sy + this._sliceBottom,\r\n centerWidth,\r\n bottomHeight,\r\n centerLeftOffset + 1,\r\n bottomOffset,\r\n targetCenterWidth - 2,\r\n bottomHeightAdjusted\r\n );\r\n //Bottom Right\r\n this._drawImage(context, sx + this._sliceRight, sy + this._sliceBottom, rightWidth, bottomHeight, rightOffset, bottomOffset, rightWidthAdjusted, bottomHeightAdjusted);\r\n }\r\n\r\n public override dispose() {\r\n super.dispose();\r\n this.onImageLoadedObservable.clear();\r\n this.onSVGAttributesComputedObservable.clear();\r\n this._removeCacheUsage(this._source);\r\n }\r\n\r\n // Static\r\n /** STRETCH_NONE */\r\n public static readonly STRETCH_NONE = 0;\r\n /** STRETCH_FILL */\r\n public static readonly STRETCH_FILL = 1;\r\n /** STRETCH_UNIFORM */\r\n public static readonly STRETCH_UNIFORM = 2;\r\n /** STRETCH_EXTEND */\r\n public static readonly STRETCH_EXTEND = 3;\r\n /** NINE_PATCH */\r\n public static readonly STRETCH_NINE_PATCH = 4;\r\n}\r\nRegisterClass(\"BABYLON.GUI.Image\", Image);\r\n"]}
package/2D/xmlLoader.js CHANGED
@@ -68,8 +68,9 @@ export class XmlLoader {
68
68
  guiNode.linkWithMesh(window[node.attributes[i].value]);
69
69
  }
70
70
  }
71
- else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
72
- const element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
71
+ else if (node.attributes[i].value.match(/{{.*}}/)) {
72
+ const matches = node.attributes[i].value.match(/{{(.*)}}/);
73
+ const element = node.attributes[i].value.replace(/{{.*}}/, `${this._getChainElement(matches[1])}`);
73
74
  guiNode[node.attributes[i].name] = element;
74
75
  }
75
76
  else if (!this._objectAttributes[node.attributes[i].name]) {
@@ -1 +1 @@
1
- {"version":3,"file":"xmlLoader.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/xmlLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,0CAA4B;AAG/C,MAAM,cAAc,GAAG,2DAA2D,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,SAAS;IAuBlB;;;OAGG;IACH,YAAY,cAAmB,IAAI;QA1B3B,WAAM,GAAQ,EAAE,CAAC;QAEjB,eAAU,GAAQ;YACtB,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,CAAC;SACV,CAAC;QAEM,cAAS,GAAY,KAAK,CAAC;QAE3B,sBAAiB,GAAQ;YAC7B,uBAAuB,EAAE,CAAC;YAC1B,qBAAqB,EAAE,CAAC;YACxB,mBAAmB,EAAE,CAAC;YACtB,iBAAiB,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;SACb,CAAC;QAWE,IAAI,WAAW,EAAE;YACb,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;SACnC;IACL,CAAC;IAEO,gBAAgB,CAAC,cAAmB;QACxC,IAAI,OAAO,GAAQ,MAAM,CAAC;QAE1B,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;SAC/B;QACD,IAAI,KAAK,GAAG,cAAc,CAAC;QAC3B,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,OAAO,GAAG,OAAO,CAAC,KA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CACJ","sourcesContent":["import { GetClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst XmlLoaderError = \"XmlLoader Exception : XML file is malformed or corrupted.\";\r\n\r\n/**\r\n * Class used to load GUI via XML.\r\n */\r\nexport class XmlLoader {\r\n private _nodes: any = {};\r\n\r\n private _nodeTypes: any = {\r\n element: 1,\r\n attribute: 2,\r\n text: 3,\r\n };\r\n\r\n private _isLoaded: boolean = false;\r\n\r\n private _objectAttributes: any = {\r\n textHorizontalAlignment: 1,\r\n textVerticalAlignment: 2,\r\n horizontalAlignment: 3,\r\n verticalAlignment: 4,\r\n stretch: 5,\r\n };\r\n\r\n private _rootNode: any;\r\n\r\n private _parentClass: any;\r\n\r\n /**\r\n * Create a new xml loader\r\n * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context\r\n */\r\n constructor(parentClass: any = null) {\r\n if (parentClass) {\r\n this._parentClass = parentClass;\r\n }\r\n }\r\n\r\n private _getChainElement(attributeValue: any): any {\r\n let element: any = window;\r\n\r\n if (this._parentClass) {\r\n element = this._parentClass;\r\n }\r\n let value = attributeValue;\r\n value = value.split(\".\");\r\n\r\n for (let i = 0; i < value.length; i++) {\r\n element = element[value[i]];\r\n }\r\n return element;\r\n }\r\n\r\n private _getClassAttribute(attributeName: string): any {\r\n const attribute = attributeName.split(\".\");\r\n const className = GetClass(\"BABYLON.GUI.\" + attribute[0]);\r\n return className[attribute[1]];\r\n }\r\n\r\n private _createGuiElement(node: any, parent: any, linkParent: boolean = true): void {\r\n try {\r\n const className = GetClass(\"BABYLON.GUI.\" + node.nodeName);\r\n const guiNode = new className();\r\n\r\n if (parent && linkParent) {\r\n parent.addControl(guiNode);\r\n }\r\n\r\n for (let i = 0; i < node.attributes.length; i++) {\r\n if (node.attributes[i].name.toLowerCase().includes(\"datasource\")) {\r\n continue;\r\n }\r\n\r\n if (node.attributes[i].name.toLowerCase().includes(\"observable\")) {\r\n const element = this._getChainElement(node.attributes[i].value);\r\n guiNode[node.attributes[i].name].add(element);\r\n\r\n continue;\r\n } else if (node.attributes[i].name == \"linkWithMesh\") {\r\n if (this._parentClass) {\r\n guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);\r\n } else {\r\n guiNode.linkWithMesh(window[node.attributes[i].value]);\r\n }\r\n } else if (node.attributes[i].value.startsWith(\"{{\") && node.attributes[i].value.endsWith(\"}}\")) {\r\n const element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));\r\n guiNode[node.attributes[i].name] = element;\r\n } else if (!this._objectAttributes[node.attributes[i].name]) {\r\n if (node.attributes[i].value == \"true\" || node.attributes[i].value == \"false\") {\r\n guiNode[node.attributes[i].name] = node.attributes[i].value == \"true\";\r\n } else {\r\n guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;\r\n }\r\n } else {\r\n guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);\r\n }\r\n }\r\n\r\n if (!node.attributes.getNamedItem(\"id\")) {\r\n this._nodes[node.nodeName + Object.keys(this._nodes).length + \"_gen\"] = guiNode;\r\n return guiNode;\r\n }\r\n\r\n let id = node.attributes.getNamedItem(\"id\").value;\r\n if (id.startsWith(\"{{\") && id.endsWith(\"}}\")) {\r\n id = this._getChainElement(id.substring(2, id.length - 2));\r\n }\r\n\r\n if (!this._nodes[id]) {\r\n this._nodes[id] = guiNode;\r\n } else {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute\";\r\n }\r\n return guiNode;\r\n } catch (exception) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Error parsing Control \" + node.nodeName + \",\" + exception + \".\";\r\n }\r\n }\r\n\r\n private _parseGrid(node: any, guiNode: any, parent: any): void {\r\n let width;\r\n let height;\r\n let columns;\r\n const rows = node.children;\r\n let cells;\r\n let isPixel = false;\r\n let cellNode;\r\n let rowNumber = -1;\r\n let columnNumber = -1;\r\n let totalColumnsNumber = 0;\r\n\r\n for (let i = 0; i < rows.length; i++) {\r\n if (rows[i].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (rows[i].nodeName != \"Row\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Row node, received \" + rows[i].nodeName;\r\n }\r\n rowNumber += 1;\r\n columns = rows[i].children;\r\n\r\n if (!rows[i].attributes.getNamedItem(\"height\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Height must be defined for grid rows\";\r\n }\r\n height = Number(rows[i].attributes.getNamedItem(\"height\").nodeValue);\r\n isPixel = rows[i].attributes.getNamedItem(\"isPixel\") ? JSON.parse(rows[i].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addRowDefinition(height, isPixel);\r\n\r\n for (let j = 0; j < columns.length; j++) {\r\n if (columns[j].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (columns[j].nodeName != \"Column\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Column node, received \" + columns[j].nodeName;\r\n }\r\n columnNumber += 1;\r\n if (rowNumber > 0 && columnNumber > totalColumnsNumber) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.\";\r\n }\r\n\r\n if (rowNumber == 0) {\r\n if (!columns[j].attributes.getNamedItem(\"width\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Width must be defined for all the grid columns in the first row\";\r\n }\r\n width = Number(columns[j].attributes.getNamedItem(\"width\").nodeValue);\r\n isPixel = columns[j].attributes.getNamedItem(\"isPixel\") ? JSON.parse(columns[j].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addColumnDefinition(width, isPixel);\r\n }\r\n\r\n cells = columns[j].children;\r\n\r\n for (let k = 0; k < cells.length; k++) {\r\n if (cells[k].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n cellNode = this._createGuiElement(cells[k], guiNode, false);\r\n guiNode.addControl(cellNode, rowNumber, columnNumber);\r\n if (cells[k].firstChild) {\r\n this._parseXml(cells[k].firstChild, cellNode);\r\n }\r\n }\r\n }\r\n if (rowNumber == 0) {\r\n totalColumnsNumber = columnNumber;\r\n }\r\n columnNumber = -1;\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _parseElement(node: any, guiNode: any, parent: any): void {\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode);\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _prepareSourceElement(node: any, guiNode: any, variable: any, source: any, iterator: any): void {\r\n if (this._parentClass) {\r\n this._parentClass[variable] = source[iterator];\r\n } else {\r\n window[variable] = source[iterator];\r\n }\r\n\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode, true);\r\n }\r\n }\r\n\r\n private _parseElementsFromSource(node: any, guiNode: any, parent: any): void {\r\n const dataSource = node.attributes.getNamedItem(\"dataSource\").value;\r\n\r\n if (!dataSource.includes(\" in \")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must include an in\";\r\n } else {\r\n let isArray = true;\r\n const splittedSource = dataSource.split(\" in \");\r\n if (splittedSource.length < 2) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must have an iterator and a source\";\r\n }\r\n let source = splittedSource[1];\r\n if (source.startsWith(\"{\") && source.endsWith(\"}\")) {\r\n isArray = false;\r\n }\r\n\r\n if (!isArray || (source.startsWith(\"[\") && source.endsWith(\"]\"))) {\r\n source = source.substring(1, source.length - 1);\r\n }\r\n\r\n if (this._parentClass) {\r\n source = this._parentClass[source];\r\n } else {\r\n source = window[source];\r\n }\r\n\r\n if (isArray) {\r\n for (let i = 0; i < source.length; i++) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n } else {\r\n for (const i in source) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n }\r\n\r\n private _parseXml(node: any, parent: any, generated: boolean = false): void {\r\n if (node.nodeType != this._nodeTypes.element) {\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent, generated);\r\n }\r\n return;\r\n }\r\n\r\n if (generated) {\r\n node.setAttribute(\"id\", parent.id + (parent._children.length + 1));\r\n }\r\n\r\n const guiNode = this._createGuiElement(node, parent);\r\n\r\n if (!this._rootNode) {\r\n this._rootNode = guiNode;\r\n }\r\n\r\n if (node.nodeName == \"Grid\") {\r\n this._parseGrid(node, guiNode, parent);\r\n } else if (!node.attributes.getNamedItem(\"dataSource\")) {\r\n this._parseElement(node, guiNode, parent);\r\n } else {\r\n this._parseElementsFromSource(node, guiNode, parent);\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the loading has finished.\r\n * @returns whether the loading has finished or not\r\n */\r\n public isLoaded(): boolean {\r\n return this._isLoaded;\r\n }\r\n\r\n /**\r\n * Gets a loaded node / control by id.\r\n * @param id the Controls id set in the xml\r\n * @returns element of type Control\r\n */\r\n public getNodeById(id: string): any {\r\n return this._nodes[id];\r\n }\r\n\r\n /**\r\n * Gets all loaded nodes / controls\r\n * @returns Array of controls\r\n */\r\n public getNodes(): any {\r\n return this._nodes;\r\n }\r\n /**\r\n * Disposes the loaded layout\r\n */\r\n public dispose(): void {\r\n if (this._rootNode) {\r\n this._rootNode.dispose();\r\n this._rootNode = null;\r\n this._nodes = {};\r\n }\r\n }\r\n\r\n /**\r\n * Initiates the xml layout loading\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @param onSuccess defines the callback called on layout load successfully.\r\n * @param onError defines the callback called on layout load failure.\r\n */\r\n public loadLayout(xmlFile: any, rootNode: any, onSuccess: Nullable<() => void> = null, onError: Nullable<(error: string) => void> = null): void {\r\n const xhttp = new XMLHttpRequest();\r\n xhttp.onload = () => {\r\n if (xhttp.readyState === 4 && xhttp.status === 200) {\r\n if (!xhttp.responseXML) {\r\n if (onError) {\r\n onError(XmlLoaderError);\r\n return;\r\n } else {\r\n throw XmlLoaderError;\r\n }\r\n }\r\n\r\n const xmlDoc = xhttp.responseXML.documentElement;\r\n this._parseXml(xmlDoc.firstChild, rootNode);\r\n this._isLoaded = true;\r\n\r\n if (onSuccess) {\r\n onSuccess();\r\n }\r\n }\r\n };\r\n\r\n xhttp.onerror = function () {\r\n if (onError) {\r\n onError(\"an error occurred during loading the layout\");\r\n }\r\n };\r\n\r\n xhttp.open(\"GET\", xmlFile, true);\r\n xhttp.send();\r\n }\r\n /**\r\n * Initiates the xml layout loading asynchronously\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @returns Promise\r\n */\r\n public async loadLayoutAsync(xmlFile: any, rootNode: any): Promise<any> {\r\n return new Promise((resolve: any, reject: any) => {\r\n this.loadLayout(xmlFile, rootNode, resolve, reject);\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"xmlLoader.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/xmlLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,0CAA4B;AAG/C,MAAM,cAAc,GAAG,2DAA2D,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,SAAS;IAuBlB;;;OAGG;IACH,YAAY,cAAmB,IAAI;QA1B3B,WAAM,GAAQ,EAAE,CAAC;QAEjB,eAAU,GAAQ;YACtB,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,CAAC;SACV,CAAC;QAEM,cAAS,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EAAE,QAAQ,CAAC,CAAC;gBAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBAEtB,IAAI,SAAS,EAAE;oBACX,SAAS,EAAE,CAAC;iBACf;aACJ;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,OAAO,GAAG;YACZ,IAAI,OAAO,EAAE;gBACT,OAAO,CAAC,6CAA6C,CAAC,CAAC;aAC1D;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,OAAY,EAAE,QAAa;QACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAY,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { GetClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst XmlLoaderError = \"XmlLoader Exception : XML file is malformed or corrupted.\";\r\n\r\n/**\r\n * Class used to load GUI via XML.\r\n */\r\nexport class XmlLoader {\r\n private _nodes: any = {};\r\n\r\n private _nodeTypes: any = {\r\n element: 1,\r\n attribute: 2,\r\n text: 3,\r\n };\r\n\r\n private _isLoaded: boolean = false;\r\n\r\n private _objectAttributes: any = {\r\n textHorizontalAlignment: 1,\r\n textVerticalAlignment: 2,\r\n horizontalAlignment: 3,\r\n verticalAlignment: 4,\r\n stretch: 5,\r\n };\r\n\r\n private _rootNode: any;\r\n\r\n private _parentClass: any;\r\n\r\n /**\r\n * Create a new xml loader\r\n * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context\r\n */\r\n constructor(parentClass: any = null) {\r\n if (parentClass) {\r\n this._parentClass = parentClass;\r\n }\r\n }\r\n\r\n private _getChainElement(attributeValue: any): any {\r\n let element: any = window;\r\n\r\n if (this._parentClass) {\r\n element = this._parentClass;\r\n }\r\n let value = attributeValue;\r\n value = value.split(\".\");\r\n\r\n for (let i = 0; i < value.length; i++) {\r\n element = element[value[i]];\r\n }\r\n return element;\r\n }\r\n\r\n private _getClassAttribute(attributeName: string): any {\r\n const attribute = attributeName.split(\".\");\r\n const className = GetClass(\"BABYLON.GUI.\" + attribute[0]);\r\n return className[attribute[1]];\r\n }\r\n\r\n private _createGuiElement(node: any, parent: any, linkParent: boolean = true): void {\r\n try {\r\n const className = GetClass(\"BABYLON.GUI.\" + node.nodeName);\r\n const guiNode = new className();\r\n\r\n if (parent && linkParent) {\r\n parent.addControl(guiNode);\r\n }\r\n\r\n for (let i = 0; i < node.attributes.length; i++) {\r\n if (node.attributes[i].name.toLowerCase().includes(\"datasource\")) {\r\n continue;\r\n }\r\n\r\n if (node.attributes[i].name.toLowerCase().includes(\"observable\")) {\r\n const element = this._getChainElement(node.attributes[i].value);\r\n guiNode[node.attributes[i].name].add(element);\r\n\r\n continue;\r\n } else if (node.attributes[i].name == \"linkWithMesh\") {\r\n if (this._parentClass) {\r\n guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);\r\n } else {\r\n guiNode.linkWithMesh(window[node.attributes[i].value]);\r\n }\r\n } else if (node.attributes[i].value.match(/{{.*}}/)) {\r\n const matches = node.attributes[i].value.match(/{{(.*)}}/);\r\n const element = (node.attributes[i].value as string).replace(/{{.*}}/, `${this._getChainElement(matches[1])}`);\r\n guiNode[node.attributes[i].name] = element;\r\n } else if (!this._objectAttributes[node.attributes[i].name]) {\r\n if (node.attributes[i].value == \"true\" || node.attributes[i].value == \"false\") {\r\n guiNode[node.attributes[i].name] = node.attributes[i].value == \"true\";\r\n } else {\r\n guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;\r\n }\r\n } else {\r\n guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);\r\n }\r\n }\r\n\r\n if (!node.attributes.getNamedItem(\"id\")) {\r\n this._nodes[node.nodeName + Object.keys(this._nodes).length + \"_gen\"] = guiNode;\r\n return guiNode;\r\n }\r\n\r\n let id = node.attributes.getNamedItem(\"id\").value;\r\n if (id.startsWith(\"{{\") && id.endsWith(\"}}\")) {\r\n id = this._getChainElement(id.substring(2, id.length - 2));\r\n }\r\n\r\n if (!this._nodes[id]) {\r\n this._nodes[id] = guiNode;\r\n } else {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute\";\r\n }\r\n return guiNode;\r\n } catch (exception) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Error parsing Control \" + node.nodeName + \",\" + exception + \".\";\r\n }\r\n }\r\n\r\n private _parseGrid(node: any, guiNode: any, parent: any): void {\r\n let width;\r\n let height;\r\n let columns;\r\n const rows = node.children;\r\n let cells;\r\n let isPixel = false;\r\n let cellNode;\r\n let rowNumber = -1;\r\n let columnNumber = -1;\r\n let totalColumnsNumber = 0;\r\n\r\n for (let i = 0; i < rows.length; i++) {\r\n if (rows[i].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (rows[i].nodeName != \"Row\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Row node, received \" + rows[i].nodeName;\r\n }\r\n rowNumber += 1;\r\n columns = rows[i].children;\r\n\r\n if (!rows[i].attributes.getNamedItem(\"height\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Height must be defined for grid rows\";\r\n }\r\n height = Number(rows[i].attributes.getNamedItem(\"height\").nodeValue);\r\n isPixel = rows[i].attributes.getNamedItem(\"isPixel\") ? JSON.parse(rows[i].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addRowDefinition(height, isPixel);\r\n\r\n for (let j = 0; j < columns.length; j++) {\r\n if (columns[j].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (columns[j].nodeName != \"Column\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Column node, received \" + columns[j].nodeName;\r\n }\r\n columnNumber += 1;\r\n if (rowNumber > 0 && columnNumber > totalColumnsNumber) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.\";\r\n }\r\n\r\n if (rowNumber == 0) {\r\n if (!columns[j].attributes.getNamedItem(\"width\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Width must be defined for all the grid columns in the first row\";\r\n }\r\n width = Number(columns[j].attributes.getNamedItem(\"width\").nodeValue);\r\n isPixel = columns[j].attributes.getNamedItem(\"isPixel\") ? JSON.parse(columns[j].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addColumnDefinition(width, isPixel);\r\n }\r\n\r\n cells = columns[j].children;\r\n\r\n for (let k = 0; k < cells.length; k++) {\r\n if (cells[k].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n cellNode = this._createGuiElement(cells[k], guiNode, false);\r\n guiNode.addControl(cellNode, rowNumber, columnNumber);\r\n if (cells[k].firstChild) {\r\n this._parseXml(cells[k].firstChild, cellNode);\r\n }\r\n }\r\n }\r\n if (rowNumber == 0) {\r\n totalColumnsNumber = columnNumber;\r\n }\r\n columnNumber = -1;\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _parseElement(node: any, guiNode: any, parent: any): void {\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode);\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _prepareSourceElement(node: any, guiNode: any, variable: any, source: any, iterator: any): void {\r\n if (this._parentClass) {\r\n this._parentClass[variable] = source[iterator];\r\n } else {\r\n window[variable] = source[iterator];\r\n }\r\n\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode, true);\r\n }\r\n }\r\n\r\n private _parseElementsFromSource(node: any, guiNode: any, parent: any): void {\r\n const dataSource = node.attributes.getNamedItem(\"dataSource\").value;\r\n\r\n if (!dataSource.includes(\" in \")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must include an in\";\r\n } else {\r\n let isArray = true;\r\n const splittedSource = dataSource.split(\" in \");\r\n if (splittedSource.length < 2) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must have an iterator and a source\";\r\n }\r\n let source = splittedSource[1];\r\n if (source.startsWith(\"{\") && source.endsWith(\"}\")) {\r\n isArray = false;\r\n }\r\n\r\n if (!isArray || (source.startsWith(\"[\") && source.endsWith(\"]\"))) {\r\n source = source.substring(1, source.length - 1);\r\n }\r\n\r\n if (this._parentClass) {\r\n source = this._parentClass[source];\r\n } else {\r\n source = window[source];\r\n }\r\n\r\n if (isArray) {\r\n for (let i = 0; i < source.length; i++) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n } else {\r\n for (const i in source) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n }\r\n\r\n private _parseXml(node: any, parent: any, generated: boolean = false): void {\r\n if (node.nodeType != this._nodeTypes.element) {\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent, generated);\r\n }\r\n return;\r\n }\r\n\r\n if (generated) {\r\n node.setAttribute(\"id\", parent.id + (parent._children.length + 1));\r\n }\r\n\r\n const guiNode = this._createGuiElement(node, parent);\r\n\r\n if (!this._rootNode) {\r\n this._rootNode = guiNode;\r\n }\r\n\r\n if (node.nodeName == \"Grid\") {\r\n this._parseGrid(node, guiNode, parent);\r\n } else if (!node.attributes.getNamedItem(\"dataSource\")) {\r\n this._parseElement(node, guiNode, parent);\r\n } else {\r\n this._parseElementsFromSource(node, guiNode, parent);\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the loading has finished.\r\n * @returns whether the loading has finished or not\r\n */\r\n public isLoaded(): boolean {\r\n return this._isLoaded;\r\n }\r\n\r\n /**\r\n * Gets a loaded node / control by id.\r\n * @param id the Controls id set in the xml\r\n * @returns element of type Control\r\n */\r\n public getNodeById(id: string): any {\r\n return this._nodes[id];\r\n }\r\n\r\n /**\r\n * Gets all loaded nodes / controls\r\n * @returns Array of controls\r\n */\r\n public getNodes(): any {\r\n return this._nodes;\r\n }\r\n /**\r\n * Disposes the loaded layout\r\n */\r\n public dispose(): void {\r\n if (this._rootNode) {\r\n this._rootNode.dispose();\r\n this._rootNode = null;\r\n this._nodes = {};\r\n }\r\n }\r\n\r\n /**\r\n * Initiates the xml layout loading\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @param onSuccess defines the callback called on layout load successfully.\r\n * @param onError defines the callback called on layout load failure.\r\n */\r\n public loadLayout(xmlFile: any, rootNode: any, onSuccess: Nullable<() => void> = null, onError: Nullable<(error: string) => void> = null): void {\r\n const xhttp = new XMLHttpRequest();\r\n xhttp.onload = () => {\r\n if (xhttp.readyState === 4 && xhttp.status === 200) {\r\n if (!xhttp.responseXML) {\r\n if (onError) {\r\n onError(XmlLoaderError);\r\n return;\r\n } else {\r\n throw XmlLoaderError;\r\n }\r\n }\r\n\r\n const xmlDoc = xhttp.responseXML.documentElement;\r\n this._parseXml(xmlDoc.firstChild, rootNode);\r\n this._isLoaded = true;\r\n\r\n if (onSuccess) {\r\n onSuccess();\r\n }\r\n }\r\n };\r\n\r\n xhttp.onerror = function () {\r\n if (onError) {\r\n onError(\"an error occurred during loading the layout\");\r\n }\r\n };\r\n\r\n xhttp.open(\"GET\", xmlFile, true);\r\n xhttp.send();\r\n }\r\n /**\r\n * Initiates the xml layout loading asynchronously\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @returns Promise\r\n */\r\n public async loadLayoutAsync(xmlFile: any, rootNode: any): Promise<any> {\r\n return new Promise((resolve: any, reject: any) => {\r\n this.loadLayout(xmlFile, rootNode, resolve, reject);\r\n });\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/gui",
3
- "version": "7.14.0",
3
+ "version": "7.15.1",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "postcompile": "build-tools -c add-js-to-es6"
19
19
  },
20
20
  "devDependencies": {
21
- "@babylonjs/core": "^7.14.0",
21
+ "@babylonjs/core": "^7.15.1",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/gui": "1.0.0"
24
24
  },