@3driseai/3drise-viewer 0.1.29 → 0.1.31
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/animationsV2/ClipPlayer.d.ts.map +1 -1
- package/dist/animationsV2/ClipPlayer.js +14 -12
- package/dist/animationsV2/ClipsRuntime.d.ts +13 -0
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
- package/dist/animationsV2/ClipsRuntime.js +115 -4
- package/dist/animationsV2/appliers.d.ts.map +1 -1
- package/dist/animationsV2/appliers.js +21 -2
- package/dist/animationsV2/clipUtils.d.ts.map +1 -1
- package/dist/animationsV2/clipUtils.js +5 -1
- package/dist/animationsV2/sequenceUtils.d.ts +5 -0
- package/dist/animationsV2/sequenceUtils.d.ts.map +1 -1
- package/dist/animationsV2/sequenceUtils.js +14 -5
- package/dist/animationsV2/sunSystemLive.d.ts +12 -0
- package/dist/animationsV2/sunSystemLive.d.ts.map +1 -0
- package/dist/animationsV2/sunSystemLive.js +8 -0
- package/dist/animationsV2/types.d.ts +6 -0
- package/dist/animationsV2/types.d.ts.map +1 -1
- package/dist/api/sceneHandle.d.ts +3 -1
- package/dist/api/sceneHandle.d.ts.map +1 -1
- package/dist/api/sceneHandle.js +2 -2
- package/dist/components/AdaptiveResolution.d.ts +9 -0
- package/dist/components/AdaptiveResolution.d.ts.map +1 -0
- package/dist/components/AdaptiveResolution.js +61 -0
- package/dist/components/CameraController.d.ts.map +1 -1
- package/dist/components/CameraController.js +24 -7
- package/dist/components/EffectsGenerator.d.ts.map +1 -1
- package/dist/components/EffectsGenerator.js +43 -38
- package/dist/components/GeometryShape.d.ts.map +1 -1
- package/dist/components/GeometryShape.js +22 -2
- package/dist/components/MoonDisc.d.ts.map +1 -1
- package/dist/components/MoonDisc.js +2 -1
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +6 -17
- package/dist/components/OceanBuilder.d.ts +4 -1
- package/dist/components/OceanBuilder.d.ts.map +1 -1
- package/dist/components/OceanBuilder.js +2 -1
- package/dist/components/ParticlesGenerator.d.ts.map +1 -1
- package/dist/components/ParticlesGenerator.js +46 -24
- package/dist/components/PickVolume.d.ts +17 -0
- package/dist/components/PickVolume.d.ts.map +1 -0
- package/dist/components/PickVolume.js +20 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +5 -2
- package/dist/components/SkyStars.d.ts.map +1 -1
- package/dist/components/SkyStars.js +83 -2
- package/dist/components/Skybox.d.ts.map +1 -1
- package/dist/components/Skybox.js +2 -1
- package/dist/components/SunLight.d.ts.map +1 -1
- package/dist/components/SunLight.js +3 -2
- package/dist/components/TextGenerator.d.ts.map +1 -1
- package/dist/components/TextGenerator.js +3 -2
- package/dist/components/index.d.ts +2 -8
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -4
- package/dist/components/lightBulb/LightBulb.d.ts.map +1 -1
- package/dist/components/lightBulb/LightBulb.js +7 -2
- package/dist/components/particles/BioluminescentWakeParticles.d.ts +5 -0
- package/dist/components/particles/BioluminescentWakeParticles.d.ts.map +1 -1
- package/dist/components/particles/BioluminescentWakeParticles.js +2 -1
- package/dist/components/particles/BrownianDustParticles.d.ts +5 -0
- package/dist/components/particles/BrownianDustParticles.d.ts.map +1 -1
- package/dist/components/particles/BrownianDustParticles.js +2 -0
- package/dist/components/particles/ChladniSandParticles.d.ts +5 -0
- package/dist/components/particles/ChladniSandParticles.d.ts.map +1 -1
- package/dist/components/particles/ChladniSandParticles.js +2 -1
- package/dist/components/particles/ElectronOrbitalsParticles.d.ts +5 -0
- package/dist/components/particles/ElectronOrbitalsParticles.d.ts.map +1 -1
- package/dist/components/particles/ElectronOrbitalsParticles.js +2 -1
- package/dist/components/particles/FaradayPowderParticles.d.ts +5 -0
- package/dist/components/particles/FaradayPowderParticles.d.ts.map +1 -1
- package/dist/components/particles/FaradayPowderParticles.js +2 -1
- package/dist/components/particles/FireworksParticles.d.ts +22 -0
- package/dist/components/particles/FireworksParticles.d.ts.map +1 -0
- package/dist/components/particles/FireworksParticles.js +1649 -0
- package/dist/components/particles/GrinderSparksParticles.d.ts +5 -0
- package/dist/components/particles/GrinderSparksParticles.d.ts.map +1 -1
- package/dist/components/particles/GrinderSparksParticles.js +2 -1
- package/dist/components/particles/MagneticBottleParticles.d.ts +5 -0
- package/dist/components/particles/MagneticBottleParticles.d.ts.map +1 -1
- package/dist/components/particles/MagneticBottleParticles.js +2 -1
- package/dist/components/particles/NeonRainParticles.d.ts +5 -0
- package/dist/components/particles/NeonRainParticles.d.ts.map +1 -1
- package/dist/components/particles/NeonRainParticles.js +2 -1
- package/dist/components/particles/ShapeBurstParticles.d.ts +5 -0
- package/dist/components/particles/ShapeBurstParticles.d.ts.map +1 -1
- package/dist/components/particles/ShapeBurstParticles.js +2 -1
- package/dist/components/particles/ShapeFlowParticles.d.ts +5 -0
- package/dist/components/particles/ShapeFlowParticles.d.ts.map +1 -1
- package/dist/components/particles/ShapeFlowParticles.js +2 -1
- package/dist/components/particles/TidalStreamParticles.d.ts +5 -0
- package/dist/components/particles/TidalStreamParticles.d.ts.map +1 -1
- package/dist/components/particles/TidalStreamParticles.js +2 -0
- package/dist/components/particles/index.d.ts +2 -0
- package/dist/components/particles/index.d.ts.map +1 -1
- package/dist/components/particles/index.js +1 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
- package/dist/components/terrain/TerrainSurface.js +26 -4
- package/dist/components/text/PlainText.d.ts +15 -0
- package/dist/components/text/PlainText.d.ts.map +1 -0
- package/dist/components/text/PlainText.js +4 -0
- package/dist/components/text/TextObjectView.d.ts +3 -1
- package/dist/components/text/TextObjectView.d.ts.map +1 -1
- package/dist/components/text/TextObjectView.js +9 -3
- package/dist/components/text/engine/looks/index.d.ts.map +1 -1
- package/dist/components/text/engine/looks/index.js +2 -1
- package/dist/components/text/engine/looks/plain.d.ts +146 -0
- package/dist/components/text/engine/looks/plain.d.ts.map +1 -0
- package/dist/components/text/engine/looks/plain.js +104 -0
- package/dist/components/text/fonts/bebas-neue.outline.d.ts +3 -0
- package/dist/components/text/fonts/bebas-neue.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/bebas-neue.outline.js +4 -0
- package/dist/components/text/fonts/bebas-neue.strokes.d.ts +3 -0
- package/dist/components/text/fonts/bebas-neue.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/bebas-neue.strokes.js +4 -0
- package/dist/components/text/fonts/index.d.ts +1 -1
- package/dist/components/text/fonts/index.d.ts.map +1 -1
- package/dist/components/text/fonts/index.js +15 -1
- package/dist/components/text/fonts/inter.outline.d.ts +3 -0
- package/dist/components/text/fonts/inter.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/inter.outline.js +4 -0
- package/dist/components/text/fonts/inter.strokes.d.ts +3 -0
- package/dist/components/text/fonts/inter.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/inter.strokes.js +4 -0
- package/dist/components/text/fonts/lora.outline.d.ts +3 -0
- package/dist/components/text/fonts/lora.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/lora.outline.js +4 -0
- package/dist/components/text/fonts/lora.strokes.d.ts +3 -0
- package/dist/components/text/fonts/lora.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/lora.strokes.js +4 -0
- package/dist/components/text/fonts/montserrat.outline.d.ts +3 -0
- package/dist/components/text/fonts/montserrat.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/montserrat.outline.js +4 -0
- package/dist/components/text/fonts/montserrat.strokes.d.ts +3 -0
- package/dist/components/text/fonts/montserrat.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/montserrat.strokes.js +4 -0
- package/dist/components/text/fonts/oswald.outline.d.ts +3 -0
- package/dist/components/text/fonts/oswald.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/oswald.outline.js +4 -0
- package/dist/components/text/fonts/oswald.strokes.d.ts +3 -0
- package/dist/components/text/fonts/oswald.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/oswald.strokes.js +4 -0
- package/dist/components/text/fonts/playfair-display.outline.d.ts +3 -0
- package/dist/components/text/fonts/playfair-display.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/playfair-display.outline.js +4 -0
- package/dist/components/text/fonts/playfair-display.strokes.d.ts +3 -0
- package/dist/components/text/fonts/playfair-display.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/playfair-display.strokes.js +4 -0
- package/dist/components/text/fonts/roboto.outline.d.ts +3 -0
- package/dist/components/text/fonts/roboto.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/roboto.outline.js +4 -0
- package/dist/components/text/fonts/roboto.strokes.d.ts +3 -0
- package/dist/components/text/fonts/roboto.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/roboto.strokes.js +4 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/index.d.ts.map +1 -1
- package/dist/components/text/index.js +1 -0
- package/dist/components/text/useTextObject.d.ts +1 -0
- package/dist/components/text/useTextObject.d.ts.map +1 -1
- package/dist/components/text/useTextObject.js +23 -11
- package/dist/components/water/OceanSurface.d.ts.map +1 -1
- package/dist/components/water/OceanSurface.js +5 -1
- package/dist/components/water/types.d.ts +3 -1
- package/dist/components/water/types.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/hooks/useOceanMaterial.d.ts +6 -2
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.js +22 -2
- package/dist/hooks/useOrbitTargetFollow.d.ts +10 -0
- package/dist/hooks/useOrbitTargetFollow.d.ts.map +1 -0
- package/dist/hooks/useOrbitTargetFollow.js +194 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/operations/catalogue/flock.d.ts.map +1 -1
- package/dist/operations/catalogue/flock.js +44 -9
- package/dist/operations/catalogue/inkBloom.d.ts.map +1 -1
- package/dist/operations/catalogue/inkBloom.js +46 -9
- package/dist/operations/catalogue/liquidMetal.d.ts.map +1 -1
- package/dist/operations/catalogue/liquidMetal.js +41 -12
- package/dist/operations/catalogue/particleSwarm.d.ts.map +1 -1
- package/dist/operations/catalogue/particleSwarm.js +29 -9
- package/dist/operations/catalogue/petalPeel.d.ts.map +1 -1
- package/dist/operations/catalogue/petalPeel.js +33 -9
- package/dist/operations/catalogue/portal.d.ts.map +1 -1
- package/dist/operations/catalogue/portal.js +33 -11
- package/dist/operations/catalogue/sandErosion.d.ts.map +1 -1
- package/dist/operations/catalogue/sandErosion.js +36 -14
- package/dist/operations/catalogue/teleport.d.ts.map +1 -1
- package/dist/operations/catalogue/teleport.js +43 -12
- package/dist/operations/catalogue/unweave.d.ts.map +1 -1
- package/dist/operations/catalogue/unweave.js +34 -15
- package/dist/operations/catalogue/voxelize.d.ts.map +1 -1
- package/dist/operations/catalogue/voxelize.js +37 -10
- package/dist/shaders/glsl/terrainCore.glsl.d.ts +18 -3
- package/dist/shaders/glsl/terrainCore.glsl.d.ts.map +1 -1
- package/dist/shaders/glsl/terrainCore.glsl.js +42 -21
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +36 -11
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -1
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +96 -5
- package/dist/triggers/engine.d.ts +1 -1
- package/dist/triggers/engine.d.ts.map +1 -1
- package/dist/triggers/engine.js +3 -0
- package/dist/triggers/hosts/actions.d.ts.map +1 -1
- package/dist/triggers/hosts/actions.js +3 -1
- package/dist/triggers/hosts/interactions.d.ts.map +1 -1
- package/dist/triggers/hosts/interactions.js +1 -1
- package/dist/triggers/hosts/timelineCues.js +1 -1
- package/dist/triggers/kinds/change.d.ts +4 -0
- package/dist/triggers/kinds/change.d.ts.map +1 -0
- package/dist/triggers/kinds/change.js +50 -0
- package/dist/triggers/kinds/index.d.ts +1 -0
- package/dist/triggers/kinds/index.d.ts.map +1 -1
- package/dist/triggers/kinds/index.js +1 -0
- package/dist/utils/CameraSingleton.d.ts +4 -0
- package/dist/utils/CameraSingleton.d.ts.map +1 -1
- package/dist/utils/CameraSingleton.js +4 -0
- package/dist/utils/deviceTier.d.ts +2 -0
- package/dist/utils/deviceTier.d.ts.map +1 -0
- package/dist/utils/deviceTier.js +16 -0
- package/dist/utils/environmentDrawOrder.d.ts +23 -0
- package/dist/utils/environmentDrawOrder.d.ts.map +1 -0
- package/dist/utils/environmentDrawOrder.js +22 -0
- package/dist/utils/pickProxy.d.ts +11 -0
- package/dist/utils/pickProxy.d.ts.map +1 -0
- package/dist/utils/pickProxy.js +36 -0
- package/dist/utils/shapes.d.ts +4 -0
- package/dist/utils/shapes.d.ts.map +1 -1
- package/dist/utils/shapes.js +4 -1
- package/dist/utils/terrainUniforms.d.ts +7 -0
- package/dist/utils/terrainUniforms.d.ts.map +1 -1
- package/dist/utils/terrainUniforms.js +15 -2
- package/dist/utils/textShape.d.ts +24 -0
- package/dist/utils/textShape.d.ts.map +1 -0
- package/dist/utils/textShape.js +102 -0
- package/package.json +2 -2
|
@@ -9,10 +9,12 @@ import { createPlayback } from './engine/playback.js';
|
|
|
9
9
|
import { VARIANTS } from './engine/variants.js';
|
|
10
10
|
import { layoutOutline, layoutStrokeFont } from './engine/glyphs.js';
|
|
11
11
|
import { loadOutline, loadStrokes } from './fonts/index.js';
|
|
12
|
+
import { extentOf } from './engine/methods.js';
|
|
13
|
+
import { stopRaycast } from '../../utils/pickProxy.js';
|
|
12
14
|
/** One em of the font in world units: the object's own size, so a text of 0.5 m high default. The parent transform does the rest. */
|
|
13
15
|
export const TEXT_EM = 0.5;
|
|
14
16
|
// Keys that are not look knobs.
|
|
15
|
-
const BASE_KEYS = new Set(['type', '
|
|
17
|
+
const BASE_KEYS = new Set(['type', 'shown', 'text', 'font', 'drawMethod', 'drawDuration', 'drawEase', 'drawStagger', 'drawAngle',
|
|
16
18
|
'eraseMethod', 'eraseDuration', 'eraseEase', 'eraseStagger', 'eraseAngle', 'autoPlay', 'loop', 'yoyo', 'holdTime', 'hiddenTime']);
|
|
17
19
|
/** Animation keys that bake a schedule into the geometry: a change rebuilds. */
|
|
18
20
|
const ANIM_STRUCTURAL = ['drawMethod', 'drawStagger', 'drawAngle', 'eraseMethod', 'eraseStagger', 'eraseAngle'];
|
|
@@ -36,6 +38,8 @@ export function useTextObject(look, props) {
|
|
|
36
38
|
const S = staticOf(look);
|
|
37
39
|
const rootRef = useRef(null);
|
|
38
40
|
const innerRef = useRef(null);
|
|
41
|
+
// Hover / click land on one plane over the text's box (em units, inside the em-scaled group), never on a letter.
|
|
42
|
+
const proxyRef = useRef(null);
|
|
39
43
|
const cfg = useMemo(() => withConfigDefaults(DEFAULT_TEXT_OBJECTS[look], config), [config, look]);
|
|
40
44
|
useObjectReady(rootRef, cfg, onObjectReady, onObjectDispose);
|
|
41
45
|
const cfgRef = useRef(cfg);
|
|
@@ -71,10 +75,18 @@ export function useTextObject(look, props) {
|
|
|
71
75
|
const now = cfgRef.current;
|
|
72
76
|
syncAnim(now);
|
|
73
77
|
built = V.build(layout, lookCfg(now), anim.current);
|
|
78
|
+
stopRaycast(built.object);
|
|
74
79
|
innerRef.current.add(built.object);
|
|
75
80
|
inst.current = built;
|
|
81
|
+
const e = extentOf(layout.strokes);
|
|
82
|
+
const pad = 0.12; // em: a little air around the glyphs
|
|
83
|
+
const proxy = proxyRef.current;
|
|
84
|
+
if (proxy) {
|
|
85
|
+
proxy.position.set((e.x0 + e.x1) / 2, (e.y0 + e.y1) / 2, 0);
|
|
86
|
+
proxy.scale.set(e.w + 2 * pad, e.h + 2 * pad, 1);
|
|
87
|
+
}
|
|
76
88
|
pb.current.reset(anim.current);
|
|
77
|
-
if (now.
|
|
89
|
+
if (now.shown === false)
|
|
78
90
|
pb.current.hide();
|
|
79
91
|
});
|
|
80
92
|
return () => { dead = true; if (built) {
|
|
@@ -84,24 +96,24 @@ export function useTextObject(look, props) {
|
|
|
84
96
|
inst.current = null;
|
|
85
97
|
} };
|
|
86
98
|
}, [look, rebuildKey, lookCfg, syncAnim]);
|
|
87
|
-
// `
|
|
88
|
-
const prev = useRef({
|
|
99
|
+
// `shown` is the trigger: on draws, off erases (then stays hidden). Loop / yoyo restart the cycle.
|
|
100
|
+
const prev = useRef({ shown: cfg.shown, loop: cfg.loop, yoyo: cfg.yoyo });
|
|
89
101
|
useEffect(() => {
|
|
90
102
|
const p = prev.current;
|
|
91
|
-
const
|
|
103
|
+
const changedShown = p.shown !== cfg.shown;
|
|
92
104
|
const changedPlay = p.loop !== cfg.loop || p.yoyo !== cfg.yoyo;
|
|
93
|
-
prev.current = {
|
|
105
|
+
prev.current = { shown: cfg.shown, loop: cfg.loop, yoyo: cfg.yoyo };
|
|
94
106
|
if (!inst.current)
|
|
95
107
|
return;
|
|
96
|
-
if (
|
|
97
|
-
if (cfg.
|
|
108
|
+
if (changedShown) {
|
|
109
|
+
if (cfg.shown === false)
|
|
98
110
|
pb.current.playErase(anim.current);
|
|
99
111
|
else
|
|
100
112
|
pb.current.restart(anim.current);
|
|
101
113
|
}
|
|
102
|
-
else if (changedPlay && cfg.
|
|
114
|
+
else if (changedPlay && cfg.shown !== false)
|
|
103
115
|
pb.current.restart(anim.current);
|
|
104
|
-
}, [cfg.
|
|
116
|
+
}, [cfg.shown, cfg.loop, cfg.yoyo]);
|
|
105
117
|
const scale = useMemo(() => new THREE.Vector3(), []);
|
|
106
118
|
useFrame((state, dt) => {
|
|
107
119
|
const i = inst.current;
|
|
@@ -114,5 +126,5 @@ export function useTextObject(look, props) {
|
|
|
114
126
|
root.getWorldScale(scale);
|
|
115
127
|
i.update(st, state.clock.elapsedTime, px * Math.abs(scale.x) * TEXT_EM);
|
|
116
128
|
});
|
|
117
|
-
return { rootRef, innerRef };
|
|
129
|
+
return { rootRef, innerRef, proxyRef };
|
|
118
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OceanSurface.d.ts","sourceRoot":"","sources":["../../../src/components/water/OceanSurface.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OceanSurface.d.ts","sourceRoot":"","sources":["../../../src/components/water/OceanSurface.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAItC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+D3C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OCEAN_DRAW_ORDER, ringDrawOrder } from '../../utils/environmentDrawOrder.js';
|
|
2
3
|
import { useRef } from 'react';
|
|
3
4
|
import { useObjectReady } from '../../hooks/useObjectReady.js';
|
|
4
5
|
import { useClipmap } from '../../hooks/useClipmap.js';
|
|
@@ -25,7 +26,7 @@ import { useOceanMaterial } from '../../hooks/useOceanMaterial.js';
|
|
|
25
26
|
* a sea at 0. What connects them is computed — the shoreline is where the ground
|
|
26
27
|
* crosses this surface — never configured.
|
|
27
28
|
*/
|
|
28
|
-
const OceanSurface = ({ id = '3drise-water', config, quality, skySettings, timeSettings, sunIntensity = 1, animations, mouseMove, onObjectReady, onObjectDispose, }) => {
|
|
29
|
+
const OceanSurface = ({ id = '3drise-water', config, quality, skySettings, timeSettings, sunIntensity = 1, animations, mouseMove, terrain, onObjectReady, onObjectDispose, }) => {
|
|
29
30
|
const clipmap = useClipmap(quality.levels, quality.segments, quality.cellSize);
|
|
30
31
|
const meshRefs = useRef([]);
|
|
31
32
|
const { material, rootRef } = useOceanMaterial({
|
|
@@ -37,6 +38,7 @@ const OceanSurface = ({ id = '3drise-water', config, quality, skySettings, timeS
|
|
|
37
38
|
sunIntensity,
|
|
38
39
|
animations,
|
|
39
40
|
mouseMove,
|
|
41
|
+
terrain,
|
|
40
42
|
onFrame: (cfg, _qual, state) => {
|
|
41
43
|
// ONE origin for the whole pyramid, snapped to twice the finest cell.
|
|
42
44
|
//
|
|
@@ -54,6 +56,8 @@ const OceanSurface = ({ id = '3drise-water', config, quality, skySettings, timeS
|
|
|
54
56
|
});
|
|
55
57
|
useObjectReady(rootRef, { id, type: 'ocean', config, quality }, onObjectReady, onObjectDispose);
|
|
56
58
|
return (_jsx("group", { ref: rootRef, children: clipmap.levels.map((ring, i) => (_jsx("mesh", { ref: (m) => { meshRefs.current[i] = m; }, geometry: ring.geometry, material: material, receiveShadow: quality.receiveShadows,
|
|
59
|
+
// Before the terrain, inner ring first: see environmentDrawOrder.
|
|
60
|
+
renderOrder: ringDrawOrder(OCEAN_DRAW_ORDER, ring.level),
|
|
57
61
|
// Displacement happens in the vertex shader, so the
|
|
58
62
|
// object-space bounds describe a flat plane. Culling against
|
|
59
63
|
// them hides the water the moment the camera tilts up.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SkySettings, TimeSettings } from '@3driseai/3drise-core';
|
|
2
2
|
import type { ObjectReadyProps } from '../../types/objectReady';
|
|
3
|
-
import type { OceanConfig, OceanMeshSettings, OceanQualityConfig, ObjectAnimations, MouseMoveInteractions } from '@3driseai/3drise-core';
|
|
3
|
+
import type { OceanConfig, OceanMeshSettings, OceanQualityConfig, ObjectAnimations, MouseMoveInteractions, TerrainConfig } from '@3driseai/3drise-core';
|
|
4
4
|
/** Shared by every water type. The builder hands all four the same shape. */
|
|
5
5
|
export interface OceanLayerProps extends ObjectReadyProps {
|
|
6
6
|
/** Scene id, so a controller can findById() the water and drive it live. */
|
|
@@ -20,5 +20,7 @@ export interface OceanLayerProps extends ObjectReadyProps {
|
|
|
20
20
|
animations?: ObjectAnimations;
|
|
21
21
|
/** Pointer bindings; same `ocean` domain. */
|
|
22
22
|
mouseMove?: MouseMoveInteractions;
|
|
23
|
+
/** The environment terrain, for the world ocean's shoreline and terrain shadow. */
|
|
24
|
+
terrain?: TerrainConfig | null;
|
|
23
25
|
}
|
|
24
26
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/water/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/water/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAExJ,6EAA6E;AAC7E,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACrD,4EAA4E;IAC5E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,kBAAkB,CAAC;IAC5B;;4DAEwD;IACxD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,mEAAmE;IACnE,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,mFAAmF;IACnF,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CAClC"}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,oCAA2B,CAAC;AACzD,eAAO,MAAM,qBAAqB,aAqBhC,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ const PRODUCTION_DATA_CENTER_SERVER = 'https://3drise.ai/api/data/';
|
|
|
3
3
|
const isLocalHostRuntime = typeof window !== 'undefined' &&
|
|
4
4
|
(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');
|
|
5
5
|
// export const dataCenterServer = isLocalHostRuntime ? LOCAL_DATA_CENTER_SERVER : PRODUCTION_DATA_CENTER_SERVER;
|
|
6
|
-
export const dataCenterServer =
|
|
6
|
+
export const dataCenterServer = LOCAL_DATA_CENTER_SERVER;
|
|
7
7
|
export const SELF_MANAGED_MATERIAL = new Set([
|
|
8
8
|
// The landscape owns its shader: splat arrays, height blending and the
|
|
9
9
|
// heightmap displacement are the material. useMaterialApplication would
|
|
@@ -17,6 +17,8 @@ export const SELF_MANAGED_MATERIAL = new Set([
|
|
|
17
17
|
'environment',
|
|
18
18
|
// Land objects draw with the terrain material (TERRAIN_PATCH).
|
|
19
19
|
'land',
|
|
20
|
+
// Text looks (plain, handwriting, neon…) draw with their own shaders; 3d text is a mesh and takes a material.
|
|
21
|
+
'text',
|
|
20
22
|
// The water surface owns its shader — one material for both hosts, built
|
|
21
23
|
// around the wave field. Left out of this set, useMaterialApplication
|
|
22
24
|
// overwrites it with whatever the registry has under materialType, which for
|
|
@@ -2,7 +2,7 @@ import * as THREE from 'three';
|
|
|
2
2
|
import { type RootState } from '@react-three/fiber';
|
|
3
3
|
import type { SkySettings, TimeSettings } from '@3driseai/3drise-core';
|
|
4
4
|
import { OceanSurfaceMaterial } from '../shaders/ocean/OceanSurfaceMaterial';
|
|
5
|
-
import type { OceanConfig, OceanQualityConfig, ObjectAnimations, MouseMoveInteractions } from '@3driseai/3drise-core';
|
|
5
|
+
import type { OceanConfig, OceanQualityConfig, ObjectAnimations, MouseMoveInteractions, TerrainConfig } from '@3driseai/3drise-core';
|
|
6
6
|
/**
|
|
7
7
|
* Everything the two water hosts share: the material, the live-edit handle, and
|
|
8
8
|
* the per-frame uniform push.
|
|
@@ -27,6 +27,10 @@ export interface UseOceanMaterialOptions {
|
|
|
27
27
|
animations?: ObjectAnimations;
|
|
28
28
|
/** Pointer bindings; same `ocean` domain. */
|
|
29
29
|
mouseMove?: MouseMoveInteractions;
|
|
30
|
+
/** The environment terrain's config, when it is on: the water reads the ground
|
|
31
|
+
* under it for the shoreline (waves shoal, shallow colour, shore foam) and
|
|
32
|
+
* marches the terrain's shadow. World host only. */
|
|
33
|
+
terrain?: TerrainConfig | null;
|
|
30
34
|
/** Runs after the uniforms are pushed, with the live overrides already
|
|
31
35
|
* merged in — where a host does its own per-frame work (snapping the
|
|
32
36
|
* clipmap to the camera, say) with the config it is actually rendering. */
|
|
@@ -38,6 +42,6 @@ export interface OceanMaterialHandle {
|
|
|
38
42
|
* handle a controller reaches through `findById`. */
|
|
39
43
|
rootRef: React.RefObject<THREE.Group | null>;
|
|
40
44
|
}
|
|
41
|
-
export declare function useOceanMaterial({ id, config, quality, skySettings, timeSettings, sunIntensity, animations, mouseMove, onFrame, }: UseOceanMaterialOptions): OceanMaterialHandle;
|
|
45
|
+
export declare function useOceanMaterial({ id, config, quality, skySettings, timeSettings, sunIntensity, animations, mouseMove, terrain, onFrame, }: UseOceanMaterialOptions): OceanMaterialHandle;
|
|
42
46
|
export default useOceanMaterial;
|
|
43
47
|
//# sourceMappingURL=useOceanMaterial.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOceanMaterial.d.ts","sourceRoot":"","sources":["../../src/hooks/useOceanMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAU7E,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useOceanMaterial.d.ts","sourceRoot":"","sources":["../../src/hooks/useOceanMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAU7E,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AASrI;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,uBAAuB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC;;yDAEqD;IACrD,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/B;;gFAE4E;IAC5E,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACtF;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B;0DACsD;IACtD,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;CAChD;AAED,wBAAgB,gBAAgB,CAAC,EAC7B,EAAE,EACF,MAAM,EACN,OAAO,EACP,WAAW,EACX,YAAY,EACZ,YAAgB,EAChB,UAAU,EACV,SAAS,EACT,OAAO,EACP,OAAO,GACV,EAAE,uBAAuB,GAAG,mBAAmB,CA0H/C;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { useCloudSun } from './useCloudSun.js';
|
|
|
5
5
|
import { OCEAN_LIVE_KEY } from './useOceanLive.js';
|
|
6
6
|
import { OceanSurfaceMaterial } from '../shaders/ocean/OceanSurfaceMaterial.js';
|
|
7
7
|
import { applySunUniforms } from '../utils/cloudUniforms.js';
|
|
8
|
-
import { applyTerrainAmbient } from '../utils/terrainUniforms.js';
|
|
8
|
+
import { applyTerrainAmbient, applyTerrainFieldUniforms } from '../utils/terrainUniforms.js';
|
|
9
9
|
import { applyOceanUniforms } from '../utils/oceanUniforms.js';
|
|
10
10
|
import { resolveMoon, moonlightFactor, MOON_LIGHT_COLOR } from '../utils/skyMoon.js';
|
|
11
11
|
/** Moonlight on the water relative to the sun's (sunIntensity 1). The key light
|
|
@@ -14,7 +14,7 @@ import { resolveMoon, moonlightFactor, MOON_LIGHT_COLOR } from '../utils/skyMoon
|
|
|
14
14
|
const MOON_WATER_STRENGTH = 0.15;
|
|
15
15
|
import { getAnimatableProperties } from '@3driseai/3drise-core';
|
|
16
16
|
import { applyConfigKeyframeAnimations, applyConfigMouseMove, } from '../utils/configAnimations.js';
|
|
17
|
-
export function useOceanMaterial({ id, config, quality, skySettings, timeSettings, sunIntensity = 1, animations, mouseMove, onFrame, }) {
|
|
17
|
+
export function useOceanMaterial({ id, config, quality, skySettings, timeSettings, sunIntensity = 1, animations, mouseMove, terrain, onFrame, }) {
|
|
18
18
|
const { state: sun, update: updateSun } = useCloudSun({ skySettings, timeSettings });
|
|
19
19
|
const moon = useRef({ direction: new THREE.Vector3(), illumination: 0 });
|
|
20
20
|
const material = useMemo(() => new OceanSurfaceMaterial(), []);
|
|
@@ -82,6 +82,26 @@ export function useOceanMaterial({ id, config, quality, skySettings, timeSetting
|
|
|
82
82
|
const cfg = { ...config, ...o, ...liveConfig.current };
|
|
83
83
|
const qual = { ...quality, ...liveQuality.current };
|
|
84
84
|
applyOceanUniforms(shader, cfg, qual);
|
|
85
|
+
// The shoreline. OCEAN_TERRAIN compiles the terrain field into the water;
|
|
86
|
+
// it flips only when terrain is switched on or off, never per frame.
|
|
87
|
+
const withTerrain = !!terrain?.enabled;
|
|
88
|
+
const defines = (shader.defines ??= {});
|
|
89
|
+
if (withTerrain !== ('OCEAN_TERRAIN' in defines)) {
|
|
90
|
+
if (withTerrain)
|
|
91
|
+
defines.OCEAN_TERRAIN = '';
|
|
92
|
+
else
|
|
93
|
+
delete defines.OCEAN_TERRAIN;
|
|
94
|
+
shader.needsUpdate = true;
|
|
95
|
+
}
|
|
96
|
+
const u = shader.uniforms;
|
|
97
|
+
u.u_shoreDepth.value = Math.max(cfg.shoreDepth ?? 3, 0.05);
|
|
98
|
+
u.u_shoreFoam.value = cfg.shoreFoam ?? 1;
|
|
99
|
+
if (withTerrain && terrain) {
|
|
100
|
+
applyTerrainFieldUniforms(shader, terrain);
|
|
101
|
+
u.u_sunShadow.value = cfg.terrainShadow ?? 1;
|
|
102
|
+
u.u_shadowSteps.value = Math.round(qual.terrainShadowSteps ?? 10);
|
|
103
|
+
u.u_shadowDistance.value = Math.max(qual.terrainShadowDistance ?? 4000, 1);
|
|
104
|
+
}
|
|
85
105
|
shader.uniforms.u_time.value = state.clock.getElapsedTime();
|
|
86
106
|
// World size of one pixel at unit distance. The detail fade and the
|
|
87
107
|
// specular filtering are both screen-space decisions — whether a ripple
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ControlsConfig, OrbitTargetObject } from '@3driseai/3drise-core';
|
|
2
|
+
export declare function useOrbitTargetFollow(controlsRef: React.MutableRefObject<any>, targetObject: OrbitTargetObject | null | undefined, followObject: OrbitTargetObject | null | undefined,
|
|
3
|
+
/** True while something else owns the camera position (a camera animation). */
|
|
4
|
+
isCameraBusy: () => boolean,
|
|
5
|
+
/** False when the orbit controls are switched off: the camera keeps its own orientation. */
|
|
6
|
+
orbiting: boolean,
|
|
7
|
+
/** The authored controls — their limits are what the widening falls back to. */
|
|
8
|
+
authored: ControlsConfig): void;
|
|
9
|
+
export default useOrbitTargetFollow;
|
|
10
|
+
//# sourceMappingURL=useOrbitTargetFollow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOrbitTargetFollow.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrbitTargetFollow.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAsE/E,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,EACxC,YAAY,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,EAClD,YAAY,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS;AAClD,+EAA+E;AAC/E,YAAY,EAAE,MAAM,OAAO;AAC3B,4FAA4F;AAC5F,QAAQ,EAAE,OAAO;AACjB,gFAAgF;AAChF,QAAQ,EAAE,cAAc,QAqE3B;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// useOrbitTargetFollow — the camera tracks scene objects
|
|
3
|
+
// =============================================================================
|
|
4
|
+
//
|
|
5
|
+
// Two independent settings on `controls`:
|
|
6
|
+
//
|
|
7
|
+
// targetObject ORBIT TARGET — the orbit point (what the camera looks at) sits on the
|
|
8
|
+
// object's centre every frame. The camera position is not touched; it
|
|
9
|
+
// only turns to keep looking at the object.
|
|
10
|
+
// followObject FOLLOW — the camera travels with the object: it (and the orbit point)
|
|
11
|
+
// moves by exactly as much as the object moved, so the distance and
|
|
12
|
+
// angle stay the same. Translation only — the object spinning in place
|
|
13
|
+
// does not swing the camera around.
|
|
14
|
+
//
|
|
15
|
+
// Both together: the camera rides along with one object and looks at another (or the
|
|
16
|
+
// same one).
|
|
17
|
+
//
|
|
18
|
+
// Smoothness — why this runs in scene.onBeforeRender and not in useFrame:
|
|
19
|
+
// clips, actions, effects and physics move objects in useFrame callbacks, some of them
|
|
20
|
+
// after this component's. Reading the object in useFrame would see last frame's position
|
|
21
|
+
// half the time, so the camera would trail the object by a frame and stutter. Three calls
|
|
22
|
+
// scene.onBeforeRender inside gl.render, after it has updated every matrixWorld and before
|
|
23
|
+
// it builds the view — so here every object is exactly where it is drawn this frame. We
|
|
24
|
+
// move the camera, re-aim it and update its matrix ourselves, and this frame's image is
|
|
25
|
+
// already right.
|
|
26
|
+
//
|
|
27
|
+
// The object's centre is its bounding-box centre, measured once in the object's own space
|
|
28
|
+
// when it is found and then carried by its matrixWorld every frame — exact under animation
|
|
29
|
+
// and cheap (no per-frame box).
|
|
30
|
+
//
|
|
31
|
+
// Limits vs a moving target: OrbitControls clamps the camera's distance and angles to
|
|
32
|
+
// the target on every update. When the TARGET moves (the plane climbs above a camera
|
|
33
|
+
// limited to 88°), that clamp would drag the camera along — the camera must not move.
|
|
34
|
+
// So while looking at an object, the limits are widened each frame just enough to hold
|
|
35
|
+
// where the camera is now: the object can take the view outside the authored range,
|
|
36
|
+
// the user still can't rotate / zoom further out of it, and moving back in tightens
|
|
37
|
+
// them to the authored values again. The authored values come from `controls`.
|
|
38
|
+
//
|
|
39
|
+
// Height limits (controls.minHeight / maxHeight) are world Y, not relative to the target,
|
|
40
|
+
// and are applied after everything else in the frame.
|
|
41
|
+
//
|
|
42
|
+
// While a camera animation (path / gsap) runs, follow does not move the camera — the
|
|
43
|
+
// animation owns its position; the follow just keeps counting, so nothing jumps after.
|
|
44
|
+
//
|
|
45
|
+
import { useEffect, useRef } from 'react';
|
|
46
|
+
import { useFrame, useThree } from '@react-three/fiber';
|
|
47
|
+
import { Box3, Vector3 } from 'three';
|
|
48
|
+
import { orbitAngleLimits } from '@3driseai/3drise-core';
|
|
49
|
+
import { findById } from '../utils/sceneQuery.js';
|
|
50
|
+
const RESOLVE_EVERY = 30; // frames between lookups while the object is missing
|
|
51
|
+
const _box = new Box3();
|
|
52
|
+
const _p = new Vector3();
|
|
53
|
+
const _d = new Vector3();
|
|
54
|
+
const _off = new Vector3();
|
|
55
|
+
const keyOf = (t) => (t?.id ? `${t.id}|${t.node ?? ''}` : '');
|
|
56
|
+
/** Finds one object and gives its centre in world space, every frame, without lag. */
|
|
57
|
+
class Tracker {
|
|
58
|
+
key = '';
|
|
59
|
+
obj = null;
|
|
60
|
+
local = new Vector3(); // bounding-box centre in the object's own space
|
|
61
|
+
missingSince = -1e9;
|
|
62
|
+
locked = false; // first point taken
|
|
63
|
+
last = new Vector3(); // point at the previous frame
|
|
64
|
+
sync(t) {
|
|
65
|
+
const key = keyOf(t);
|
|
66
|
+
if (key === this.key)
|
|
67
|
+
return;
|
|
68
|
+
this.key = key;
|
|
69
|
+
this.obj = null;
|
|
70
|
+
this.missingSince = -1e9;
|
|
71
|
+
this.locked = false;
|
|
72
|
+
}
|
|
73
|
+
/** Writes the object's centre into `out`; false while the object is not there. */
|
|
74
|
+
point(t, frame, out) {
|
|
75
|
+
if (!this.obj || !this.obj.parent) {
|
|
76
|
+
if (frame - this.missingSince < RESOLVE_EVERY)
|
|
77
|
+
return false;
|
|
78
|
+
const root = findById(t.id);
|
|
79
|
+
const obj = root && t.node ? root.getObjectByName(t.node) ?? null : root;
|
|
80
|
+
if (!obj) {
|
|
81
|
+
this.missingSince = frame;
|
|
82
|
+
this.obj = null;
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
this.obj = obj;
|
|
86
|
+
this.locked = false;
|
|
87
|
+
obj.updateWorldMatrix(true, true);
|
|
88
|
+
_box.setFromObject(obj);
|
|
89
|
+
if (_box.isEmpty())
|
|
90
|
+
this.local.set(0, 0, 0);
|
|
91
|
+
else
|
|
92
|
+
obj.worldToLocal(_box.getCenter(this.local));
|
|
93
|
+
}
|
|
94
|
+
out.copy(this.local).applyMatrix4(this.obj.matrixWorld);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Authored limits, widened to include the camera's current distance and angles to the target. */
|
|
99
|
+
function widenLimits(controls, cameraPos, auth) {
|
|
100
|
+
_off.copy(cameraPos).sub(controls.target);
|
|
101
|
+
const r = _off.length();
|
|
102
|
+
if (r < 1e-6)
|
|
103
|
+
return;
|
|
104
|
+
const phi = Math.acos(Math.min(1, Math.max(-1, _off.y / r)));
|
|
105
|
+
const theta = Math.atan2(_off.x, _off.z);
|
|
106
|
+
const lim = orbitAngleLimits(auth);
|
|
107
|
+
const minD = auth.minDistance ?? 0, maxD = auth.maxDistance ?? Infinity;
|
|
108
|
+
controls.minDistance = Math.min(minD, r);
|
|
109
|
+
controls.maxDistance = Math.max(maxD, r);
|
|
110
|
+
controls.minPolarAngle = Math.min(lim.minPolarAngle, phi);
|
|
111
|
+
controls.maxPolarAngle = Math.max(lim.maxPolarAngle, phi);
|
|
112
|
+
// Azimuth: only when it is limited (the full circle needs nothing).
|
|
113
|
+
if (lim.maxAzimuthAngle - lim.minAzimuthAngle < Math.PI * 2 - 1e-6) {
|
|
114
|
+
controls.minAzimuthAngle = Math.min(lim.minAzimuthAngle, theta);
|
|
115
|
+
controls.maxAzimuthAngle = Math.max(lim.maxAzimuthAngle, theta);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export function useOrbitTargetFollow(controlsRef, targetObject, followObject,
|
|
119
|
+
/** True while something else owns the camera position (a camera animation). */
|
|
120
|
+
isCameraBusy,
|
|
121
|
+
/** False when the orbit controls are switched off: the camera keeps its own orientation. */
|
|
122
|
+
orbiting,
|
|
123
|
+
/** The authored controls — their limits are what the widening falls back to. */
|
|
124
|
+
authored) {
|
|
125
|
+
const { scene, camera } = useThree();
|
|
126
|
+
const live = useRef({ targetObject, followObject, isCameraBusy, orbiting, authored });
|
|
127
|
+
live.current = { targetObject, followObject, isCameraBusy, orbiting, authored };
|
|
128
|
+
const frame = useRef(0);
|
|
129
|
+
const done = useRef(-1);
|
|
130
|
+
const aim = useRef(new Tracker());
|
|
131
|
+
const follow = useRef(new Tracker());
|
|
132
|
+
// A frame counter, so the render hook runs once per frame even if the scene is
|
|
133
|
+
// rendered more than once (reflections, previews).
|
|
134
|
+
useFrame(() => { frame.current++; });
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
const prev = scene.onBeforeRender;
|
|
137
|
+
scene.onBeforeRender = function (...args) {
|
|
138
|
+
prev.apply(this, args);
|
|
139
|
+
const cam = args[2];
|
|
140
|
+
if (cam !== camera || done.current === frame.current)
|
|
141
|
+
return;
|
|
142
|
+
done.current = frame.current;
|
|
143
|
+
const controls = controlsRef.current;
|
|
144
|
+
const { targetObject: tObj, followObject: fObj, isCameraBusy: busy, orbiting: orb, authored: auth } = live.current;
|
|
145
|
+
const f = follow.current, a = aim.current;
|
|
146
|
+
f.sync(fObj);
|
|
147
|
+
a.sync(tObj);
|
|
148
|
+
let moved = false;
|
|
149
|
+
// FOLLOW: move the camera and the orbit point with the object.
|
|
150
|
+
if (fObj && f.point(fObj, frame.current, _p)) {
|
|
151
|
+
if (!f.locked) {
|
|
152
|
+
f.last.copy(_p);
|
|
153
|
+
f.locked = true;
|
|
154
|
+
}
|
|
155
|
+
_d.copy(_p).sub(f.last);
|
|
156
|
+
f.last.copy(_p);
|
|
157
|
+
if (_d.lengthSq() > 0 && !busy()) {
|
|
158
|
+
camera.position.add(_d);
|
|
159
|
+
if (controls)
|
|
160
|
+
controls.target.add(_d);
|
|
161
|
+
moved = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// ORBIT TARGET: look at the object; the camera stays where it is.
|
|
165
|
+
if (tObj && controls && a.point(tObj, frame.current, _p)) {
|
|
166
|
+
if (!a.locked || !controls.target.equals(_p)) {
|
|
167
|
+
controls.target.copy(_p);
|
|
168
|
+
if (orb)
|
|
169
|
+
camera.lookAt(_p);
|
|
170
|
+
a.locked = true;
|
|
171
|
+
moved = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// HEIGHT LIMITS (world Y): last, so nothing — user, target, follow, a clip — ends
|
|
175
|
+
// the frame under the floor or over the ceiling. The camera keeps facing the target.
|
|
176
|
+
const minH = typeof auth.minHeight === 'number' ? auth.minHeight : -Infinity;
|
|
177
|
+
const maxH = typeof auth.maxHeight === 'number' ? auth.maxHeight : Infinity;
|
|
178
|
+
const y = Math.min(maxH, Math.max(minH, camera.position.y));
|
|
179
|
+
if (y !== camera.position.y) {
|
|
180
|
+
camera.position.y = y;
|
|
181
|
+
if (orb && controls)
|
|
182
|
+
camera.lookAt(controls.target);
|
|
183
|
+
moved = true;
|
|
184
|
+
}
|
|
185
|
+
if (moved)
|
|
186
|
+
camera.updateMatrixWorld();
|
|
187
|
+
// Limits hold the camera where the moving target left it (see the header).
|
|
188
|
+
if (tObj && controls && a.locked)
|
|
189
|
+
widenLimits(controls, camera.position, auth);
|
|
190
|
+
};
|
|
191
|
+
return () => { scene.onBeforeRender = prev; };
|
|
192
|
+
}, [scene, camera, controlsRef]);
|
|
193
|
+
}
|
|
194
|
+
export default useOrbitTargetFollow;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,16 +15,17 @@ export { cameraManager } from './utils/CameraSingleton';
|
|
|
15
15
|
export { applyAnchorSettings, createCurves, createSunPosition, randomRange, } from './utils/utils3d';
|
|
16
16
|
export { applyAnchorSettings as applyAnchorSettingsLegacy } from './utils/anchorUtils';
|
|
17
17
|
export * from './utils/shapes';
|
|
18
|
+
export * from './utils/pickProxy';
|
|
18
19
|
export { hasHoverAnimation } from './utils/hasHoverAnimation';
|
|
19
20
|
export { findById } from './utils/sceneQuery';
|
|
20
21
|
export { hasFrameRenderer, registerFrameRenderer, renderFrame } from './utils/frameRenderer';
|
|
21
22
|
export type { FrameRenderer } from './utils/frameRenderer';
|
|
22
23
|
export { resolveObject3D } from './utils/resolveObject3D';
|
|
23
24
|
export type { Object3DRefLike, Object3DSource } from './utils/resolveObject3D';
|
|
24
|
-
export * from './utils/textEffects';
|
|
25
25
|
export { applyTerrainUniforms, applyTerrainTextures } from './utils/terrainUniforms';
|
|
26
26
|
export { useTerrainTextures } from './hooks/useTerrainTextures';
|
|
27
27
|
export { terrainHeightAt } from './utils/terrainHeight';
|
|
28
|
+
export { isMobileDevice } from './utils/deviceTier';
|
|
28
29
|
export { setTerrainTextureResolver, resolveTerrainTextureSets, useTerrainTextureResolverVersion, type TerrainTextureResolver } from './utils/terrainTextureResolver';
|
|
29
30
|
export { landHeightAt, landWorldHeightAt, landSeedOffset, landToTerrainConfig, LAND_SEGMENTS } from './utils/landPatch';
|
|
30
31
|
export type { TerrainTextureState } from './hooks/useTerrainTextures';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG5F,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CA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,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,14 +18,15 @@ export { cameraManager } from './utils/CameraSingleton.js';
|
|
|
18
18
|
export { applyAnchorSettings, createCurves, createSunPosition, randomRange, } from './utils/utils3d.js';
|
|
19
19
|
export { applyAnchorSettings as applyAnchorSettingsLegacy } from './utils/anchorUtils.js';
|
|
20
20
|
export * from './utils/shapes.js';
|
|
21
|
+
export * from './utils/pickProxy.js';
|
|
21
22
|
export { hasHoverAnimation } from './utils/hasHoverAnimation.js';
|
|
22
23
|
export { findById } from './utils/sceneQuery.js';
|
|
23
24
|
export { hasFrameRenderer, registerFrameRenderer, renderFrame } from './utils/frameRenderer.js';
|
|
24
25
|
export { resolveObject3D } from './utils/resolveObject3D.js';
|
|
25
|
-
export * from './utils/textEffects.js';
|
|
26
26
|
export { applyTerrainUniforms, applyTerrainTextures } from './utils/terrainUniforms.js';
|
|
27
27
|
export { useTerrainTextures } from './hooks/useTerrainTextures.js';
|
|
28
28
|
export { terrainHeightAt } from './utils/terrainHeight.js';
|
|
29
|
+
export { isMobileDevice } from './utils/deviceTier.js';
|
|
29
30
|
export { setTerrainTextureResolver, resolveTerrainTextureSets, useTerrainTextureResolverVersion } from './utils/terrainTextureResolver.js';
|
|
30
31
|
export { landHeightAt, landWorldHeightAt, landSeedOffset, landToTerrainConfig, LAND_SEGMENTS } from './utils/landPatch.js';
|
|
31
32
|
export { applyLandscapeMaps, applyLandscapeUniforms } from './utils/landscapeUniforms.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flock.d.ts","sourceRoot":"","sources":["../../../src/operations/catalogue/flock.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"flock.d.ts","sourceRoot":"","sources":["../../../src/operations/catalogue/flock.ts"],"names":[],"mappings":";AA+CA,wBAyJG"}
|