From 58d6e528799dd6064510985ddb1fab7e13602b5f Mon Sep 17 00:00:00 2001 From: Takahiro Date: Sat, 9 Sep 2023 14:55:41 +0900 Subject: [PATCH] bitECS: Fix F key inspect This commit fixes F key inspect with the new loader enabled. --- src/systems/camera-system.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/systems/camera-system.js b/src/systems/camera-system.js index 332d6b2d1d..f80658bd58 100644 --- a/src/systems/camera-system.js +++ b/src/systems/camera-system.js @@ -8,7 +8,8 @@ import { qsGet } from "../utils/qs_truthy"; const customFOV = qsGet("fov"); const enableThirdPersonMode = qsTruthy("thirdPerson"); import { Layers } from "../camera-layers"; -import { Inspectable } from "../bit-components"; +import { defineQuery } from "bitecs"; +import { Inspectable, HoveredRemoteRight } from "../bit-components"; import { findAncestorWithComponent, shouldUseNewLoader } from "../utils/bit-utils"; function getInspectableInHierarchy(eid) { @@ -201,6 +202,7 @@ function getAudio(o) { return audio; } +const hoveredQuery = defineQuery([HoveredRemoteRight]); const FALLOFF = 0.9; export class CameraSystem { constructor(camera, renderer) { @@ -448,6 +450,18 @@ export class CameraSystem { this.interaction = this.interaction || scene.systems.interaction; if (this.userinput.get(paths.actions.startInspecting) && this.mode !== CAMERA_MODE_INSPECT) { + if (shouldUseNewLoader()) { + const hoveredEids = hoveredQuery(APP.world); + if (hoveredEids.length > 0) { + this.inspect(APP.world.eid2obj.get(hoveredEids[0]), 1.5); + } + } else { + const hoverEl = this.interaction.state.rightRemote.hovered || this.interaction.state.leftRemote.hovered; + + if (hoverEl) { + this.inspect(hoverEl.object3D, 1.5); + } + } const hoverEl = this.interaction.state.rightRemote.hovered || this.interaction.state.leftRemote.hovered; if (hoverEl) {