mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-26 12:34:30 +02:00
wip
This commit is contained in:
@@ -164,6 +164,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue';
|
import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue';
|
||||||
import XObjectCustomizeForm from './room.object-customize-form.vue';
|
import XObjectCustomizeForm from './room.object-customize-form.vue';
|
||||||
|
import type { RoomControllerOptions } from '@/world/room/controller.js';
|
||||||
import { definePage } from '@/page.js';
|
import { definePage } from '@/page.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { ensureSignin } from '@/i';
|
import { ensureSignin } from '@/i';
|
||||||
@@ -204,7 +205,7 @@ const graphicsQualityAutoValue = computed<number>(() => deviceKind === 'smartpho
|
|||||||
const graphicsQuality = computed<number>(() => graphicsQualityRaw.value ?? graphicsQualityAutoValue.value);
|
const graphicsQuality = computed<number>(() => graphicsQualityRaw.value ?? graphicsQualityAutoValue.value);
|
||||||
|
|
||||||
const fpsRaw = prefer.model('world.fps');
|
const fpsRaw = prefer.model('world.fps');
|
||||||
const fpsAutoValue = computed<number | null>(() => graphicsQuality.value >= GRAPHICS_QUALITY_HIGH ? null : 30);
|
const fpsAutoValue = computed<number | null>(() => deviceKind === 'smartphone' ? 30 : 60);
|
||||||
const fps = computed<number | null>(() =>
|
const fps = computed<number | null>(() =>
|
||||||
fpsRaw.value == null ? fpsAutoValue.value :
|
fpsRaw.value == null ? fpsAutoValue.value :
|
||||||
fpsRaw.value === 'max' ? null :
|
fpsRaw.value === 'max' ? null :
|
||||||
@@ -212,6 +213,10 @@ const fps = computed<number | null>(() =>
|
|||||||
fpsRaw.value === '60' ? 60 :
|
fpsRaw.value === '60' ? 60 :
|
||||||
30);
|
30);
|
||||||
|
|
||||||
|
const resolutionRaw = prefer.model('world.resolution');
|
||||||
|
const resolutionAutoValue = computed<number>(() => deviceKind === 'smartphone' ? 0.5 : 1);
|
||||||
|
const resolution = computed<number>(() => resolutionRaw.value ?? resolutionAutoValue.value);
|
||||||
|
|
||||||
const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet');
|
const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet');
|
||||||
|
|
||||||
const joyStickRadiusPx = 100;
|
const joyStickRadiusPx = 100;
|
||||||
@@ -259,11 +264,14 @@ const data = localStorage.getItem('roomData') != null ? JSON.parse(localStorage.
|
|||||||
|
|
||||||
let latestData = deepClone(data);
|
let latestData = deepClone(data);
|
||||||
|
|
||||||
const controller = new RoomController(data, {
|
const roomControllerOptions = computed<RoomControllerOptions>(() => ({
|
||||||
graphicsQuality: graphicsQuality.value,
|
graphicsQuality: graphicsQuality.value,
|
||||||
fps: fps.value,
|
fps: fps.value,
|
||||||
|
resolution: resolution.value,
|
||||||
useVirtualJoystick,
|
useVirtualJoystick,
|
||||||
});
|
}));
|
||||||
|
|
||||||
|
const controller = new RoomController(data, roomControllerOptions.value);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
controller.init(canvas.value!);
|
controller.init(canvas.value!);
|
||||||
@@ -314,6 +322,10 @@ onMounted(async () => {
|
|||||||
controller.setCameraJoystickRotateVector(vector);
|
controller.setCameraJoystickRotateVector(vector);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch([graphicsQuality, fps, resolution], () => {
|
||||||
|
refresh();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@@ -426,11 +438,7 @@ async function revert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
await controller.reset(null, {
|
await controller.reset(null, roomControllerOptions.value);
|
||||||
graphicsQuality: graphicsQuality.value,
|
|
||||||
fps: fps.value,
|
|
||||||
useVirtualJoystick,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function expor() {
|
function expor() {
|
||||||
@@ -486,6 +494,17 @@ function showOtherMenu(ev: PointerEvent) {
|
|||||||
'~30fps': '30',
|
'~30fps': '30',
|
||||||
},
|
},
|
||||||
ref: fpsRaw,
|
ref: fpsRaw,
|
||||||
|
}, {
|
||||||
|
type: 'radio',
|
||||||
|
text: 'Resolution',
|
||||||
|
caption: resolutionRaw.value == null ? i18n.ts.auto : resolutionRaw.value + 'x',
|
||||||
|
options: {
|
||||||
|
[`Auto (${resolutionAutoValue.value})`]: null,
|
||||||
|
'2x': 2,
|
||||||
|
'1x': 1,
|
||||||
|
'0.5x': 0.5,
|
||||||
|
},
|
||||||
|
ref: resolutionRaw,
|
||||||
}, {
|
}, {
|
||||||
type: 'divider',
|
type: 'divider',
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -539,6 +539,9 @@ export const PREF_DEF = definePreferences({
|
|||||||
'world.fps': {
|
'world.fps': {
|
||||||
default: null as 'max' | '120' | '60' | '30' | null,
|
default: null as 'max' | '120' | '60' | '30' | null,
|
||||||
},
|
},
|
||||||
|
'world.resolution': {
|
||||||
|
default: null as 0.5 | 1 | 2 | null,
|
||||||
|
},
|
||||||
|
|
||||||
'experimental.stackingRouterView': {
|
'experimental.stackingRouterView': {
|
||||||
default: false,
|
default: false,
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ import type { RoomState } from './engine.js';
|
|||||||
import type { ObjectDef, RoomStateObject } from './object.js';
|
import type { ObjectDef, RoomStateObject } from './object.js';
|
||||||
import * as sound from '@/utility/sound.js';
|
import * as sound from '@/utility/sound.js';
|
||||||
|
|
||||||
type Options = {
|
export type RoomControllerOptions = {
|
||||||
workerMode?: boolean;
|
workerMode?: boolean;
|
||||||
graphicsQuality: number;
|
graphicsQuality: number;
|
||||||
fps: number | null;
|
fps: number | null;
|
||||||
|
resolution: number | null;
|
||||||
useVirtualJoystick?: boolean;
|
useVirtualJoystick?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ export class RoomController {
|
|||||||
private worker: Worker | null = null;
|
private worker: Worker | null = null;
|
||||||
private engine: RoomEngine | null = null;
|
private engine: RoomEngine | null = null;
|
||||||
private canvas: HTMLCanvasElement | null = null;
|
private canvas: HTMLCanvasElement | null = null;
|
||||||
private options: Options;
|
private options: RoomControllerOptions;
|
||||||
private isCanvasDragging = false;
|
private isCanvasDragging = false;
|
||||||
public isReady = ref(false);
|
public isReady = ref(false);
|
||||||
public isSitting = ref(false);
|
public isSitting = ref(false);
|
||||||
@@ -40,7 +41,7 @@ export class RoomController {
|
|||||||
public roomState: ShallowRef<RoomState>;
|
public roomState: ShallowRef<RoomState>;
|
||||||
public initializeProgress = ref(0);
|
public initializeProgress = ref(0);
|
||||||
|
|
||||||
constructor(roomState: RoomState, options: Options) {
|
constructor(roomState: RoomState, options: RoomControllerOptions) {
|
||||||
this.roomState = shallowRef(roomState);
|
this.roomState = shallowRef(roomState);
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
@@ -68,6 +69,8 @@ export class RoomController {
|
|||||||
babylonEngine.compatibilityMode = false;
|
babylonEngine.compatibilityMode = false;
|
||||||
babylonEngine.enableOfflineSupport = false;
|
babylonEngine.enableOfflineSupport = false;
|
||||||
await babylonEngine.initAsync();
|
await babylonEngine.initAsync();
|
||||||
|
if (this.options.resolution === 2) babylonEngine.setHardwareScalingLevel(0.5);
|
||||||
|
if (this.options.resolution === 0.5) babylonEngine.setHardwareScalingLevel(2);
|
||||||
|
|
||||||
this.engine = new RoomEngine(this.roomState.value, { canvas, engine: babylonEngine, ...this.options });
|
this.engine = new RoomEngine(this.roomState.value, { canvas, engine: babylonEngine, ...this.options });
|
||||||
this.engine.on('loadingProgress', ({ progress }) => {
|
this.engine.on('loadingProgress', ({ progress }) => {
|
||||||
@@ -174,7 +177,7 @@ export class RoomController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async reset(roomState?: RoomState | null, options?: Options | null, canvas?: HTMLCanvasElement | null) {
|
public async reset(roomState?: RoomState | null, options?: RoomControllerOptions | null, canvas?: HTMLCanvasElement | null) {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
if (roomState != null) this.roomState.value = roomState;
|
if (roomState != null) this.roomState.value = roomState;
|
||||||
if (options != null) this.options = options;
|
if (options != null) this.options = options;
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
|||||||
registerBuiltInLoaders();
|
registerBuiltInLoaders();
|
||||||
|
|
||||||
this.engine = options.engine;
|
this.engine = options.engine;
|
||||||
if (options.graphicsQuality <= GRAPHICS_QUALITY_LOW) this.engine.setHardwareScalingLevel(2);
|
|
||||||
this.scene = new BABYLON.Scene(this.engine);
|
this.scene = new BABYLON.Scene(this.engine);
|
||||||
// なんかレンダリングがおかしくなるときがあるのでコメントアウト
|
// なんかレンダリングがおかしくなるときがあるのでコメントアウト
|
||||||
// オブジェクトを選択し、後ろを向いて別のオブジェクトを選択した後、最初のオブジェクトに振り返ると消えているなど
|
// オブジェクトを選択し、後ろを向いて別のオブジェクトを選択した後、最初のオブジェクトに振り返ると消えているなど
|
||||||
|
|||||||
Reference in New Issue
Block a user