Enhance shadow handling and visibility settings across components
This commit is contained in:
@@ -216,6 +216,7 @@ const GlobalProperties: React.FC = () => {
|
|||||||
// setRenderDistance(parseInt(e.target.value));
|
// setRenderDistance(parseInt(e.target.value));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="global-properties-container">
|
<div className="global-properties-container">
|
||||||
<section>
|
<section>
|
||||||
@@ -239,12 +240,12 @@ const GlobalProperties: React.FC = () => {
|
|||||||
label="Wall Visibility"
|
label="Wall Visibility"
|
||||||
onClick={changeWallVisibility}
|
onClick={changeWallVisibility}
|
||||||
/>
|
/>
|
||||||
{/* <InputToggle
|
<InputToggle
|
||||||
value={shadows}
|
value={shadows}
|
||||||
inputKey="3"
|
inputKey="3"
|
||||||
label="Shadows Visibility"
|
label="Shadows Visibility"
|
||||||
onClick={shadowVisibility}
|
onClick={shadowVisibility}
|
||||||
/> */}
|
/>
|
||||||
<LabeledButton
|
<LabeledButton
|
||||||
label="Reset Camera"
|
label="Reset Camera"
|
||||||
onClick={toggleResetCamera}
|
onClick={toggleResetCamera}
|
||||||
|
|||||||
@@ -92,6 +92,17 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
}
|
}
|
||||||
}, [asset.modelUuid, ikData])
|
}, [asset.modelUuid, ikData])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (gltfScene) {
|
||||||
|
gltfScene.traverse((child: any) => {
|
||||||
|
if (child.isMesh) {
|
||||||
|
child.castShadow = true;
|
||||||
|
child.receiveShadow = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [gltfScene]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDeletableFloorItem(null);
|
setDeletableFloorItem(null);
|
||||||
if (selectedFloorItem === null || selectedFloorItem.userData.modelUuid !== asset.modelUuid) {
|
if (selectedFloorItem === null || selectedFloorItem.userData.modelUuid !== asset.modelUuid) {
|
||||||
@@ -481,6 +492,8 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
rotation={asset.rotation}
|
rotation={asset.rotation}
|
||||||
visible={asset.isVisible}
|
visible={asset.isVisible}
|
||||||
userData={{ ...asset, iks: ikData }}
|
userData={{ ...asset, iks: ikData }}
|
||||||
|
castShadow
|
||||||
|
receiveShadow
|
||||||
onDoubleClick={(e) => {
|
onDoubleClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!toggleView) {
|
if (!toggleView) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useToggleView, useWallVisibility } from '../../../../../store/builder/s
|
|||||||
import { useBuilderStore } from '../../../../../store/builder/useBuilderStore';
|
import { useBuilderStore } from '../../../../../store/builder/useBuilderStore';
|
||||||
import * as Constants from '../../../../../types/world/worldConstants';
|
import * as Constants from '../../../../../types/world/worldConstants';
|
||||||
|
|
||||||
import DecalInstance from '../../../Decal/decalInstance';
|
// import DecalInstance from '../../../Decal/decalInstance';
|
||||||
|
|
||||||
import defaultMaterial from '../../../../../assets/textures/floor/wall-tex.png';
|
import defaultMaterial from '../../../../../assets/textures/floor/wall-tex.png';
|
||||||
import material1 from '../../../../../assets/textures/floor/factory wall texture.jpg';
|
import material1 from '../../../../../assets/textures/floor/factory wall texture.jpg';
|
||||||
@@ -63,10 +63,10 @@ function Wall({ wall }: { readonly wall: Wall }) {
|
|||||||
|
|
||||||
const materials = useMemo(() => {
|
const materials = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible }), // Left
|
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible, clipShadows: true }), // Left
|
||||||
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible }), // Right
|
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible, clipShadows: true }), // Right
|
||||||
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible }), // Top
|
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible, clipShadows: true }), // Top
|
||||||
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible }), // Bottom
|
new THREE.MeshStandardMaterial({ color: Constants.wallConfig.defaultColor, side: THREE.DoubleSide, visible: visible, clipShadows: true }), // Bottom
|
||||||
new THREE.MeshStandardMaterial({
|
new THREE.MeshStandardMaterial({
|
||||||
color: Constants.wallConfig.defaultColor,
|
color: Constants.wallConfig.defaultColor,
|
||||||
side: THREE.DoubleSide,
|
side: THREE.DoubleSide,
|
||||||
@@ -99,11 +99,15 @@ function Wall({ wall }: { readonly wall: Wall }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<mesh
|
<mesh
|
||||||
|
castShadow
|
||||||
|
receiveShadow
|
||||||
name={`Wall-${wall.wallUuid}`}
|
name={`Wall-${wall.wallUuid}`}
|
||||||
key={wall.wallUuid}
|
key={wall.wallUuid}
|
||||||
userData={wall}
|
userData={wall}
|
||||||
>
|
>
|
||||||
<Base
|
<Base
|
||||||
|
castShadow
|
||||||
|
receiveShadow
|
||||||
ref={meshRef}
|
ref={meshRef}
|
||||||
geometry={geometry}
|
geometry={geometry}
|
||||||
position={[centerX, centerY, centerZ]}
|
position={[centerX, centerY, centerZ]}
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ function Floor({ room }: { room: Point[] }) {
|
|||||||
<mesh name="Wall-Floor" rotation={[Math.PI / 2, 0, 0]}>
|
<mesh name="Wall-Floor" rotation={[Math.PI / 2, 0, 0]}>
|
||||||
<Extrude
|
<Extrude
|
||||||
receiveShadow
|
receiveShadow
|
||||||
|
castShadow
|
||||||
name="Wall-Floor"
|
name="Wall-Floor"
|
||||||
args={[shape, { depth: Constants.floorConfig.height, bevelEnabled: false }]}
|
args={[shape, { depth: Constants.floorConfig.height, bevelEnabled: false }]}
|
||||||
position={[0, 0, 0]}
|
position={[0, 0, 0]}
|
||||||
|
|||||||
@@ -9,21 +9,17 @@ import {
|
|||||||
useTileDistance,
|
useTileDistance,
|
||||||
} from "../../../store/builder/store";
|
} from "../../../store/builder/store";
|
||||||
import * as CONSTANTS from "../../../types/world/worldConstants";
|
import * as CONSTANTS from "../../../types/world/worldConstants";
|
||||||
const shadowWorker = new Worker(
|
|
||||||
new URL(
|
const shadowWorker = new Worker(new URL("../../../services/factoryBuilder/webWorkers/shadowWorker", import.meta.url));
|
||||||
"../../../services/factoryBuilder/webWorkers/shadowWorker",
|
|
||||||
import.meta.url
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function Shadows() {
|
export default function Shadows() {
|
||||||
const { shadows, setShadows } = useShadows();
|
const { shadows } = useShadows();
|
||||||
const { sunPosition, setSunPosition } = useSunPosition();
|
const { sunPosition } = useSunPosition();
|
||||||
const lightRef = useRef<THREE.DirectionalLight | null>(null);
|
const lightRef = useRef<THREE.DirectionalLight | null>(null);
|
||||||
const targetRef = useRef<THREE.Object3D | null>(null);
|
const targetRef = useRef<THREE.Object3D | null>(null);
|
||||||
const { controls, gl } = useThree();
|
const { controls, gl } = useThree();
|
||||||
const { elevation, setElevation } = useElevation();
|
const { elevation } = useElevation();
|
||||||
const { azimuth, setAzimuth } = useAzimuth();
|
const { azimuth } = useAzimuth();
|
||||||
const { planeValue } = useTileDistance();
|
const { planeValue } = useTileDistance();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -265,8 +265,10 @@ export const planeConfig: PlaneConfig = {
|
|||||||
|
|
||||||
export const shadowConfig: ShadowConfig = {
|
export const shadowConfig: ShadowConfig = {
|
||||||
shadowOffset: 50, // Offset of the shadow
|
shadowOffset: 50, // Offset of the shadow
|
||||||
shadowmapSizewidth: 1024, // Width of the shadow map
|
// shadowmapSizewidth: 1024, // Width of the shadow map
|
||||||
shadowmapSizeheight: 1024, // Height of the shadow map
|
// shadowmapSizeheight: 1024, // Height of the shadow map
|
||||||
|
shadowmapSizewidth: 2048, // Width of the shadow map
|
||||||
|
shadowmapSizeheight: 2048, // Height of the shadow map
|
||||||
// shadowmapSizewidth: 8192, // Width of the shadow map
|
// shadowmapSizewidth: 8192, // Width of the shadow map
|
||||||
// shadowmapSizeheight: 8192, // Height of the shadow map
|
// shadowmapSizeheight: 8192, // Height of the shadow map
|
||||||
shadowcamerafar: 70, // Far plane of the shadow camera
|
shadowcamerafar: 70, // Far plane of the shadow camera
|
||||||
|
|||||||
Reference in New Issue
Block a user