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
Biluo Shen
Neos
Commits
294a516d
Commit
294a516d
authored
Dec 28, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add DuelHandsComponent
parent
6d9fab15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
1 deletion
+125
-1
src/ui/Duel/babylon.tsx
src/ui/Duel/babylon.tsx
+3
-1
src/ui/Duel/hands_.tsx
src/ui/Duel/hands_.tsx
+122
-0
No files found.
src/ui/Duel/babylon.tsx
View file @
294a516d
import
React
,
{
useEffect
}
from
"
react
"
;
import
React
from
"
react
"
;
import
{
Engine
,
Scene
}
from
"
react-babylonjs
"
;
import
{
Engine
,
Scene
}
from
"
react-babylonjs
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
DuelHands
from
"
./hands_
"
;
const
BabylonCanvas
=
()
=>
(
const
BabylonCanvas
=
()
=>
(
<
div
>
<
div
>
...
@@ -9,6 +10,7 @@ const BabylonCanvas = () => (
...
@@ -9,6 +10,7 @@ const BabylonCanvas = () => (
<
Scene
>
<
Scene
>
<
DuelCamera
/>
<
DuelCamera
/>
<
DuelLight
/>
<
DuelLight
/>
<
DuelHands
/>
<
DuelGround
/>
<
DuelGround
/>
</
Scene
>
</
Scene
>
</
Engine
>
</
Engine
>
...
...
src/ui/Duel/hands_.tsx
0 → 100644
View file @
294a516d
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
selectMeHands
}
from
"
../../reducers/duel/handsSlice
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
{
Card
,
InteractType
}
from
"
../../reducers/duel/util
"
;
import
{
setCardModalImgUrl
,
setCardModalIsOpen
,
setCardModalText
,
setCardModalInteractivies
,
}
from
"
../../reducers/duel/mod
"
;
import
{
store
}
from
"
../../store
"
;
import
{
useClick
,
useHover
}
from
"
react-babylonjs
"
;
import
{
useState
,
useRef
}
from
"
react
"
;
const
DuelHands
=
()
=>
{
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
return
(
<>
{
hands
.
map
((
hand
,
idx
)
=>
{
return
<
DuelHand
state=
{
hand
}
idx=
{
idx
}
/>;
})
}
</>
);
};
const
DuelHand
=
(
props
:
{
state
:
Card
;
idx
:
number
})
=>
{
const
handShape
=
CONFIG
.
HandShape
();
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
planeRef
=
useRef
(
null
);
const
[
state
,
idx
]
=
[
props
.
state
,
props
.
idx
];
const
[
hovered
,
setHovered
]
=
useState
(
false
);
const
dispatch
=
store
.
dispatch
;
useHover
(
()
=>
setHovered
(
true
),
()
=>
setHovered
(
false
),
planeRef
);
useClick
(()
=>
{
dispatch
(
setCardModalText
([
state
.
meta
.
text
.
name
,
state
.
meta
.
text
.
desc
]));
dispatch
(
setCardModalImgUrl
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
state
.
meta
.
id
}
.jpg`
)
);
dispatch
(
setCardModalInteractivies
(
state
.
interactivities
.
map
((
interactive
)
=>
{
return
{
desc
:
interactTypeToString
(
interactive
.
interactType
),
response
:
interactive
.
response
,
};
})
)
);
dispatch
(
setCardModalIsOpen
(
true
));
},
planeRef
);
return
(
<>
<
plane
name=
{
`hand-${idx}`
}
ref=
{
planeRef
}
width=
{
hovered
?
handShape
.
width
*
hoverScale
.
x
:
handShape
.
width
}
height=
{
hovered
?
handShape
.
height
*
hoverScale
.
z
:
handShape
.
height
}
position=
{
new
BABYLON
.
Vector3
(
state
.
transform
.
position
?.
x
,
state
.
transform
.
position
?.
y
,
state
.
transform
.
position
?.
z
)
}
rotation=
{
new
BABYLON
.
Vector3
(
state
.
transform
.
rotation
?.
x
,
state
.
transform
.
rotation
?.
y
,
state
.
transform
.
rotation
?.
z
)
}
>
<
standardMaterial
name=
{
`handMaterial-${idx}`
}
diffuseTexture=
{
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/${state.meta.id}.jpg`
)
}
/>
</
plane
>
</>
);
};
function
interactTypeToString
(
t
:
InteractType
):
string
{
switch
(
t
)
{
case
InteractType
.
SUMMON
:
{
return
"
普通召唤
"
;
}
case
InteractType
.
SP_SUMMON
:
{
return
"
特殊召唤
"
;
}
case
InteractType
.
POS_CHANGE
:
{
return
"
改变表示形式
"
;
}
case
InteractType
.
MSET
:
{
return
"
前场放置
"
;
}
case
InteractType
.
SSET
:
{
return
"
后场放置
"
;
}
case
InteractType
.
ACTIVATE
:
{
return
"
发动效果
"
;
}
default
:
{
return
"
未知选项
"
;
}
}
}
export
default
DuelHands
;
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