Commit 29cdd9df authored by Chunchi Che's avatar Chunchi Che

add Magics Component

parent 669a8a7d
Pipeline #18897 passed with stages
in 3 minutes and 34 seconds
...@@ -7,6 +7,7 @@ import Hands from "./hands_"; ...@@ -7,6 +7,7 @@ import Hands from "./hands_";
import Monsters from "./monsters_"; import Monsters from "./monsters_";
import CardModal from "./cardModal"; import CardModal from "./cardModal";
import HintNotification from "./hintNotification"; import HintNotification from "./hintNotification";
import Magics from "./magics_";
const BabylonCanvas = () => ( const BabylonCanvas = () => (
<> <>
...@@ -19,6 +20,7 @@ const BabylonCanvas = () => ( ...@@ -19,6 +20,7 @@ const BabylonCanvas = () => (
<Light /> <Light />
<Hands /> <Hands />
<Monsters /> <Monsters />
<Magics />
<Ground /> <Ground />
</Provider> </Provider>
</Scene> </Scene>
......
import * as BABYLON from "@babylonjs/core";
import * as CONFIG from "../../config/ui";
// TODO: use config
const left = -2.15;
const gap = 1.05;
const Magics = () => {
return (
<>
{[0, 1, 2, 3, 4].map((idx) => {
return <Magic idx={idx} />;
})}
</>
);
};
const Magic = (props: { idx: number }) => {
const shape = CONFIG.CardSlotShape();
const position = new BABYLON.Vector3(
left + gap * props.idx,
shape.depth / 2 + CONFIG.Floating,
-2.6
);
const rotation = CONFIG.CardSlotRotation();
return (
<plane
name={`magic-${props.idx}`}
width={shape.width}
height={shape.height}
position={position}
rotation={rotation}
>
<standardMaterial
name={`magic-mat-${props.idx}`}
diffuseTexture={
new BABYLON.Texture(`http://localhost:3030/images/card_slot.png`)
}
alpha={0.2}
></standardMaterial>
</plane>
);
};
export default Magics;
...@@ -27,9 +27,10 @@ const Monsters = () => { ...@@ -27,9 +27,10 @@ const Monsters = () => {
const CMonster = (props: { state: Monster }) => { const CMonster = (props: { state: Monster }) => {
const planeRef = useRef(null); const planeRef = useRef(null);
const shape = CONFIG.CardSlotShape();
const position = new BABYLON.Vector3( const position = new BABYLON.Vector3(
left + gap * props.state.sequence, left + gap * props.state.sequence,
CONFIG.CardSlotShape().depth / 2 + CONFIG.Floating, shape.depth / 2 + CONFIG.Floating,
-1.35 -1.35
); );
const rotation = CONFIG.CardSlotRotation(); const rotation = CONFIG.CardSlotRotation();
...@@ -53,6 +54,8 @@ const CMonster = (props: { state: Monster }) => { ...@@ -53,6 +54,8 @@ const CMonster = (props: { state: Monster }) => {
<plane <plane
name={`monster-${props.state.selectInfo}`} name={`monster-${props.state.selectInfo}`}
ref={planeRef} ref={planeRef}
width={shape.width}
height={shape.height}
position={position} position={position}
rotation={rotation} rotation={rotation}
enableEdgesRendering enableEdgesRendering
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment