Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
deft
Neos
Commits
de6a77e6
Commit
de6a77e6
authored
Dec 10, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'optimize/button' into 'main'
Optimize/button See merge request
mycard/Neos!37
parents
77623173
6d1a060f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
33 deletions
+53
-33
src/config/ui.ts
src/config/ui.ts
+2
-2
src/ui/Duel/simpleDuel/hands.ts
src/ui/Duel/simpleDuel/hands.ts
+51
-31
No files found.
src/config/ui.ts
View file @
de6a77e6
...
@@ -62,9 +62,9 @@ export const HandHoverOutScaling = () => {
...
@@ -62,9 +62,9 @@ export const HandHoverOutScaling = () => {
return
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
return
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
};
};
export
const
HandInteractShape
=
()
=>
{
export
const
HandInteractShape
=
()
=>
{
return
{
width
:
0.
4
,
height
:
0.1
};
return
{
width
:
0.
8
,
height
:
0.2
};
};
};
export
const
HandInteractFontSize
=
3
00
;
export
const
HandInteractFontSize
=
2
00
;
// 怪兽区
// 怪兽区
export
const
MonsterColor
=
()
=>
{
export
const
MonsterColor
=
()
=>
{
...
...
src/ui/Duel/simpleDuel/hands.ts
View file @
de6a77e6
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
BABYLON_GUI
from
"
@babylonjs/gui
"
;
import
*
as
BABYLON_GUI
from
"
@babylonjs/gui
"
;
import
*
as
CONFIG
from
"
../../../config/ui
"
;
import
*
as
CONFIG
from
"
../../../config/ui
"
;
import
{
Card
}
from
"
../../../reducers/duel/util
"
;
import
{
Card
,
InteractType
}
from
"
../../../reducers/duel/util
"
;
export
default
(
hands
:
Card
[],
scene
:
BABYLON
.
Scene
)
=>
{
export
default
(
hands
:
Card
[],
scene
:
BABYLON
.
Scene
)
=>
{
const
handShape
=
CONFIG
.
HandShape
();
const
handShape
=
CONFIG
.
HandShape
();
...
@@ -59,26 +59,40 @@ function setupHandInteractivity(
...
@@ -59,26 +59,40 @@ function setupHandInteractivity(
scene
:
BABYLON
.
Scene
scene
:
BABYLON
.
Scene
)
{
)
{
const
interactShape
=
CONFIG
.
HandInteractShape
();
const
interactShape
=
CONFIG
.
HandInteractShape
();
const
interact
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
const
interactivities
=
state
.
interactivities
;
`handInteract
${
handIdx
}
`
,
interactShape
,
scene
);
interact
.
parent
=
mesh
;
interact
.
position
.
x
=
CONFIG
.
HandShape
().
width
/
2
+
interactShape
.
width
/
2
;
const
advancedTexture
=
for
(
let
i
=
0
;
i
<
interactivities
.
length
;
i
++
)
{
BABYLON_GUI
.
AdvancedDynamicTexture
.
CreateForMesh
(
interact
);
const
interact
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
const
button
=
BABYLON_GUI
.
Button
.
CreateSimpleButton
(
`handInteract_
${
handIdx
}
_
${
i
}
`
,
`handInteractButtion
${
handIdx
}
`
,
interactShape
,
"
test
"
scene
);
);
button
.
fontSize
=
CONFIG
.
HandInteractFontSize
;
interact
.
parent
=
mesh
;
button
.
background
=
"
gray
"
;
// 调整位置
button
.
onPointerClickObservable
.
add
(()
=>
{
interact
.
translate
(
console
.
log
(
`<Interact>hand
${
handIdx
}
`
);
new
BABYLON
.
Vector3
(
0
,
1
,
0
),
});
CONFIG
.
HandShape
().
height
/
2
+
advancedTexture
.
addControl
(
button
);
interactShape
.
height
/
2
+
interactShape
.
height
*
i
);
const
advancedTexture
=
BABYLON_GUI
.
AdvancedDynamicTexture
.
CreateForMesh
(
interact
);
const
button
=
BABYLON_GUI
.
Button
.
CreateImageWithCenterTextButton
(
`handInteractButtion_
${
handIdx
}
_
${
i
}
`
,
interactTypeToString
(
interactivities
[
i
].
interactType
),
"
http://localhost:3030/images/interact_button.png
"
);
button
.
fontSize
=
CONFIG
.
HandInteractFontSize
;
button
.
color
=
"
white
"
;
button
.
onPointerClickObservable
.
add
(()
=>
{
console
.
log
(
`<Interact>hand
${
handIdx
}
`
);
});
advancedTexture
.
addControl
(
button
);
interact
.
visibility
=
0.2
;
// interact.setEnabled(false);
}
}
}
function
setupHandAction
(
function
setupHandAction
(
...
@@ -98,6 +112,8 @@ function setupHandAction(
...
@@ -98,6 +112,8 @@ function setupHandAction(
)
)
);
);
// 监听`Hover`事件
// 监听`Hover`事件
//
// TODO: 应该在`Hover`的时候开启子组件(按钮),`Hover`离开的时候禁用
mesh
.
actionManager
.
registerAction
(
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
CombineAction
(
new
BABYLON
.
CombineAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
},
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
},
...
@@ -110,12 +126,12 @@ function setupHandAction(
...
@@ -110,12 +126,12 @@ function setupHandAction(
"
scaling
"
,
"
scaling
"
,
CONFIG
.
HandHoverScaling
()
CONFIG
.
HandHoverScaling
()
),
),
// TODO: 这里后续应该加上显示可操作按钮的处理
new
BABYLON
.
InterpolateValueAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
(
event
)
=>
{
mesh
.
getChildMeshes
(),
console
.
log
(
`<Hover>hand:
${
handIdx
}
`
,
"
event:
"
,
event
);
"
visibility
"
,
}
1.0
,
10
),
),
]
]
)
)
...
@@ -133,14 +149,18 @@ function setupHandAction(
...
@@ -133,14 +149,18 @@ function setupHandAction(
"
scaling
"
,
"
scaling
"
,
CONFIG
.
HandHoverOutScaling
()
CONFIG
.
HandHoverOutScaling
()
),
),
// TODO: 这里后续应该加上禁用可操作按钮的处理
new
BABYLON
.
InterpolateValueAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
mesh
.
getChildMeshes
()
,
(
event
)
=>
{
"
visibility
"
,
console
.
log
(
`<Hover Out>hand:
${
handIdx
}
`
,
"
event:
"
,
event
);
0.2
,
}
10
),
),
]
]
)
)
);
);
}
}
function
interactTypeToString
(
t
:
InteractType
):
string
{
return
InteractType
[
t
];
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment