Skip to content

Commit

Permalink
fix: improve text positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Battlesquid committed Dec 20, 2024
1 parent 714f03a commit 0c3489e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/app/src/components/skyline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export function Skyline(props: SkylineModelProps) {
<SkylineModel parameters={parameters} weeks={weeks} />
</Bounds>
<ambientLight intensity={Math.PI / 2} />
<spotLight position={[10, 100, 40]} angle={0.55} penumbra={0.1} decay={0.4} intensity={Math.PI} />
<pointLight position={[-10, -10, -10]} decay={0} intensity={Math.PI} />
<directionalLight color="#fff" position={[13, 100, 100]} />
<OrbitControls makeDefault minPolarAngle={0} maxPolarAngle={Math.PI / 2.5} autoRotate autoRotateSpeed={0.5} />
<spotLight position={[0, 20, 50]} angle={0.50} penumbra={0.1} decay={0.4} intensity={Math.PI} />
<pointLight position={[0, 20, 0]} decay={0} intensity={Math.PI} />
<directionalLight color="#fff" position={[0, 10, -50]} />
<OrbitControls makeDefault minPolarAngle={0} maxPolarAngle={Math.PI} />
</Canvas>
);
}
5 changes: 3 additions & 2 deletions packages/app/src/components/skyline_model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function SkylineModel(props: SkylineModelProps) {

const getDimensions = (mesh: Mesh): Dimensions => {
mesh.geometry.computeBoundingBox();
mesh.geometry.center();
return {
width: mesh.geometry.boundingBox!.max.x - mesh.geometry.boundingBox!.min.x,
height: mesh.geometry.boundingBox!.max.y - mesh.geometry.boundingBox!.min.y
Expand Down Expand Up @@ -94,7 +95,7 @@ export function SkylineModel(props: SkylineModelProps) {
<Text3D
ref={nameRef}
font={parameters.font}
position={[-length / 2 + 1, -platformHeight / 2 - nameDimensions.height / 2, (width / 2) + parameters.padding]}
position={[-length / 2 + nameDimensions.width / 2 + 1, -platformHeight / 2, (width / 2) + parameters.padding]}
height={parameters.textDepth}
size={textSize}
>
Expand All @@ -104,7 +105,7 @@ export function SkylineModel(props: SkylineModelProps) {
<Text3D
ref={yearRef}
font={parameters.font}
position={[length / 2 - yearDimensions.width - 1, -platformHeight / 2 - yearDimensions.height / 2, (width / 2) + parameters.padding]}
position={[length / 2 - yearDimensions.width / 2 - 1, -platformHeight / 2, (width / 2) + parameters.padding]}
height={parameters.textDepth}
size={textSize}
>
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/parameters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FontData } from "@react-three/drei";
import { DEFAULT_FONT_SELECTION, defaultFonts } from "./stores";

export interface SkylineModelParameters {
name: string;
Expand All @@ -16,7 +17,7 @@ export const defaults: SkylineModelParameters = {
name: "Battlesquid",
year: new Date().getFullYear(),
color: "#575757",
font: "/Inter_Bold.json",
font: defaultFonts[DEFAULT_FONT_SELECTION],
showContributionColor: false,
padding: 0.5,
textDepth: 0.25,
Expand Down

0 comments on commit 0c3489e

Please sign in to comment.