Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially fix rotating and scaling via the spacebar menu buttons #6514

Draft
wants to merge 1 commit into
base: addons
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bit-systems/object-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function startRotation(world: HubsWorld, menuEid: EntityID, targetEid: EntityID)
}
const transformSystem = APP.scene!.systems["transform-selected-object"];
const physicsSystem = AFRAME.scenes[0].systems["hubs-systems"].physicsSystem;
physicsSystem.updateRigidBody(Rigidbody.bodyId[targetEid], { type: "kinematic" });
physicsSystem.updateRigidBody(targetEid, { type: "kinematic" });
const rightCursorEid = anyEntityWith(world, RemoteRight)!;
transformSystem.startTransform(world.eid2obj.get(targetEid)!, world.eid2obj.get(rightCursorEid)!, {
mode: TRANSFORM_MODE.CURSOR
Expand Down Expand Up @@ -137,7 +137,7 @@ function startScaling(world: HubsWorld, menuEid: EntityID, targetEid: EntityID)
// TODO: Remove the dependency with AFRAME
const transformSystem = (AFRAME as any).scenes[0].systems["transform-selected-object"];
const physicsSystem = AFRAME.scenes[0].systems["hubs-systems"].physicsSystem;
physicsSystem.updateRigidBody(Rigidbody.bodyId[targetEid], { type: "kinematic" });
physicsSystem.updateRigidBody(targetEid, { type: "kinematic" });
const rightCursorEid = anyEntityWith(world, RemoteRight)!;
scalingHandler = new ScalingHandler(world.eid2obj.get(targetEid), transformSystem);
scalingHandler!.objectToScale = world.eid2obj.get(targetEid);
Expand Down
2 changes: 1 addition & 1 deletion src/components/transform-object-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ AFRAME.registerComponent("transform-button", {
if (!NAF.utils.isMine(this.targetEl) && !NAF.utils.takeOwnership(this.targetEl)) {
return;
}
if (this.targetEl.body) {
if (this.targetEl.hasAttribute("body-helper")) {
this.targetEl.setAttribute("body-helper", AMMO_BODY_ATTRIBUTES);
}
this.transformSystem = this.transformSystem || AFRAME.scenes[0].systems["transform-selected-object"];
Expand Down
11 changes: 7 additions & 4 deletions src/systems/hold-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import {
HeldHandLeft,
AEntity,
Networked,
Rigidbody
Rigidbody,
HoldableButton
} from "../bit-components";
import { canMove } from "../utils/permissions-utils";
import { canMove as canMoveEntity } from "../utils/bit-permissions-utils";
import { isPinned } from "../bit-systems/networking";
import { takeOwnership } from "../utils/take-ownership";
import { findAncestorWithComponents } from "../utils/bit-utils";
import { findAncestorWithComponents, findAncestorWithComponent } from "../utils/bit-utils";
import { HOLDABLE_FLAGS } from "../inflators/holdable";

const GRAB_REMOTE_RIGHT = paths.actions.cursor.right.grab;
Expand Down Expand Up @@ -82,8 +83,10 @@ export function isAEntityPinned(world, eid) {
function grab(world, userinput, queryHovered, held, grabPath) {
const hovered = queryHovered(world)[0];

const holdablebutton = findAncestorWithComponent(world, HoldableButton, hovered);
const interactable = findAncestorWithComponents(world, [Holdable, Rigidbody], hovered);
const target = interactable ? interactable : hovered;
const holdtarget = holdablebutton ? holdablebutton : target;
const isEntityPinned = isPinned(target) || isAEntityPinned(world, target);

if (
Expand All @@ -96,8 +99,8 @@ function grab(world, userinput, queryHovered, held, grabPath) {
if (hasComponent(world, Networked, target)) {
takeOwnership(world, target);
}
addComponent(world, held, target);
addComponent(world, Held, target);
addComponent(world, held, holdtarget);
addComponent(world, Held, holdtarget);
}
}

Expand Down
Loading