mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
wip
This commit is contained in:
parent
43958fc70d
commit
2df145c458
8 changed files with 27 additions and 2 deletions
|
|
@ -3717,7 +3717,7 @@ _miRoom:
|
|||
height: "高さ"
|
||||
width: "幅"
|
||||
hangingTShirt: "吊り下げTシャツ"
|
||||
icosahedron: "正二十面体"
|
||||
icosahedron: "正二十面体のオブジェ"
|
||||
_icosahedron:
|
||||
mat: "素材"
|
||||
ironFrameTable: "アイアンフレームテーブル"
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export class RoomEngine extends EngineBase<{
|
|||
'changeSittingState': (ctx: { isSitting: boolean }) => void;
|
||||
'changeGridSnapping': (ctx: { gridSnapping: { enabled: boolean; scale: number } }) => void;
|
||||
'changeRoomState': (ctx: { roomState: RoomState }) => void;
|
||||
'changeMyPlayerState': (ctx: { playerState: PlayerState }) => void;
|
||||
'playSfxUrl': (ctx: {
|
||||
url: string;
|
||||
options: {
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -91,6 +91,7 @@ import * as Misskey from 'misskey-js';
|
|||
import { cm, getHex, getRgb, WORLD_SCALE } from 'misskey-world/src/utility.js';
|
||||
import { GRAPHICS_QUALITY } from 'misskey-world-engine/src/room/utility.js';
|
||||
import { OBJECT_SCHEMA_DEFS } from 'misskey-world/src/room/object-schema-defs.js';
|
||||
import { useInterval } from '@@/js/use-interval.js';
|
||||
import XObjectCustomizeForm from './room.object-customize-form.vue';
|
||||
import XEnvOptions from './room.env-options.vue';
|
||||
import type { RoomControllerOptions } from '@/world/room/controller.js';
|
||||
|
|
@ -346,6 +347,10 @@ onMounted(async () => {
|
|||
(window as any).disableGlobalHotkeys();
|
||||
});
|
||||
|
||||
useInterval(() => {
|
||||
multiplayer.updateState(controller.myPlayerState.value);
|
||||
}, 1000, { immediate: false, afterMounted: true });
|
||||
|
||||
onDeactivated(() => {
|
||||
controller.destroy();
|
||||
multiplayer.dispose();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import type { ShallowRef } from 'vue';
|
|||
import type { RoomStateObject } from 'misskey-world/src/room/object.js';
|
||||
import type { RoomEngine } from 'misskey-world-engine/src/room/engine.js';
|
||||
import type { RoomAttachments, RoomState } from 'misskey-world/src/room/type.js';
|
||||
import type { PlayerState } from 'misskey-world-engine/src/PlayerContainer.js';
|
||||
import * as sound from '@/utility/sound.js';
|
||||
import { deepEqual } from '@/utility/deep-equal.js';
|
||||
import { deepClone } from '@/utility/clone.js';
|
||||
|
|
@ -40,6 +41,10 @@ export class RoomController extends EngineControllerBase<RoomEngine> {
|
|||
}[];
|
||||
} | null>(null);
|
||||
public roomState: ShallowRef<RoomState>;
|
||||
public myPlayerState = shallowRef<PlayerState>({
|
||||
position: [0, 0, 0],
|
||||
rotation: [0, 0, 0],
|
||||
});
|
||||
|
||||
constructor(roomState: RoomState, options: RoomControllerOptions) {
|
||||
super(options);
|
||||
|
|
@ -103,6 +108,10 @@ export class RoomController extends EngineControllerBase<RoomEngine> {
|
|||
}
|
||||
});
|
||||
|
||||
engineEvents.on('changeMyPlayerState', ({ playerState }) => {
|
||||
this.myPlayerState.value = playerState;
|
||||
});
|
||||
|
||||
engineEvents.on('playSfxUrl', ({ url, options }) => {
|
||||
sound.playUrl(url, options);
|
||||
});
|
||||
|
|
@ -117,6 +126,10 @@ export class RoomController extends EngineControllerBase<RoomEngine> {
|
|||
this.isRoomLightOn.value = true;
|
||||
this.grabbing.value = null;
|
||||
this.selected.value = null;
|
||||
this.myPlayerState.value = {
|
||||
position: [0, 0, 0],
|
||||
rotation: [0, 0, 0],
|
||||
};
|
||||
await this.init(canvas, attachments);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import type { PlayerState } from 'misskey-world-engine/src/PlayerContainer.js';
|
|||
import { useStream } from '@/stream.js';
|
||||
import * as os from '@/os.js';
|
||||
import { withTimeout } from '@/utility/promise-timeout.js';
|
||||
import { deepEqual } from '@/utility/deep-equal.js';
|
||||
|
||||
export class Multiplayer {
|
||||
public isOnline = ref(false);
|
||||
|
|
@ -48,9 +49,14 @@ export class Multiplayer {
|
|||
this.isOnline.value = false;
|
||||
}
|
||||
|
||||
private prevState: PlayerState | null = null;
|
||||
|
||||
public updateState(state: PlayerState) {
|
||||
if (this.connection == null || !this.isOnline.value) return;
|
||||
if (this.prevState != null && deepEqual(this.prevState, state)) return;
|
||||
|
||||
this.connection.send('update', state);
|
||||
this.prevState = state;
|
||||
}
|
||||
|
||||
private onSync(states: Record<string, PlayerState>) {
|
||||
|
|
|
|||
|
|
@ -13854,7 +13854,7 @@ export interface Locale extends ILocale {
|
|||
*/
|
||||
"hangingTShirt": string;
|
||||
/**
|
||||
* 正二十面体
|
||||
* 正二十面体のオブジェ
|
||||
*/
|
||||
"icosahedron": string;
|
||||
"_icosahedron": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue