This commit is contained in:
syuilo
2026-07-31 12:24:50 +09:00
parent 6e7bc106f0
commit 5185b298fa
3 changed files with 21 additions and 7 deletions
@@ -5,18 +5,24 @@
import { shallowRef } from 'vue';
import { EngineControllerBase } from './EngineControllerBase.js';
import type { EngineControllerBaseOptions } from './EngineControllerBase.js';
import type { PlayerProfile, PlayerState } from 'misskey-world-engine/src/PlayerContainer.js';
import type { MultiplayEngineBase, MultiplayEngineBaseEvents } from 'misskey-world-engine/src/MultiplayEngineBase.js';
import type { Wasd } from './Wasd.js';
export type MultiplayerEngineControllerBaseOptions = {
workerMode?: boolean;
graphicsQuality: number;
fps: number | null;
resolution: number;
antialias: boolean;
export type MultiplayerEngineControllerBaseOptions = EngineControllerBaseOptions & {
showUsernameOnAvatar: boolean;
show2dAvatarOnAvatar: boolean;
};
export abstract class MultiplayerEngineControllerBase<T extends MultiplayEngineBase<MultiplayEngineBaseEvents>, E> extends EngineControllerBase<T, E> {
protected options: MultiplayerEngineControllerBaseOptions;
constructor(options: MultiplayerEngineControllerBaseOptions, wasd?: Wasd) {
super(options, wasd);
this.options = options;
}
public myPlayerState = shallowRef<PlayerState>({
position: [0, 0, 0],
rotation: [0, 0, 0],
+7 -1
View File
@@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { shallowRef } from 'vue';
import { MultiplayerEngineControllerBase } from './MultiplayerEngineControllerBase.js';
import { Wasd } from './Wasd.js';
import type { WorldEngine } from 'misskey-world-engine/src/engine.js';
@@ -14,18 +13,25 @@ export type WorldEngineControllerOptions = {
fps: number | null;
resolution: number;
antialias: boolean;
fov: number;
useVirtualJoystick?: boolean;
showUsernameOnAvatar: boolean;
show2dAvatarOnAvatar: boolean;
};
// 抽象化レイヤー
export class WorldEngineController extends MultiplayerEngineControllerBase<WorldEngine, {
'playerPointed': { playerId: string; };
}> {
protected options: WorldEngineControllerOptions;
constructor(options: WorldEngineControllerOptions) {
super(options, new Wasd({
setCameraMoveVector: (vec, dash) => {
this.call('cameraMove', [vec, dash]);
},
}));
this.options = options;
}
public async init(canvas: HTMLCanvasElement) {
@@ -31,6 +31,7 @@ export type RoomControllerOptions = {
export class RoomController extends MultiplayerEngineControllerBase<RoomEngine, {
'playerPointed': { playerId: string; };
}> {
protected options: RoomControllerOptions;
public isSitting = ref(false);
public isEditMode = ref(false);
public isRoomLightOn = ref(true);
@@ -53,6 +54,7 @@ export class RoomController extends MultiplayerEngineControllerBase<RoomEngine,
this.call('cameraMove', [vec, dash]);
},
}));
this.options = options;
this.roomState = shallowRef(deepClone(roomState));
}