Commit 97f54765 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feat/ui/hover' into 'main'

Feat/ui/hover

See merge request mycard/Neos!35
parents f788671c ab36dbe3
Pipeline #18499 passed with stages
in 2 minutes and 13 seconds
......@@ -55,6 +55,12 @@ export const HandRotation = () => {
export const HandColor = () => {
return BABYLON.Color3.White();
};
export const HandHoverScaling = () => {
return new BABYLON.Vector3(1.2, 1.2, 1);
};
export const HandHoverOutScaling = () => {
return new BABYLON.Vector3(1, 1, 1);
};
// 怪兽区
export const MonsterColor = () => {
......
......@@ -29,6 +29,7 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
scene
);
hand.material = handMaterial;
// 事件管理
hand.actionManager = new BABYLON.ActionManager(scene);
// 监听点击事件
......@@ -40,5 +41,39 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
}
)
);
// 监听`Hover`事件
hand.actionManager.registerAction(
new BABYLON.CombineAction(
{ trigger: BABYLON.ActionManager.OnPointerOverTrigger },
[
new BABYLON.SetValueAction(
{
trigger: BABYLON.ActionManager.OnPointerOverTrigger,
},
hand,
"scaling",
CONFIG.HandHoverScaling()
),
// TODO: 这里后续应该加上显示可操作按钮的处理
new BABYLON.ExecuteCodeAction(
BABYLON.ActionManager.OnPointerOverTrigger,
(event) => {
console.log(`<Hover>hand: ${idx}`, "event: ", event);
}
),
]
)
);
// 监听`Hover`离开事件
hand.actionManager.registerAction(
new BABYLON.SetValueAction(
{
trigger: BABYLON.ActionManager.OnPointerOutTrigger,
},
hand,
"scaling",
CONFIG.HandHoverOutScaling()
)
);
});
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment