@3driseai/3drise-viewer 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Clouds.d.ts.map +1 -1
- package/dist/components/Clouds.js +0 -1
- package/dist/components/CloudsGenerator.d.ts +32 -0
- package/dist/components/CloudsGenerator.d.ts.map +1 -0
- package/dist/components/CloudsGenerator.js +58 -0
- package/dist/components/CustomPrimitive.js +1 -1
- package/dist/components/EnvironmentManager.d.ts +47 -5
- package/dist/components/EnvironmentManager.d.ts.map +1 -1
- package/dist/components/EnvironmentManager.js +35 -66
- package/dist/components/GeometryShape.d.ts.map +1 -1
- package/dist/components/GeometryShape.js +19 -3
- package/dist/components/HdrEnvironment.d.ts +20 -0
- package/dist/components/HdrEnvironment.d.ts.map +1 -0
- package/dist/components/HdrEnvironment.js +44 -0
- package/dist/components/LandscapeBuilder.d.ts +23 -0
- package/dist/components/LandscapeBuilder.d.ts.map +1 -0
- package/dist/components/LandscapeBuilder.js +25 -0
- package/dist/components/LandscapeObject.d.ts +24 -0
- package/dist/components/LandscapeObject.d.ts.map +1 -0
- package/dist/components/LandscapeObject.js +27 -0
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +11 -9
- package/dist/components/OceanBuilder.d.ts +35 -0
- package/dist/components/OceanBuilder.d.ts.map +1 -0
- package/dist/components/OceanBuilder.js +53 -0
- package/dist/components/ParticlesR3f.d.ts.map +1 -1
- package/dist/components/ParticlesR3f.js +63 -12
- package/dist/components/PointCloud.d.ts.map +1 -1
- package/dist/components/PointCloud.js +50 -10
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SkySystem.d.ts +27 -6
- package/dist/components/SkySystem.d.ts.map +1 -1
- package/dist/components/SkySystem.js +6 -5
- package/dist/components/SunLight.d.ts.map +1 -1
- package/dist/components/SunLight.js +4 -1
- package/dist/components/TerrainBuilder.d.ts +30 -0
- package/dist/components/TerrainBuilder.d.ts.map +1 -0
- package/dist/components/TerrainBuilder.js +44 -0
- package/dist/components/index.d.ts +17 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +10 -0
- package/dist/components/landscape/LandscapeMesh.d.ts +18 -0
- package/dist/components/landscape/LandscapeMesh.d.ts.map +1 -0
- package/dist/components/landscape/LandscapeMesh.js +278 -0
- package/dist/components/landscape/index.d.ts +3 -0
- package/dist/components/landscape/index.d.ts.map +1 -0
- package/dist/components/landscape/index.js +1 -0
- package/dist/components/landscape/types.d.ts +13 -0
- package/dist/components/landscape/types.d.ts.map +1 -0
- package/dist/components/landscape/types.js +1 -0
- package/dist/components/terrain/Canyon.d.ts +23 -0
- package/dist/components/terrain/Canyon.d.ts.map +1 -0
- package/dist/components/terrain/Canyon.js +29 -0
- package/dist/components/terrain/Dunes.d.ts +22 -0
- package/dist/components/terrain/Dunes.d.ts.map +1 -0
- package/dist/components/terrain/Dunes.js +25 -0
- package/dist/components/terrain/Hills.d.ts +17 -0
- package/dist/components/terrain/Hills.d.ts.map +1 -0
- package/dist/components/terrain/Hills.js +20 -0
- package/dist/components/terrain/Mountains.d.ts +19 -0
- package/dist/components/terrain/Mountains.d.ts.map +1 -0
- package/dist/components/terrain/Mountains.js +22 -0
- package/dist/components/terrain/TerrainSurface.d.ts +22 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -0
- package/dist/components/terrain/TerrainSurface.js +94 -0
- package/dist/components/terrain/index.d.ts +7 -0
- package/dist/components/terrain/index.d.ts.map +1 -0
- package/dist/components/terrain/index.js +7 -0
- package/dist/components/terrain/types.d.ts +17 -0
- package/dist/components/terrain/types.d.ts.map +1 -0
- package/dist/components/terrain/types.js +1 -0
- package/dist/components/volumetricClouds/Cirrus.d.ts +14 -0
- package/dist/components/volumetricClouds/Cirrus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Cirrus.js +13 -0
- package/dist/components/volumetricClouds/Cumulonimbus.d.ts +17 -0
- package/dist/components/volumetricClouds/Cumulonimbus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Cumulonimbus.js +20 -0
- package/dist/components/volumetricClouds/Cumulus.d.ts +14 -0
- package/dist/components/volumetricClouds/Cumulus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Cumulus.js +17 -0
- package/dist/components/volumetricClouds/Stratocumulus.d.ts +12 -0
- package/dist/components/volumetricClouds/Stratocumulus.d.ts.map +1 -0
- package/dist/components/volumetricClouds/Stratocumulus.js +16 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +42 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.js +298 -0
- package/dist/components/volumetricClouds/index.d.ts +8 -0
- package/dist/components/volumetricClouds/index.d.ts.map +1 -0
- package/dist/components/volumetricClouds/index.js +7 -0
- package/dist/components/volumetricClouds/types.d.ts +17 -0
- package/dist/components/volumetricClouds/types.d.ts.map +1 -0
- package/dist/components/volumetricClouds/types.js +1 -0
- package/dist/components/water/Host.d.ts +12 -0
- package/dist/components/water/Host.d.ts.map +1 -0
- package/dist/components/water/Host.js +12 -0
- package/dist/components/water/Lake.d.ts +18 -0
- package/dist/components/water/Lake.d.ts.map +1 -0
- package/dist/components/water/Lake.js +21 -0
- package/dist/components/water/OceanSurface.d.ts +27 -0
- package/dist/components/water/OceanSurface.d.ts.map +1 -0
- package/dist/components/water/OceanSurface.js +60 -0
- package/dist/components/water/Sea.d.ts +18 -0
- package/dist/components/water/Sea.d.ts.map +1 -0
- package/dist/components/water/Sea.js +17 -0
- package/dist/components/water/Shore.d.ts +16 -0
- package/dist/components/water/Shore.d.ts.map +1 -0
- package/dist/components/water/Shore.js +15 -0
- package/dist/components/water/Storm.d.ts +14 -0
- package/dist/components/water/Storm.d.ts.map +1 -0
- package/dist/components/water/Storm.js +13 -0
- package/dist/components/water/WaterBody.d.ts +31 -0
- package/dist/components/water/WaterBody.d.ts.map +1 -0
- package/dist/components/water/WaterBody.js +76 -0
- package/dist/components/water/index.d.ts +9 -0
- package/dist/components/water/index.d.ts.map +1 -0
- package/dist/components/water/index.js +11 -0
- package/dist/components/water/types.d.ts +20 -0
- package/dist/components/water/types.d.ts.map +1 -0
- package/dist/components/water/types.js +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +15 -0
- package/dist/hooks/index.d.ts +24 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/useClipmap.d.ts +71 -0
- package/dist/hooks/useClipmap.d.ts.map +1 -0
- package/dist/hooks/useClipmap.js +81 -0
- package/dist/hooks/useCloudLive.d.ts +29 -0
- package/dist/hooks/useCloudLive.d.ts.map +1 -0
- package/dist/hooks/useCloudLive.js +43 -0
- package/dist/hooks/useCloudNoise.d.ts +28 -0
- package/dist/hooks/useCloudNoise.d.ts.map +1 -0
- package/dist/hooks/useCloudNoise.js +128 -0
- package/dist/hooks/useCloudSun.d.ts +49 -0
- package/dist/hooks/useCloudSun.d.ts.map +1 -0
- package/dist/hooks/useCloudSun.js +84 -0
- package/dist/hooks/useCubeCamera.d.ts +27 -9
- package/dist/hooks/useCubeCamera.d.ts.map +1 -1
- package/dist/hooks/useCubeCamera.js +28 -70
- package/dist/hooks/useEnvironmentProbe.d.ts +32 -0
- package/dist/hooks/useEnvironmentProbe.d.ts.map +1 -0
- package/dist/hooks/useEnvironmentProbe.js +35 -0
- package/dist/hooks/useFrameRenderer.d.ts +15 -0
- package/dist/hooks/useFrameRenderer.d.ts.map +1 -0
- package/dist/hooks/useFrameRenderer.js +23 -0
- package/dist/hooks/useLandscapeLive.d.ts +29 -0
- package/dist/hooks/useLandscapeLive.d.ts.map +1 -0
- package/dist/hooks/useLandscapeLive.js +41 -0
- package/dist/hooks/useLandscapeMaps.d.ts +32 -0
- package/dist/hooks/useLandscapeMaps.d.ts.map +1 -0
- package/dist/hooks/useLandscapeMaps.js +138 -0
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +2 -3
- package/dist/hooks/useMaterialOptions.d.ts +2 -2
- package/dist/hooks/useMaterialOptions.d.ts.map +1 -1
- package/dist/hooks/useMaterialOptions.js +13 -31
- package/dist/hooks/useObjectEdges.d.ts.map +1 -1
- package/dist/hooks/useObjectEdges.js +3 -49
- package/dist/hooks/useOceanLive.d.ts +29 -0
- package/dist/hooks/useOceanLive.d.ts.map +1 -0
- package/dist/hooks/useOceanLive.js +38 -0
- package/dist/hooks/useOceanMaterial.d.ts +39 -0
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -0
- package/dist/hooks/useOceanMaterial.js +65 -0
- package/dist/hooks/useTerrainClipmap.d.ts +12 -0
- package/dist/hooks/useTerrainClipmap.d.ts.map +1 -0
- package/dist/hooks/useTerrainClipmap.js +10 -0
- package/dist/hooks/useTerrainLive.d.ts +34 -0
- package/dist/hooks/useTerrainLive.d.ts.map +1 -0
- package/dist/hooks/useTerrainLive.js +45 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/presets/landscapePresets.d.ts +60 -0
- package/dist/presets/landscapePresets.d.ts.map +1 -0
- package/dist/presets/landscapePresets.js +194 -0
- package/dist/presets/landscapeTypes.d.ts +195 -0
- package/dist/presets/landscapeTypes.d.ts.map +1 -0
- package/dist/presets/landscapeTypes.js +315 -0
- package/dist/presets/oceanSurfacePresets.d.ts +33 -0
- package/dist/presets/oceanSurfacePresets.d.ts.map +1 -0
- package/dist/presets/oceanSurfacePresets.js +245 -0
- package/dist/presets/terrainPresets.d.ts +28 -0
- package/dist/presets/terrainPresets.d.ts.map +1 -0
- package/dist/presets/terrainPresets.js +293 -0
- package/dist/presets/volumetricCloudPresets.d.ts +38 -0
- package/dist/presets/volumetricCloudPresets.d.ts.map +1 -0
- package/dist/presets/volumetricCloudPresets.js +480 -0
- package/dist/shaders/clouds/CirrusMaterial.d.ts +84 -0
- package/dist/shaders/clouds/CirrusMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CirrusMaterial.js +167 -0
- package/dist/shaders/clouds/CloudCompositeMaterial.d.ts +20 -0
- package/dist/shaders/clouds/CloudCompositeMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CloudCompositeMaterial.js +82 -0
- package/dist/shaders/clouds/CloudResolveMaterial.d.ts +22 -0
- package/dist/shaders/clouds/CloudResolveMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CloudResolveMaterial.js +77 -0
- package/dist/shaders/clouds/CloudVolumeMaterial.d.ts +143 -0
- package/dist/shaders/clouds/CloudVolumeMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/CloudVolumeMaterial.js +249 -0
- package/dist/shaders/clouds/SkyBackgroundMaterial.d.ts +21 -0
- package/dist/shaders/clouds/SkyBackgroundMaterial.d.ts.map +1 -0
- package/dist/shaders/clouds/SkyBackgroundMaterial.js +42 -0
- package/dist/shaders/glsl/cloudCore.glsl.d.ts +24 -0
- package/dist/shaders/glsl/cloudCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/cloudCore.glsl.js +348 -0
- package/dist/shaders/glsl/landscapeCore.glsl.d.ts +49 -0
- package/dist/shaders/glsl/landscapeCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/landscapeCore.glsl.js +518 -0
- package/dist/shaders/glsl/noiseBake.glsl.d.ts +30 -0
- package/dist/shaders/glsl/noiseBake.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/noiseBake.glsl.js +164 -0
- package/dist/shaders/glsl/oceanCore.glsl.d.ts +52 -0
- package/dist/shaders/glsl/oceanCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/oceanCore.glsl.js +421 -0
- package/dist/shaders/glsl/terrainCore.glsl.d.ts +78 -0
- package/dist/shaders/glsl/terrainCore.glsl.d.ts.map +1 -0
- package/dist/shaders/glsl/terrainCore.glsl.js +625 -0
- package/dist/shaders/landscape/LandscapeMaterial.d.ts +73 -0
- package/dist/shaders/landscape/LandscapeMaterial.d.ts.map +1 -0
- package/dist/shaders/landscape/LandscapeMaterial.js +136 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +57 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +268 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts +80 -0
- package/dist/shaders/terrain/TerrainMaterial.d.ts.map +1 -0
- package/dist/shaders/terrain/TerrainMaterial.js +291 -0
- package/dist/types/cloudConfigs.d.ts +244 -0
- package/dist/types/cloudConfigs.d.ts.map +1 -0
- package/dist/types/cloudConfigs.js +282 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +4 -1
- package/dist/types/landscapeConfigs.d.ts +218 -0
- package/dist/types/landscapeConfigs.d.ts.map +1 -0
- package/dist/types/landscapeConfigs.js +256 -0
- package/dist/types/oceanConfigs.d.ts +290 -0
- package/dist/types/oceanConfigs.d.ts.map +1 -0
- package/dist/types/oceanConfigs.js +380 -0
- package/dist/types/terrainConfigs.d.ts +251 -0
- package/dist/types/terrainConfigs.d.ts.map +1 -0
- package/dist/types/terrainConfigs.js +292 -0
- package/dist/utils/cloudUniforms.d.ts +14 -0
- package/dist/utils/cloudUniforms.d.ts.map +1 -0
- package/dist/utils/cloudUniforms.js +122 -0
- package/dist/utils/frameRenderer.d.ts +33 -0
- package/dist/utils/frameRenderer.d.ts.map +1 -0
- package/dist/utils/frameRenderer.js +24 -0
- package/dist/utils/handleCloudsAnimations.d.ts +16 -0
- package/dist/utils/handleCloudsAnimations.d.ts.map +1 -0
- package/dist/utils/handleCloudsAnimations.js +64 -0
- package/dist/utils/landscapeGeometry.d.ts +61 -0
- package/dist/utils/landscapeGeometry.d.ts.map +1 -0
- package/dist/utils/landscapeGeometry.js +126 -0
- package/dist/utils/landscapeHeight.d.ts +44 -0
- package/dist/utils/landscapeHeight.d.ts.map +1 -0
- package/dist/utils/landscapeHeight.js +65 -0
- package/dist/utils/landscapeTextures.d.ts +94 -0
- package/dist/utils/landscapeTextures.d.ts.map +1 -0
- package/dist/utils/landscapeTextures.js +290 -0
- package/dist/utils/landscapeUniforms.d.ts +20 -0
- package/dist/utils/landscapeUniforms.d.ts.map +1 -0
- package/dist/utils/landscapeUniforms.js +61 -0
- package/dist/utils/oceanUniforms.d.ts +47 -0
- package/dist/utils/oceanUniforms.d.ts.map +1 -0
- package/dist/utils/oceanUniforms.js +216 -0
- package/dist/utils/pointsMaterialOwnership.d.ts +9 -0
- package/dist/utils/pointsMaterialOwnership.d.ts.map +1 -0
- package/dist/utils/pointsMaterialOwnership.js +14 -0
- package/dist/utils/rtin.d.ts +63 -0
- package/dist/utils/rtin.d.ts.map +1 -0
- package/dist/utils/rtin.js +202 -0
- package/dist/utils/terrainUniforms.d.ts +14 -0
- package/dist/utils/terrainUniforms.d.ts.map +1 -0
- package/dist/utils/terrainUniforms.js +196 -0
- package/package.json +2 -2
|
@@ -1,73 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useThree
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export const useCubeCamera = (options) => {
|
|
6
|
-
const { hdrSettings, skyVisible, sunSystemVisible, timeSettings, resolution = 512, position = new THREE.Vector3(0, 50, 0), onEnvironmentUpdate } = options;
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useThree } from '@react-three/fiber';
|
|
3
|
+
import { CubeCameraManager } from '@3driseai/3drise-core';
|
|
4
|
+
export const useCubeCamera = (options = {}) => {
|
|
7
5
|
const { scene, gl: renderer } = useThree();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const hdrActive = hdrSettings.visible && (hdrSettings.name || (hdrSettings.urls && hdrSettings.urls.length > 0)) ? true : false;
|
|
11
|
-
const initializeCubeCamera = useCallback(() => {
|
|
12
|
-
if (!renderer || !scene)
|
|
13
|
-
return null;
|
|
14
|
-
if (cubeCameraRef.current)
|
|
15
|
-
disposeCubeCamera(cubeCameraRef.current, scene);
|
|
16
|
-
cubeCameraRef.current = createCubeCamera(scene, resolution, position);
|
|
17
|
-
return cubeCameraRef.current;
|
|
18
|
-
}, [scene, renderer, resolution, position]);
|
|
19
|
-
const updateEnvironment = useCallback(() => {
|
|
20
|
-
if (!cubeCameraRef.current || !renderer || !scene)
|
|
21
|
-
return null;
|
|
22
|
-
if (isUpdatingRef.current)
|
|
23
|
-
return null;
|
|
24
|
-
try {
|
|
25
|
-
isUpdatingRef.current = true;
|
|
26
|
-
const texture = updateCubeCamera(cubeCameraRef.current, renderer, scene);
|
|
27
|
-
setSceneEnvironment(scene, texture);
|
|
28
|
-
onEnvironmentUpdate?.(texture);
|
|
29
|
-
return texture;
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
isUpdatingRef.current = false;
|
|
36
|
-
}
|
|
37
|
-
}, [scene, renderer, onEnvironmentUpdate]);
|
|
38
|
-
const dispose = useCallback(() => {
|
|
39
|
-
if (cubeCameraRef.current && scene) {
|
|
40
|
-
disposeCubeCamera(cubeCameraRef.current, scene);
|
|
41
|
-
cubeCameraRef.current = null;
|
|
42
|
-
}
|
|
43
|
-
}, [scene]);
|
|
44
|
-
// Create or dispose cube camera based on active sky / HDR state
|
|
6
|
+
const manager = CubeCameraManager.getInstance();
|
|
7
|
+
const { resolution = 512, position, onEnvironmentUpdate } = options;
|
|
45
8
|
useEffect(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
updateEnvironment();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
// Cleanup on unmount
|
|
71
|
-
useEffect(() => () => dispose(), [dispose]);
|
|
72
|
-
return { cubeCamera: cubeCameraRef.current, updateEnvironment, initializeCubeCamera, dispose };
|
|
9
|
+
manager.attach(scene, renderer);
|
|
10
|
+
return () => {
|
|
11
|
+
manager.detach();
|
|
12
|
+
};
|
|
13
|
+
}, [manager, scene, renderer]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
manager.setOnUpdate(onEnvironmentUpdate ?? null);
|
|
16
|
+
return () => {
|
|
17
|
+
manager.setOnUpdate(null);
|
|
18
|
+
};
|
|
19
|
+
}, [manager, onEnvironmentUpdate]);
|
|
20
|
+
return useMemo(() => ({
|
|
21
|
+
manager,
|
|
22
|
+
get cubeCamera() {
|
|
23
|
+
return manager.getCubeCamera();
|
|
24
|
+
},
|
|
25
|
+
initializeCubeCamera: () => manager.initCubeCamera(resolution, position),
|
|
26
|
+
updateEnvironment: () => manager.updateEnvironment(),
|
|
27
|
+
clear: () => manager.clear(),
|
|
28
|
+
dispose: () => manager.dispose(),
|
|
29
|
+
}), [manager, resolution, position]);
|
|
73
30
|
};
|
|
31
|
+
export default useCubeCamera;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When the scene's cube-camera probe should exist, and how often it refreshes.
|
|
3
|
+
*
|
|
4
|
+
* This is the *policy* half of the cube camera; useCubeCamera is the imperative
|
|
5
|
+
* half. It lives in a hook rather than inside EnvironmentManager because two
|
|
6
|
+
* hosts need it — the composed EnvironmentManager used by published scenes, and
|
|
7
|
+
* the editor's HDR connector, which subscribes to Redux and composes the leaf
|
|
8
|
+
* components itself. Duplicating a rule this fiddly is how the two paths drifted
|
|
9
|
+
* apart last time.
|
|
10
|
+
*
|
|
11
|
+
* The rule itself:
|
|
12
|
+
* - An HDR background provides its own IBL, so the probe is disposed.
|
|
13
|
+
* - Otherwise, if there is any sky, the probe exists and captures it.
|
|
14
|
+
* - Otherwise there is nothing to capture, so dispose and clear the environment.
|
|
15
|
+
*
|
|
16
|
+
* The refresh accumulates delta and resets. The obvious-looking
|
|
17
|
+
* `clock.getElapsedTime() * 1000 > interval` is true on *every* frame after the
|
|
18
|
+
* first 0.3 s, which re-renders all six cube faces per frame.
|
|
19
|
+
*/
|
|
20
|
+
export interface UseEnvironmentProbeOptions {
|
|
21
|
+
/** An HDR background or playlist is supplying the environment map. */
|
|
22
|
+
hdrActive: boolean;
|
|
23
|
+
/** Analytic sky or the sun rig is visible — something worth capturing. */
|
|
24
|
+
skyActive: boolean;
|
|
25
|
+
/** Time of day is animating, so the capture goes stale and needs refreshing. */
|
|
26
|
+
autoAnimate: boolean;
|
|
27
|
+
resolution?: number;
|
|
28
|
+
intervalMs?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function useEnvironmentProbe({ hdrActive, skyActive, autoAnimate, resolution, intervalMs, }: UseEnvironmentProbeOptions): void;
|
|
31
|
+
export default useEnvironmentProbe;
|
|
32
|
+
//# sourceMappingURL=useEnvironmentProbe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEnvironmentProbe.d.ts","sourceRoot":"","sources":["../../src/hooks/useEnvironmentProbe.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,0BAA0B;IACvC,sEAAsE;IACtE,SAAS,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;IACnB,gFAAgF;IAChF,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,mBAAmB,CAAC,EAChC,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAgB,EAChB,UAAgB,GACnB,EAAE,0BAA0B,GAAG,IAAI,CA6BnC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useFrame } from '@react-three/fiber';
|
|
3
|
+
import { useCubeCamera } from './useCubeCamera.js';
|
|
4
|
+
export function useEnvironmentProbe({ hdrActive, skyActive, autoAnimate, resolution = 512, intervalMs = 300, }) {
|
|
5
|
+
const { manager, initializeCubeCamera, updateEnvironment, dispose, clear } = useCubeCamera({
|
|
6
|
+
resolution,
|
|
7
|
+
});
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (hdrActive) {
|
|
10
|
+
dispose();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (skyActive) {
|
|
14
|
+
initializeCubeCamera();
|
|
15
|
+
updateEnvironment();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
dispose();
|
|
19
|
+
clear();
|
|
20
|
+
}
|
|
21
|
+
}, [hdrActive, skyActive, initializeCubeCamera, updateEnvironment, dispose, clear]);
|
|
22
|
+
const elapsedMsRef = useRef(0);
|
|
23
|
+
useFrame((_, delta) => {
|
|
24
|
+
if (hdrActive || !skyActive || !autoAnimate)
|
|
25
|
+
return;
|
|
26
|
+
if (!manager.hasCubeCamera())
|
|
27
|
+
return;
|
|
28
|
+
elapsedMsRef.current += delta * 1000;
|
|
29
|
+
if (elapsedMsRef.current >= intervalMs) {
|
|
30
|
+
elapsedMsRef.current = 0;
|
|
31
|
+
updateEnvironment();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export default useEnvironmentProbe;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FrameRenderer } from '../utils/frameRenderer';
|
|
2
|
+
/**
|
|
3
|
+
* Declare that this component produces the finished frame.
|
|
4
|
+
*
|
|
5
|
+
* For a full-screen pass that runs at `useFrame(…, 1)` and composites to the canvas
|
|
6
|
+
* itself. Everything that needs a complete image — screenshots, thumbnails — asks
|
|
7
|
+
* through `renderFrame()` rather than calling `gl.render(scene, camera)`, which would
|
|
8
|
+
* draw the scene graph and silently drop whatever the pass adds.
|
|
9
|
+
*
|
|
10
|
+
* Pass a stable callback (a ref-held function or useCallback); it is registered on
|
|
11
|
+
* mount and released on unmount, so plain rendering resumes when the pass goes away.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useFrameRenderer(render: FrameRenderer | null | undefined): void;
|
|
14
|
+
export default useFrameRenderer;
|
|
15
|
+
//# sourceMappingURL=useFrameRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFrameRenderer.d.ts","sourceRoot":"","sources":["../../src/hooks/useFrameRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEnF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAM/E;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useThree } from '@react-three/fiber';
|
|
3
|
+
import { registerFrameRenderer } from '../utils/frameRenderer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Declare that this component produces the finished frame.
|
|
6
|
+
*
|
|
7
|
+
* For a full-screen pass that runs at `useFrame(…, 1)` and composites to the canvas
|
|
8
|
+
* itself. Everything that needs a complete image — screenshots, thumbnails — asks
|
|
9
|
+
* through `renderFrame()` rather than calling `gl.render(scene, camera)`, which would
|
|
10
|
+
* draw the scene graph and silently drop whatever the pass adds.
|
|
11
|
+
*
|
|
12
|
+
* Pass a stable callback (a ref-held function or useCallback); it is registered on
|
|
13
|
+
* mount and released on unmount, so plain rendering resumes when the pass goes away.
|
|
14
|
+
*/
|
|
15
|
+
export function useFrameRenderer(render) {
|
|
16
|
+
const gl = useThree((s) => s.gl);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!render)
|
|
19
|
+
return;
|
|
20
|
+
return registerFrameRenderer(gl, render);
|
|
21
|
+
}, [gl, render]);
|
|
22
|
+
}
|
|
23
|
+
export default useFrameRenderer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Object3D } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Live landscape editing, the counterpart to `useTerrainLive` and `useOceanLive`.
|
|
4
|
+
*
|
|
5
|
+
* The rule is the same — a slider drag writes straight into the renderer and
|
|
6
|
+
* Redux only hears about it on slider end — but the stakes are higher here.
|
|
7
|
+
* `meshError` re-runs RTIN, `chunks` rebuilds every index buffer,
|
|
8
|
+
* `arrayResolution` repacks the texture arrays and `surfaceSamples` recompiles
|
|
9
|
+
* the shader. Those are commit-on-release; everything else is a uniform and goes
|
|
10
|
+
* through this, and the renderer's handle enforces the split from
|
|
11
|
+
* `LANDSCAPE_LIVE_*_KEYS` so a controller cannot half-apply a rebuild key by
|
|
12
|
+
* passing it here.
|
|
13
|
+
*
|
|
14
|
+
* Pass the ID, not a resolved Object3D: the panel is routinely open before the
|
|
15
|
+
* landscape exists, and a findById() memoised in the controller resolves to null
|
|
16
|
+
* exactly once and stays null for the session.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LANDSCAPE_LIVE_KEY = "__landscapeLive";
|
|
19
|
+
export interface LandscapeLiveHandle {
|
|
20
|
+
config(key: string, value: number | boolean | string): void;
|
|
21
|
+
quality(key: string, value: number | boolean | string): void;
|
|
22
|
+
/** One field of one surface, by index. The surface list drives this. */
|
|
23
|
+
surface(index: number, key: string, value: number | boolean | string): void;
|
|
24
|
+
/** One field of the generated-splat block. Every one of them is a uniform. */
|
|
25
|
+
autoSplat(key: string, value: number | boolean | string): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function useLandscapeLive(target?: Object3D | string | null): LandscapeLiveHandle;
|
|
28
|
+
export default useLandscapeLive;
|
|
29
|
+
//# sourceMappingURL=useLandscapeLive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLandscapeLive.d.ts","sourceRoot":"","sources":["../../src/hooks/useLandscapeLive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGrC;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,kBAAkB,oBAAoB,CAAA;AAEnD,MAAM,WAAW,mBAAmB;IAChC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3D,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;IAC5D,wEAAwE;IACxE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3E,8EAA8E;IAC9E,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;CACjE;AASD,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,mBAAmB,CAcvF;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { findById } from '../utils/sceneQuery.js';
|
|
3
|
+
/**
|
|
4
|
+
* Live landscape editing, the counterpart to `useTerrainLive` and `useOceanLive`.
|
|
5
|
+
*
|
|
6
|
+
* The rule is the same — a slider drag writes straight into the renderer and
|
|
7
|
+
* Redux only hears about it on slider end — but the stakes are higher here.
|
|
8
|
+
* `meshError` re-runs RTIN, `chunks` rebuilds every index buffer,
|
|
9
|
+
* `arrayResolution` repacks the texture arrays and `surfaceSamples` recompiles
|
|
10
|
+
* the shader. Those are commit-on-release; everything else is a uniform and goes
|
|
11
|
+
* through this, and the renderer's handle enforces the split from
|
|
12
|
+
* `LANDSCAPE_LIVE_*_KEYS` so a controller cannot half-apply a rebuild key by
|
|
13
|
+
* passing it here.
|
|
14
|
+
*
|
|
15
|
+
* Pass the ID, not a resolved Object3D: the panel is routinely open before the
|
|
16
|
+
* landscape exists, and a findById() memoised in the controller resolves to null
|
|
17
|
+
* exactly once and stays null for the session.
|
|
18
|
+
*/
|
|
19
|
+
export const LANDSCAPE_LIVE_KEY = '__landscapeLive';
|
|
20
|
+
const NOOP = {
|
|
21
|
+
config: () => { },
|
|
22
|
+
quality: () => { },
|
|
23
|
+
surface: () => { },
|
|
24
|
+
autoSplat: () => { },
|
|
25
|
+
};
|
|
26
|
+
export function useLandscapeLive(target) {
|
|
27
|
+
return useMemo(() => {
|
|
28
|
+
const resolve = () => {
|
|
29
|
+
const object = typeof target === 'string' ? findById(target) : target;
|
|
30
|
+
const handle = object?.userData?.[LANDSCAPE_LIVE_KEY];
|
|
31
|
+
return handle ?? NOOP;
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
config: (key, value) => resolve().config(key, value),
|
|
35
|
+
quality: (key, value) => resolve().quality(key, value),
|
|
36
|
+
surface: (index, key, value) => resolve().surface(index, key, value),
|
|
37
|
+
autoSplat: (key, value) => resolve().autoSplat(key, value),
|
|
38
|
+
};
|
|
39
|
+
}, [target]);
|
|
40
|
+
}
|
|
41
|
+
export default useLandscapeLive;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type DecodedHeightmap } from '../utils/landscapeTextures';
|
|
2
|
+
import type { LandscapeConfig, LandscapeQualityConfig } from '../types/landscapeConfigs';
|
|
3
|
+
import type { LandscapeMapUniforms } from '../utils/landscapeUniforms';
|
|
4
|
+
/**
|
|
5
|
+
* Every image a landscape needs, loaded and packed.
|
|
6
|
+
*
|
|
7
|
+
* The surfaces go into two `DataArrayTexture`s rather than sixteen samplers:
|
|
8
|
+
* one binding, one integer layer index, no branch tree. Every layer must be the
|
|
9
|
+
* same size and user uploads never are, so each image is redrawn at
|
|
10
|
+
* `arrayResolution` on the way in.
|
|
11
|
+
*
|
|
12
|
+
* **The height maps ride in the normal array's alpha channel.** A tangent-space
|
|
13
|
+
* normal map only needs RGB, so the surface's own height — the thing that makes
|
|
14
|
+
* a transition read as material rather than as a cross-fade — costs nothing but
|
|
15
|
+
* the channel that was already there. A third array would have been another
|
|
16
|
+
* 100 MB at 1024.
|
|
17
|
+
*
|
|
18
|
+
* Loading is one effect with a cancellation flag, and the previous set is
|
|
19
|
+
* disposed only after the new one is ready, so a change of preset does not blink
|
|
20
|
+
* the ground away.
|
|
21
|
+
*/
|
|
22
|
+
export interface LandscapeMapsState extends LandscapeMapUniforms {
|
|
23
|
+
/** The decoded heightmap, for RTIN and for CPU height queries. */
|
|
24
|
+
heightField: DecodedHeightmap | null;
|
|
25
|
+
ready: boolean;
|
|
26
|
+
error: string | null;
|
|
27
|
+
/** Surfaces that actually contributed a layer, in order. */
|
|
28
|
+
layerCount: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function useLandscapeMaps(config: LandscapeConfig, quality: LandscapeQualityConfig): LandscapeMapsState;
|
|
31
|
+
export default useLandscapeMaps;
|
|
32
|
+
//# sourceMappingURL=useLandscapeMaps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLandscapeMaps.d.ts","sourceRoot":"","sources":["../../src/hooks/useLandscapeMaps.ts"],"names":[],"mappings":"AAEA,OAAO,EAOH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AACxF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC5D,kEAAkE;IAClE,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAA;IACpC,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAA;CACrB;AA4CD,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,sBAAsB,GAChC,kBAAkB,CAmHpB;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { buildFieldTexture, buildTextureArray, decodeHeightmap, loadImage, smoothHeightfield, textureFromImage, } from '../utils/landscapeTextures.js';
|
|
4
|
+
const EMPTY = {
|
|
5
|
+
height: null,
|
|
6
|
+
heightSize: new THREE.Vector2(1, 1),
|
|
7
|
+
field: null,
|
|
8
|
+
fieldSize: new THREE.Vector2(1, 1),
|
|
9
|
+
gradScale: 1,
|
|
10
|
+
diffuse: null,
|
|
11
|
+
normal: null,
|
|
12
|
+
splat0: null,
|
|
13
|
+
splat1: null,
|
|
14
|
+
ao: null,
|
|
15
|
+
means: [],
|
|
16
|
+
heightField: null,
|
|
17
|
+
ready: false,
|
|
18
|
+
error: null,
|
|
19
|
+
layerCount: 0,
|
|
20
|
+
};
|
|
21
|
+
function disposeState(state) {
|
|
22
|
+
state.height?.dispose();
|
|
23
|
+
state.field?.dispose();
|
|
24
|
+
state.diffuse?.dispose();
|
|
25
|
+
state.normal?.dispose();
|
|
26
|
+
state.splat0?.dispose();
|
|
27
|
+
state.splat1?.dispose();
|
|
28
|
+
state.ao?.dispose();
|
|
29
|
+
}
|
|
30
|
+
/** Only the URLs and the packing size matter; nothing here should re-run because
|
|
31
|
+
* a slider moved. */
|
|
32
|
+
function mapsKey(config, quality) {
|
|
33
|
+
return JSON.stringify([
|
|
34
|
+
config.heightMap,
|
|
35
|
+
config.heightEncoding,
|
|
36
|
+
config.splatMaps,
|
|
37
|
+
config.aoMap ?? '',
|
|
38
|
+
quality.arrayResolution,
|
|
39
|
+
quality.anisotropy,
|
|
40
|
+
config.surfaces.map((s) => [s.diffuse, s.normal ?? '', s.displacement ?? '']),
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
export function useLandscapeMaps(config, quality) {
|
|
44
|
+
const key = useMemo(() => mapsKey(config, quality), [config, quality]);
|
|
45
|
+
const [state, setState] = useState(EMPTY);
|
|
46
|
+
const current = useRef(EMPTY);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
let cancelled = false;
|
|
49
|
+
const surfaces = config.surfaces.filter((s) => !!s.diffuse);
|
|
50
|
+
if (!config.heightMap || surfaces.length === 0) {
|
|
51
|
+
setState({ ...EMPTY, error: null });
|
|
52
|
+
return () => { cancelled = true; };
|
|
53
|
+
}
|
|
54
|
+
const run = async () => {
|
|
55
|
+
const size = quality.arrayResolution;
|
|
56
|
+
const [heightImage, splatImages, aoImage, diffuseImages, normalImages, heightImages] = await Promise.all([
|
|
57
|
+
loadImage(config.heightMap),
|
|
58
|
+
Promise.all(config.splatMaps.slice(0, 2).map((url) => loadImage(url))),
|
|
59
|
+
config.aoMap ? loadImage(config.aoMap) : Promise.resolve(null),
|
|
60
|
+
Promise.all(surfaces.map((s) => loadImage(s.diffuse))),
|
|
61
|
+
Promise.all(surfaces.map((s) => (s.normal ? loadImage(s.normal) : Promise.resolve(null)))),
|
|
62
|
+
Promise.all(surfaces.map((s) => (s.displacement ? loadImage(s.displacement) : Promise.resolve(null)))),
|
|
63
|
+
]);
|
|
64
|
+
if (cancelled)
|
|
65
|
+
return;
|
|
66
|
+
// Smoothed before anything else uses it. An 8-bit heightmap's own
|
|
67
|
+
// quantisation is a 1.33 m staircase over 340 m of relief, which is
|
|
68
|
+
// what RTIN's error metric measures instead of the terrain, and what
|
|
69
|
+
// the surface gradient would otherwise be computed from.
|
|
70
|
+
const raw = decodeHeightmap(heightImage, config.heightEncoding);
|
|
71
|
+
const heightField = smoothHeightfield(raw, 1);
|
|
72
|
+
const field = buildFieldTexture(heightField);
|
|
73
|
+
const height = textureFromImage(heightImage, THREE.NoColorSpace);
|
|
74
|
+
// No mips and no filtering surprises: the vertex stage samples this
|
|
75
|
+
// at lod 0 and the bicubic filter does its own footprint widening.
|
|
76
|
+
height.minFilter = THREE.LinearFilter;
|
|
77
|
+
height.magFilter = THREE.LinearFilter;
|
|
78
|
+
height.generateMipmaps = false;
|
|
79
|
+
const diffuse = buildTextureArray(diffuseImages, size, THREE.SRGBColorSpace);
|
|
80
|
+
const normal = buildTextureArray(normalImages, size, THREE.NoColorSpace, heightImages,
|
|
81
|
+
// A flat normal for a surface with no normal map.
|
|
82
|
+
[128, 128, 255, 128]);
|
|
83
|
+
diffuse.texture.anisotropy = quality.anisotropy;
|
|
84
|
+
normal.texture.anisotropy = quality.anisotropy;
|
|
85
|
+
const splats = splatImages.map((image) => {
|
|
86
|
+
const texture = textureFromImage(image, THREE.NoColorSpace);
|
|
87
|
+
texture.generateMipmaps = false;
|
|
88
|
+
texture.minFilter = THREE.LinearFilter;
|
|
89
|
+
return texture;
|
|
90
|
+
});
|
|
91
|
+
const ao = aoImage ? textureFromImage(aoImage, THREE.NoColorSpace) : null;
|
|
92
|
+
if (cancelled) {
|
|
93
|
+
height.dispose();
|
|
94
|
+
field.texture.dispose();
|
|
95
|
+
diffuse.texture.dispose();
|
|
96
|
+
normal.texture.dispose();
|
|
97
|
+
splats.forEach((t) => t.dispose());
|
|
98
|
+
ao?.dispose();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const next = {
|
|
102
|
+
height,
|
|
103
|
+
heightSize: new THREE.Vector2(heightField.tileSize, heightField.tileSize),
|
|
104
|
+
field: field.texture,
|
|
105
|
+
fieldSize: new THREE.Vector2(heightField.tileSize, heightField.tileSize),
|
|
106
|
+
gradScale: field.gradScale,
|
|
107
|
+
diffuse: diffuse.texture,
|
|
108
|
+
normal: normal.texture,
|
|
109
|
+
splat0: splats[0] ?? null,
|
|
110
|
+
splat1: splats[1] ?? null,
|
|
111
|
+
ao,
|
|
112
|
+
means: diffuse.means,
|
|
113
|
+
heightField,
|
|
114
|
+
ready: true,
|
|
115
|
+
error: null,
|
|
116
|
+
layerCount: surfaces.length,
|
|
117
|
+
};
|
|
118
|
+
const previous = current.current;
|
|
119
|
+
current.current = next;
|
|
120
|
+
setState(next);
|
|
121
|
+
// Only now — swapping first would blink the ground away mid-edit.
|
|
122
|
+
disposeState(previous);
|
|
123
|
+
};
|
|
124
|
+
run().catch((error) => {
|
|
125
|
+
if (cancelled)
|
|
126
|
+
return;
|
|
127
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
128
|
+
// eslint-disable-next-line no-console
|
|
129
|
+
console.error('[landscape] map load failed:', message);
|
|
130
|
+
setState({ ...EMPTY, error: message });
|
|
131
|
+
});
|
|
132
|
+
return () => { cancelled = true; };
|
|
133
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
|
+
}, [key]);
|
|
135
|
+
useEffect(() => () => { disposeState(current.current); }, []);
|
|
136
|
+
return state;
|
|
137
|
+
}
|
|
138
|
+
export default useLandscapeMaps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaterialApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialApplication.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useMaterialApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialApplication.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,eAAO,MAAM,sBAAsB,GAAI,QAAQ,cAAc,EAAE,kBAAkB,gBAAgB,EAAE,4BAA4B,OAAO,EAAE,YAAY,MAAM,IAAI,KAAG,IAuIhK,CAAC"}
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
import { useEffect, useRef } from 'react';
|
|
9
9
|
import { createAndApplyMaterial, MATERIAL_INSTANCE_KEY, MaterialRegistryAPI, ObjectManager, resolveTextures, traverseSkippingEdgesAndEffects } from '@3driseai/3drise-core';
|
|
10
10
|
import { resolveObject3D } from "../utils/resolveObject3D.js";
|
|
11
|
-
// TEST: 0=raw defaults, 1=+DoubleSide, 2=+transparent, 3=+metalness/roughness
|
|
12
|
-
const TEST_MATERIAL_MODE = 1;
|
|
13
11
|
export const useMaterialApplication = (source, materialSettings, shouldApply3driseMaterial, onApplied) => {
|
|
14
12
|
// Track all material instances we've created so we can release them on change/unmount
|
|
15
13
|
// const { getTypeByName } = useObjectTypes();
|
|
@@ -29,7 +27,8 @@ export const useMaterialApplication = (source, materialSettings, shouldApply3dri
|
|
|
29
27
|
// attached refs, so this is the first point the object reliably exists.
|
|
30
28
|
const obj = resolveObject3D(source);
|
|
31
29
|
if (!obj || !materialSettings || materialSettings.materialType === 'advanced' ||
|
|
32
|
-
materialSettings.materialVariant === '3dRiseShader'
|
|
30
|
+
materialSettings.materialVariant === '3dRiseShader'
|
|
31
|
+
|| (shouldApply3driseMaterial === false))
|
|
33
32
|
return;
|
|
34
33
|
handleSettingsChange(obj, materialSettings);
|
|
35
34
|
return () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MaterialRegistryAPI } from '@3driseai/3drise-core';
|
|
2
|
-
import type { CreatedObjectType,
|
|
2
|
+
import type { CreatedObjectType, MaterialSettings, ModeGroup, SelectOptions } from '@3driseai/3drise-core';
|
|
3
3
|
type RegistryMaterialType = Exclude<Parameters<typeof MaterialRegistryAPI.getVariants>[0], undefined>;
|
|
4
4
|
export interface UseMaterialOptionsReturn {
|
|
5
5
|
selectedType: RegistryMaterialType;
|
|
@@ -9,6 +9,6 @@ export interface UseMaterialOptionsReturn {
|
|
|
9
9
|
handleTypeChange: (type: RegistryMaterialType) => void;
|
|
10
10
|
handleVariantChange: (variant: string) => void;
|
|
11
11
|
}
|
|
12
|
-
export declare const useMaterialOptions: (initialSettings: MaterialSettings, onSettingsChange?: (newSettings: MaterialSettings) => void, objectType?: CreatedObjectType,
|
|
12
|
+
export declare const useMaterialOptions: (initialSettings: MaterialSettings, onSettingsChange?: (newSettings: MaterialSettings) => void, objectType?: CreatedObjectType, surface?: ModeGroup) => UseMaterialOptionsReturn;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=useMaterialOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMaterialOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useMaterialOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAA2B,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3G,KAAK,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAEtG,MAAM,WAAW,wBAAwB;IACrC,YAAY,EAAE,oBAAoB,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,aAAa,CAAC;IACnC,cAAc,EAAE,aAAa,CAAC;IAC9B,gBAAgB,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACvD,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,kBAAkB,GAAI,iBAAiB,gBAAgB,EAAE,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI,EAAE,aAAY,iBAA0B,EAAE,UAAS,SAAkB,KAAG,wBA0FvM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
-
import { MaterialRegistryAPI } from '@3driseai/3drise-core';
|
|
2
|
+
import { MaterialRegistryAPI, materialTypeFitsSurface } from '@3driseai/3drise-core';
|
|
3
3
|
import { FrontSide } from 'three';
|
|
4
|
-
export const useMaterialOptions = (initialSettings, onSettingsChange, objectType = 'mesh',
|
|
4
|
+
export const useMaterialOptions = (initialSettings, onSettingsChange, objectType = 'mesh', surface = 'mesh') => {
|
|
5
5
|
// Ensure we always have a valid material type
|
|
6
6
|
const validType = (initialSettings.materialType || 'basic');
|
|
7
7
|
const [selectedType, setSelectedType] = useState(validType);
|
|
@@ -18,35 +18,17 @@ export const useMaterialOptions = (initialSettings, onSettingsChange, objectType
|
|
|
18
18
|
setSelectedVariant(initialSettings.materialVariant || variants[0] || '');
|
|
19
19
|
}, [initialSettings.materialType, initialSettings.materialVariant]);
|
|
20
20
|
const allmaterialTypes = MaterialRegistryAPI.getTypes();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const materialTypeOptions = () =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
if (is3dRiseShaderMaterial) {
|
|
34
|
-
return dRiseShaderMaterialTypes.map((type) => ({
|
|
35
|
-
value: type,
|
|
36
|
-
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
if (isLineMaterial) {
|
|
40
|
-
return lineMaterialTypes.map((type) => ({
|
|
41
|
-
value: type,
|
|
42
|
-
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
return meshMaterialTypes.map((type) => ({
|
|
46
|
-
value: type,
|
|
47
|
-
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
48
|
-
}));
|
|
49
|
-
};
|
|
21
|
+
// Offer only the families that can actually draw on this object's surface.
|
|
22
|
+
// A <points> takes the `particles` family and nothing else; every other
|
|
23
|
+
// surface takes everything except it. Note this keys off the surface, never
|
|
24
|
+
// off the currently selected material — the previous version did the latter,
|
|
25
|
+
// which meant an object could never get back to a family once it left it.
|
|
26
|
+
const materialTypeOptions = () => allmaterialTypes
|
|
27
|
+
.filter((type) => materialTypeFitsSurface(type, surface))
|
|
28
|
+
.map((type) => ({
|
|
29
|
+
value: type,
|
|
30
|
+
label: type.charAt(0).toUpperCase() + type.slice(1)
|
|
31
|
+
}));
|
|
50
32
|
// is3dRiseShaderMaterial ?
|
|
51
33
|
// dRiseShaderMaterialTypes.map((type: string) => ({
|
|
52
34
|
// value: type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObjectEdges.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectEdges.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useObjectEdges.d.ts","sourceRoot":"","sources":["../../src/hooks/useObjectEdges.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAmH/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,CA6ChH"}
|