fix: a pb with octree
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
This commit is contained in:
@@ -8,6 +8,7 @@ export function useOctreeGraphNode(
|
|||||||
graphNodeRef: RefObject<Object3D | null>,
|
graphNodeRef: RefObject<Object3D | null>,
|
||||||
onOctreeReady: OctreeReadyHandler,
|
onOctreeReady: OctreeReadyHandler,
|
||||||
rebuildKey: string | number = 0,
|
rebuildKey: string | number = 0,
|
||||||
|
enabled = true,
|
||||||
): void {
|
): void {
|
||||||
const octreeBuilt = useRef(false);
|
const octreeBuilt = useRef(false);
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ export function useOctreeGraphNode(
|
|||||||
}, [rebuildKey]);
|
}, [rebuildKey]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!enabled) return;
|
||||||
|
|
||||||
const graphNode = graphNodeRef.current;
|
const graphNode = graphNodeRef.current;
|
||||||
if (octreeBuilt.current || !graphNode) return;
|
if (octreeBuilt.current || !graphNode) return;
|
||||||
octreeBuilt.current = true;
|
octreeBuilt.current = true;
|
||||||
@@ -25,5 +28,5 @@ export function useOctreeGraphNode(
|
|||||||
const octree = new Octree();
|
const octree = new Octree();
|
||||||
octree.fromGraphNode(graphNode);
|
octree.fromGraphNode(graphNode);
|
||||||
onOctreeReady(octree);
|
onOctreeReady(octree);
|
||||||
}, [graphNodeRef, onOctreeReady, rebuildKey]);
|
}, [enabled, graphNodeRef, onOctreeReady, rebuildKey]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,13 +62,17 @@ class ModelErrorBoundary extends Component<
|
|||||||
|
|
||||||
interface GameMapProps {
|
interface GameMapProps {
|
||||||
onOctreeReady: OctreeReadyHandler;
|
onOctreeReady: OctreeReadyHandler;
|
||||||
|
buildOctree?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GameMap({ onOctreeReady }: GameMapProps): React.JSX.Element {
|
export function GameMap({
|
||||||
|
onOctreeReady,
|
||||||
|
buildOctree = true,
|
||||||
|
}: GameMapProps): React.JSX.Element {
|
||||||
const [mapNodes, setMapNodes] = useState<LoadedMapNode[]>([]);
|
const [mapNodes, setMapNodes] = useState<LoadedMapNode[]>([]);
|
||||||
const groupRef = useRef<THREE.Group>(null);
|
const groupRef = useRef<THREE.Group>(null);
|
||||||
|
|
||||||
useOctreeGraphNode(groupRef, onOctreeReady, mapNodes.length);
|
useOctreeGraphNode(groupRef, onOctreeReady, mapNodes.length, buildOctree);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadMap = async () => {
|
const loadMap = async () => {
|
||||||
|
|||||||
+18
-5
@@ -19,10 +19,21 @@ import { GameStageContent } from "@/world/GameStageContent";
|
|||||||
import { Player } from "@/world/player/Player";
|
import { Player } from "@/world/player/Player";
|
||||||
import { TestMap } from "@/world/debug/TestMap";
|
import { TestMap } from "@/world/debug/TestMap";
|
||||||
|
|
||||||
|
function hasBootFlag(name: string): boolean {
|
||||||
|
if (typeof window === "undefined") return false;
|
||||||
|
return new URLSearchParams(window.location.search).has(name);
|
||||||
|
}
|
||||||
|
|
||||||
export function World(): React.JSX.Element {
|
export function World(): React.JSX.Element {
|
||||||
const cameraMode = useCameraMode();
|
const cameraMode = useCameraMode();
|
||||||
const sceneMode = useSceneMode();
|
const sceneMode = useSceneMode();
|
||||||
const [octree, setOctree] = useState<Octree | null>(null);
|
const [octree, setOctree] = useState<Octree | null>(null);
|
||||||
|
const noCinematics = hasBootFlag("noCinematics");
|
||||||
|
const noDialogues = hasBootFlag("noDialogues");
|
||||||
|
const noMap = hasBootFlag("noMap");
|
||||||
|
const noMusic = hasBootFlag("noMusic");
|
||||||
|
const noOctree = hasBootFlag("noOctree");
|
||||||
|
const noPlayer = hasBootFlag("noPlayer");
|
||||||
const playerSpawnPosition =
|
const playerSpawnPosition =
|
||||||
sceneMode === "game"
|
sceneMode === "game"
|
||||||
? PLAYER_SPAWN_POSITION_GAME
|
? PLAYER_SPAWN_POSITION_GAME
|
||||||
@@ -43,17 +54,19 @@ export function World(): React.JSX.Element {
|
|||||||
|
|
||||||
{sceneMode === "game" ? (
|
{sceneMode === "game" ? (
|
||||||
<>
|
<>
|
||||||
<GameMusic />
|
{noMusic ? null : <GameMusic />}
|
||||||
<GameCinematics />
|
{noCinematics ? null : <GameCinematics />}
|
||||||
<GameDialogues />
|
{noDialogues ? null : <GameDialogues />}
|
||||||
<GameMap onOctreeReady={setOctree} />
|
{noMap ? null : (
|
||||||
|
<GameMap onOctreeReady={setOctree} buildOctree={!noOctree} />
|
||||||
|
)}
|
||||||
<GameStageContent />
|
<GameStageContent />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<TestMap onOctreeReady={setOctree} />
|
<TestMap onOctreeReady={setOctree} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{cameraMode !== "debug" ? (
|
{cameraMode !== "debug" && !noPlayer ? (
|
||||||
<Player octree={octree} spawnPosition={playerSpawnPosition} />
|
<Player octree={octree} spawnPosition={playerSpawnPosition} />
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user