@3driseai/3drise-viewer 0.1.8 → 0.1.10
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.
|
@@ -4,32 +4,46 @@ import { type SkySystemRef, type SkySystemProps } from './SkySystem';
|
|
|
4
4
|
import type { EnvironmentConfig, FogSettings, HdrSettings, SkySettings, TimeSettings } from '@3driseai/3drise-core';
|
|
5
5
|
import type { VolumetricCloudsSettings } from '../types/cloudConfigs';
|
|
6
6
|
import type { ProceduralTerrainSettings } from '../types/terrainConfigs';
|
|
7
|
+
import type { LandscapeSettings } from '../types/landscapeConfigs';
|
|
8
|
+
import type { OceanWaterSettings } from '../types/oceanConfigs';
|
|
7
9
|
import type { ObjectReadyProps } from '../types/objectReady';
|
|
8
10
|
/**
|
|
9
11
|
* The whole environment in one component: HDR background, image-based lighting,
|
|
10
|
-
* sky, sun, fog, clouds and
|
|
12
|
+
* sky, sun, fog, clouds, terrain, landscape and water.
|
|
11
13
|
*
|
|
12
14
|
* This is the *composed* entry point, for SceneBuilder and for anyone embedding a
|
|
13
15
|
* published scene, where the settings arrive as one saved blob and nothing
|
|
14
16
|
* re-renders unless the project changes.
|
|
15
17
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* **Everything comes off `environment`.** That prop is the environment record as
|
|
19
|
+
* it is stored — one object with a key per feature — and it is the same object
|
|
20
|
+
* the editor's `useLoadProject` fans out into Redux, key by key, before its
|
|
21
|
+
* connectors subscribe to the slices. Same blob, same components, two
|
|
22
|
+
* subscription granularities; that is the only thing that should ever differ
|
|
23
|
+
* between the editor and an embed.
|
|
24
|
+
*
|
|
25
|
+
* A host with fine-grained reactive state should compose the pieces itself, one
|
|
26
|
+
* store subscription per feature. Every piece here is exported for exactly that:
|
|
19
27
|
* HdrEnvironment, useEnvironmentProbe, SkySystem, SceneFog, CloudsGenerator,
|
|
20
|
-
* TerrainBuilder
|
|
21
|
-
* granularity differs, and that is the only thing that should ever differ.
|
|
28
|
+
* TerrainBuilder, LandscapeBuilder, OceanBuilder.
|
|
22
29
|
*/
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
30
|
+
/** The stored environment record.
|
|
31
|
+
*
|
|
32
|
+
* core's `EnvironmentConfig` still types `clouds` and `ocean` as the retired
|
|
33
|
+
* flat shapes and has no `terrain` or `landscape` at all. All four are declared
|
|
34
|
+
* here rather than in core for the same reason: a feature's config type lives
|
|
35
|
+
* next to the shader that consumes it, and core cannot reference the viewer.
|
|
36
|
+
*
|
|
37
|
+
* A project saved before any of these existed still carries the old shape at
|
|
38
|
+
* runtime. Each builder normalises its own blob on read and decides what an
|
|
39
|
+
* absent or legacy block means — see `normalizeTerrain` (drops it: a scene
|
|
40
|
+
* authored without ground should not gain a landscape) versus `normalizeOcean`
|
|
41
|
+
* (maps it: a scene authored with the old flat plane really did have water). */
|
|
42
|
+
export type ViewerEnvironmentConfig = Omit<EnvironmentConfig, 'clouds' | 'ocean'> & {
|
|
27
43
|
clouds?: VolumetricCloudsSettings;
|
|
28
|
-
/** core's EnvironmentConfig has no terrain field at all, and its
|
|
29
|
-
* `TerrainSettings` is the retired flat shape. Declared here for the same
|
|
30
|
-
* reason `clouds` is narrowed here: the config type lives next to the shader
|
|
31
|
-
* that consumes it, and core cannot reference the viewer. */
|
|
32
44
|
terrain?: ProceduralTerrainSettings;
|
|
45
|
+
landscape?: LandscapeSettings;
|
|
46
|
+
ocean?: OceanWaterSettings;
|
|
33
47
|
};
|
|
34
48
|
export interface EnvironmentManagerProps extends ObjectReadyProps {
|
|
35
49
|
timeSettings: TimeSettings;
|
|
@@ -39,6 +53,8 @@ export interface EnvironmentManagerProps extends ObjectReadyProps {
|
|
|
39
53
|
skySettings?: SkySettings;
|
|
40
54
|
cloudsSettings?: VolumetricCloudsSettings;
|
|
41
55
|
terrainSettings?: ProceduralTerrainSettings;
|
|
56
|
+
landscapeSettings?: LandscapeSettings;
|
|
57
|
+
oceanSettings?: OceanWaterSettings;
|
|
42
58
|
fogSettings?: FogSettings;
|
|
43
59
|
cubeCameraResolution?: number;
|
|
44
60
|
skyboxScale?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentManager.d.ts","sourceRoot":"","sources":["../../src/components/EnvironmentManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGhF,OAAO,KAAK,EACR,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"EnvironmentManager.d.ts","sourceRoot":"","sources":["../../src/components/EnvironmentManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGhF,OAAO,KAAK,EACR,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;iFAWiF;AACjF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG;IAChF,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAEF,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC7D,YAAY,EAAE,YAAY,CAAC;IAC3B,iFAAiF;IACjF,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;IACxD,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACjD;AAoBD,QAAA,MAAM,kBAAkB,8FAiGtB,CAAC;AAGH,eAAe,kBAAkB,CAAC"}
|
|
@@ -5,6 +5,8 @@ import SkySystem from './SkySystem.js';
|
|
|
5
5
|
import HdrEnvironment, { isHdrActive } from './HdrEnvironment.js';
|
|
6
6
|
import { useEnvironmentProbe } from '../hooks/useEnvironmentProbe.js';
|
|
7
7
|
import TerrainBuilder from './TerrainBuilder.js';
|
|
8
|
+
import LandscapeBuilder from './LandscapeBuilder.js';
|
|
9
|
+
import OceanBuilder from './OceanBuilder.js';
|
|
8
10
|
const DEFAULT_HDR = {
|
|
9
11
|
visible: false,
|
|
10
12
|
name: null,
|
|
@@ -21,23 +23,26 @@ const DEFAULT_HDR = {
|
|
|
21
23
|
},
|
|
22
24
|
};
|
|
23
25
|
const ORIGIN = new Vector3(0, 0, 0);
|
|
24
|
-
const EnvironmentManager = forwardRef(({ timeSettings, environment, hdrSettings, skySettings, cloudsSettings, terrainSettings, fogSettings, cubeCameraResolution = 512, skyboxScale = 100000, playerPosition = ORIGIN, onTimeOfDayChange, onTimeUpdate, onObjectReady, onObjectDispose, }, ref) => {
|
|
26
|
+
const EnvironmentManager = forwardRef(({ timeSettings, environment, hdrSettings, skySettings, cloudsSettings, terrainSettings, landscapeSettings, oceanSettings, fogSettings, cubeCameraResolution = 512, skyboxScale = 100000, playerPosition = ORIGIN, onTimeOfDayChange, onTimeUpdate, onObjectReady, onObjectDispose, }, ref) => {
|
|
25
27
|
const hdr = hdrSettings ?? environment?.hdr ?? DEFAULT_HDR;
|
|
26
28
|
const sky = skySettings ?? environment?.sky;
|
|
27
29
|
const clouds = cloudsSettings ?? environment?.clouds;
|
|
28
30
|
const terrain = terrainSettings ?? environment?.terrain;
|
|
31
|
+
const landscape = landscapeSettings ?? environment?.landscape;
|
|
32
|
+
const ocean = oceanSettings ?? environment?.ocean;
|
|
29
33
|
const fog = fogSettings ?? environment?.fog;
|
|
30
34
|
const sunSystemVisible = !!sky?.sunSystem?.visible;
|
|
31
35
|
// Previously hardcoded true, which kept a cube camera alive — and re-captured
|
|
32
36
|
// its six faces — for scenes that have no sky at all.
|
|
33
37
|
const skyActive = !!sky?.visible || sunSystemVisible;
|
|
38
|
+
const sunIntensity = sky?.sunSystem?.intensity ?? 1;
|
|
34
39
|
useEnvironmentProbe({
|
|
35
40
|
hdrActive: isHdrActive(hdr),
|
|
36
41
|
skyActive,
|
|
37
42
|
autoAnimate: !!timeSettings.autoAnimate,
|
|
38
43
|
resolution: cubeCameraResolution,
|
|
39
44
|
});
|
|
40
|
-
return (_jsxs(_Fragment, { children: [_jsx(HdrEnvironment, { hdr: hdr, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose }), _jsx(TerrainBuilder, { settings: terrain, skySettings: sky, timeSettings: timeSettings, sunIntensity: sky
|
|
45
|
+
return (_jsxs(_Fragment, { children: [_jsx(HdrEnvironment, { hdr: hdr, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose }), _jsx(TerrainBuilder, { settings: terrain, skySettings: sky, timeSettings: timeSettings, sunIntensity: sunIntensity, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose }), _jsx(LandscapeBuilder, { settings: landscape, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose }), _jsx(OceanBuilder, { settings: ocean, skySettings: sky, timeSettings: timeSettings, sunIntensity: sunIntensity, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose }), _jsx(SkySystem, { ref: ref, timeSettings: timeSettings, visible: true, sunSystemVisible: sunSystemVisible, sunSize: sky?.sunSystem?.sunSize, moonSize: sky?.sunSystem?.moonSize, skyboxScale: skyboxScale, sunIntensity: sunIntensity, castShadow: sky?.sunSystem?.castShadow, shadowMapSize: sky?.sunSystem?.shadowMapSize, playerPosition: playerPosition, cloudsSettings: clouds, skyControllerSettings: sky, fogSettings: fog, onTimeOfDayChange: onTimeOfDayChange, onTimeUpdate: onTimeUpdate, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose })] }));
|
|
41
46
|
});
|
|
42
47
|
EnvironmentManager.displayName = 'EnvironmentManager';
|
|
43
48
|
export default EnvironmentManager;
|