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

Rename NametagEntity to LabelEntity for clarity. #200

Merged
merged 3 commits into from
Oct 25, 2023
Merged
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
12 changes: 6 additions & 6 deletions src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,14 @@ export default defineComponent({
},
{
icon: "badge",
label: "Nametags",
label: "Labels",
action: () => {
userStore.avatar.showNametags = !userStore.avatar.showNametags;
Log.info(Log.types.OTHER, "Toggle Avatar Nametags");
userStore.avatar.showLabels = !userStore.avatar.showLabels;
Log.info(Log.types.OTHER, "Toggle Labels");
},
isCategory: false,
separator: true,
caption: "nametag_setting"
caption: "boolean"
},
{
icon: "lightbulb",
Expand Down Expand Up @@ -722,8 +722,8 @@ export default defineComponent({
},
formatMenuItemCaption(caption: string) {
switch (caption) {
case "nametag_setting":
return this.userStore.avatar.showNametags ? "On" : "Off";
case "boolean":
return this.userStore.avatar.showLabels ? "On" : "Off";
default:
return caption;
}
Expand Down
8 changes: 3 additions & 5 deletions src/modules/avatar/controller/inputController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,11 +904,9 @@ export class InputController extends ScriptComponent {
// Set the visibility of the avatar.
this._gameObject.isVisible = visible;

// Set the visibility of the avatar's nametag.
const meshes = this._gameObject.getChildMeshes(true, (mesh) => mesh.name === "Nametag");
if (meshes.length > 0) {
meshes[0].isVisible = visible;
}
// Set the visibility of the avatar's label.
const meshes = this._gameObject.getChildMeshes(true, (mesh) => mesh.name === "Label");
meshes.forEach((mesh) => (mesh.isVisible = visible));

// Set the visibility of the avatar's mesh.
const meshComponent = this._gameObject.getComponent("Mesh");
Expand Down
30 changes: 15 additions & 15 deletions src/modules/entity/components/components/ModelComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Node,
} from "@babylonjs/core";
import { IModelEntity } from "../../EntityInterfaces";
import { NametagEntity } from "@Modules/entity/entities";
import { LabelEntity } from "@Modules/entity/entities";
import { updateContentLoadingProgress } from "@Modules/scene/LoadingScreen";
import { applicationStore } from "@Stores/index";
import Log from "@Modules/debugging/log";
Expand Down Expand Up @@ -74,10 +74,10 @@ export class ModelComponent extends MeshComponent {
this.mesh = meshes[0];
this.renderGroupId = DEFAULT_MESH_RENDER_GROUP_ID;

// Add a nametag to any of the model's children if they match any of the InteractiveModelTypes.
const defaultNametagHeight = 0.6;
const nametagOffset = 0.25;
const nametagPopDistance =
// Add a label to any of the model's children if they match any of the InteractiveModelTypes.
const defaultLabelHeight = 0.6;
const labelOffset = 0.25;
const labelPopDistance =
applicationStore.interactions.interactionDistance;
const childNodes = this.mesh.getChildren(
(node) => "getBoundingInfo" in node,
Expand All @@ -96,13 +96,13 @@ export class ModelComponent extends MeshComponent {
const boundingInfo = childNode.getBoundingInfo();
const height =
boundingInfo.maximum.y - boundingInfo.minimum.y;
NametagEntity.create(
LabelEntity.create(
childNode,
height + nametagOffset,
height + labelOffset,
genericModelType.name,
true,
undefined,
nametagPopDistance,
labelPopDistance,
() => !applicationStore.interactions.isInteracting
);
});
Expand All @@ -113,29 +113,29 @@ export class ModelComponent extends MeshComponent {
if (!genericModelType) {
return;
}
NametagEntity.create(
LabelEntity.create(
childNode,
defaultNametagHeight,
defaultLabelHeight,
genericModelType.name,
true,
undefined,
nametagPopDistance,
labelPopDistance,
() => !applicationStore.interactions.isInteracting
);
});

// Add a nametag to the model itself if it matches any of the InteractiveModelTypes.
// Add a label to the model itself if it matches any of the InteractiveModelTypes.
const genericModelType = InteractiveModelTypes.find((type) =>
type.condition.test(this.mesh?.name ?? "")
);
if (genericModelType) {
NametagEntity.create(
LabelEntity.create(
this.mesh,
defaultNametagHeight,
defaultLabelHeight,
genericModelType.name,
true,
undefined,
nametagPopDistance,
labelPopDistance,
() => !applicationStore.interactions.isInteracting
);
}
Expand Down
Loading
Loading