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
Hide 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,82 +10,105 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
...
@@ -10,82 +10,105 @@ 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
,
item
.
transform
.
position
?.
z
);
hand
.
rotation
=
new
BABYLON
.
Vector3
(
item
.
transform
.
rotation
?.
x
,
item
.
transform
.
rotation
?.
y
,
item
.
transform
.
rotation
?.
z
);
// 材质
// 材质
const
handMaterial
=
new
BABYLON
.
StandardMaterial
(
"
handMaterial
"
,
scene
);
setupHandMaterial
(
hand
,
item
,
scene
);
// 材质贴纸
handMaterial
.
diffuseTexture
=
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
item
.
meta
.
id
}
.jpg`
,
scene
);
hand
.
material
=
handMaterial
;
// 事件管理
// 事件管理
hand
.
actionManager
=
new
BABYLON
.
ActionManager
(
scene
);
setupHandAction
(
hand
,
item
,
idx
,
scene
);
// 监听点击事件
hand
.
actionManager
.
registerAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPickTrigger
,
(
event
)
=>
{
console
.
log
(
`<Click>hand:
${
idx
}
`
,
"
card:
"
,
item
,
"
event:
"
,
event
);
}
)
);
// 监听`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
.
CombineAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
},
[
new
BABYLON
.
SetValueAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
},
hand
,
"
scaling
"
,
CONFIG
.
HandHoverOutScaling
()
),
// TODO: 这里后续应该加上禁用可操作按钮的处理
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
(
event
)
=>
{
console
.
log
(
`<Hover Out>hand:
${
idx
}
`
,
"
event:
"
,
event
);
}
),
]
)
);
});
});
};
};
function
setupHandTransform
(
mesh
:
BABYLON
.
Mesh
,
state
:
Card
)
{
mesh
.
position
=
new
BABYLON
.
Vector3
(
state
.
transform
.
position
?.
x
,
state
.
transform
.
position
?.
y
,
state
.
transform
.
position
?.
z
);
mesh
.
rotation
=
new
BABYLON
.
Vector3
(
state
.
transform
.
rotation
?.
x
,
state
.
transform
.
rotation
?.
y
,
state
.
transform
.
rotation
?.
z
);
}
function
setupHandMaterial
(
mesh
:
BABYLON
.
Mesh
,
state
:
Card
,
scene
:
BABYLON
.
Scene
)
{
const
handMaterial
=
new
BABYLON
.
StandardMaterial
(
`handMaterial
${
state
.
meta
.
id
}
`
,
scene
);
// 材质贴纸
handMaterial
.
diffuseTexture
=
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
state
.
meta
.
id
}
.jpg`
,
scene
);
mesh
.
material
=
handMaterial
;
}
function
setupHandAction
(
mesh
:
BABYLON
.
Mesh
,
state
:
Card
,
handIdx
:
number
,
scene
:
BABYLON
.
Scene
)
{
mesh
.
actionManager
=
new
BABYLON
.
ActionManager
(
scene
);
// 监听点击事件
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPickTrigger
,
(
event
)
=>
{
console
.
log
(
`<Click>hand:
${
handIdx
}
`
,
"
card:
"
,
state
,
"
event:
"
,
event
);
}
)
);
// 监听`Hover`事件
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
CombineAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
},
[
new
BABYLON
.
SetValueAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
},
mesh
,
"
scaling
"
,
CONFIG
.
HandHoverScaling
()
),
// TODO: 这里后续应该加上显示可操作按钮的处理
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
(
event
)
=>
{
console
.
log
(
`<Hover>hand:
${
handIdx
}
`
,
"
event:
"
,
event
);
}
),
]
)
);
// 监听`Hover`离开事件
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
CombineAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
},
[
new
BABYLON
.
SetValueAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
},
mesh
,
"
scaling
"
,
CONFIG
.
HandHoverOutScaling
()
),
// TODO: 这里后续应该加上禁用可操作按钮的处理
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPointerOutTrigger
,
(
event
)
=>
{
console
.
log
(
`<Hover Out>hand:
${
handIdx
}
`
,
"
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