mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
2 Commits
ai-ux-impr
...
refactor/p
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ae0f2687a5 | ||
![]() |
56bcb79dcd |
133
Extensions/JsExtensionTypes.d.ts
vendored
133
Extensions/JsExtensionTypes.d.ts
vendored
@@ -4,6 +4,107 @@ type GDNamespace = typeof import('../GDevelop.js/types');
|
||||
// in this file and merge it with the other namespace declarations.
|
||||
declare namespace PIXI {}
|
||||
|
||||
/**
|
||||
* Expose functions to load PIXI textures or fonts, given the names of
|
||||
* resources and a gd.Project.
|
||||
*/
|
||||
declare class PixiResourcesLoader {
|
||||
burstCache();
|
||||
|
||||
async reloadResource(project: gd.Project, resourceName: string);
|
||||
|
||||
/**
|
||||
* Reload the given resources.
|
||||
*/
|
||||
async reloadResources(
|
||||
project: gd.Project,
|
||||
resourceNames: Array<string>
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* Return the PIXI texture represented by the given resource.
|
||||
* If not loaded, it will load it.
|
||||
*/
|
||||
getPIXITexture(project: gd.Project, resourceName: string): PIXI.Texture;
|
||||
|
||||
/**
|
||||
* Return the three.js texture associated to the specified resource name.
|
||||
* Returns a placeholder texture if not found.
|
||||
* @param project The project
|
||||
* @param resourceName The name of the resource
|
||||
* @returns The requested texture, or a placeholder if not found.
|
||||
*/
|
||||
getThreeTexture(project: gd.Project, resourceName: string): THREE.Texture;
|
||||
|
||||
/**
|
||||
* Return the three.js material associated to the specified resource name.
|
||||
* @param project The project
|
||||
* @param resourceName The name of the resource
|
||||
* @param options Set if the material should be transparent or not.
|
||||
* @returns The requested material.
|
||||
*/
|
||||
getThreeMaterial(
|
||||
project: gd.Project,
|
||||
resourceName: string,
|
||||
{ useTransparentTexture }: { useTransparentTexture: boolean }
|
||||
): THREE.Material;
|
||||
|
||||
/**
|
||||
* Return the three.js material associated to the specified resource name.
|
||||
* @param project The project
|
||||
* @param resourceName The name of the resource
|
||||
* @param options
|
||||
* @returns The requested material.
|
||||
*/
|
||||
get3DModel(
|
||||
project: gd.Project,
|
||||
resourceName: string
|
||||
): Promise<THREE.THREE_ADDONS.GLTF>;
|
||||
|
||||
/**
|
||||
* Return the Pixi spine data for the specified resource name.
|
||||
* @param project The project
|
||||
* @param spineName The name of the spine json resource
|
||||
* @returns The requested spine skeleton.
|
||||
*/
|
||||
async getSpineData(
|
||||
project: gd.Project,
|
||||
spineName: string
|
||||
): Promise<SpineDataOrLoadingError>;
|
||||
|
||||
/**
|
||||
* Return the PIXI video texture represented by the given resource.
|
||||
* If not loaded, it will load it.
|
||||
* @returns The PIXI.Texture to be used. It can be loading, so you
|
||||
* should listen to PIXI.Texture `update` event, and refresh your object
|
||||
* if this event is triggered.
|
||||
*/
|
||||
getPIXIVideoTexture(project: gd.Project, resourceName: string): PIXI.Texture;
|
||||
|
||||
/**
|
||||
* Load the given font from its url/filename.
|
||||
* @returns a Promise that resolves with the font-family to be used
|
||||
* to render a text with the font.
|
||||
*/
|
||||
loadFontFamily(project: gd.Project, resourceName: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* Get the font family name for the given font resource.
|
||||
* The font won't be loaded.
|
||||
* @returns The font-family to be used to render a text with the font.
|
||||
*/
|
||||
getFontFamily(project: gd.Project, resourceName: string): string;
|
||||
|
||||
/**
|
||||
* Get the data from a bitmap font file (fnt/xml) resource in the IDE.
|
||||
*/
|
||||
getBitmapFontData(project: gd.Project, resourceName: string): Promise<any>;
|
||||
|
||||
getInvalidPIXITexture();
|
||||
|
||||
getResourceJsonData(project: gd.Project, resourceName: string);
|
||||
}
|
||||
|
||||
/**
|
||||
* RenderedInstance is the base class used for creating 2D renderers of instances,
|
||||
* which display on the scene editor, using Pixi.js, the instance of an object (see InstancesEditor).
|
||||
@@ -14,17 +115,17 @@ class RenderedInstance {
|
||||
_instance: gd.InitialInstance;
|
||||
_associatedObjectConfiguration: gd.ObjectConfiguration;
|
||||
_pixiContainer: PIXI.Container;
|
||||
_pixiResourcesLoader: Class<PixiResourcesLoader>;
|
||||
_pixiResourcesLoader: PixiResourcesLoader;
|
||||
_pixiObject: PIXI.DisplayObject;
|
||||
wasUsed: boolean;
|
||||
|
||||
constructor(
|
||||
project: gdProject,
|
||||
layout: gdLayout,
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
project: gd.Project,
|
||||
layout: gd.Layout,
|
||||
instance: gd.InitialInstance,
|
||||
associatedObjectConfiguration: gd.ObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -85,25 +186,25 @@ class RenderedInstance {
|
||||
* It can also display 2D artifacts on Pixi 2D plane (3D object shadow projected on the plane for instance).
|
||||
*/
|
||||
class Rendered3DInstance {
|
||||
_project: gdProject;
|
||||
_layout: gdLayout;
|
||||
_instance: gdInitialInstance;
|
||||
_associatedObjectConfiguration: gdObjectConfiguration;
|
||||
_project: gd.Project;
|
||||
_layout: gd.Layout;
|
||||
_instance: gd.InitialInstance;
|
||||
_associatedObjectConfiguration: gd.ObjectConfiguration;
|
||||
_pixiContainer: PIXI.Container;
|
||||
_threeGroup: THREE.Group;
|
||||
_pixiResourcesLoader: Class<PixiResourcesLoader>;
|
||||
_pixiResourcesLoader: PixiResourcesLoader;
|
||||
_pixiObject: PIXI.DisplayObject;
|
||||
_threeObject: THREE.Object3D | null;
|
||||
wasUsed: boolean;
|
||||
|
||||
constructor(
|
||||
project: gdProject,
|
||||
layout: gdLayout,
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
project: gd.Project,
|
||||
layout: gd.Layout,
|
||||
instance: gd.InitialInstance,
|
||||
associatedObjectConfiguration: gd.ObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -1290,6 +1290,7 @@ module.exports = {
|
||||
manager.getOrLoadTextureCache(
|
||||
this._loadTileMapWithCallback.bind(this),
|
||||
(textureName) =>
|
||||
// @ts-ignore
|
||||
this._pixiResourcesLoader.getPIXITexture(
|
||||
this._project,
|
||||
mapping[textureName] || textureName
|
||||
|
@@ -88,7 +88,7 @@ namespace gdjs {
|
||||
* @param callback A function called when the tiles textures are split.
|
||||
*/
|
||||
getOrLoadTextureCache(
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>,
|
||||
getTexture: (textureName: string) => PIXI.Texture,
|
||||
atlasImageResourceName: string,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -58,7 +58,7 @@ export declare class TileMapManager {
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tileMapFileContent: TileMapFileContent | null) => void
|
||||
) => void,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>,
|
||||
getTexture: (textureName: string) => PIXI.Texture,
|
||||
atlasImageResourceName: string,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapManager.d.ts","sourceRoot":"","sources":["../../src/render/TileMapManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,mBAAmB,CAAkC;;IAO7D;;;OAGG;IACH,MAAM,CAAC,UAA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levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
atlasTexture: PIXI.Texture | null,
|
||||
getTexture: (textureName: string) => PIXI.Texture
|
||||
): TileTextureCache | null;
|
||||
/**
|
||||
* Re-renders the tile map whenever its rendering settings have been changed
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TileMapPixiHelper.d.ts","sourceRoot":"","sources":["../../src/render/TileMapPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,yBAAiB,iBAAiB,CAAC;IACjC;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,kBAAkB,EAC3B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,EACpD,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GACnE,gBAAgB,GAAG,IAAI,CAuBzB;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,iBAAiB,CAC/B,kBAAkB,EAAE,GAAG,EACvB,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,gBAAgB,EAC9B,WAAW,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,EACxC,UAAU,EAAE,MAAM,GACjB,IAAI,CA0GN;IAED;;OAEG;IACH,SAAgB,uBAAuB,CACrC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAC3B,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,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|
||||
import { TileTextureCache } from '../TileTextureCache';
|
||||
import { LDtkTileMap } from '../../load/ldtk/LDtkFormat';
|
||||
type Texture = PIXI.BaseTexture<PIXI.Resource>;
|
||||
type TextureLoader = (textureName: string) => PIXI.BaseTexture<PIXI.Resource>;
|
||||
export declare namespace LDtkPixiHelper {
|
||||
/**
|
||||
* Split an atlas image into Pixi textures.
|
||||
@@ -15,9 +13,8 @@ export declare namespace LDtkPixiHelper {
|
||||
function parseAtlas(
|
||||
tileMap: LDtkTileMap,
|
||||
levelIndex: number,
|
||||
atlasTexture: Texture | null,
|
||||
getTexture: TextureLoader
|
||||
atlasTexture: PIXI.Texture | null,
|
||||
getTexture: (textureName: string) => PIXI.Texture
|
||||
): TileTextureCache | null;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=LDtkPixiHelper.d.ts.map
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"LDtkPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/ldtk/LDtkPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAkB,MAAM,4BAA4B,CAAC;AAGzE,KAAK,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/C,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAmC9E,yBAAiB,cAAc,CAAC;IAC9B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,GAAG,IAAI,EAC5B,UAAU,EAAE,aAAa,GACxB,gBAAgB,GAAG,IAAI,CAoFzB;CACF"}
|
||||
{"version":3,"file":"LDtkPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/ldtk/LDtkPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAkB,MAAM,4BAA4B,CAAC;AAoCzE,yBAAiB,cAAc,CAAC;IAC9B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,EACjC,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,OAAO,GAChD,gBAAgB,GAAG,IAAI,CAoFzB;CACF"}
|
@@ -13,8 +13,8 @@ export declare namespace TiledPixiHelper {
|
||||
function parseAtlas(
|
||||
tileMap: TiledTileMap,
|
||||
levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
atlasTexture: PIXI.Texture | null,
|
||||
getTexture: (textureName: string) => PIXI.Texture
|
||||
): TileTextureCache | null;
|
||||
}
|
||||
//# sourceMappingURL=TiledPixiHelper.d.ts.map
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"TiledPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/tiled/TiledPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,yBAAiB,eAAe,CAAC;IAC/B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,EACpD,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GACnE,gBAAgB,GAAG,IAAI,CA8FzB;CACF"}
|
||||
{"version":3,"file":"TiledPixiHelper.d.ts","sourceRoot":"","sources":["../../../src/render/tiled/TiledPixiHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,yBAAiB,eAAe,CAAC;IAC/B;;;;;;;;OAQG;IACH,SAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,EACjC,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,OAAO,GAChD,gBAAgB,GAAG,IAAI,CA8FzB;CACF"}
|
@@ -136,11 +136,7 @@ namespace gdjs {
|
||||
this._tilemapJsonFile,
|
||||
textureName
|
||||
);
|
||||
return (game
|
||||
.getImageManager()
|
||||
.getPIXITexture(mappedName) as unknown) as PIXI.BaseTexture<
|
||||
PIXI.Resource
|
||||
>;
|
||||
return game.getImageManager().getPIXITexture(mappedName);
|
||||
},
|
||||
this._tilemapAtlasImage,
|
||||
this._tilemapJsonFile,
|
||||
|
@@ -132,7 +132,7 @@ export class TileMapManager {
|
||||
tileSetJsonResourceName: string,
|
||||
callback: (tileMapFileContent: TileMapFileContent | null) => void
|
||||
) => void,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>,
|
||||
getTexture: (textureName: string) => PIXI.Texture,
|
||||
atlasImageResourceName: string,
|
||||
tileMapJsonResourceName: string,
|
||||
tileSetJsonResourceName: string,
|
||||
|
@@ -23,8 +23,8 @@ export namespace PixiTileMapHelper {
|
||||
export function parseAtlas(
|
||||
tileMap: TileMapFileContent,
|
||||
levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
atlasTexture: PIXI.Texture | null,
|
||||
getTexture: (textureName: string) => PIXI.Texture
|
||||
): TileTextureCache | null {
|
||||
if (tileMap.kind === "ldtk") {
|
||||
return LDtkPixiHelper.parseAtlas(
|
||||
|
@@ -2,20 +2,17 @@ import { TileTextureCache } from "../TileTextureCache";
|
||||
import { LDtkTileMap, LDtkTilesetDef } from "../../load/ldtk/LDtkFormat";
|
||||
import { getLDtkTileId } from "../../load/ldtk/LDtkTileMapLoaderHelper";
|
||||
|
||||
type Texture = PIXI.BaseTexture<PIXI.Resource>;
|
||||
type TextureLoader = (textureName: string) => PIXI.BaseTexture<PIXI.Resource>;
|
||||
|
||||
function getAtlasTexture(
|
||||
atlasTextures: Record<number, Texture | null>,
|
||||
atlasTextures: Record<number, PIXI.Texture | null>,
|
||||
tilesetCache: Record<number, LDtkTilesetDef>,
|
||||
getTexture: TextureLoader,
|
||||
getTexture: (textureName: string) => PIXI.Texture,
|
||||
tilesetId: number
|
||||
): Texture | null {
|
||||
): PIXI.Texture | null {
|
||||
if (atlasTextures[tilesetId]) {
|
||||
return atlasTextures[tilesetId];
|
||||
}
|
||||
|
||||
let texture: Texture | null = null;
|
||||
let texture: PIXI.Texture | null = null;
|
||||
|
||||
const tileset = tilesetCache[tilesetId];
|
||||
if (tileset?.relPath) {
|
||||
@@ -51,8 +48,8 @@ export namespace LDtkPixiHelper {
|
||||
export function parseAtlas(
|
||||
tileMap: LDtkTileMap,
|
||||
levelIndex: number,
|
||||
atlasTexture: Texture | null,
|
||||
getTexture: TextureLoader
|
||||
atlasTexture: PIXI.Texture | null,
|
||||
getTexture: (textureName: string) => PIXI.Texture
|
||||
): TileTextureCache | null {
|
||||
const level = tileMap.levels[levelIndex > -1 ? levelIndex : 0];
|
||||
if (!level || !level.layerInstances) {
|
||||
@@ -68,7 +65,7 @@ export namespace LDtkPixiHelper {
|
||||
// List the tiles that have been loaded to Pixi by all the layers of the level.
|
||||
// The keys are a composition (getLDtkTileId) between the tileset's id and the tile's id.
|
||||
const levelTileCache: Record<number, boolean> = {};
|
||||
const atlasTextures: Record<number, Texture | null> = {};
|
||||
const atlasTextures: Record<number, PIXI.Texture | null> = {};
|
||||
|
||||
for (let iLayer = level.layerInstances.length - 1; iLayer >= 0; --iLayer) {
|
||||
const layer = level.layerInstances[iLayer];
|
||||
@@ -113,7 +110,7 @@ export namespace LDtkPixiHelper {
|
||||
const [x, y] = tile.src;
|
||||
const rect = new PIXI.Rectangle(x, y, gridSize, gridSize);
|
||||
|
||||
const texture = new PIXI.Texture(atlasTexture, rect);
|
||||
const texture = new PIXI.Texture(atlasTexture.baseTexture, rect);
|
||||
|
||||
textureCache.setTexture(tileId, texture);
|
||||
} catch (error) {
|
||||
@@ -131,7 +128,7 @@ export namespace LDtkPixiHelper {
|
||||
if (level.bgRelPath) {
|
||||
const atlasTexture = getTexture(level.bgRelPath);
|
||||
const rect = new PIXI.Rectangle(0, 0, level.pxWid, level.pxHei);
|
||||
const texture = new PIXI.Texture(atlasTexture!, rect);
|
||||
const texture = new PIXI.Texture(atlasTexture!.baseTexture, rect);
|
||||
|
||||
textureCache.setLevelBackgroundTexture(level.bgRelPath, texture);
|
||||
}
|
||||
|
@@ -15,8 +15,8 @@ export namespace TiledPixiHelper {
|
||||
export function parseAtlas(
|
||||
tileMap: TiledTileMap,
|
||||
levelIndex: number,
|
||||
atlasTexture: PIXI.BaseTexture<PIXI.Resource> | null,
|
||||
getTexture: (textureName: string) => PIXI.BaseTexture<PIXI.Resource>
|
||||
atlasTexture: PIXI.Texture | null,
|
||||
getTexture: (textureName: string) => PIXI.Texture
|
||||
): TileTextureCache | null {
|
||||
if (!tileMap.tiledversion) {
|
||||
console.warn(
|
||||
@@ -99,7 +99,7 @@ export namespace TiledPixiHelper {
|
||||
|
||||
try {
|
||||
const rect = new PIXI.Rectangle(x, y, tilewidth, tileheight);
|
||||
const texture = new PIXI.Texture(atlasTexture!, rect);
|
||||
const texture = new PIXI.Texture(atlasTexture!.baseTexture, rect);
|
||||
|
||||
textureCache.setTexture(tileId, texture);
|
||||
} catch (error) {
|
||||
|
@@ -175,7 +175,7 @@ import useCreateProject from '../Utils/UseCreateProject';
|
||||
import newNameGenerator from '../Utils/NewNameGenerator';
|
||||
import { addDefaultLightToAllLayers } from '../ProjectCreation/CreateProject';
|
||||
import useEditorTabsStateSaving from './EditorTabs/UseEditorTabsStateSaving';
|
||||
import PixiResourcesLoader from '../ObjectsRendering/PixiResourcesLoader';
|
||||
import { pixiResourcesLoader } from '../ObjectsRendering/PixiResourcesLoader';
|
||||
import useResourcesWatcher from './ResourcesWatcher';
|
||||
import { extractGDevelopApiErrorStatusAndCode } from '../Utils/GDevelopServices/Errors';
|
||||
import useVersionHistory from '../VersionHistory/UseVersionHistory';
|
||||
@@ -901,7 +901,7 @@ const MainFrame = (props: Props) => {
|
||||
// the URL to a resource with a name in the old project is not re-used
|
||||
// for another resource with the same name in the new project.
|
||||
ResourcesLoader.burstAllUrlsCache();
|
||||
PixiResourcesLoader.burstCache();
|
||||
pixiResourcesLoader.burstCache();
|
||||
|
||||
const state = await setState(state => ({
|
||||
...state,
|
||||
|
@@ -25,7 +25,7 @@ import { makeDragSourceAndDropTarget } from '../../UI/DragAndDrop/DragSourceAndD
|
||||
import { DragHandleIcon } from '../../UI/DragHandle';
|
||||
import DropIndicator from '../../UI/SortableVirtualizedItemList/DropIndicator';
|
||||
import GDevelopThemeContext from '../../UI/Theme/GDevelopThemeContext';
|
||||
import PixiResourcesLoader from '../../ObjectsRendering/PixiResourcesLoader';
|
||||
import { pixiResourcesLoader } from '../../ObjectsRendering/PixiResourcesLoader';
|
||||
import useAlertDialog from '../../UI/Alert/useAlertDialog';
|
||||
import { type GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
||||
import * as SkeletonUtils from 'three/examples/jsm/utils/SkeletonUtils';
|
||||
@@ -155,7 +155,7 @@ const Model3DEditor = ({
|
||||
const [gltf, setGltf] = React.useState<GLTF | null>(null);
|
||||
const loadGltf = React.useCallback(
|
||||
async (modelResourceName: string) => {
|
||||
const newModel3d = await PixiResourcesLoader.get3DModel(
|
||||
const newModel3d = await pixiResourcesLoader.get3DModel(
|
||||
project,
|
||||
modelResourceName
|
||||
);
|
||||
|
@@ -24,7 +24,8 @@ import { makeDragSourceAndDropTarget } from '../../UI/DragAndDrop/DragSourceAndD
|
||||
import { DragHandleIcon } from '../../UI/DragHandle';
|
||||
import DropIndicator from '../../UI/SortableVirtualizedItemList/DropIndicator';
|
||||
import GDevelopThemeContext from '../../UI/Theme/GDevelopThemeContext';
|
||||
import PixiResourcesLoader, {
|
||||
import {
|
||||
pixiResourcesLoader,
|
||||
type SpineDataOrLoadingError,
|
||||
} from '../../ObjectsRendering/PixiResourcesLoader';
|
||||
import useAlertDialog from '../../UI/Alert/useAlertDialog';
|
||||
@@ -109,7 +110,7 @@ const SpineEditor = ({
|
||||
React.useEffect(
|
||||
() => {
|
||||
(async () => {
|
||||
const spineData = await PixiResourcesLoader.getSpineData(
|
||||
const spineData = await pixiResourcesLoader.getSpineData(
|
||||
project,
|
||||
spineResourceName
|
||||
);
|
||||
|
@@ -10,7 +10,7 @@ import RenderedTextEntryInstance from './Renderers/RenderedTextEntryInstance';
|
||||
import RenderedParticleEmitterInstance from './Renderers/RenderedParticleEmitterInstance';
|
||||
import RenderedCustomObjectInstance from './Renderers/RenderedCustomObjectInstance';
|
||||
import RenderedSprite3DInstance from './Renderers/RenderedSprite3DInstance';
|
||||
import PixiResourcesLoader from './PixiResourcesLoader';
|
||||
import { pixiResourcesLoader } from './PixiResourcesLoader';
|
||||
import ResourcesLoader from '../ResourcesLoader';
|
||||
import RenderedInstance from './Renderers/RenderedInstance';
|
||||
import Rendered3DInstance from './Renderers/Rendered3DInstance';
|
||||
@@ -90,7 +90,7 @@ const ObjectsRenderingService = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
threeGroup,
|
||||
PixiResourcesLoader
|
||||
pixiResourcesLoader
|
||||
);
|
||||
} else if (this.renderers.hasOwnProperty(objectType))
|
||||
return new this.renderers[objectType](
|
||||
@@ -99,7 +99,7 @@ const ObjectsRenderingService = {
|
||||
instance,
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
PixiResourcesLoader
|
||||
pixiResourcesLoader
|
||||
);
|
||||
else {
|
||||
if (project.hasEventsBasedObject(objectType)) {
|
||||
@@ -116,7 +116,7 @@ const ObjectsRenderingService = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
threeGroup,
|
||||
PixiResourcesLoader
|
||||
pixiResourcesLoader
|
||||
);
|
||||
} else {
|
||||
return new RenderedCustomObjectInstance(
|
||||
@@ -126,7 +126,7 @@ const ObjectsRenderingService = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
threeGroup,
|
||||
PixiResourcesLoader
|
||||
pixiResourcesLoader
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ const ObjectsRenderingService = {
|
||||
instance,
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
PixiResourcesLoader
|
||||
pixiResourcesLoader
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@@ -234,7 +234,7 @@ const getEmbedderResources = (
|
||||
* This internally uses ResourcesLoader to get the URL of the resources.
|
||||
*/
|
||||
export default class PixiResourcesLoader {
|
||||
static burstCache() {
|
||||
burstCache() {
|
||||
loadedBitmapFonts = {};
|
||||
loadedFontFamilies = {};
|
||||
loadedTextures = {};
|
||||
@@ -245,7 +245,7 @@ export default class PixiResourcesLoader {
|
||||
spineDataPromises = {};
|
||||
}
|
||||
|
||||
static async _reloadEmbedderResources(
|
||||
async _reloadEmbedderResources(
|
||||
project: gdProject,
|
||||
embeddedResourceName: string,
|
||||
embedderResourceKind: ResourceKind
|
||||
@@ -262,7 +262,7 @@ export default class PixiResourcesLoader {
|
||||
);
|
||||
}
|
||||
|
||||
static async reloadResource(project: gdProject, resourceName: string) {
|
||||
async reloadResource(project: gdProject, resourceName: string) {
|
||||
const loadedTexture = loadedTextures[resourceName];
|
||||
if (loadedTexture && loadedTexture.textureCacheIds) {
|
||||
// The property textureCacheIds indicates that the PIXI.Texture object has some
|
||||
@@ -279,7 +279,7 @@ export default class PixiResourcesLoader {
|
||||
await this._reloadEmbedderResources(project, resourceName, 'atlas');
|
||||
}
|
||||
|
||||
await PixiResourcesLoader.loadTextures(project, [resourceName]);
|
||||
await this.reloadResources(project, [resourceName]);
|
||||
|
||||
if (loadedOrLoading3DModelPromises[resourceName]) {
|
||||
delete loadedOrLoading3DModelPromises[resourceName];
|
||||
@@ -333,9 +333,9 @@ export default class PixiResourcesLoader {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* (Re)load the PIXI texture represented by the given resources.
|
||||
* Reload the the given resources.
|
||||
*/
|
||||
static async loadTextures(
|
||||
async reloadResources(
|
||||
project: gdProject,
|
||||
resourceNames: Array<string>
|
||||
): Promise<void> {
|
||||
@@ -449,7 +449,7 @@ export default class PixiResourcesLoader {
|
||||
* should listen to PIXI.Texture `update` event, and refresh your object
|
||||
* if this event is triggered.
|
||||
*/
|
||||
static getPIXITexture(project: gdProject, resourceName: string) {
|
||||
getPIXITexture(project: gdProject, resourceName: string) {
|
||||
if (loadedTextures[resourceName]) {
|
||||
// TODO: we never consider textures as not valid anymore. When we
|
||||
// update the IDE to unload textures, we should handle loading them again
|
||||
@@ -494,20 +494,14 @@ export default class PixiResourcesLoader {
|
||||
* @param resourceName The name of the resource
|
||||
* @returns The requested texture, or a placeholder if not found.
|
||||
*/
|
||||
static getThreeTexture(
|
||||
project: gdProject,
|
||||
resourceName: string
|
||||
): THREE.Texture {
|
||||
getThreeTexture(project: gdProject, resourceName: string): THREE.Texture {
|
||||
const loadedThreeTexture = loadedThreeTextures[resourceName];
|
||||
if (loadedThreeTexture) return loadedThreeTexture;
|
||||
|
||||
// Texture is not loaded, load it now from the PixiJS texture.
|
||||
// TODO (3D) - optimization: don't load the PixiJS Texture if not used by PixiJS.
|
||||
// TODO (3D) - optimization: Ideally we could even share the same WebGL texture.
|
||||
const pixiTexture = PixiResourcesLoader.getPIXITexture(
|
||||
project,
|
||||
resourceName
|
||||
);
|
||||
const pixiTexture = this.getPIXITexture(project, resourceName);
|
||||
|
||||
// @ts-ignore - source does exist on resource.
|
||||
const image = pixiTexture.baseTexture.resource.source;
|
||||
@@ -540,7 +534,7 @@ export default class PixiResourcesLoader {
|
||||
* @param options Set if the material should be transparent or not.
|
||||
* @returns The requested material.
|
||||
*/
|
||||
static getThreeMaterial(
|
||||
getThreeMaterial(
|
||||
project: gdProject,
|
||||
resourceName: string,
|
||||
{ useTransparentTexture }: {| useTransparentTexture: boolean |}
|
||||
@@ -566,7 +560,7 @@ export default class PixiResourcesLoader {
|
||||
* @param options
|
||||
* @returns The requested material.
|
||||
*/
|
||||
static get3DModel(
|
||||
get3DModel(
|
||||
project: gdProject,
|
||||
resourceName: string
|
||||
): Promise<THREE.THREE_ADDONS.GLTF> {
|
||||
@@ -584,7 +578,7 @@ export default class PixiResourcesLoader {
|
||||
* @param spineTextureAtlasName The name of the atlas texture resource.
|
||||
* @returns The requested texture atlas, or null if it could not be loaded.
|
||||
*/
|
||||
static async _getSpineTextureAtlas(
|
||||
async _getSpineTextureAtlas(
|
||||
project: gdProject,
|
||||
spineTextureAtlasName: string
|
||||
): Promise<SpineTextureAtlasOrLoadingError> {
|
||||
@@ -707,7 +701,7 @@ export default class PixiResourcesLoader {
|
||||
* @param spineName The name of the spine json resource
|
||||
* @returns The requested spine skeleton.
|
||||
*/
|
||||
static async getSpineData(
|
||||
async getSpineData(
|
||||
project: gdProject,
|
||||
spineName: string
|
||||
): Promise<SpineDataOrLoadingError> {
|
||||
@@ -811,7 +805,7 @@ export default class PixiResourcesLoader {
|
||||
* should listen to PIXI.Texture `update` event, and refresh your object
|
||||
* if this event is triggered.
|
||||
*/
|
||||
static getPIXIVideoTexture(project: gdProject, resourceName: string) {
|
||||
getPIXIVideoTexture(project: gdProject, resourceName: string) {
|
||||
if (loadedTextures[resourceName]) {
|
||||
// TODO: we never consider textures as not valid anymore. When we
|
||||
// update the IDE to unload textures, we should handle loading them again
|
||||
@@ -860,10 +854,7 @@ export default class PixiResourcesLoader {
|
||||
* @returns a Promise that resolves with the font-family to be used
|
||||
* to render a text with the font.
|
||||
*/
|
||||
static loadFontFamily(
|
||||
project: gdProject,
|
||||
resourceName: string
|
||||
): Promise<string> {
|
||||
loadFontFamily(project: gdProject, resourceName: string): Promise<string> {
|
||||
// Avoid reloading a font if it's already cached
|
||||
if (loadedFontFamilies[resourceName]) {
|
||||
return Promise.resolve(loadedFontFamilies[resourceName]);
|
||||
@@ -909,7 +900,7 @@ export default class PixiResourcesLoader {
|
||||
* The font won't be loaded.
|
||||
* @returns The font-family to be used to render a text with the font.
|
||||
*/
|
||||
static getFontFamily(project: gdProject, resourceName: string) {
|
||||
getFontFamily(project: gdProject, resourceName: string) {
|
||||
if (loadedFontFamilies[resourceName]) {
|
||||
return loadedFontFamilies[resourceName];
|
||||
}
|
||||
@@ -921,10 +912,7 @@ export default class PixiResourcesLoader {
|
||||
/**
|
||||
* Get the data from a bitmap font file (fnt/xml) resource in the IDE.
|
||||
*/
|
||||
static getBitmapFontData(
|
||||
project: gdProject,
|
||||
resourceName: string
|
||||
): Promise<any> {
|
||||
getBitmapFontData(project: gdProject, resourceName: string): Promise<any> {
|
||||
if (loadedBitmapFonts[resourceName]) {
|
||||
return Promise.resolve(loadedBitmapFonts[resourceName].data);
|
||||
}
|
||||
@@ -963,17 +951,14 @@ export default class PixiResourcesLoader {
|
||||
});
|
||||
}
|
||||
|
||||
static getInvalidPIXITexture() {
|
||||
getInvalidPIXITexture() {
|
||||
return invalidTexture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data from a json resource in the IDE.
|
||||
*/
|
||||
static getResourceJsonData(
|
||||
project: gdProject,
|
||||
resourceName: string
|
||||
): Promise<any> {
|
||||
getResourceJsonData(project: gdProject, resourceName: string): Promise<any> {
|
||||
if (!project.getResourcesManager().hasResource(resourceName))
|
||||
return Promise.reject(
|
||||
new Error(`Can't find resource called ${resourceName}.`)
|
||||
@@ -999,3 +984,6 @@ export default class PixiResourcesLoader {
|
||||
.then(response => response.data);
|
||||
}
|
||||
}
|
||||
|
||||
/** The global, unique instance of PixiResourcesLoader. */
|
||||
export const pixiResourcesLoader = new PixiResourcesLoader();
|
||||
|
@@ -15,7 +15,7 @@ export default class Rendered3DInstance {
|
||||
_associatedObjectConfiguration: gdObjectConfiguration;
|
||||
_pixiContainer: PIXI.Container;
|
||||
_threeGroup: THREE.Group;
|
||||
_pixiResourcesLoader: Class<PixiResourcesLoader>;
|
||||
_pixiResourcesLoader: PixiResourcesLoader;
|
||||
_pixiObject: PIXI.DisplayObject;
|
||||
_threeObject: THREE.Object3D | null;
|
||||
wasUsed: boolean;
|
||||
@@ -27,7 +27,7 @@ export default class Rendered3DInstance {
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
this._pixiObject = null;
|
||||
this._threeObject = null;
|
||||
|
@@ -45,7 +45,7 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -175,7 +175,7 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
|
||||
if (this.childrenRenderedInstances.length === 0) {
|
||||
// Show a placeholder.
|
||||
this._pixiObject = new PIXI.Sprite(
|
||||
PixiResourcesLoader.getInvalidPIXITexture()
|
||||
this._pixiResourcesLoader.getInvalidPIXITexture()
|
||||
);
|
||||
this._pixiContainer.addChild(this._pixiObject);
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ export default function makeRenderer(iconPath: string) {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
|
@@ -12,7 +12,7 @@ export default class RenderedInstance {
|
||||
_instance: gdInitialInstance;
|
||||
_associatedObjectConfiguration: gdObjectConfiguration;
|
||||
_pixiContainer: PIXI.Container;
|
||||
_pixiResourcesLoader: Class<PixiResourcesLoader>;
|
||||
_pixiResourcesLoader: PixiResourcesLoader;
|
||||
_pixiObject: PIXI.DisplayObject;
|
||||
wasUsed: boolean;
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class RenderedInstance {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
this._pixiObject = null;
|
||||
this._instance = instance;
|
||||
|
@@ -28,7 +28,7 @@ export default class RenderedPanelSpriteInstance extends RenderedInstance {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -86,7 +86,7 @@ export default class RenderedPanelSpriteInstance extends RenderedInstance {
|
||||
this._associatedObjectConfiguration
|
||||
);
|
||||
this._textureName = panelSprite.getTexture();
|
||||
const texture = PixiResourcesLoader.getPIXITexture(
|
||||
const texture = this._pixiResourcesLoader.getPIXITexture(
|
||||
this._project,
|
||||
this._textureName
|
||||
);
|
||||
@@ -237,7 +237,7 @@ export default class RenderedPanelSpriteInstance extends RenderedInstance {
|
||||
this._associatedObjectConfiguration
|
||||
);
|
||||
this._textureName = panelSprite.getTexture();
|
||||
const texture = PixiResourcesLoader.getPIXITexture(
|
||||
const texture = this._pixiResourcesLoader.getPIXITexture(
|
||||
this._project,
|
||||
this._textureName
|
||||
);
|
||||
|
@@ -16,7 +16,7 @@ export default class RenderedParticleEmitterInstance extends RenderedInstance {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
|
@@ -29,7 +29,7 @@ export default class RenderedSprite3DInstance extends Rendered3DInstance {
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
|
@@ -24,7 +24,7 @@ export default class RenderedSpriteInstance extends RenderedInstance {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
|
@@ -38,7 +38,7 @@ export default class RenderedTextInstance extends RenderedInstance {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -133,10 +133,8 @@ export default class RenderedTextInstance extends RenderedInstance {
|
||||
if (this._fontName !== textObjectConfiguration.getFontName()) {
|
||||
//Avoid calling loadFontFamily if the font didn't changed.
|
||||
this._fontName = textObjectConfiguration.getFontName();
|
||||
PixiResourcesLoader.loadFontFamily(
|
||||
this._project,
|
||||
textObjectConfiguration.getFontName()
|
||||
)
|
||||
this._pixiResourcesLoader
|
||||
.loadFontFamily(this._project, textObjectConfiguration.getFontName())
|
||||
.then(fontFamily => {
|
||||
// Once the font is loaded, we can use the given fontFamily.
|
||||
this._fontFamily = fontFamily;
|
||||
|
@@ -17,7 +17,7 @@ export default class RenderedTiledSpriteInstance extends RenderedInstance {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -34,7 +34,10 @@ export default class RenderedTiledSpriteInstance extends RenderedInstance {
|
||||
);
|
||||
this._texture = tiledSprite.getTexture();
|
||||
this._pixiObject = new PIXI.TilingSprite(
|
||||
PixiResourcesLoader.getPIXITexture(project, tiledSprite.getTexture()),
|
||||
this._pixiResourcesLoader.getPIXITexture(
|
||||
project,
|
||||
tiledSprite.getTexture()
|
||||
),
|
||||
tiledSprite.getWidth(),
|
||||
tiledSprite.getHeight()
|
||||
);
|
||||
@@ -80,7 +83,7 @@ export default class RenderedTiledSpriteInstance extends RenderedInstance {
|
||||
|
||||
if (this._texture !== tiledSprite.getTexture()) {
|
||||
this._texture = tiledSprite.getTexture();
|
||||
this._pixiObject.texture = PixiResourcesLoader.getPIXITexture(
|
||||
this._pixiObject.texture = this._pixiResourcesLoader.getPIXITexture(
|
||||
this._project,
|
||||
tiledSprite.getTexture()
|
||||
);
|
||||
|
@@ -14,7 +14,7 @@ export default class RenderedUnknownInstance extends RenderedInstance {
|
||||
instance: gdInitialInstance,
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: PixiResourcesLoader
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
|
@@ -38,7 +38,7 @@ import {
|
||||
getHistoryInitialState,
|
||||
saveToHistory,
|
||||
} from '../Utils/History';
|
||||
import PixiResourcesLoader from '../ObjectsRendering/PixiResourcesLoader';
|
||||
import { pixiResourcesLoader } from '../ObjectsRendering/PixiResourcesLoader';
|
||||
import {
|
||||
type ObjectWithContext,
|
||||
type GroupWithContext,
|
||||
@@ -236,7 +236,7 @@ export default class SceneEditor extends React.Component<Props, State> {
|
||||
// through the RenderedInstance's, triggering crashes. So the scene rendering
|
||||
// is paused during this period.
|
||||
editorDisplay.startSceneRendering(false);
|
||||
await PixiResourcesLoader.reloadResource(project, resourceName);
|
||||
await pixiResourcesLoader.reloadResource(project, resourceName);
|
||||
|
||||
editorDisplay.forceUpdateObjectsList();
|
||||
|
||||
@@ -1610,12 +1610,14 @@ export default class SceneEditor extends React.Component<Props, State> {
|
||||
.toJSArray();
|
||||
resourcesInUse.delete();
|
||||
|
||||
PixiResourcesLoader.loadTextures(project, objectResourceNames).then(() => {
|
||||
if (this.editorDisplay)
|
||||
this.editorDisplay.instancesHandlers.resetInstanceRenderersFor(
|
||||
object.getName()
|
||||
);
|
||||
});
|
||||
pixiResourcesLoader
|
||||
.reloadResources(project, objectResourceNames)
|
||||
.then(() => {
|
||||
if (this.editorDisplay)
|
||||
this.editorDisplay.instancesHandlers.resetInstanceRenderersFor(
|
||||
object.getName()
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
|
Reference in New Issue
Block a user