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
a29adad0
Commit
a29adad0
authored
Dec 31, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
18828d1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
22 deletions
+35
-22
src/ui/Duel/hands.tsx
src/ui/Duel/hands.tsx
+35
-22
No files found.
src/ui/Duel/hands.tsx
View file @
a29adad0
...
...
@@ -14,6 +14,7 @@ import { useHover } from "react-babylonjs";
import
{
useClick
}
from
"
./hook
"
;
import
{
useState
,
useRef
,
useEffect
}
from
"
react
"
;
import
{
useSpring
,
animated
}
from
"
./spring
"
;
import
{
config
}
from
"
@react-spring/web
"
;
const
groundShape
=
CONFIG
.
GroundShape
();
const
left
=
-
(
groundShape
.
width
/
2
);
...
...
@@ -39,41 +40,53 @@ const Hands = () => {
const
CHand
=
(
props
:
{
state
:
Hand
;
idx
:
number
;
gap
:
number
})
=>
{
const
handShape
=
CONFIG
.
HandShape
();
const
rotation
=
CONFIG
.
HandRotation
();
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
defaultScale
=
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
const
planeRef
=
useRef
(
null
);
const
[
state
,
idx
]
=
[
props
.
state
,
props
.
idx
];
const
[
hovered
,
setHovered
]
=
useState
(
false
);
const
dispatch
=
store
.
dispatch
;
const
[
position
,
setPosition
]
=
useState
(
new
BABYLON
.
Vector3
(
left
+
props
.
gap
*
props
.
idx
,
handShape
.
height
/
2
,
-
(
groundShape
.
height
/
2
)
-
1
)
);
const
[
spring
,
api
]
=
useSpring
(
()
=>
({
from
:
{
position
:
new
BABYLON
.
Vector3
(
left
+
props
.
gap
*
props
.
idx
,
handShape
.
height
/
2
,
-
(
groundShape
.
height
/
2
)
-
1
),
position
,
},
config
:
{
mass
:
1.0
,
tension
:
170
,
friction
:
900
,
precision
:
0.01
,
velocity
:
0.0
,
clamp
:
true
,
duration
:
2000
,
},
}),
[
props
.
idx
,
props
.
gap
]
[]
);
useEffect
(()
=>
{
api
({
position
:
new
BABYLON
.
Vector3
(
left
+
props
.
gap
*
props
.
idx
,
handShape
.
height
/
2
,
-
(
groundShape
.
height
/
2
)
-
1
),
});
},
[
props
.
idx
,
props
.
gap
]);
const
newPosition
=
new
BABYLON
.
Vector3
(
left
+
props
.
gap
*
props
.
idx
,
handShape
.
height
/
2
,
-
(
groundShape
.
height
/
2
)
-
1
);
const
rotation
=
CONFIG
.
HandRotation
();
api
.
start
({
position
:
newPosition
,
});
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
defaultScale
=
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
const
planeRef
=
useRef
(
null
);
const
[
state
,
idx
]
=
[
props
.
state
,
props
.
idx
];
const
[
hovered
,
setHovered
]
=
useState
(
false
);
const
dispatch
=
store
.
dispatch
;
setPosition
(
newPosition
);
},
[
props
.
idx
,
props
.
gap
]);
useHover
(
()
=>
setHovered
(
true
),
...
...
@@ -116,7 +129,7 @@ const CHand = (props: { state: Hand; idx: number; gap: number }) => {
position=
{
spring
.
position
}
rotation=
{
rotation
}
>
<
standardMaterial
<
animated
.
standardMaterial
name=
{
`hand-mat-${idx}`
}
diffuseTexture=
{
new
BABYLON
.
Texture
(
...
...
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