diff --git a/packages/app/src/components/three/contribution_tower.tsx b/packages/app/src/components/three/contribution_tower.tsx index 5a21e8f..dc93cd2 100644 --- a/packages/app/src/components/three/contribution_tower.tsx +++ b/packages/app/src/components/three/contribution_tower.tsx @@ -11,21 +11,18 @@ interface ContributionTowerProps extends MeshProps { x: number; y: number; height: number; + size: number; day: NonNullable< ResultOf["user"] >["contributionsCollection"]["contributionCalendar"]["weeks"][number]["contributionDays"][number]; } export function ContributionTower(props: ContributionTowerProps) { - const { x, y, height, day, ...rest } = props; - // This reference will give us direct access to the THREE.Mesh object - const ref = useRef(null!); - // Hold state for hovered and clicked events + const { x, y, height, day, size, ...rest } = props; const [hovered, hover] = useState(false); const [clicked, click] = useState(false); const [position, setPosition] = useState({ x: 0, y: 0 }); - // Rotate mesh every frame, this is outside of React without overhead // useFrame((state, delta) => (ref.current.rotation.x += 0.01)) const color = new THREE.Color(day.color); @@ -35,7 +32,6 @@ export function ContributionTower(props: ContributionTowerProps) { <> { event.stopPropagation(); @@ -59,8 +55,7 @@ export function ContributionTower(props: ContributionTowerProps) { hover(false); }} > - - {/* */} + diff --git a/packages/app/src/components/three/skyline.tsx b/packages/app/src/components/three/skyline.tsx index d6d144b..96e0e6e 100644 --- a/packages/app/src/components/three/skyline.tsx +++ b/packages/app/src/components/three/skyline.tsx @@ -1,5 +1,5 @@ import { useMantineTheme } from "@mantine/core"; -import { OrbitControls, Stage } from "@react-three/drei"; +import { Bounds, OrbitControls, Stage } from "@react-three/drei"; import { Canvas } from "@react-three/fiber"; import { ResultOf } from "gql.tada"; import { ContributionQuery } from "../../api/query"; @@ -16,12 +16,16 @@ export function Skyline(props: SkylineProps) { const theme = useMantineTheme(); return ( - + - {/* */} - + + + - {/* */} diff --git a/packages/app/src/components/three/skyline_base.tsx b/packages/app/src/components/three/skyline_base.tsx deleted file mode 100644 index 51adaa2..0000000 --- a/packages/app/src/components/three/skyline_base.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { useLoader } from "@react-three/fiber"; -import * as THREE from "three"; -import { TextGeometry } from 'three/addons/geometries/TextGeometry.js'; -import { BufferGeometryUtils, FontLoader } from "three/examples/jsm/Addons.js"; - -interface SkylineBaseProps { - username: string; - year: string; - length: number; - width: number; - height: number; - padding: number; - font: string; -} - -export function SkylineBase(props: SkylineBaseProps) { - // const font = useFont(props.font); - const font = useLoader(FontLoader, "/Inter_Bold.json"); - - const geometry = new THREE.BufferGeometry(); - - const username = new TextGeometry(props.username, { - font - }) - - const year = new TextGeometry(props.username, { - font - }) - - const base = new THREE.BoxGeometry( - props.length + props.padding, - props.height, - props.width + props.padding - ); - - - const geometries = [ - base - ] - - const merged = BufferGeometryUtils.mergeGeometries(geometries) -} \ No newline at end of file diff --git a/packages/app/src/components/three/skyline_model.tsx b/packages/app/src/components/three/skyline_model.tsx index c955fd8..e7a2dad 100644 --- a/packages/app/src/components/three/skyline_model.tsx +++ b/packages/app/src/components/three/skyline_model.tsx @@ -1,11 +1,12 @@ -import { Text3D } from "@react-three/drei"; +import { Center, Stars, Text3D } from "@react-three/drei"; import { ContributionTower } from "./contribution_tower"; import { ContributionQuery } from "../../api/query"; import { ResultOf } from "gql.tada"; -import { useThree } from "@react-three/fiber"; +import { Canvas, useFrame, useThree } from "@react-three/fiber"; import { STLExporter } from "three/examples/jsm/Addons.js"; import { useSceneStore } from "../../scene"; -import { useEffect } from "react"; +import { useEffect, useRef, useState } from "react"; +import { Group, Mesh } from "three"; interface SkylineModelProps { user: string; @@ -15,14 +16,24 @@ interface SkylineModelProps { export function SkylineModel(props: SkylineModelProps) { const { user, weeks, year } = props; - const length = weeks.length / 2; - const width = 7 / 2; + const size = 0.5; + const length = weeks.length * size; + const width = 7 * size; const padding = 0.5; - const platform_height = 2; - const text_depth = 0.25; + const font = "/Inter_Bold.json"; + const platform_height = size * 3; + const text_size = platform_height / 2; + const text_depth = 0.35; + const tower_height = (count: number) => count * size / 10 + size / 10; + const color = "#575757"; const scene = useThree((state) => state.scene); const sceneStore = useSceneStore(); + console.log(length, width) + + const [usingControls, setUsingControls] = useState(false); + const group = useRef(null!); + useFrame((state, delta) => (group.current.rotation.y += 0.001)) // useEffect(() => { // setInterval(() => { @@ -38,36 +49,47 @@ export function SkylineModel(props: SkylineModelProps) { // clone.updateMatrixWorld(); // }, 1000 * 5); // }, []) - + return ( - <> + {weeks.map((week, i) => week.contributionDays.map((day, j) => ( - - )), + + )) )} - + - + {user} - - - - {year} - + - +
+ + {year} + + +
+
) } \ No newline at end of file