Skip to content

Commit

Permalink
chore: fix gui hitinfo types
Browse files Browse the repository at this point in the history
  • Loading branch information
lslzl3000 committed Nov 10, 2024
1 parent 4b5bc9c commit 5d8ef8c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orillusion/core",
"version": "0.8.4-dev.1",
"version": "0.8.4-dev.2",
"author": "Orillusion",
"description": "Orillusion WebGPU Engine",
"type": "module",
Expand Down
7 changes: 3 additions & 4 deletions src/components/gui/GUIPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { webGPUContext } from '../../gfx/graphics/webGpu/Context3D';
import { Ray } from '../../math/Ray';
import { Vector2 } from '../../math/Vector2';
import { Time } from '../../util/Time';
import { IUIInteractive, UIInteractiveStyle } from './uiComponents/IUIInteractive';
import { IUIInteractive, UIInteractiveStyle, GUIHitInfo } from './uiComponents/IUIInteractive';
import { UITransform } from './uiComponents/UITransform';
import { View3D } from '../../core/View3D';
import { UIPanel } from './uiComponents/UIPanel';
import { HitInfo } from '../shape/ColliderShape';

/**
* Pickup logic for GUI interactive components
Expand Down Expand Up @@ -193,12 +192,12 @@ export class GUIPick {
return this._colliderOut;
}

private pick(colliders: IUIInteractive[]): HitInfo {
private pick(colliders: IUIInteractive[]): GUIHitInfo {
this._ray = this._view.camera.screenPointToRay(Engine3D.inputSystem.mouseX, Engine3D.inputSystem.mouseY);
let screenPos = new Vector2(Engine3D.inputSystem.mouseX, Engine3D.inputSystem.mouseY);
let screenSize = new Vector2(webGPUContext.canvas.clientWidth, webGPUContext.canvas.clientHeight);

let hitInfo: HitInfo;
let hitInfo: GUIHitInfo;
for (const iterator of colliders) {
if (iterator.interactive && iterator.enable && iterator.interactiveVisible) {
let panel = this._iteractive2PanelDict.get(iterator);
Expand Down
6 changes: 3 additions & 3 deletions src/components/gui/GUIPickHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Ray } from "../../math/Ray";
import { Vector2 } from "../../math/Vector2";
import { Vector3 } from "../../math/Vector3";
import { UITransform } from "./uiComponents/UITransform";
import { GUIConfig, GUISpace } from "./GUIConfig";
import { HitInfo } from "../shape/ColliderShape";
import { GUISpace } from "./GUIConfig";
import { GUIHitInfo } from "./uiComponents/IUIInteractive";

/**
* @internal
Expand Down Expand Up @@ -34,7 +34,7 @@ export class GUIPickHelper {
this._worldMatrix = new Matrix4();
}

public static rayPick(ray: Ray, screenPos: Vector2, screenSize: Vector2, space: GUISpace, panelRatio: number, uiTransform: UITransform, worldMatrix: Matrix4): HitInfo {
public static rayPick(ray: Ray, screenPos: Vector2, screenSize: Vector2, space: GUISpace, panelRatio: number, uiTransform: UITransform, worldMatrix: Matrix4): GUIHitInfo {
if (!this._isInit) {
this.init();
this._isInit = true;
Expand Down
9 changes: 4 additions & 5 deletions src/components/gui/uiComponents/IUIInteractive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Object3D } from "../../../core/entities/Object3D";
import { Ray } from "../../../math/Ray";
import { Vector2 } from "../../../math/Vector2";
import { Vector3 } from "../../../math/Vector3";

export enum UIInteractiveStyle {
NORMAL,
Expand All @@ -9,17 +10,15 @@ export enum UIInteractiveStyle {
DISABLE
}

export type GUIHitInfo = { intersectPoint?: Vector3; distance: number; collider?: IUIInteractive };

export interface IUIInteractive {
interactive: boolean;
enable: boolean;
visible: boolean;
object3D?: Object3D;

get interactiveVisible(): boolean;

rayPick(ray: Ray, panel: any, screenPos: Vector2, screenSize: Vector2);

rayPick(ray: Ray, panel: any, screenPos: Vector2, screenSize: Vector2) : GUIHitInfo;
destroy(): void;

set mouseStyle(value: UIInteractiveStyle);
}
6 changes: 2 additions & 4 deletions src/components/gui/uiComponents/UIInteractive.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { UIComponentBase } from './UIComponentBase';
import { IUIInteractive, UIInteractiveStyle } from "./IUIInteractive";
import { IUIInteractive, UIInteractiveStyle, GUIHitInfo } from "./IUIInteractive";
import { Vector2 } from '../../../math/Vector2';
import { Ray } from '../../../math/Ray';
import { GUIPickHelper } from '../GUIPickHelper';
import { Object3D } from '../../../core/entities/Object3D';
import { Vector3 } from '../../../math/Vector3';
import { UIPanel } from './UIPanel';
import { HitInfo } from '../../shape/ColliderShape';

/**
* The basic class of interactive GUI component
Expand Down Expand Up @@ -42,7 +40,7 @@ export class UIInteractive extends UIComponentBase implements IUIInteractive {
super.destroy();
}

public rayPick(ray: Ray, panel: UIPanel, screenPos: Vector2, screenSize: Vector2): HitInfo {
public rayPick(ray: Ray, panel: UIPanel, screenPos: Vector2, screenSize: Vector2): GUIHitInfo {
return GUIPickHelper.rayPick(ray, screenPos, screenSize, panel.space, panel.panelRatio, this._uiTransform, panel.transform.worldMatrix);
}

Expand Down

0 comments on commit 5d8ef8c

Please sign in to comment.