* This is called to update the PIXI object on the scene editor, without reloading the tilemap.
()
| 1835 | * This is called to update the PIXI object on the scene editor, without reloading the tilemap. |
| 1836 | */ |
| 1837 | updatePixiTileMap() { |
| 1838 | const tilemapAtlasImage = this._tilemapAtlasImage; |
| 1839 | const tilemapJsonFile = this._tilemapJsonFile; |
| 1840 | const tilesetJsonFile = this._tilesetJsonFile; |
| 1841 | const layerIndex = this._layerIndex; |
| 1842 | const levelIndex = this._levelIndex; |
| 1843 | const displayMode = this._displayMode; |
| 1844 | |
| 1845 | const tilemapResource = this._project |
| 1846 | .getResourcesManager() |
| 1847 | .getResource(tilemapJsonFile); |
| 1848 | |
| 1849 | let metadata = {}; |
| 1850 | try { |
| 1851 | const tilemapMetadataAsString = tilemapResource.getMetadata(); |
| 1852 | if (tilemapMetadataAsString) |
| 1853 | metadata = JSON.parse(tilemapMetadataAsString); |
| 1854 | } catch (error) { |
| 1855 | console.warn('Malformed metadata in a tilemap object:', error); |
| 1856 | } |
| 1857 | const mapping = metadata.embeddedResourcesMapping || {}; |
| 1858 | |
| 1859 | /** @type {TileMapHelper.TileMapManager} */ |
| 1860 | const manager = TilemapHelper.TileMapManager.getManager(this._project); |
| 1861 | |
| 1862 | /** @type {TileMapHelper.TileTextureCache} */ |
| 1863 | manager.getOrLoadTextureCache( |
| 1864 | this._loadTileMapWithCallback.bind(this), |
| 1865 | (textureName) => |
| 1866 | this._pixiResourcesLoader.getPIXITexture( |
| 1867 | this._project, |
| 1868 | mapping[textureName] || textureName |
| 1869 | ), |
| 1870 | tilemapAtlasImage, |
| 1871 | tilemapJsonFile, |
| 1872 | tilesetJsonFile, |
| 1873 | levelIndex, |
| 1874 | (textureCache) => { |
| 1875 | if (this._wasDestroyed) return; |
| 1876 | if (!textureCache) { |
| 1877 | this._onLoadingError(); |
| 1878 | // getOrLoadTextureCache already log warns and errors. |
| 1879 | return; |
| 1880 | } |
| 1881 | this._onLoadingSuccess(); |
| 1882 | if (!this._editableTileMap) return; |
| 1883 | |
| 1884 | this.width = this._editableTileMap.getWidth(); |
| 1885 | this.height = this._editableTileMap.getHeight(); |
| 1886 | TilemapHelper.PixiTileMapHelper.updatePixiTileMap( |
| 1887 | this.tileMapPixiObject, |
| 1888 | this._editableTileMap, |
| 1889 | textureCache, |
| 1890 | displayMode, |
| 1891 | layerIndex, |
| 1892 | 0, |
| 1893 | this._editableTileMap.getDimensionX(), |
| 1894 | 0, |
no test coverage detected