@fps-games/editor 0.2.1-beta.2 → 0.2.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +41 -41
- package/dist/local-editor-harness.d.ts.map +1 -1
- package/dist/local-editor-harness.js +16 -7
- package/dist/local-editor-harness.js.map +1 -1
- package/dist/playable-babylon-rendering.d.ts +8 -7
- package/dist/playable-babylon-rendering.d.ts.map +1 -1
- package/dist/playable-babylon-rendering.js +77 -32
- package/dist/playable-babylon-rendering.js.map +1 -1
- package/dist/playable-product-projection-preview.d.ts +2 -0
- package/dist/playable-product-projection-preview.d.ts.map +1 -1
- package/dist/playable-product-projection-preview.js +7 -4
- package/dist/playable-product-projection-preview.js.map +1 -1
- package/dist/playable-sdk.d.ts +1 -1
- package/dist/playable-sdk.d.ts.map +1 -1
- package/dist/playable-sdk.js +1 -1
- package/dist/playable-sdk.js.map +1 -1
- package/dist/playable-standard-project.d.ts +0 -1
- package/dist/playable-standard-project.d.ts.map +1 -1
- package/dist/playable-standard-project.js +13 -4
- package/dist/playable-standard-project.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/environment/environment-texture-controller.d.ts +4 -2
- package/node_modules/@fps-games/babylon-renderer/dist/environment/environment-texture-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/environment/environment-texture-controller.js +301 -121
- package/node_modules/@fps-games/babylon-renderer/dist/environment/environment-texture-controller.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/environment/profile.js +5 -4
- package/node_modules/@fps-games/babylon-renderer/dist/environment/profile.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/environment/types.d.ts +4 -4
- package/node_modules/@fps-games/babylon-renderer/dist/environment/types.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/environment/types.js +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/environment/types.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/game-world-plugin-lifecycle.d.ts +2 -0
- package/node_modules/@fps-games/babylon-renderer/dist/game-world-plugin-lifecycle.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/game-world-plugin-lifecycle.js +12 -1
- package/node_modules/@fps-games/babylon-renderer/dist/game-world-plugin-lifecycle.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/plugin.d.ts +6 -3
- package/node_modules/@fps-games/babylon-renderer/dist/plugin.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/plugin.js +100 -39
- package/node_modules/@fps-games/babylon-renderer/dist/plugin.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/reference.d.ts +1 -3
- package/node_modules/@fps-games/babylon-renderer/dist/reference.d.ts.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/dist/reference.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/package.json +11 -8
- package/node_modules/@fps-games/editor-babylon/package.json +6 -6
- package/node_modules/@fps-games/editor-browser/package.json +7 -7
- package/node_modules/@fps-games/editor-core/package.json +6 -6
- package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-database/generated-module.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-database/generated-module.js +10 -3
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-database/generated-module.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-database/index.d.ts +2 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-database/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-database/index.js +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/asset-database/index.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/package-resolution/aliases.d.ts +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/package-resolution/aliases.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/package-resolution/aliases.js +4 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/package-resolution/aliases.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/panel.js +4 -4
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/panel.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/types.d.ts +2 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/rendering-profile/types.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/runtime-preview/assets.js +1 -5
- package/node_modules/@fps-games/editor-playable-sdk/dist/runtime-preview/assets.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/upgrade-doctor/inspectors.js +53 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/upgrade-doctor/inspectors.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/upgrade-doctor/types.d.ts +2 -0
- package/node_modules/@fps-games/editor-playable-sdk/dist/upgrade-doctor/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/dist/upgrade-doctor/types.js.map +1 -1
- package/node_modules/@fps-games/editor-playable-sdk/package.json +6 -6
- package/node_modules/@fps-games/editor-protocol/package.json +2 -2
- package/node_modules/@fps-games/editor-tooling/package.json +3 -3
- package/node_modules/@fps-games/editor-ui/package.json +1 -1
- package/node_modules/@fps-games/playable-assets/dist/identity.d.ts +1 -0
- package/node_modules/@fps-games/playable-assets/dist/identity.d.ts.map +1 -1
- package/node_modules/@fps-games/playable-assets/dist/identity.js +1 -1
- package/node_modules/@fps-games/playable-assets/dist/identity.js.map +1 -1
- package/node_modules/@fps-games/playable-assets/dist/index.d.ts +1 -0
- package/node_modules/@fps-games/playable-assets/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/playable-assets/dist/index.js +1 -0
- package/node_modules/@fps-games/playable-assets/dist/index.js.map +1 -1
- package/node_modules/@fps-games/playable-assets/dist/resource-resolver.d.ts +46 -0
- package/node_modules/@fps-games/playable-assets/dist/resource-resolver.d.ts.map +1 -0
- package/node_modules/@fps-games/playable-assets/dist/resource-resolver.js +109 -0
- package/node_modules/@fps-games/playable-assets/dist/resource-resolver.js.map +1 -0
- package/node_modules/@fps-games/playable-assets/package.json +1 -1
- package/node_modules/@fps-games/playable-contracts/package.json +1 -1
- package/node_modules/@fps-games/playable-rendering/package.json +2 -2
- package/node_modules/@fps-games/playable-runtime/dist/runtime.d.ts.map +1 -1
- package/node_modules/@fps-games/playable-runtime/dist/runtime.js +5 -0
- package/node_modules/@fps-games/playable-runtime/dist/runtime.js.map +1 -1
- package/node_modules/@fps-games/playable-runtime/dist/types.d.ts +2 -0
- package/node_modules/@fps-games/playable-runtime/dist/types.d.ts.map +1 -1
- package/node_modules/@fps-games/playable-runtime/dist/types.js.map +1 -1
- package/node_modules/@fps-games/playable-runtime/package.json +12 -12
- package/node_modules/@fps-games/playable-runtime-data/package.json +4 -4
- package/node_modules/@fps-games/playable-scene/package.json +2 -2
- package/node_modules/@fps-games/plugin-api/package.json +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/reference.d.ts.map +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/reference.js +11 -4
- package/node_modules/@fps-games/plugin-assets/dist/reference.js.map +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/renderer.d.ts +8 -0
- package/node_modules/@fps-games/plugin-assets/dist/renderer.d.ts.map +1 -0
- package/node_modules/@fps-games/plugin-assets/dist/renderer.js +13 -0
- package/node_modules/@fps-games/plugin-assets/dist/renderer.js.map +1 -0
- package/node_modules/@fps-games/plugin-assets/dist/resources.d.ts +12 -0
- package/node_modules/@fps-games/plugin-assets/dist/resources.d.ts.map +1 -0
- package/node_modules/@fps-games/plugin-assets/dist/resources.js +8 -0
- package/node_modules/@fps-games/plugin-assets/dist/resources.js.map +1 -0
- package/node_modules/@fps-games/plugin-assets/dist/runtime.d.ts +2 -1
- package/node_modules/@fps-games/plugin-assets/dist/runtime.d.ts.map +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/runtime.js +3 -0
- package/node_modules/@fps-games/plugin-assets/dist/runtime.js.map +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-assets/package.json +32 -8
- package/node_modules/@fps-games/plugin-hierarchy/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-hierarchy/package.json +5 -5
- package/node_modules/@fps-games/plugin-host/package.json +2 -2
- package/node_modules/@fps-games/plugin-markers/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-markers/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-markers/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-markers/package.json +5 -5
- package/node_modules/@fps-games/plugin-materials/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-materials/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-materials/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-materials/package.json +5 -5
- package/node_modules/@fps-games/plugin-rendering/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-rendering/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-rendering/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-rendering/package.json +5 -5
- package/node_modules/@fps-games/plugin-scene/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-scene/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-scene/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-scene/package.json +5 -5
- package/node_modules/@fps-games/plugin-shadow-map-experiment/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-shadow-map-experiment/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-shadow-map-experiment/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-shadow-map-experiment/package.json +5 -5
- package/node_modules/@fps-games/plugin-shadows/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-shadows/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-shadows/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-shadows/package.json +7 -7
- package/package.json +24 -22
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { CubeTexture } from '@babylonjs/core/Materials/Textures/cubeTexture.js';
|
|
2
2
|
import type { Scene } from '@babylonjs/core/scene.js';
|
|
3
|
+
import type { PlayableResolvedAssetResource } from '@fps-games/playable-assets';
|
|
3
4
|
export interface BabylonEnvironmentTextureLoadCallbacks {
|
|
4
5
|
readonly onLoad?: () => void;
|
|
5
6
|
readonly onError?: (message?: string, exception?: unknown) => void;
|
|
6
7
|
}
|
|
7
|
-
export type BabylonEnvironmentTextureFactory = (
|
|
8
|
+
export type BabylonEnvironmentTextureFactory = (resource: PlayableResolvedAssetResource, scene: Scene, callbacks?: BabylonEnvironmentTextureLoadCallbacks) => CubeTexture;
|
|
8
9
|
export interface BabylonEnvironmentTextureControllerOptions {
|
|
9
10
|
readonly createTexture?: BabylonEnvironmentTextureFactory;
|
|
10
11
|
}
|
|
11
12
|
export interface BabylonEnvironmentTextureProfile {
|
|
12
|
-
|
|
13
|
+
texture: PlayableResolvedAssetResource | null;
|
|
13
14
|
intensity: number;
|
|
14
15
|
rotationY: number;
|
|
15
16
|
}
|
|
16
17
|
export interface BabylonEnvironmentTextureController {
|
|
17
|
-
|
|
18
|
-
setProfileAsync(profile: BabylonEnvironmentTextureProfile | null | undefined, signal?: AbortSignal): Promise<void>;
|
|
18
|
+
applyProfile(profile: BabylonEnvironmentTextureProfile | null, signal?: AbortSignal): Promise<void>;
|
|
19
19
|
getProfile(): BabylonEnvironmentTextureProfile | null;
|
|
20
20
|
getTexture(): unknown | null;
|
|
21
21
|
dispose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/environment/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/environment/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAEhF,MAAM,WAAW,sCAAsC;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpE;AAED,MAAM,MAAM,gCAAgC,GAAG,CAC7C,QAAQ,EAAE,6BAA6B,EACvC,KAAK,EAAE,KAAK,EACZ,SAAS,CAAC,EAAE,sCAAsC,KAC/C,WAAW,CAAC;AAEjB,MAAM,WAAW,0CAA0C;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,gCAAgC,CAAC;CAC3D;AAED,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mCAAmC;IAClD,YAAY,CACV,OAAO,EAAE,gCAAgC,GAAG,IAAI,EAChD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,UAAU,IAAI,gCAAgC,GAAG,IAAI,CAAC;IACtD,UAAU,IAAI,OAAO,GAAG,IAAI,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,eAAO,MAAM,2CAA2C,EAAE,gCAIzD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/environment/types.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,MAAM,2CAA2C,GAAqC;IAC3F,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/environment/types.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,MAAM,2CAA2C,GAAqC;IAC3F,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;CACb,CAAC","sourcesContent":["import type { CubeTexture } from '@babylonjs/core/Materials/Textures/cubeTexture.js';\nimport type { Scene } from '@babylonjs/core/scene.js';\nimport type { PlayableResolvedAssetResource } from '@fps-games/playable-assets';\n\nexport interface BabylonEnvironmentTextureLoadCallbacks {\n readonly onLoad?: () => void;\n readonly onError?: (message?: string, exception?: unknown) => void;\n}\n\nexport type BabylonEnvironmentTextureFactory = (\n resource: PlayableResolvedAssetResource,\n scene: Scene,\n callbacks?: BabylonEnvironmentTextureLoadCallbacks,\n) => CubeTexture;\n\nexport interface BabylonEnvironmentTextureControllerOptions {\n readonly createTexture?: BabylonEnvironmentTextureFactory;\n}\n\nexport interface BabylonEnvironmentTextureProfile {\n texture: PlayableResolvedAssetResource | null;\n intensity: number;\n rotationY: number;\n}\n\nexport interface BabylonEnvironmentTextureController {\n applyProfile(\n profile: BabylonEnvironmentTextureProfile | null,\n signal?: AbortSignal,\n ): Promise<void>;\n getProfile(): BabylonEnvironmentTextureProfile | null;\n getTexture(): unknown | null;\n dispose(): void;\n}\n\nexport const DEFAULT_BABYLON_ENVIRONMENT_TEXTURE_PROFILE: BabylonEnvironmentTextureProfile = {\n texture: null,\n intensity: 1,\n rotationY: 0,\n};\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { FpsRuntimeData } from '@fps-games/playable-contracts';
|
|
2
2
|
import type { FpsDiagnostic, FpsPluginEnvironmentModule } from '@fps-games/plugin-api';
|
|
3
3
|
import { type FpsPluginHost } from '@fps-games/plugin-host';
|
|
4
|
+
import { type FpsAssetCatalogSource } from '@fps-games/plugin-assets/resources';
|
|
4
5
|
import { type FpsBabylonRendererContext, type FpsBabylonRendererService } from './plugin.js';
|
|
5
6
|
export interface FpsBabylonGameWorldPluginLifecycleOptions {
|
|
6
7
|
readonly runtimeModule: FpsPluginEnvironmentModule;
|
|
7
8
|
readonly rendererModule: FpsPluginEnvironmentModule;
|
|
8
9
|
readonly runtimeData: FpsRuntimeData;
|
|
10
|
+
readonly assetCatalog: FpsAssetCatalogSource['catalog'];
|
|
9
11
|
readonly apiVersion: number;
|
|
10
12
|
readonly report?: (diagnostic: FpsDiagnostic) => void;
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-world-plugin-lifecycle.d.ts","sourceRoot":"","sources":["../src/game-world-plugin-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EACV,aAAa,EACb,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAIL,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC/B,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,yCAAyC;IACxD,QAAQ,CAAC,aAAa,EAAE,0BAA0B,CAAC;IACnD,QAAQ,CAAC,cAAc,EAAE,0BAA0B,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QA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,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,WAAW,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACpD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,cAAc,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACvF,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAID,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,yCAAyC,GACjD,kCAAkC,CAiLpC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createFpsRuntimeDataSnapshot, FPS_RUNTIME_DATA } from '@fps-games/playable-runtime-data';
|
|
2
2
|
import { createFpsPluginHostFromEnvironmentModule, } from '@fps-games/plugin-host';
|
|
3
|
+
import { FPS_ASSET_CATALOG_SOURCE, } from '@fps-games/plugin-assets/resources';
|
|
3
4
|
import { FPS_BABYLON_RENDERER_CONTEXT, FPS_BABYLON_RENDERER_DATA, FPS_BABYLON_RENDERER_SERVICE, } from './plugin.js';
|
|
4
5
|
export function createFpsBabylonGameWorldPluginLifecycle(options) {
|
|
5
6
|
assertEnvironmentModule(options.runtimeModule, 'runtime');
|
|
@@ -59,7 +60,13 @@ export function createFpsBabylonGameWorldPluginLifecycle(options) {
|
|
|
59
60
|
module: options.runtimeModule,
|
|
60
61
|
apiVersion: options.apiVersion,
|
|
61
62
|
scope: 'project',
|
|
62
|
-
initialServices: [
|
|
63
|
+
initialServices: [
|
|
64
|
+
{ token: FPS_RUNTIME_DATA, value: runtimeData },
|
|
65
|
+
{
|
|
66
|
+
token: FPS_ASSET_CATALOG_SOURCE,
|
|
67
|
+
value: Object.freeze({ catalog: options.assetCatalog }),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
63
70
|
report: options.report,
|
|
64
71
|
});
|
|
65
72
|
runtimeHost = host;
|
|
@@ -90,6 +97,10 @@ export function createFpsBabylonGameWorldPluginLifecycle(options) {
|
|
|
90
97
|
initialServices: [
|
|
91
98
|
{ token: FPS_BABYLON_RENDERER_CONTEXT, value: context },
|
|
92
99
|
{ token: FPS_BABYLON_RENDERER_DATA, value: runtimeData },
|
|
100
|
+
{
|
|
101
|
+
token: FPS_ASSET_CATALOG_SOURCE,
|
|
102
|
+
value: Object.freeze({ catalog: options.assetCatalog }),
|
|
103
|
+
},
|
|
93
104
|
],
|
|
94
105
|
report: options.report,
|
|
95
106
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-world-plugin-lifecycle.js","sourceRoot":"","sources":["../src/game-world-plugin-lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAKlG,OAAO,EACL,wCAAwC,GAEzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,GAG7B,MAAM,aAAa,CAAC;AAsBrB,MAAM,UAAU,wCAAwC,CACtD,OAAkD;IAElD,uBAAuB,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC1D,uBAAuB,CAAC,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,4BAA4B,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtE,IAAI,WAAW,GAAyB,IAAI,CAAC;IAC7C,IAAI,YAAY,GAAyB,IAAI,CAAC;IAC9C,IAAI,QAAQ,GAAqC,IAAI,CAAC;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AAC,IAAa;IAChD,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAkC,EAClC,mBAA2C;IAE3C,IAAI,MAAM,CAAC,WAAW,KAAK,mBAAmB,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,cAAc,mBAAmB,wCAAwC,MAAM,CAAC,WAAW,GAAG,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { FpsRuntimeData } from '@fps-games/playable-contracts';\nimport { createFpsRuntimeDataSnapshot, FPS_RUNTIME_DATA } from '@fps-games/playable-runtime-data';\nimport type {\n FpsDiagnostic,\n FpsPluginEnvironmentModule,\n} from '@fps-games/plugin-api';\nimport {\n createFpsPluginHostFromEnvironmentModule,\n type FpsPluginHost,\n} from '@fps-games/plugin-host';\nimport {\n FPS_BABYLON_RENDERER_CONTEXT,\n FPS_BABYLON_RENDERER_DATA,\n FPS_BABYLON_RENDERER_SERVICE,\n type FpsBabylonRendererContext,\n type FpsBabylonRendererService,\n} from './plugin.js';\n\nexport interface FpsBabylonGameWorldPluginLifecycleOptions {\n readonly runtimeModule: FpsPluginEnvironmentModule;\n readonly rendererModule: FpsPluginEnvironmentModule;\n readonly runtimeData: FpsRuntimeData;\n readonly apiVersion: number;\n readonly report?: (diagnostic: FpsDiagnostic) => void;\n}\n\nexport interface FpsBabylonGameWorldPluginLifecycle {\n readonly runtimeHost: FpsPluginHost | null;\n readonly rendererHost: FpsPluginHost | null;\n readonly renderer: FpsBabylonRendererService | null;\n startRuntime(): Promise<void>;\n attachRenderer(context: FpsBabylonRendererContext): Promise<FpsBabylonRendererService>;\n detachRenderer(): Promise<void>;\n dispose(): Promise<void>;\n}\n\ntype GameWorldPluginLifecycleOperation = 'start-runtime' | 'attach-renderer' | 'detach-renderer' | 'dispose';\n\nexport function createFpsBabylonGameWorldPluginLifecycle(\n options: FpsBabylonGameWorldPluginLifecycleOptions,\n): FpsBabylonGameWorldPluginLifecycle {\n assertEnvironmentModule(options.runtimeModule, 'runtime');\n assertEnvironmentModule(options.rendererModule, 'renderer');\n const runtimeData = createFpsRuntimeDataSnapshot(options.runtimeData);\n let runtimeHost: FpsPluginHost | null = null;\n let rendererHost: FpsPluginHost | null = null;\n let renderer: FpsBabylonRendererService | null = null;\n let rendererScene: FpsBabylonRendererContext['scene'] | null = null;\n let rendererOwnershipOpen = false;\n let operationInProgress: GameWorldPluginLifecycleOperation | null = null;\n\n const run = <T>(\n operation: GameWorldPluginLifecycleOperation,\n callback: () => Promise<T>,\n ): Promise<T> => {\n if (operationInProgress) {\n return Promise.reject(new Error(\n `GameWorld Plugin lifecycle cannot ${operation} while ${operationInProgress} is in progress.`,\n ));\n }\n operationInProgress = operation;\n return callback().finally(() => { operationInProgress = null; });\n };\n\n const clearRuntimeHostIfDisposed = (host: FpsPluginHost): void => {\n if (runtimeHost === host && host.state === 'disposed') runtimeHost = null;\n };\n const clearRendererHostIfDisposed = (host: FpsPluginHost): void => {\n if (rendererHost !== host || host.state !== 'disposed') return;\n rendererHost = null;\n renderer = null;\n rendererScene = null;\n rendererOwnershipOpen = false;\n };\n\n const cleanupFailedStart = async (\n host: FpsPluginHost,\n clear: (host: FpsPluginHost) => void,\n primaryError: unknown,\n ): Promise<never> => {\n const cleanupErrors: unknown[] = [];\n if (host.state !== 'disposed') {\n try { await host.dispose(); } catch (error) { cleanupErrors.push(error); }\n }\n clear(host);\n if (cleanupErrors.length > 0 && primaryError && typeof primaryError === 'object') {\n try { Object.assign(primaryError, { cleanupErrors: Object.freeze(cleanupErrors) }); }\n catch { /* Preserve the primary failure even when it cannot be annotated. */ }\n }\n throw primaryError;\n };\n\n const startRuntime = (): Promise<void> => run('start-runtime', async () => {\n if (runtimeHost?.state === 'started') return;\n if (runtimeHost) {\n throw new Error(`GameWorld Runtime Host is retained in ${runtimeHost.state}; dispose it before restarting.`);\n }\n const host = createFpsPluginHostFromEnvironmentModule({\n module: options.runtimeModule,\n apiVersion: options.apiVersion,\n scope: 'project',\n initialServices: [{ token: FPS_RUNTIME_DATA, value: runtimeData }],\n report: options.report,\n });\n runtimeHost = host;\n try {\n await host.start();\n } catch (error) {\n return cleanupFailedStart(host, clearRuntimeHostIfDisposed, error);\n }\n });\n\n const attachRenderer = (\n context: FpsBabylonRendererContext,\n ): Promise<FpsBabylonRendererService> => run('attach-renderer', async () => {\n if (runtimeHost?.state !== 'started') {\n throw new Error('GameWorld Runtime Host must be started before attaching the Renderer Host.');\n }\n if (rendererHost?.state === 'started' && renderer) {\n if (rendererScene !== context.scene) {\n throw new Error('GameWorld Renderer Host is already attached to a different Scene.');\n }\n return renderer;\n }\n if (rendererHost) {\n throw new Error(`GameWorld Renderer Host is retained in ${rendererHost.state}; detach it before restarting.`);\n }\n const host = createFpsPluginHostFromEnvironmentModule({\n module: options.rendererModule,\n apiVersion: options.apiVersion,\n scope: 'application',\n initialServices: [\n { token: FPS_BABYLON_RENDERER_CONTEXT, value: context },\n { token: FPS_BABYLON_RENDERER_DATA, value: runtimeData },\n ],\n report: options.report,\n });\n rendererHost = host;\n rendererScene = context.scene;\n try {\n await host.start();\n const rendererController = host.services.get(FPS_BABYLON_RENDERER_SERVICE);\n rendererOwnershipOpen = true;\n const shadows: FpsBabylonRendererService['shadows'] = Object.freeze({\n registerRuntimeShadowObjects: (\n input: Parameters<FpsBabylonRendererService['shadows']['registerRuntimeShadowObjects']>[0],\n ) => {\n assertRendererOwnershipOpen(rendererOwnershipOpen);\n return rendererController.shadows.registerRuntimeShadowObjects(input);\n },\n registerActivitySource: (\n input: Parameters<FpsBabylonRendererService['shadows']['registerActivitySource']>[0],\n ) => {\n assertRendererOwnershipOpen(rendererOwnershipOpen);\n return rendererController.shadows.registerActivitySource(input);\n },\n getRuntimeSnapshot: () => rendererController.shadows.getRuntimeSnapshot(),\n getEvidence: () => rendererController.shadows.getEvidence(),\n });\n renderer = Object.freeze({ shadows });\n return renderer;\n } catch (error) {\n return cleanupFailedStart(host, clearRendererHostIfDisposed, error);\n }\n });\n\n const detachRenderer = (): Promise<void> => run('detach-renderer', async () => {\n const host = rendererHost;\n if (!host) return;\n rendererOwnershipOpen = false;\n try {\n await host.dispose();\n } finally {\n clearRendererHostIfDisposed(host);\n }\n });\n\n const dispose = (): Promise<void> => run('dispose', async () => {\n const errors: unknown[] = [];\n const currentRendererHost = rendererHost;\n if (currentRendererHost) {\n rendererOwnershipOpen = false;\n try { await currentRendererHost.dispose(); } catch (error) { errors.push(error); }\n finally { clearRendererHostIfDisposed(currentRendererHost); }\n }\n const currentRuntimeHost = runtimeHost;\n if (currentRuntimeHost) {\n try { await currentRuntimeHost.dispose(); } catch (error) { errors.push(error); }\n finally { clearRuntimeHostIfDisposed(currentRuntimeHost); }\n }\n if (errors.length === 1) throw errors[0];\n if (errors.length > 1) {\n throw Object.assign(new Error('GameWorld Plugin lifecycle disposal failed.'), {\n cleanupErrors: Object.freeze(errors),\n });\n }\n });\n\n return Object.freeze({\n get runtimeHost() { return runtimeHost; },\n get rendererHost() { return rendererHost; },\n get renderer() { return renderer; },\n startRuntime,\n attachRenderer,\n detachRenderer,\n dispose,\n });\n}\n\nfunction assertRendererOwnershipOpen(open: boolean): void {\n if (!open) throw new Error('Babylon renderer service is disposed.');\n}\n\nfunction assertEnvironmentModule(\n module: FpsPluginEnvironmentModule,\n expectedEnvironment: 'runtime' | 'renderer',\n): void {\n if (module.environment !== expectedEnvironment) {\n throw new Error(\n `Expected a ${expectedEnvironment} Plugin environment module, received ${module.environment}.`,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"game-world-plugin-lifecycle.js","sourceRoot":"","sources":["../src/game-world-plugin-lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAKlG,OAAO,EACL,wCAAwC,GAEzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,wBAAwB,GAEzB,MA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AC,CAAC;YAAC,CAAC;oBACzE,CAAC;gBAAC,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;YAAC,CAAC;QAC7D,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,6CAA6C,CAAC,EAAE;gBAC5E,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;aACrC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,WAAW,KAAK,OAAO,WAAW,CAAC,CAAC,CAAC;QACzC,IAAI,YAAY,KAAK,OAAO,YAAY,CAAC,CAAC,CAAC;QAC3C,IAAI,QAAQ,KAAK,OAAO,QAAQ,CAAC,CAAC,CAAC;QACnC,YAAY;QACZ,cAAc;QACd,cAAc;QACd,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAa;IAChD,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAkC,EAClC,mBAA2C;IAE3C,IAAI,MAAM,CAAC,WAAW,KAAK,mBAAmB,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,cAAc,mBAAmB,wCAAwC,MAAM,CAAC,WAAW,GAAG,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { FpsRuntimeData } from '@fps-games/playable-contracts';\nimport { createFpsRuntimeDataSnapshot, FPS_RUNTIME_DATA } from '@fps-games/playable-runtime-data';\nimport type {\n FpsDiagnostic,\n FpsPluginEnvironmentModule,\n} from '@fps-games/plugin-api';\nimport {\n createFpsPluginHostFromEnvironmentModule,\n type FpsPluginHost,\n} from '@fps-games/plugin-host';\nimport {\n FPS_ASSET_CATALOG_SOURCE,\n type FpsAssetCatalogSource,\n} from '@fps-games/plugin-assets/resources';\nimport {\n FPS_BABYLON_RENDERER_CONTEXT,\n FPS_BABYLON_RENDERER_DATA,\n FPS_BABYLON_RENDERER_SERVICE,\n type FpsBabylonRendererContext,\n type FpsBabylonRendererService,\n} from './plugin.js';\n\nexport interface FpsBabylonGameWorldPluginLifecycleOptions {\n readonly runtimeModule: FpsPluginEnvironmentModule;\n readonly rendererModule: FpsPluginEnvironmentModule;\n readonly runtimeData: FpsRuntimeData;\n readonly assetCatalog: FpsAssetCatalogSource['catalog'];\n readonly apiVersion: number;\n readonly report?: (diagnostic: FpsDiagnostic) => void;\n}\n\nexport interface FpsBabylonGameWorldPluginLifecycle {\n readonly runtimeHost: FpsPluginHost | null;\n readonly rendererHost: FpsPluginHost | null;\n readonly renderer: FpsBabylonRendererService | null;\n startRuntime(): Promise<void>;\n attachRenderer(context: FpsBabylonRendererContext): Promise<FpsBabylonRendererService>;\n detachRenderer(): Promise<void>;\n dispose(): Promise<void>;\n}\n\ntype GameWorldPluginLifecycleOperation = 'start-runtime' | 'attach-renderer' | 'detach-renderer' | 'dispose';\n\nexport function createFpsBabylonGameWorldPluginLifecycle(\n options: FpsBabylonGameWorldPluginLifecycleOptions,\n): FpsBabylonGameWorldPluginLifecycle {\n assertEnvironmentModule(options.runtimeModule, 'runtime');\n assertEnvironmentModule(options.rendererModule, 'renderer');\n const runtimeData = createFpsRuntimeDataSnapshot(options.runtimeData);\n let runtimeHost: FpsPluginHost | null = null;\n let rendererHost: FpsPluginHost | null = null;\n let renderer: FpsBabylonRendererService | null = null;\n let rendererScene: FpsBabylonRendererContext['scene'] | null = null;\n let rendererOwnershipOpen = false;\n let operationInProgress: GameWorldPluginLifecycleOperation | null = null;\n\n const run = <T>(\n operation: GameWorldPluginLifecycleOperation,\n callback: () => Promise<T>,\n ): Promise<T> => {\n if (operationInProgress) {\n return Promise.reject(new Error(\n `GameWorld Plugin lifecycle cannot ${operation} while ${operationInProgress} is in progress.`,\n ));\n }\n operationInProgress = operation;\n return callback().finally(() => { operationInProgress = null; });\n };\n\n const clearRuntimeHostIfDisposed = (host: FpsPluginHost): void => {\n if (runtimeHost === host && host.state === 'disposed') runtimeHost = null;\n };\n const clearRendererHostIfDisposed = (host: FpsPluginHost): void => {\n if (rendererHost !== host || host.state !== 'disposed') return;\n rendererHost = null;\n renderer = null;\n rendererScene = null;\n rendererOwnershipOpen = false;\n };\n\n const cleanupFailedStart = async (\n host: FpsPluginHost,\n clear: (host: FpsPluginHost) => void,\n primaryError: unknown,\n ): Promise<never> => {\n const cleanupErrors: unknown[] = [];\n if (host.state !== 'disposed') {\n try { await host.dispose(); } catch (error) { cleanupErrors.push(error); }\n }\n clear(host);\n if (cleanupErrors.length > 0 && primaryError && typeof primaryError === 'object') {\n try { Object.assign(primaryError, { cleanupErrors: Object.freeze(cleanupErrors) }); }\n catch { /* Preserve the primary failure even when it cannot be annotated. */ }\n }\n throw primaryError;\n };\n\n const startRuntime = (): Promise<void> => run('start-runtime', async () => {\n if (runtimeHost?.state === 'started') return;\n if (runtimeHost) {\n throw new Error(`GameWorld Runtime Host is retained in ${runtimeHost.state}; dispose it before restarting.`);\n }\n const host = createFpsPluginHostFromEnvironmentModule({\n module: options.runtimeModule,\n apiVersion: options.apiVersion,\n scope: 'project',\n initialServices: [\n { token: FPS_RUNTIME_DATA, value: runtimeData },\n {\n token: FPS_ASSET_CATALOG_SOURCE,\n value: Object.freeze({ catalog: options.assetCatalog }),\n },\n ],\n report: options.report,\n });\n runtimeHost = host;\n try {\n await host.start();\n } catch (error) {\n return cleanupFailedStart(host, clearRuntimeHostIfDisposed, error);\n }\n });\n\n const attachRenderer = (\n context: FpsBabylonRendererContext,\n ): Promise<FpsBabylonRendererService> => run('attach-renderer', async () => {\n if (runtimeHost?.state !== 'started') {\n throw new Error('GameWorld Runtime Host must be started before attaching the Renderer Host.');\n }\n if (rendererHost?.state === 'started' && renderer) {\n if (rendererScene !== context.scene) {\n throw new Error('GameWorld Renderer Host is already attached to a different Scene.');\n }\n return renderer;\n }\n if (rendererHost) {\n throw new Error(`GameWorld Renderer Host is retained in ${rendererHost.state}; detach it before restarting.`);\n }\n const host = createFpsPluginHostFromEnvironmentModule({\n module: options.rendererModule,\n apiVersion: options.apiVersion,\n scope: 'application',\n initialServices: [\n { token: FPS_BABYLON_RENDERER_CONTEXT, value: context },\n { token: FPS_BABYLON_RENDERER_DATA, value: runtimeData },\n {\n token: FPS_ASSET_CATALOG_SOURCE,\n value: Object.freeze({ catalog: options.assetCatalog }),\n },\n ],\n report: options.report,\n });\n rendererHost = host;\n rendererScene = context.scene;\n try {\n await host.start();\n const rendererController = host.services.get(FPS_BABYLON_RENDERER_SERVICE);\n rendererOwnershipOpen = true;\n const shadows: FpsBabylonRendererService['shadows'] = Object.freeze({\n registerRuntimeShadowObjects: (\n input: Parameters<FpsBabylonRendererService['shadows']['registerRuntimeShadowObjects']>[0],\n ) => {\n assertRendererOwnershipOpen(rendererOwnershipOpen);\n return rendererController.shadows.registerRuntimeShadowObjects(input);\n },\n registerActivitySource: (\n input: Parameters<FpsBabylonRendererService['shadows']['registerActivitySource']>[0],\n ) => {\n assertRendererOwnershipOpen(rendererOwnershipOpen);\n return rendererController.shadows.registerActivitySource(input);\n },\n getRuntimeSnapshot: () => rendererController.shadows.getRuntimeSnapshot(),\n getEvidence: () => rendererController.shadows.getEvidence(),\n });\n renderer = Object.freeze({ shadows });\n return renderer;\n } catch (error) {\n return cleanupFailedStart(host, clearRendererHostIfDisposed, error);\n }\n });\n\n const detachRenderer = (): Promise<void> => run('detach-renderer', async () => {\n const host = rendererHost;\n if (!host) return;\n rendererOwnershipOpen = false;\n try {\n await host.dispose();\n } finally {\n clearRendererHostIfDisposed(host);\n }\n });\n\n const dispose = (): Promise<void> => run('dispose', async () => {\n const errors: unknown[] = [];\n const currentRendererHost = rendererHost;\n if (currentRendererHost) {\n rendererOwnershipOpen = false;\n try { await currentRendererHost.dispose(); } catch (error) { errors.push(error); }\n finally { clearRendererHostIfDisposed(currentRendererHost); }\n }\n const currentRuntimeHost = runtimeHost;\n if (currentRuntimeHost) {\n try { await currentRuntimeHost.dispose(); } catch (error) { errors.push(error); }\n finally { clearRuntimeHostIfDisposed(currentRuntimeHost); }\n }\n if (errors.length === 1) throw errors[0];\n if (errors.length > 1) {\n throw Object.assign(new Error('GameWorld Plugin lifecycle disposal failed.'), {\n cleanupErrors: Object.freeze(errors),\n });\n }\n });\n\n return Object.freeze({\n get runtimeHost() { return runtimeHost; },\n get rendererHost() { return rendererHost; },\n get renderer() { return renderer; },\n startRuntime,\n attachRenderer,\n detachRenderer,\n dispose,\n });\n}\n\nfunction assertRendererOwnershipOpen(open: boolean): void {\n if (!open) throw new Error('Babylon renderer service is disposed.');\n}\n\nfunction assertEnvironmentModule(\n module: FpsPluginEnvironmentModule,\n expectedEnvironment: 'runtime' | 'renderer',\n): void {\n if (module.environment !== expectedEnvironment) {\n throw new Error(\n `Expected a ${expectedEnvironment} Plugin environment module, received ${module.environment}.`,\n );\n }\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Camera } from '@babylonjs/core/Cameras/camera.js';
|
|
2
2
|
import type { Scene } from '@babylonjs/core/scene.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { FpsRuntimeData } from '@fps-games/playable-contracts';
|
|
4
4
|
import { type FpsPluginEntry, type FpsPluginManifest } from '@fps-games/plugin-api';
|
|
5
5
|
import { createFpsPluginHost, type FpsPluginHost } from '@fps-games/plugin-host';
|
|
6
|
+
import { type FpsAssetCatalogSource } from '@fps-games/plugin-assets/resources';
|
|
6
7
|
import { FPS_BABYLON_RENDERER_PLUGIN_ID, type FpsBabylonRendererPluginConfig } from './reference.js';
|
|
7
8
|
import type { BabylonEnvironmentTextureController, BabylonEnvironmentTextureFactory } from './environment/types.js';
|
|
8
9
|
import type { BabylonDefaultPostProcessPipelineController } from './post-process/types.js';
|
|
@@ -12,7 +13,6 @@ export { FPS_BABYLON_RENDERER_PLUGIN_ID } from './reference.js';
|
|
|
12
13
|
export interface FpsBabylonRendererContext {
|
|
13
14
|
readonly scene: Scene;
|
|
14
15
|
readonly cameras: readonly Camera[];
|
|
15
|
-
readonly resolveAssetUrl?: (assetId: string, asset: FpsRuntimeAsset | null) => string | null;
|
|
16
16
|
readonly createEnvironmentTexture?: BabylonEnvironmentTextureFactory;
|
|
17
17
|
}
|
|
18
18
|
export interface FpsBabylonRendererService {
|
|
@@ -44,6 +44,7 @@ export interface FpsBabylonRendererPluginOptions {
|
|
|
44
44
|
}
|
|
45
45
|
export interface FpsBabylonRendererHostOptions extends FpsBabylonRendererPluginOptions {
|
|
46
46
|
readonly data: FpsRuntimeData;
|
|
47
|
+
readonly assetCatalog: FpsAssetCatalogSource['catalog'];
|
|
47
48
|
readonly context: FpsBabylonRendererContext;
|
|
48
49
|
readonly config?: FpsBabylonRendererPluginConfig;
|
|
49
50
|
readonly report?: Parameters<typeof createFpsPluginHost>[0]['report'];
|
|
@@ -55,8 +56,10 @@ export interface FpsBabylonRendererHost {
|
|
|
55
56
|
dispose(): Promise<void>;
|
|
56
57
|
}
|
|
57
58
|
export declare const FPS_BABYLON_RENDERER_CONTEXT: import("@fps-games/plugin-api").FpsServiceToken<FpsBabylonRendererContext>;
|
|
58
|
-
export declare const FPS_BABYLON_RENDERER_DATA: import("@fps-games/plugin-api").FpsServiceToken<FpsRuntimeData<FpsRuntimeAsset, import("@fps-games/playable-contracts").FpsRuntimeSceneNode>>;
|
|
59
|
+
export declare const FPS_BABYLON_RENDERER_DATA: import("@fps-games/plugin-api").FpsServiceToken<FpsRuntimeData<import("@fps-games/playable-contracts").FpsRuntimeAsset, import("@fps-games/playable-contracts").FpsRuntimeSceneNode>>;
|
|
59
60
|
export declare const FPS_BABYLON_RENDERER_SERVICE: import("@fps-games/plugin-api").FpsServiceToken<FpsBabylonRendererHostController>;
|
|
61
|
+
export type FpsBabylonRendererHostCleanup = () => Promise<void>;
|
|
62
|
+
export declare function readFpsBabylonRendererHostCleanup(error: unknown): FpsBabylonRendererHostCleanup | null;
|
|
60
63
|
export declare const pluginEntry: Readonly<{
|
|
61
64
|
pluginId: string;
|
|
62
65
|
environment: "renderer";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAepE,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAMjF,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,8BAA8B,EAC9B,KAAK,8BAA8B,EACpC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,mCAAmC,EACnC,gCAAgC,EACjC,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EACV,2CAA2C,EAC5C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,KAAK,gCAAgC,EACrC,KAAK,uCAAuC,EAC5C,KAAK,mCAAmC,EACxC,KAAK,kCAAkC,EAExC,MAAM,2CAA2C,CAAC;AACnD,OA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IN_ID, createShadowMapExperimentPlanSnapshot, normalizeEditorSceneRenderingProfile, } from '@fps-games/playable-rendering/runtime';
|
|
3
3
|
import { defineFpsPluginEntry, defineFpsPluginManifest, defineFpsServiceToken, } from '@fps-games/plugin-api';
|
|
4
4
|
import { createFpsPluginHost } from '@fps-games/plugin-host';
|
|
5
|
+
import { FPS_ASSETS_PLUGIN_ID, createFpsAssetsPluginManifest, } from '@fps-games/plugin-assets';
|
|
6
|
+
import { pluginEntry as assetsRendererPluginEntry } from '@fps-games/plugin-assets/renderer';
|
|
7
|
+
import { FPS_ASSET_CATALOG_SOURCE, FPS_ASSET_RESOURCE_RESOLVER, } from '@fps-games/plugin-assets/resources';
|
|
5
8
|
import { createBabylonEnvironmentTextureController } from './environment/environment-texture-controller.js';
|
|
6
9
|
import { FPS_BABYLON_RENDERER_PLUGIN_ID, } from './reference.js';
|
|
7
10
|
import { createBabylonDefaultPostProcessPipelineController, readBabylonDefaultPostProcessPipelineControllerCleanup, } from './post-process/babylon-default-pipeline.js';
|
|
@@ -10,6 +13,13 @@ export { FPS_BABYLON_RENDERER_PLUGIN_ID } from './reference.js';
|
|
|
10
13
|
export const FPS_BABYLON_RENDERER_CONTEXT = defineFpsServiceToken('fps.renderer.babylon.context');
|
|
11
14
|
export const FPS_BABYLON_RENDERER_DATA = defineFpsServiceToken('fps.renderer.babylon.runtime-data');
|
|
12
15
|
export const FPS_BABYLON_RENDERER_SERVICE = defineFpsServiceToken('fps.renderer.babylon.service');
|
|
16
|
+
export function readFpsBabylonRendererHostCleanup(error) {
|
|
17
|
+
if (!error || (typeof error !== 'object' && typeof error !== 'function'))
|
|
18
|
+
return null;
|
|
19
|
+
const cleanup = error
|
|
20
|
+
.fpsBabylonRendererHostCleanup;
|
|
21
|
+
return typeof cleanup === 'function' ? cleanup : null;
|
|
22
|
+
}
|
|
13
23
|
const fpsBabylonRendererSceneOwners = new WeakMap();
|
|
14
24
|
export const pluginEntry = defineFpsPluginEntry({
|
|
15
25
|
pluginId: FPS_BABYLON_RENDERER_PLUGIN_ID,
|
|
@@ -17,10 +27,11 @@ export const pluginEntry = defineFpsPluginEntry({
|
|
|
17
27
|
register(context) {
|
|
18
28
|
const rendererContext = context.services.get(FPS_BABYLON_RENDERER_CONTEXT);
|
|
19
29
|
const runtimeData = context.services.get(FPS_BABYLON_RENDERER_DATA);
|
|
30
|
+
const assetResources = context.services.get(FPS_ASSET_RESOURCE_RESOLVER);
|
|
20
31
|
const releaseSceneOwnership = reserveFpsBabylonRendererScene(rendererContext.scene);
|
|
21
32
|
let createdService;
|
|
22
33
|
try {
|
|
23
|
-
createdService = createFpsBabylonRendererService(runtimeData, rendererContext,
|
|
34
|
+
createdService = createFpsBabylonRendererService(runtimeData, rendererContext, assetResources, diagnostic => context.report(diagnostic), releaseSceneOwnership);
|
|
24
35
|
}
|
|
25
36
|
catch (error) {
|
|
26
37
|
const recoverConstruction = readFpsBabylonRendererConstructionCleanup(error)
|
|
@@ -74,6 +85,7 @@ export function createFpsBabylonRendererPlugin(options) {
|
|
|
74
85
|
services: [
|
|
75
86
|
FPS_BABYLON_RENDERER_CONTEXT.id,
|
|
76
87
|
FPS_BABYLON_RENDERER_DATA.id,
|
|
88
|
+
FPS_ASSET_RESOURCE_RESOLVER.id,
|
|
77
89
|
],
|
|
78
90
|
},
|
|
79
91
|
provides: { services: [FPS_BABYLON_RENDERER_SERVICE.id] },
|
|
@@ -85,19 +97,39 @@ export function createFpsBabylonRendererPlugin(options) {
|
|
|
85
97
|
}
|
|
86
98
|
export async function createFpsBabylonRendererHost(options) {
|
|
87
99
|
const plugin = createFpsBabylonRendererPlugin(options);
|
|
100
|
+
const assetsManifest = createFpsAssetsPluginManifest();
|
|
88
101
|
const host = createFpsPluginHost({
|
|
89
102
|
environment: 'renderer',
|
|
90
103
|
apiVersion: 1,
|
|
91
|
-
manifests: [plugin.manifest],
|
|
92
|
-
pluginConfigs: {
|
|
104
|
+
manifests: [assetsManifest, plugin.manifest],
|
|
105
|
+
pluginConfigs: {
|
|
106
|
+
[FPS_ASSETS_PLUGIN_ID]: null,
|
|
107
|
+
[FPS_BABYLON_RENDERER_PLUGIN_ID]: options.config ?? {},
|
|
108
|
+
},
|
|
93
109
|
initialServices: [
|
|
94
110
|
{ token: FPS_BABYLON_RENDERER_CONTEXT, value: options.context },
|
|
95
111
|
{ token: FPS_BABYLON_RENDERER_DATA, value: options.data },
|
|
112
|
+
{
|
|
113
|
+
token: FPS_ASSET_CATALOG_SOURCE,
|
|
114
|
+
value: Object.freeze({ catalog: options.assetCatalog }),
|
|
115
|
+
},
|
|
96
116
|
],
|
|
97
|
-
loadEntry: async (manifest) => manifest.id ===
|
|
117
|
+
loadEntry: async (manifest) => (manifest.id === assetsManifest.id
|
|
118
|
+
? assetsRendererPluginEntry
|
|
119
|
+
: manifest.id === plugin.manifest.id
|
|
120
|
+
? plugin.renderer
|
|
121
|
+
: null),
|
|
98
122
|
report: options.report,
|
|
99
123
|
});
|
|
100
|
-
|
|
124
|
+
try {
|
|
125
|
+
await host.start();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (host.state !== 'cleanup-failed')
|
|
129
|
+
throw error;
|
|
130
|
+
const retryCleanup = () => host.dispose();
|
|
131
|
+
throw attachFpsBabylonRendererHostCleanup(error, retryCleanup);
|
|
132
|
+
}
|
|
101
133
|
const renderer = host.services.get(FPS_BABYLON_RENDERER_SERVICE);
|
|
102
134
|
let hostDisposePromise = null;
|
|
103
135
|
return {
|
|
@@ -107,24 +139,11 @@ export async function createFpsBabylonRendererHost(options) {
|
|
|
107
139
|
dispose: () => {
|
|
108
140
|
if (!hostDisposePromise) {
|
|
109
141
|
const operation = (async () => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
errors.push(error);
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
await host.dispose();
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
errors.push(error);
|
|
122
|
-
}
|
|
123
|
-
if (errors.length === 1)
|
|
124
|
-
throw errors[0];
|
|
125
|
-
if (errors.length > 1) {
|
|
126
|
-
throw Object.assign(new Error('Babylon renderer host disposal failed.'), { errors });
|
|
127
|
-
}
|
|
142
|
+
// Abort queued renderer work immediately. If cleanup fails, keep the
|
|
143
|
+
// Plugin Host and Scene ownership intact until the caller explicitly
|
|
144
|
+
// retries this public disposal operation.
|
|
145
|
+
await renderer.dispose();
|
|
146
|
+
await host.dispose();
|
|
128
147
|
})();
|
|
129
148
|
hostDisposePromise = operation.catch(error => {
|
|
130
149
|
hostDisposePromise = null;
|
|
@@ -135,8 +154,26 @@ export async function createFpsBabylonRendererHost(options) {
|
|
|
135
154
|
},
|
|
136
155
|
};
|
|
137
156
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
157
|
+
function attachFpsBabylonRendererHostCleanup(failure, cleanup) {
|
|
158
|
+
const error = failure instanceof Error
|
|
159
|
+
? failure
|
|
160
|
+
: new Error('Babylon Renderer Host start failed and cleanup is incomplete.');
|
|
161
|
+
const metadata = {
|
|
162
|
+
fpsBabylonRendererHostCleanup: cleanup,
|
|
163
|
+
retryCleanup: cleanup,
|
|
164
|
+
};
|
|
165
|
+
try {
|
|
166
|
+
Object.assign(error, metadata);
|
|
167
|
+
if (readFpsBabylonRendererHostCleanup(error) === cleanup)
|
|
168
|
+
return error;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// Preserve the primary rejection as cause when it cannot carry cleanup metadata.
|
|
172
|
+
}
|
|
173
|
+
return Object.assign(new Error('Babylon Renderer Host start failed and cleanup is incomplete.'), { cause: failure, ...metadata });
|
|
174
|
+
}
|
|
175
|
+
function createFpsBabylonRendererService(initialData, context, assetResources, report, releaseSceneOwnership) {
|
|
176
|
+
const initialPrepared = prepareFpsBabylonRendererUpdate(initialData, assetResources, report);
|
|
140
177
|
let data = initialPrepared.data;
|
|
141
178
|
let disposed = false;
|
|
142
179
|
let acceptingUpdates = true;
|
|
@@ -156,7 +193,7 @@ function createFpsBabylonRendererService(initialData, context, config, releaseSc
|
|
|
156
193
|
const postProcess = createBabylonDefaultPostProcessPipelineController(context.scene, [...context.cameras], null);
|
|
157
194
|
let environment;
|
|
158
195
|
try {
|
|
159
|
-
environment = createBabylonEnvironmentTextureController(context.scene,
|
|
196
|
+
environment = createBabylonEnvironmentTextureController(context.scene, {
|
|
160
197
|
createTexture: context.createEnvironmentTexture,
|
|
161
198
|
});
|
|
162
199
|
}
|
|
@@ -246,7 +283,7 @@ function createFpsBabylonRendererService(initialData, context, config, releaseSc
|
|
|
246
283
|
try {
|
|
247
284
|
shadowMapExperiment.setPlan(prepared.shadowMapExperimentPlan);
|
|
248
285
|
postProcess.setProfile(prepared.postProcess);
|
|
249
|
-
await environment.
|
|
286
|
+
await environment.applyProfile(prepared.environment, signal);
|
|
250
287
|
if (signal.aborted)
|
|
251
288
|
throw createFpsBabylonRendererAbortError();
|
|
252
289
|
data = prepared.data;
|
|
@@ -254,7 +291,7 @@ function createFpsBabylonRendererService(initialData, context, config, releaseSc
|
|
|
254
291
|
catch (error) {
|
|
255
292
|
const rollbackErrors = [];
|
|
256
293
|
try {
|
|
257
|
-
await environment.
|
|
294
|
+
await environment.applyProfile(previousEnvironment);
|
|
258
295
|
}
|
|
259
296
|
catch (rollbackError) {
|
|
260
297
|
rollbackErrors.push(rollbackError);
|
|
@@ -316,7 +353,7 @@ function createFpsBabylonRendererService(initialData, context, config, releaseSc
|
|
|
316
353
|
async update(nextData) {
|
|
317
354
|
if (!acceptingUpdates || disposed)
|
|
318
355
|
throw new Error('Babylon renderer service is disposed.');
|
|
319
|
-
await enqueue(prepareFpsBabylonRendererUpdate(nextData,
|
|
356
|
+
await enqueue(prepareFpsBabylonRendererUpdate(nextData, assetResources, report));
|
|
320
357
|
},
|
|
321
358
|
async dispose() {
|
|
322
359
|
if (disposePromise)
|
|
@@ -419,24 +456,35 @@ function getFpsBabylonRendererInternalService(context) {
|
|
|
419
456
|
function createFpsBabylonRendererAbortError() {
|
|
420
457
|
return Object.assign(new Error('Babylon renderer update aborted.'), { name: 'AbortError' });
|
|
421
458
|
}
|
|
422
|
-
function prepareFpsBabylonRendererUpdate(input,
|
|
459
|
+
function prepareFpsBabylonRendererUpdate(input, assetResources, report) {
|
|
423
460
|
const data = createFpsRuntimeDataSnapshot(input);
|
|
424
461
|
const profile = normalizeEditorSceneRenderingProfile(data.rendering);
|
|
425
462
|
const textureRef = profile.environment.texture;
|
|
426
|
-
const
|
|
427
|
-
?
|
|
463
|
+
const textureResolution = textureRef
|
|
464
|
+
? assetResources.resolve({
|
|
465
|
+
assetId: textureRef.textureAssetId,
|
|
466
|
+
url: textureRef.url,
|
|
467
|
+
})
|
|
428
468
|
: null;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
:
|
|
433
|
-
|
|
434
|
-
|
|
469
|
+
if (textureResolution && !textureResolution.ok) {
|
|
470
|
+
const diagnostic = {
|
|
471
|
+
code: textureResolution.diagnostic.code,
|
|
472
|
+
severity: 'error',
|
|
473
|
+
pluginId: FPS_BABYLON_RENDERER_PLUGIN_ID,
|
|
474
|
+
message: createAssetResourceResolutionMessage(textureResolution.diagnostic),
|
|
475
|
+
details: { ...textureResolution.diagnostic },
|
|
476
|
+
};
|
|
477
|
+
report(diagnostic);
|
|
478
|
+
throw Object.assign(new Error(diagnostic.message), {
|
|
479
|
+
code: diagnostic.code,
|
|
480
|
+
diagnostic: Object.freeze(diagnostic),
|
|
481
|
+
});
|
|
482
|
+
}
|
|
435
483
|
const shadowMapExperimentEntry = data.plugins?.find(entry => entry.pluginId === FPS_SHADOW_MAP_EXPERIMENT_PLUGIN_ID);
|
|
436
484
|
return Object.freeze({
|
|
437
485
|
data,
|
|
438
486
|
environment: Object.freeze({
|
|
439
|
-
|
|
487
|
+
texture: textureResolution?.resource ?? null,
|
|
440
488
|
intensity: profile.environment.iblIntensity,
|
|
441
489
|
rotationY: profile.environment.rotationY,
|
|
442
490
|
}),
|
|
@@ -446,4 +494,17 @@ function prepareFpsBabylonRendererUpdate(input, context, config) {
|
|
|
446
494
|
: null,
|
|
447
495
|
});
|
|
448
496
|
}
|
|
497
|
+
function createAssetResourceResolutionMessage(diagnostic) {
|
|
498
|
+
const identity = diagnostic.assetId ? ` asset ${diagnostic.assetId}` : ' external resource';
|
|
499
|
+
if (diagnostic.code === 'asset.resource.not-found') {
|
|
500
|
+
return `Environment texture${identity} was not found in the generated asset catalog.`;
|
|
501
|
+
}
|
|
502
|
+
if (diagnostic.code === 'asset.resource.format-missing') {
|
|
503
|
+
return `Environment texture${identity} has no resolvable source format.`;
|
|
504
|
+
}
|
|
505
|
+
if (diagnostic.code === 'asset.resource.format-unsupported') {
|
|
506
|
+
return `Environment texture${identity} uses unsupported format ${diagnostic.format ?? '<unknown>'}.`;
|
|
507
|
+
}
|
|
508
|
+
return `Environment texture${identity} reference is invalid.`;
|
|
509
|
+
}
|
|
449
510
|
//# sourceMappingURL=plugin.js.map
|