Enhance viewport simulation state tracking and membership signatures
This commit is contained in:
@@ -357,7 +357,10 @@ function isOpaqueExternalObjectType(type: ts.Type): boolean {
|
|||||||
declarations.some((declaration) => {
|
declarations.some((declaration) => {
|
||||||
const fileName = declaration.getSourceFile().fileName;
|
const fileName = declaration.getSourceFile().fileName;
|
||||||
return (
|
return (
|
||||||
fileName.includes(`${path.sep}node_modules${path.sep}`) ||
|
fileName.includes(`${path.sep}node_modules${path.sep}three${path.sep}`) ||
|
||||||
|
fileName.includes(
|
||||||
|
`${path.sep}node_modules${path.sep}@types${path.sep}three${path.sep}`
|
||||||
|
) ||
|
||||||
fileName.endsWith(`${path.sep}lib.dom.d.ts`)
|
fileName.endsWith(`${path.sep}lib.dom.d.ts`)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -601,6 +601,62 @@ interface LocalLightRenderObjects {
|
|||||||
light: PointLight | SpotLight;
|
light: PointLight | SpotLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ViewportSimulationVersionInfo {
|
||||||
|
sceneVersion: number;
|
||||||
|
frameVersion: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ViewportSimulationMembershipSignatures {
|
||||||
|
localLights: string;
|
||||||
|
lightVolumes: string;
|
||||||
|
modelInstances: string;
|
||||||
|
interactables: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createSortedMembershipSignature(values: readonly string[]): string {
|
||||||
|
return [...values].sort().join("|");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createViewportSimulationMembershipSignatures(
|
||||||
|
runtimeScene: RuntimeSceneDefinition | null
|
||||||
|
): ViewportSimulationMembershipSignatures {
|
||||||
|
if (runtimeScene === null) {
|
||||||
|
return {
|
||||||
|
localLights: "",
|
||||||
|
lightVolumes: "",
|
||||||
|
modelInstances: "",
|
||||||
|
interactables: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
localLights: createSortedMembershipSignature([
|
||||||
|
...runtimeScene.localLights.pointLights.map(
|
||||||
|
(light) => `point:${light.entityId}`
|
||||||
|
),
|
||||||
|
...runtimeScene.localLights.spotLights.map(
|
||||||
|
(light) => `spot:${light.entityId}`
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
lightVolumes: createSortedMembershipSignature(
|
||||||
|
runtimeScene.volumes.light.map(
|
||||||
|
(lightVolume) =>
|
||||||
|
`${lightVolume.brushId}:${String(lightVolume.lights.length)}`
|
||||||
|
)
|
||||||
|
),
|
||||||
|
modelInstances: createSortedMembershipSignature(
|
||||||
|
runtimeScene.modelInstances.map(
|
||||||
|
(modelInstance) => modelInstance.instanceId
|
||||||
|
)
|
||||||
|
),
|
||||||
|
interactables: createSortedMembershipSignature(
|
||||||
|
runtimeScene.entities.interactables.map(
|
||||||
|
(interactable) => interactable.entityId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export class ViewportHost {
|
export class ViewportHost {
|
||||||
private readonly scene = new Scene();
|
private readonly scene = new Scene();
|
||||||
private readonly worldBackgroundRenderer = new WorldBackgroundRenderer();
|
private readonly worldBackgroundRenderer = new WorldBackgroundRenderer();
|
||||||
@@ -707,10 +763,16 @@ export class ViewportHost {
|
|||||||
private currentWorld: WorldSettings | null = null;
|
private currentWorld: WorldSettings | null = null;
|
||||||
private currentSimulationScene: RuntimeSceneDefinition | null = null;
|
private currentSimulationScene: RuntimeSceneDefinition | null = null;
|
||||||
private currentSimulationClock: RuntimeClockState | null = null;
|
private currentSimulationClock: RuntimeClockState | null = null;
|
||||||
|
private currentSimulationSceneVersion = -1;
|
||||||
|
private currentSimulationFrameVersion = -1;
|
||||||
|
private currentSimulationMembershipSignatures: ViewportSimulationMembershipSignatures =
|
||||||
|
createViewportSimulationMembershipSignatures(null);
|
||||||
private readonly simulationInteractableEnabledById = new Map<
|
private readonly simulationInteractableEnabledById = new Map<
|
||||||
string,
|
string,
|
||||||
boolean
|
boolean
|
||||||
>();
|
>();
|
||||||
|
private simulationActiveNpcEntityIds = new Set<string>();
|
||||||
|
private simulationSceneIdentityMismatchWarned = false;
|
||||||
private currentCelestialShadowCaster: "sun" | "moon" | null = null;
|
private currentCelestialShadowCaster: "sun" | "moon" | null = null;
|
||||||
private currentAdvancedRenderingSettings: AdvancedRenderingSettings | null =
|
private currentAdvancedRenderingSettings: AdvancedRenderingSettings | null =
|
||||||
null;
|
null;
|
||||||
|
|||||||
Reference in New Issue
Block a user