diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 897fa75436..e6272e4946 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -3717,7 +3717,7 @@ _miRoom: height: "高さ" width: "幅" hangingTShirt: "吊り下げTシャツ" - icosahedron: "正二十面体" + icosahedron: "正二十面体のオブジェ" _icosahedron: mat: "素材" ironFrameTable: "アイアンフレームテーブル" diff --git a/packages/frontend-misskey-world-engine/src/room/engine.ts b/packages/frontend-misskey-world-engine/src/room/engine.ts index e312aba330..5bd1a858d8 100644 --- a/packages/frontend-misskey-world-engine/src/room/engine.ts +++ b/packages/frontend-misskey-world-engine/src/room/engine.ts @@ -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: { diff --git a/packages/frontend/assets/room/objects/rubik-cube/rubik-cube.blend b/packages/frontend/assets/room/objects/rubik-cube/rubik-cube.blend deleted file mode 100644 index 6c09067e78..0000000000 Binary files a/packages/frontend/assets/room/objects/rubik-cube/rubik-cube.blend and /dev/null differ diff --git a/packages/frontend/assets/room/objects/rubik-cube/rubik-cube.glb b/packages/frontend/assets/room/objects/rubik-cube/rubik-cube.glb deleted file mode 100644 index d640df9b06..0000000000 Binary files a/packages/frontend/assets/room/objects/rubik-cube/rubik-cube.glb and /dev/null differ diff --git a/packages/frontend/src/pages/rooms/room.core.vue b/packages/frontend/src/pages/rooms/room.core.vue index 4cbae66868..d452b25aa0 100644 --- a/packages/frontend/src/pages/rooms/room.core.vue +++ b/packages/frontend/src/pages/rooms/room.core.vue @@ -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(); diff --git a/packages/frontend/src/world/room/controller.ts b/packages/frontend/src/world/room/controller.ts index 1ff3c2de6b..090b0121a6 100644 --- a/packages/frontend/src/world/room/controller.ts +++ b/packages/frontend/src/world/room/controller.ts @@ -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 { }[]; } | null>(null); public roomState: ShallowRef; + public myPlayerState = shallowRef({ + position: [0, 0, 0], + rotation: [0, 0, 0], + }); constructor(roomState: RoomState, options: RoomControllerOptions) { super(options); @@ -103,6 +108,10 @@ export class RoomController extends EngineControllerBase { } }); + 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 { 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); } diff --git a/packages/frontend/src/world/room/multiplayer.ts b/packages/frontend/src/world/room/multiplayer.ts index c0f7a06200..64cc785518 100644 --- a/packages/frontend/src/world/room/multiplayer.ts +++ b/packages/frontend/src/world/room/multiplayer.ts @@ -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) { diff --git a/packages/i18n/src/autogen/locale.ts b/packages/i18n/src/autogen/locale.ts index 768de9673c..8878e15f6f 100644 --- a/packages/i18n/src/autogen/locale.ts +++ b/packages/i18n/src/autogen/locale.ts @@ -13854,7 +13854,7 @@ export interface Locale extends ILocale { */ "hangingTShirt": string; /** - * 正二十面体 + * 正二十面体のオブジェ */ "icosahedron": string; "_icosahedron": {