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
love_飞影
Neos
Commits
72a0436a
Commit
72a0436a
authored
Dec 07, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rerange simpleDuel hands.ts
parent
5c23d243
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
75 deletions
+98
-75
src/ui/Duel/simpleDuel/hands.ts
src/ui/Duel/simpleDuel/hands.ts
+98
-75
No files found.
src/ui/Duel/simpleDuel/hands.ts
View file @
72a0436a
...
@@ -10,39 +10,63 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
...
@@ -10,39 +10,63 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
handShape
,
handShape
,
scene
scene
);
);
// 位置
// 位置&旋转
hand
.
position
=
new
BABYLON
.
Vector3
(
setupHandTransform
(
hand
,
item
);
item
.
transform
.
position
?.
x
,
// 材质
item
.
transform
.
position
?.
y
,
setupHandMaterial
(
hand
,
item
,
scene
);
item
.
transform
.
position
?.
z
// 事件管理
setupHandAction
(
hand
,
item
,
idx
,
scene
);
});
};
function
setupHandTransform
(
mesh
:
BABYLON
.
Mesh
,
state
:
Card
)
{
mesh
.
position
=
new
BABYLON
.
Vector3
(
state
.
transform
.
position
?.
x
,
state
.
transform
.
position
?.
y
,
state
.
transform
.
position
?.
z
);
);
hand
.
rotation
=
new
BABYLON
.
Vector3
(
mesh
.
rotation
=
new
BABYLON
.
Vector3
(
item
.
transform
.
rotation
?.
x
,
state
.
transform
.
rotation
?.
x
,
item
.
transform
.
rotation
?.
y
,
state
.
transform
.
rotation
?.
y
,
item
.
transform
.
rotation
?.
z
state
.
transform
.
rotation
?.
z
);
}
function
setupHandMaterial
(
mesh
:
BABYLON
.
Mesh
,
state
:
Card
,
scene
:
BABYLON
.
Scene
)
{
const
handMaterial
=
new
BABYLON
.
StandardMaterial
(
`handMaterial
${
state
.
meta
.
id
}
`
,
scene
);
);
// 材质
const
handMaterial
=
new
BABYLON
.
StandardMaterial
(
"
handMaterial
"
,
scene
);
// 材质贴纸
// 材质贴纸
handMaterial
.
diffuseTexture
=
new
BABYLON
.
Texture
(
handMaterial
.
diffuseTexture
=
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
item
.
meta
.
id
}
.jpg`
,
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
state
.
meta
.
id
}
.jpg`
,
scene
scene
);
);
hand
.
material
=
handMaterial
;
mesh
.
material
=
handMaterial
;
}
// 事件管理
function
setupHandAction
(
hand
.
actionManager
=
new
BABYLON
.
ActionManager
(
scene
);
mesh
:
BABYLON
.
Mesh
,
state
:
Card
,
handIdx
:
number
,
scene
:
BABYLON
.
Scene
)
{
mesh
.
actionManager
=
new
BABYLON
.
ActionManager
(
scene
);
// 监听点击事件
// 监听点击事件
hand
.
actionManager
.
registerAction
(
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
ExecuteCodeAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPickTrigger
,
BABYLON
.
ActionManager
.
OnPickTrigger
,
(
event
)
=>
{
(
event
)
=>
{
console
.
log
(
`<Click>hand:
${
idx
}
`
,
"
card:
"
,
item
,
"
event:
"
,
event
);
console
.
log
(
`<Click>hand:
${
handIdx
}
`
,
"
card:
"
,
state
,
"
event:
"
,
event
);
}
}
)
)
);
);
// 监听`Hover`事件
// 监听`Hover`事件
hand
.
actionManager
.
registerAction
(
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
CombineAction
(
new
BABYLON
.
CombineAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
},
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
},
[
[
...
@@ -50,7 +74,7 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
...
@@ -50,7 +74,7 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
{
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
},
},
hand
,
mesh
,
"
scaling
"
,
"
scaling
"
,
CONFIG
.
HandHoverScaling
()
CONFIG
.
HandHoverScaling
()
),
),
...
@@ -58,14 +82,14 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
...
@@ -58,14 +82,14 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
new
BABYLON
.
ExecuteCodeAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
(
event
)
=>
{
(
event
)
=>
{
console
.
log
(
`<Hover>hand:
${
i
dx
}
`
,
"
event:
"
,
event
);
console
.
log
(
`<Hover>hand:
${
handI
dx
}
`
,
"
event:
"
,
event
);
}
}
),
),
]
]
)
)
);
);
// 监听`Hover`离开事件
// 监听`Hover`离开事件
hand
.
actionManager
.
registerAction
(
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
CombineAction
(
new
BABYLON
.
CombineAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
},
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
},
[
[
...
@@ -73,7 +97,7 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
...
@@ -73,7 +97,7 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
{
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
},
},
hand
,
mesh
,
"
scaling
"
,
"
scaling
"
,
CONFIG
.
HandHoverOutScaling
()
CONFIG
.
HandHoverOutScaling
()
),
),
...
@@ -81,11 +105,10 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
...
@@ -81,11 +105,10 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
new
BABYLON
.
ExecuteCodeAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
(
event
)
=>
{
(
event
)
=>
{
console
.
log
(
`<Hover Out>hand:
${
i
dx
}
`
,
"
event:
"
,
event
);
console
.
log
(
`<Hover Out>hand:
${
handI
dx
}
`
,
"
event:
"
,
event
);
}
}
),
),
]
]
)
)
);
);
});
}
};
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