Feat/map-environment #6
@@ -3,7 +3,6 @@ import type { RefObject } from "react";
|
|||||||
import type { Object3D } from "three";
|
import type { Object3D } from "three";
|
||||||
import { Octree } from "three/addons/math/Octree.js";
|
import { Octree } from "three/addons/math/Octree.js";
|
||||||
import type { OctreeReadyHandler } from "@/types/three/three";
|
import type { OctreeReadyHandler } from "@/types/three/three";
|
||||||
import { logger } from "@/utils/core/Logger";
|
|
||||||
|
|
||||||
export function useOctreeGraphNode(
|
export function useOctreeGraphNode(
|
||||||
graphNodeRef: RefObject<Object3D | null>,
|
graphNodeRef: RefObject<Object3D | null>,
|
||||||
@@ -18,25 +17,16 @@ export function useOctreeGraphNode(
|
|||||||
}, [rebuildKey]);
|
}, [rebuildKey]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
logger.debug("useOctreeGraphNode", "Check", {
|
|
||||||
enabled,
|
|
||||||
octreeBuilt: octreeBuilt.current,
|
|
||||||
hasGraphNode: !!graphNodeRef.current,
|
|
||||||
rebuildKey,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
|
|
||||||
const graphNode = graphNodeRef.current;
|
const graphNode = graphNodeRef.current;
|
||||||
if (!enabled || octreeBuilt.current || !graphNode) return;
|
if (!enabled || octreeBuilt.current || !graphNode) return;
|
||||||
octreeBuilt.current = true;
|
octreeBuilt.current = true;
|
||||||
|
|
||||||
logger.info("useOctreeGraphNode", "Building octree from graph node");
|
|
||||||
graphNode.updateMatrixWorld(true);
|
graphNode.updateMatrixWorld(true);
|
||||||
|
|
||||||
const octree = new Octree();
|
const octree = new Octree();
|
||||||
octree.fromGraphNode(graphNode);
|
octree.fromGraphNode(graphNode);
|
||||||
logger.info("useOctreeGraphNode", "Octree built, calling onOctreeReady");
|
|
||||||
onOctreeReady(octree);
|
onOctreeReady(octree);
|
||||||
}, [enabled, graphNodeRef, onOctreeReady, rebuildKey]);
|
}, [enabled, graphNodeRef, onOctreeReady, rebuildKey]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { useCallback, useEffect, useState } from "react";
|
|||||||
import type { Octree } from "three/addons/math/Octree.js";
|
import type { Octree } from "three/addons/math/Octree.js";
|
||||||
import type { SceneMode } from "@/types/debug/debug";
|
import type { SceneMode } from "@/types/debug/debug";
|
||||||
import type { SceneLoadingChangeHandler } from "@/types/world/sceneLoading";
|
import type { SceneLoadingChangeHandler } from "@/types/world/sceneLoading";
|
||||||
import { logger } from "@/utils/core/Logger";
|
|
||||||
|
|
||||||
interface UseWorldSceneLoadingOptions {
|
interface UseWorldSceneLoadingOptions {
|
||||||
onLoadingStateChange?: SceneLoadingChangeHandler | undefined;
|
onLoadingStateChange?: SceneLoadingChangeHandler | undefined;
|
||||||
@@ -32,12 +31,10 @@ export function useWorldSceneLoading({
|
|||||||
(sceneMode === "physics" && octree !== null);
|
(sceneMode === "physics" && octree !== null);
|
||||||
|
|
||||||
const handleGameMapLoaded = useCallback(() => {
|
const handleGameMapLoaded = useCallback(() => {
|
||||||
logger.info("WorldSceneLoading", "GameMap loaded");
|
|
||||||
setGameMapLoaded(true);
|
setGameMapLoaded(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleGameStageLoaded = useCallback(() => {
|
const handleGameStageLoaded = useCallback(() => {
|
||||||
logger.info("WorldSceneLoading", "GameStage loaded");
|
|
||||||
setGameStageLoaded(true);
|
setGameStageLoaded(true);
|
||||||
onLoadingStateChange?.({
|
onLoadingStateChange?.({
|
||||||
currentStep: "Initialisation gameplay",
|
currentStep: "Initialisation gameplay",
|
||||||
@@ -48,7 +45,6 @@ export function useWorldSceneLoading({
|
|||||||
|
|
||||||
const handleOctreeReady = useCallback(
|
const handleOctreeReady = useCallback(
|
||||||
(nextOctree: Octree) => {
|
(nextOctree: Octree) => {
|
||||||
logger.info("WorldSceneLoading", "Octree ready");
|
|
||||||
setOctree(nextOctree);
|
setOctree(nextOctree);
|
||||||
onLoadingStateChange?.({
|
onLoadingStateChange?.({
|
||||||
currentStep: "Collision prête",
|
currentStep: "Collision prête",
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { useOctreeGraphNode } from "@/hooks/three/useOctreeGraphNode";
|
|||||||
import type { MapNode } from "@/types/editor/editor";
|
import type { MapNode } from "@/types/editor/editor";
|
||||||
import type { OctreeReadyHandler } from "@/types/three/three";
|
import type { OctreeReadyHandler } from "@/types/three/three";
|
||||||
import type { SceneLoadingChangeHandler } from "@/types/world/sceneLoading";
|
import type { SceneLoadingChangeHandler } from "@/types/world/sceneLoading";
|
||||||
import { logger } from "@/utils/core/Logger";
|
|
||||||
import { logModelLoadError } from "@/utils/three/modelLoadLogger";
|
import { logModelLoadError } from "@/utils/three/modelLoadLogger";
|
||||||
|
|
||||||
export interface GameMapCollisionNode {
|
export interface GameMapCollisionNode {
|
||||||
@@ -109,14 +108,6 @@ export function GameMapCollision({
|
|||||||
const collisionReady =
|
const collisionReady =
|
||||||
mapReady && settledCollisionNodeCount >= collisionNodes.length;
|
mapReady && settledCollisionNodeCount >= collisionNodes.length;
|
||||||
|
|
||||||
logger.debug("GameMapCollision", "State", {
|
|
||||||
mapReady,
|
|
||||||
collisionNodesCount: collisionNodes.length,
|
|
||||||
settledCollisionNodeCount,
|
|
||||||
collisionReady,
|
|
||||||
buildOctree,
|
|
||||||
});
|
|
||||||
|
|
||||||
const notifyLoaded = useCallback(() => {
|
const notifyLoaded = useCallback(() => {
|
||||||
if (loadedNotifiedRef.current) return;
|
if (loadedNotifiedRef.current) return;
|
||||||
|
|
||||||
@@ -133,7 +124,6 @@ export function GameMapCollision({
|
|||||||
|
|
||||||
const handleOctreeReady = useCallback<OctreeReadyHandler>(
|
const handleOctreeReady = useCallback<OctreeReadyHandler>(
|
||||||
(octree) => {
|
(octree) => {
|
||||||
logger.info("GameMapCollision", "Octree built, calling onOctreeReady");
|
|
||||||
onLoadingStateChange?.({
|
onLoadingStateChange?.({
|
||||||
currentStep: "Collision prête",
|
currentStep: "Collision prête",
|
||||||
progress: 0.92,
|
progress: 0.92,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export const VEGETATION_LOD = {
|
|||||||
windFadeEnd: 70,
|
windFadeEnd: 70,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const VEGETATION_MAX_INSTANCES = 500;
|
export const VEGETATION_MAX_INSTANCES = 2000;
|
||||||
|
|
||||||
export const VEGETATION_TYPES = {
|
export const VEGETATION_TYPES = {
|
||||||
buissons: {
|
buissons: {
|
||||||
@@ -12,7 +12,7 @@ export const VEGETATION_TYPES = {
|
|||||||
modelPath: "/models/buisson/model.gltf",
|
modelPath: "/models/buisson/model.gltf",
|
||||||
castShadow: true,
|
castShadow: true,
|
||||||
receiveShadow: true,
|
receiveShadow: true,
|
||||||
enabled: false,
|
enabled: true,
|
||||||
windEnabled: false,
|
windEnabled: false,
|
||||||
windIntensity: 1.2,
|
windIntensity: 1.2,
|
||||||
},
|
},
|
||||||
@@ -39,7 +39,7 @@ export const VEGETATION_TYPES = {
|
|||||||
modelPath: "/models/champdeble/model.gltf",
|
modelPath: "/models/champdeble/model.gltf",
|
||||||
castShadow: true,
|
castShadow: true,
|
||||||
receiveShadow: true,
|
receiveShadow: true,
|
||||||
enabled: false,
|
enabled: true,
|
||||||
windEnabled: false,
|
windEnabled: false,
|
||||||
windIntensity: 1.0,
|
windIntensity: 1.0,
|
||||||
},
|
},
|
||||||
@@ -48,7 +48,7 @@ export const VEGETATION_TYPES = {
|
|||||||
modelPath: "/models/champdesoja/model.gltf",
|
modelPath: "/models/champdesoja/model.gltf",
|
||||||
castShadow: true,
|
castShadow: true,
|
||||||
receiveShadow: true,
|
receiveShadow: true,
|
||||||
enabled: false,
|
enabled: true,
|
||||||
windEnabled: false,
|
windEnabled: false,
|
||||||
windIntensity: 1.0,
|
windIntensity: 1.0,
|
||||||
},
|
},
|
||||||
@@ -57,7 +57,7 @@ export const VEGETATION_TYPES = {
|
|||||||
modelPath: "/models/champsdetournesol/model.gltf",
|
modelPath: "/models/champsdetournesol/model.gltf",
|
||||||
castShadow: true,
|
castShadow: true,
|
||||||
receiveShadow: true,
|
receiveShadow: true,
|
||||||
enabled: false,
|
enabled: true,
|
||||||
windEnabled: false,
|
windEnabled: false,
|
||||||
windIntensity: 0.9,
|
windIntensity: 0.9,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user