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

Fix scale gizmo isHovered flag #14958

Merged
merged 2 commits into from
Apr 8, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/dev/core/src/Gizmos/axisScaleGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,12 @@ export class AxisScaleGizmo extends Gizmo implements IAxisScaleGizmo {
if (this._customMeshSet) {
return;
}
this._isHovered = !!(cache.colliderMeshes.indexOf(<Mesh>pointerInfo?.pickInfo?.pickedMesh) != -1);
// axis mesh cache
let meshCache = this._parent?.getAxisCache(this._gizmoMesh);
this._isHovered = !!meshCache && !!(meshCache.colliderMeshes.indexOf(<Mesh>pointerInfo?.pickInfo?.pickedMesh) != -1);
// uniform mesh cache
meshCache = this._parent?.getAxisCache(this._rootMesh);
this._isHovered ||= !!meshCache && !!(meshCache.colliderMeshes.indexOf(<Mesh>pointerInfo?.pickInfo?.pickedMesh) != -1);
if (!this._parent) {
const material = this.dragBehavior.enabled ? (this._isHovered || this._dragging ? this._hoverMaterial : this._coloredMaterial) : this._disableMaterial;
this._setGizmoMeshMaterial(cache.gizmoMeshes, material);
Expand Down
13 changes: 11 additions & 2 deletions packages/dev/core/src/Gizmos/scaleGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class ScaleGizmo extends Gizmo implements IScaleGizmo {
* True when the mouse pointer is hovering a gizmo mesh
*/
public get isHovered() {
return this.xGizmo.isHovered || this.yGizmo.isHovered || this.zGizmo.isHovered;
return this.xGizmo.isHovered || this.yGizmo.isHovered || this.zGizmo.isHovered || this.uniformScaleGizmo.isHovered;
}

/**
Expand Down Expand Up @@ -267,7 +267,7 @@ export class ScaleGizmo extends Gizmo implements IScaleGizmo {

const cache: GizmoAxisCache = {
gizmoMeshes: [this._octahedron, this._uniformScalingMesh],
colliderMeshes: [this._uniformScalingMesh],
colliderMeshes: [this._octahedron, this._uniformScalingMesh],
material: this._coloredMaterial,
hoverMaterial: this._hoverMaterial,
disableMaterial: this._disableMaterial,
Expand Down Expand Up @@ -407,6 +407,15 @@ export class ScaleGizmo extends Gizmo implements IScaleGizmo {
this._gizmoAxisCache.set(mesh, cache);
}

/**
* Get the cache set with addToAxisCache for a specific mesh
* @param mesh Axis gizmo mesh
* @returns Gizmo axis definition used for reactive gizmo UI
*/
public getAxisCache(mesh: Mesh): GizmoAxisCache | undefined {
return this._gizmoAxisCache.get(mesh);
}

/**
* Force release the drag action by code
*/
Expand Down