mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
handle lost event
This commit is contained in:
parent
fcfd3331dd
commit
d3eb3867bd
3 changed files with 29 additions and 7 deletions
|
|
@ -70,6 +70,10 @@ export abstract class EngineControllerBase<T extends RoomEngineBase> {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'contextlost': {
|
||||
this.onContextLost();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.warn('Unrecognized message from worker:', event.data?.type);
|
||||
}
|
||||
|
|
@ -79,14 +83,18 @@ export abstract class EngineControllerBase<T extends RoomEngineBase> {
|
|||
const babylonEngine = new BABYLON.WebGPUEngine(canvas, { doNotHandleContextLost: true, powerPreference: 'high-performance', antialias: this.options.antialias });
|
||||
babylonEngine.compatibilityMode = false;
|
||||
babylonEngine.enableOfflineSupport = false;
|
||||
babylonEngine.onContextLostObservable.add(() => {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: i18n.ts.somethingHappened,
|
||||
text: i18n.ts._miWorld.crushed_description,
|
||||
});
|
||||
});
|
||||
await babylonEngine.initAsync();
|
||||
// doNotHandleContextLostがtrueだとそもそも呼ばれない
|
||||
//babylonEngine.onContextLostObservable.add(() => {
|
||||
// os.alert({
|
||||
// type: 'error',
|
||||
// title: i18n.ts.somethingHappened,
|
||||
// text: i18n.ts._miWorld.crushed_description,
|
||||
// });
|
||||
//});
|
||||
babylonEngine._device.lost.then(() => { // TODO: babylonEngineの内部プロパティに依存しない方法をforumで聞く
|
||||
this.onContextLost();
|
||||
});
|
||||
if (this.options.resolution === 2) babylonEngine.setHardwareScalingLevel(0.5);
|
||||
if (this.options.resolution === 0.5) babylonEngine.setHardwareScalingLevel(2);
|
||||
|
||||
|
|
@ -270,6 +278,14 @@ export abstract class EngineControllerBase<T extends RoomEngineBase> {
|
|||
this.initializeProgress.value = 0;
|
||||
}
|
||||
|
||||
private onContextLost() {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: i18n.ts.somethingHappened,
|
||||
text: i18n.ts._miWorld.crushed_description,
|
||||
});
|
||||
}
|
||||
|
||||
private callCounter = 0;
|
||||
|
||||
protected call<FN extends keyof T>(fn: FN, args: Parameters<T[FN]> = [] as any): void {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ onmessage = async (event) => {
|
|||
babylonEngine.compatibilityMode = false;
|
||||
babylonEngine.enableOfflineSupport = false;
|
||||
await babylonEngine.initAsync();
|
||||
babylonEngine._device.lost.then(() => { // TODO: babylonEngineの内部プロパティに依存しない方法をforumで聞く
|
||||
self.postMessage({ type: 'contextlost' });
|
||||
});
|
||||
if (event.data.options.resolution === 2) babylonEngine.setHardwareScalingLevel(0.5);
|
||||
if (event.data.options.resolution === 0.5) babylonEngine.setHardwareScalingLevel(2);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ onmessage = async (event) => {
|
|||
babylonEngine.compatibilityMode = false;
|
||||
babylonEngine.enableOfflineSupport = false;
|
||||
await babylonEngine.initAsync();
|
||||
babylonEngine._device.lost.then(() => { // TODO: babylonEngineの内部プロパティに依存しない方法をforumで聞く
|
||||
self.postMessage({ type: 'contextlost' });
|
||||
});
|
||||
if (event.data.options.resolution === 2) babylonEngine.setHardwareScalingLevel(0.5);
|
||||
if (event.data.options.resolution === 0.5) babylonEngine.setHardwareScalingLevel(2);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue