Skip to content

Commit

Permalink
fix: remove flickering on cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Cygnusfear committed Oct 8, 2023
1 parent 7fdd4fb commit c2db053
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/game/entities/facility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const Facility = (props: IFacility) => {
? palette.cursor
: "black"
}
visible={faceIndex !== undefined && faceIndex === index}
visible={false}
transparent={true}
// TODO: Remove the face highlighting completely, or use alternative face highlighting like in Townscraper
opacity={0}
Expand Down
12 changes: 8 additions & 4 deletions packages/client/src/game/input/cursor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { Sparkles } from "@react-three/drei";
import { AdditiveBlending, DoubleSide } from "three";
import { AdditiveBlending, DoubleSide, Vector3 } from "three";

import { useStore } from "../store";
import { palette } from "../utils/palette";
Expand Down Expand Up @@ -38,9 +38,13 @@ function Cursor() {
}, [cursorState, building, position, setCursor]);

return (
<group position={position.toArray()} visible={cursorState !== "hidden"}>
<group
position={position.toArray()}
visible={cursorState !== "hidden"}
scale={new Vector3(0.95, 0.95, 0.95)}
>
<mesh userData={{ type: "cursor" }} ref={cursorRef}>
<boxGeometry args={[0.96, 0.96]} />
<boxGeometry args={[1, 1]} />
{/* Face mapping for direction */}
{[...Array(6)].map((_, index) => (
<meshLambertMaterial
Expand All @@ -65,7 +69,7 @@ function Cursor() {
</mesh>
{/* 🐁 main cursor block */}
<mesh visible={cursorState === "valid"}>
<boxGeometry args={[0.99, 0.99, 0.99]} />
<boxGeometry args={[0.95, 0.95, 0.95]} />
<meshStandardMaterial
map={textures["box01"]}
color={
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/game/systems/constructionSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { palette } from "../utils/palette";
import { IFacility } from "../types/entities";
import prand from "pure-rand";

// TODO: Extract build conditions, can't build 1 tile below gravity well, only gravity well can build at y==1, etc
const canBuildAtPosition = (position: Vector3) => {
const {
input: { building },
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/worlds.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"31337": {
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3"
"address": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
}
}

0 comments on commit c2db053

Please sign in to comment.