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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
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
MyCard
Neos
Commits
afc064d0
Commit
afc064d0
authored
Nov 12, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start to draw duel plate
parent
40f7217e
Pipeline
#17824
passed with stages
in 2 minutes and 56 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
61 deletions
+60
-61
src/ui/BabylonJs.tsx
src/ui/BabylonJs.tsx
+0
-49
src/ui/Duel/simpleDuel.tsx
src/ui/Duel/simpleDuel.tsx
+60
-10
src/ui/Neos.tsx
src/ui/Neos.tsx
+0
-2
No files found.
src/ui/BabylonJs.tsx
deleted
100644 → 0
View file @
40f7217e
// 测试用的Babylon.js demo页面
import
React
,
{
useEffect
,
useRef
}
from
"
react
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
export
default
function
()
{
const
canvasRef
=
useRef
<
HTMLCanvasElement
>
(
null
);
useEffect
(()
=>
{
if
(
canvasRef
.
current
)
{
const
canvasCurrent
=
canvasRef
.
current
;
const
engine
=
new
BABYLON
.
Engine
(
canvasCurrent
,
true
);
const
scene
=
new
BABYLON
.
Scene
(
engine
);
const
camera
=
new
BABYLON
.
FreeCamera
(
"
camera1
"
,
new
BABYLON
.
Vector3
(
0
,
5
,
-
10
),
scene
);
camera
.
setTarget
(
BABYLON
.
Vector3
.
Zero
());
camera
.
attachControl
(
canvasCurrent
,
true
);
const
light
=
new
BABYLON
.
HemisphericLight
(
"
light
"
,
new
BABYLON
.
Vector3
(
0
,
1
,
0
),
scene
);
light
.
intensity
=
0.7
;
const
sphere
=
BABYLON
.
MeshBuilder
.
CreateSphere
(
"
sphere
"
,
{
diameter
:
2
,
segments
:
32
},
scene
);
sphere
.
position
.
y
=
1
;
const
ground
=
BABYLON
.
MeshBuilder
.
CreateGround
(
"
ground
"
,
{
width
:
6
,
height
:
6
},
scene
);
engine
.
runRenderLoop
(()
=>
{
scene
.
render
();
});
}
},
[
canvasRef
]);
return
<
canvas
ref=
{
canvasRef
}
/>;
}
src/ui/Duel/simpleDuel.tsx
View file @
afc064d0
...
@@ -6,8 +6,9 @@
...
@@ -6,8 +6,9 @@
import
{
IDuelPlate
,
TypeSelector
}
from
"
./duel
"
;
import
{
IDuelPlate
,
TypeSelector
}
from
"
./duel
"
;
import
*
as
DuelData
from
"
./data
"
;
import
*
as
DuelData
from
"
./data
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
React
from
"
react
"
;
import
React
,
{
useEffect
,
useRef
}
from
"
react
"
;
import
type
{
RootState
}
from
"
../../store
"
;
import
type
{
RootState
}
from
"
../../store
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
export
default
class
SimpleDuelPlateImpl
implements
IDuelPlate
{
export
default
class
SimpleDuelPlateImpl
implements
IDuelPlate
{
handsSelector
?:
TypeSelector
<
DuelData
.
Card
[]
>
;
handsSelector
?:
TypeSelector
<
DuelData
.
Card
[]
>
;
...
@@ -15,22 +16,71 @@ export default class SimpleDuelPlateImpl implements IDuelPlate {
...
@@ -15,22 +16,71 @@ export default class SimpleDuelPlateImpl implements IDuelPlate {
constructor
()
{}
constructor
()
{}
render
():
React
.
ReactElement
{
render
():
React
.
ReactElement
{
// ----- 数据获取 -----
// 默认的手牌Selector,返回三个code为-1的Card。
// 默认的手牌Selector,返回三个code为-1的Card。
const
defaultHandsSelector
=
(
_
:
RootState
)
=>
{
const
defaultHandsSelector
=
(
_
:
RootState
)
=>
{
return
new
Array
(
5
).
fill
({
code
:
-
1
});
return
new
Array
(
5
).
fill
({
code
:
-
1
});
};
};
const
hands
=
useAppSelector
(
this
.
handsSelector
||
defaultHandsSelector
);
const
hands
=
useAppSelector
(
this
.
handsSelector
||
defaultHandsSelector
);
// ----- WebGL渲染 -----
const
canvasRef
=
useRef
<
HTMLCanvasElement
>
(
null
);
useEffect
(()
=>
{
// 初始化Scene
const
canvasCurrent
=
canvasRef
.
current
;
const
engine
=
new
BABYLON
.
Engine
(
canvasCurrent
,
true
);
const
scene
=
new
BABYLON
.
Scene
(
engine
);
// 创建Camera
const
camera
=
new
BABYLON
.
FreeCamera
(
"
camera1
"
,
new
BABYLON
.
Vector3
(
1
,
5
,
-
10
),
// 俯视方向
scene
);
camera
.
setTarget
(
BABYLON
.
Vector3
.
Zero
());
// 俯视向前
camera
.
attachControl
(
canvasCurrent
,
true
);
// 创建光源
const
light
=
new
BABYLON
.
HemisphericLight
(
"
light
"
,
new
BABYLON
.
Vector3
(
1
,
2.5
,
1
),
scene
);
light
.
intensity
=
0.7
;
// 创建卡槽
const
cardSlot
=
BABYLON
.
MeshBuilder
.
CreateBox
(
"
cardSlot
"
,
{
width
:
0.5
,
height
:
0.75
,
depth
:
0.05
},
scene
);
cardSlot
.
position
=
new
BABYLON
.
Vector3
(
-
2
,
0.5
,
-
3
);
cardSlot
.
rotation
=
new
BABYLON
.
Vector3
(
1.5
,
0
,
0
);
const
boxMaterail
=
new
BABYLON
.
StandardMaterial
(
"
boxMaterail
"
,
scene
);
boxMaterail
.
diffuseColor
=
BABYLON
.
Color3
.
Blue
();
cardSlot
.
material
=
boxMaterail
;
// 创建地板
const
ground
=
BABYLON
.
MeshBuilder
.
CreateGround
(
"
ground
"
,
{
width
:
6
,
height
:
6
},
scene
);
// 渲染循环
engine
.
runRenderLoop
(()
=>
{
scene
.
render
();
});
},
[
canvasRef
]);
return
(
return
(
<
div
>
<
canvas
<
table
border=
{
1
}
>
width=
{
window
.
innerWidth
}
<
tr
>
height=
{
window
.
innerHeight
}
{
hands
.
map
((
hand
)
=>
(
ref=
{
canvasRef
}
<
td
>
{
hand
.
code
}
</
td
>
/>
))
}
</
tr
>
</
table
>
</
div
>
);
);
}
}
...
...
src/ui/Neos.tsx
View file @
afc064d0
...
@@ -2,7 +2,6 @@ import React from "react";
...
@@ -2,7 +2,6 @@ import React from "react";
import
JoinRoom
from
"
./JoinRoom
"
;
import
JoinRoom
from
"
./JoinRoom
"
;
import
WaitRoom
from
"
./WaitRoom
"
;
import
WaitRoom
from
"
./WaitRoom
"
;
import
ThreeJs
from
"
./ThreeJs
"
;
import
ThreeJs
from
"
./ThreeJs
"
;
import
BabylonJs
from
"
./BabylonJs
"
;
import
{
Routes
,
Route
}
from
"
react-router-dom
"
;
import
{
Routes
,
Route
}
from
"
react-router-dom
"
;
import
Mora
from
"
./Mora
"
;
import
Mora
from
"
./Mora
"
;
import
Duel
from
"
./Duel/main
"
;
import
Duel
from
"
./Duel/main
"
;
...
@@ -16,7 +15,6 @@ export default function () {
...
@@ -16,7 +15,6 @@ export default function () {
<
Route
path=
"/mora"
element=
{
<
Mora
/>
}
/>
<
Route
path=
"/mora"
element=
{
<
Mora
/>
}
/>
<
Route
path=
"/duel"
element=
{
<
Duel
/>
}
/>
<
Route
path=
"/duel"
element=
{
<
Duel
/>
}
/>
<
Route
path=
"/three"
element=
{
<
ThreeJs
/>
}
/>
<
Route
path=
"/three"
element=
{
<
ThreeJs
/>
}
/>
<
Route
path=
"/babylon"
element=
{
<
BabylonJs
/>
}
/>
</
Routes
>
</
Routes
>
);
);
}
}
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