@ntalmagor/3drize-viewer 0.1.23 → 0.1.25
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/AnimatedObject.js +1 -1
- package/dist/components/Clouds.d.ts +3 -3
- package/dist/components/Clouds.d.ts.map +1 -1
- package/dist/components/Clouds.js +154 -57
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +4 -6
- package/dist/components/CustomPrimitive.js +31 -27
- package/dist/components/EffectsGroup.d.ts +1 -1
- package/dist/components/EffectsGroup.d.ts.map +1 -1
- package/dist/components/EffectsGroup.js +2 -1
- package/dist/components/Frame.d.ts.map +1 -1
- package/dist/components/Frame.js +3 -1
- package/dist/components/Galaxy.d.ts +3 -1
- package/dist/components/Galaxy.d.ts.map +1 -1
- package/dist/components/Galaxy.js +3 -5
- package/dist/components/LightObject.d.ts +8 -0
- package/dist/components/LightObject.d.ts.map +1 -0
- package/dist/components/LightObject.js +65 -0
- package/dist/components/LightsManager.d.ts +2 -3
- package/dist/components/LightsManager.d.ts.map +1 -1
- package/dist/components/LightsManager.js +89 -106
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +43 -14
- package/dist/components/ObjectsRenderer.d.ts.map +1 -1
- package/dist/components/ObjectsRenderer.js +3 -1
- package/dist/components/Ocean.d.ts +2 -2
- package/dist/components/Ocean.d.ts.map +1 -1
- package/dist/components/Ocean.js +50 -36
- package/dist/components/ParticlesR3f.d.ts.map +1 -1
- package/dist/components/ParticlesR3f.js +15 -0
- package/dist/components/Rain.d.ts +2 -2
- package/dist/components/Rain.d.ts.map +1 -1
- package/dist/components/Rain.js +155 -29
- package/dist/components/SceneBuilder.js +1 -2
- package/dist/components/ShootingStars.d.ts +2 -2
- package/dist/components/ShootingStars.d.ts.map +1 -1
- package/dist/components/SkyController.d.ts.map +1 -1
- package/dist/components/SkyController.js +1 -1
- package/dist/components/SkySystem.d.ts.map +1 -1
- package/dist/components/SkySystem.js +5 -6
- package/dist/components/Skybox.d.ts.map +1 -1
- package/dist/components/Skybox.js +42 -29
- package/dist/components/Stars.d.ts +2 -2
- package/dist/components/Stars.d.ts.map +1 -1
- package/dist/components/Stars.js +37 -28
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/hooks/useCameraAnimation.js +25 -19
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.js +11 -5
- package/dist/hooks/useInteraction.d.ts.map +1 -1
- package/dist/hooks/useInteraction.js +43 -10
- package/dist/hooks/useInteractionEffects.d.ts +3 -3
- package/dist/hooks/useInteractionEffects.d.ts.map +1 -1
- package/dist/hooks/useInteractionEffects.js +66 -23
- package/dist/hooks/useLightAnimation.d.ts +10 -0
- package/dist/hooks/useLightAnimation.d.ts.map +1 -0
- package/dist/hooks/useLightAnimation.js +34 -0
- package/dist/hooks/useLightMouseMove.d.ts +11 -0
- package/dist/hooks/useLightMouseMove.d.ts.map +1 -0
- package/dist/hooks/useLightMouseMove.js +27 -0
- package/dist/hooks/useLightShadow.d.ts +6 -0
- package/dist/hooks/useLightShadow.d.ts.map +1 -0
- package/dist/hooks/useLightShadow.js +63 -0
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +65 -6
- package/dist/hooks/useMaterialOptions.d.ts.map +1 -1
- package/dist/hooks/useMaterialOptions.js +2 -0
- package/dist/hooks/useMaterialUniforms.js +6 -6
- package/dist/hooks/useObjectAnimation.d.ts.map +1 -1
- package/dist/hooks/useObjectAnimation.js +3 -3
- package/dist/hooks/useObjectEdges.d.ts +1 -2
- package/dist/hooks/useObjectEdges.d.ts.map +1 -1
- package/dist/hooks/useObjectEdges.js +5 -5
- package/dist/hooks/useParticlesTextures.js +1 -1
- package/dist/hooks/useShadowApplication.d.ts +3 -0
- package/dist/hooks/useShadowApplication.d.ts.map +1 -0
- package/dist/hooks/useShadowApplication.js +31 -0
- package/dist/hooks/useSkySystem.d.ts.map +1 -1
- package/dist/hooks/useSkySystem.js +4 -3
- package/dist/hooks/useSkyUniforms.d.ts +1 -1
- package/dist/hooks/useSkyUniforms.d.ts.map +1 -1
- package/dist/hooks/useSkyUniforms.js +10 -11
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -3
|
@@ -17,7 +17,7 @@ visible = true, children, parentRef, handleObjectClick, onPointerEnter, onPointe
|
|
|
17
17
|
const stepEase = useRef('linear');
|
|
18
18
|
const animProgress = useRef(0);
|
|
19
19
|
const hasHoverFunctionalities = hasHoverAnimation(createdObject.animations);
|
|
20
|
-
const hasMouseInteraction = createdObject.
|
|
20
|
+
const hasMouseInteraction = (createdObject.actions?.length ?? 0) > 0;
|
|
21
21
|
const baseRef = useRef({ position: [...position], scale: [...scale], rotation: [...rotation] });
|
|
22
22
|
const targetRef = useRef({
|
|
23
23
|
position: targetPosition ? [...targetPosition] : [...position],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TimeSettings, CreatedObjectSettings } from '@ntalmagor/3drize-core';
|
|
3
3
|
export interface CloudsProps {
|
|
4
|
-
settings:
|
|
5
|
-
timeSettings
|
|
4
|
+
settings: CreatedObjectSettings;
|
|
5
|
+
timeSettings?: TimeSettings;
|
|
6
6
|
}
|
|
7
7
|
declare const Clouds: React.FC<CloudsProps>;
|
|
8
8
|
export default Clouds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clouds.d.ts","sourceRoot":"","sources":["../../src/components/Clouds.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Clouds.d.ts","sourceRoot":"","sources":["../../src/components/Clouds.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,OAAO,KAAK,EAGV,YAAY,EAIZ,qBAAqB,EAEtB,MAAM,wBAAwB,CAAC;AA+BhC,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,qBAAqB,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAgFD,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAuNjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -2,12 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef, useCallback } from 'react';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
5
|
-
import { useMaterialApplication } from '../hooks/useMaterialApplication.js';
|
|
6
5
|
import { useSkySystem } from '../hooks/useSkySystem.js';
|
|
7
6
|
import { useAnimationEvents } from '../hooks/useAnimationEvents.js';
|
|
8
7
|
import { useNumericAnimation } from '../hooks/useNumericAnimation.js';
|
|
9
|
-
import {
|
|
10
|
-
import { useMouseHandlers } from '../hooks/useMouseHandlers.js';
|
|
8
|
+
import { calculateTimeProgress, applyEasing, gsapEasingMap, interpolateValue, handleTransformMouseMove, handleMaterialMouseMove, interpolateMouseMoveProperty, } from '@ntalmagor/3drize-core';
|
|
11
9
|
const CLOUD_COLORS = {
|
|
12
10
|
night: new THREE.Color(0.1, 0.1, 0.2),
|
|
13
11
|
sunrise: new THREE.Color(0.8, 0.4, 0.4),
|
|
@@ -22,20 +20,101 @@ const DEFAULT_MATERIAL = {
|
|
|
22
20
|
u_cameraPos: [0, 0, 0],
|
|
23
21
|
u_cloudColor: [1.0, 1.0, 1.0],
|
|
24
22
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// Per-domain helpers (clouds-specific writes for the `clouds` domain)
|
|
25
|
+
// =============================================================================
|
|
26
|
+
function applyCloudsKeyframeAnimations(animations, startValuesCache, config, override, currentTime) {
|
|
27
|
+
if (!animations?.length)
|
|
28
|
+
return;
|
|
29
|
+
override.speed = undefined; // reset before each pass
|
|
30
|
+
for (const anim of animations) {
|
|
31
|
+
const { property, to, duration, ease, loop = false, yoyo = false, active } = anim;
|
|
32
|
+
if (!active || to === undefined)
|
|
33
|
+
continue;
|
|
34
|
+
if (property !== 'speed')
|
|
35
|
+
continue;
|
|
36
|
+
let from = anim.from;
|
|
37
|
+
if (from === undefined) {
|
|
38
|
+
from = startValuesCache[property] ??= (config.speed ?? 1);
|
|
39
|
+
}
|
|
40
|
+
let p = calculateTimeProgress(currentTime, duration, yoyo, loop);
|
|
41
|
+
if (ease) {
|
|
42
|
+
const fn = gsapEasingMap[ease] || ease;
|
|
43
|
+
p = applyEasing(fn, p);
|
|
44
|
+
}
|
|
45
|
+
override.speed = interpolateValue(property, from, to, p);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function applyCloudsMouseMove(properties, config, override, pointer) {
|
|
49
|
+
if (!properties?.length)
|
|
50
|
+
return;
|
|
51
|
+
override.speed = undefined;
|
|
52
|
+
for (const { property, enabled, propertySettings } of properties) {
|
|
53
|
+
if (!enabled || property !== 'speed')
|
|
54
|
+
continue;
|
|
55
|
+
const { axis = 'both', sensitivity = 1, inverted = false, min, max } = propertySettings || {};
|
|
56
|
+
const base = config.speed ?? 1;
|
|
57
|
+
override.speed = interpolateMouseMoveProperty(base, min, max, pointer, axis, sensitivity, inverted);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Project legacy flat `handlers.onMouseMove.properties[]` shape into per-domain
|
|
61
|
+
// buckets so we can route it through the new handlers without a save migration.
|
|
62
|
+
function projectLegacyHandlersToDomain(legacy) {
|
|
63
|
+
const transform = [];
|
|
64
|
+
const material = [];
|
|
65
|
+
const clouds = [];
|
|
66
|
+
if (!legacy)
|
|
67
|
+
return { transform, material, clouds };
|
|
68
|
+
for (const cfg of legacy) {
|
|
69
|
+
const enabledP = { property: cfg.property, enabled: cfg.enabled ?? true, propertySettings: cfg.propertySettings };
|
|
70
|
+
if (cfg.property === 'speed')
|
|
71
|
+
clouds.push(enabledP);
|
|
72
|
+
else if (cfg.property === 'position' || cfg.property === 'rotation' || cfg.property === 'scale')
|
|
73
|
+
transform.push(enabledP);
|
|
74
|
+
else
|
|
75
|
+
material.push(enabledP);
|
|
76
|
+
}
|
|
77
|
+
return { transform, material, clouds };
|
|
78
|
+
}
|
|
79
|
+
// =============================================================================
|
|
80
|
+
// MAIN COMPONENT
|
|
81
|
+
// =============================================================================
|
|
82
|
+
const defaultTimeSettings = {
|
|
83
|
+
enabled: false,
|
|
84
|
+
timescale: 1,
|
|
85
|
+
timeOfDay: 12,
|
|
86
|
+
syncWithRealTime: false,
|
|
87
|
+
autoAnimate: false,
|
|
88
|
+
};
|
|
89
|
+
const Clouds = ({ settings, timeSettings = defaultTimeSettings }) => {
|
|
90
|
+
const visible = settings.meshSettings.visible ?? true;
|
|
91
|
+
const meshSettings = settings.meshSettings;
|
|
92
|
+
const config = settings.config;
|
|
93
|
+
const materialSettings = settings.materialSettings;
|
|
94
|
+
const position = meshSettings.position;
|
|
95
|
+
const scale = meshSettings.scale;
|
|
96
|
+
// console.log(config.speed)
|
|
97
|
+
const baseSpeed = config.speed ?? 1;
|
|
98
|
+
// console.log(baseSpeed)
|
|
99
|
+
const height = position[1];
|
|
100
|
+
const planeSize = config?.planeSize || [10000, 10000];
|
|
101
|
+
const planeSegments = config?.planeSegments || 64;
|
|
28
102
|
const meshRef = useRef(null);
|
|
29
103
|
const cloudAnimTime = useRef(0);
|
|
30
104
|
const { camera } = useThree();
|
|
31
|
-
const { interpolateProperty } = useMouseHandlers();
|
|
32
105
|
const cloudColorRef = useRef(new THREE.Color(1, 1, 1));
|
|
33
106
|
const targetCloudColorRef = useRef(new THREE.Color(1, 1, 1));
|
|
107
|
+
// Sequence-driven numeric anims (legacy `useAnimationEvents` path)
|
|
34
108
|
const numericOverrideRef = useRef(null);
|
|
35
|
-
const mouseOverrideRef = useRef({});
|
|
36
109
|
const { animateNumeric } = useNumericAnimation();
|
|
37
|
-
|
|
38
|
-
|
|
110
|
+
// Per-domain animation + mouseMove overrides
|
|
111
|
+
const animatedOverrideRef = useRef({});
|
|
112
|
+
const mouseOverrideRef = useRef({});
|
|
113
|
+
// Keyframe-animation start-value caches (one per domain that uses them)
|
|
114
|
+
const transformAnimCacheRef = useRef({});
|
|
115
|
+
const materialAnimCacheRef = useRef({});
|
|
116
|
+
const cloudsAnimCacheRef = useRef({});
|
|
117
|
+
// useMaterialApplication(visible ? (meshRef.current as any) : null, materialSettings, true);
|
|
39
118
|
const handleTimeUpdate = useCallback((state) => {
|
|
40
119
|
const { normalizedTime, isDaytime, delta } = state;
|
|
41
120
|
if (isDaytime) {
|
|
@@ -66,6 +145,7 @@ const Clouds = ({ settings, timeSettings, }) => {
|
|
|
66
145
|
onTimeUpdate: handleTimeUpdate,
|
|
67
146
|
enabled: visible,
|
|
68
147
|
});
|
|
148
|
+
// Legacy sequence-driven `speed`/`scale` anims via `useAnimationEvents`
|
|
69
149
|
useAnimationEvents({
|
|
70
150
|
onStepStart: (event) => {
|
|
71
151
|
if (!event.step?.transitions)
|
|
@@ -75,20 +155,18 @@ const Clouds = ({ settings, timeSettings, }) => {
|
|
|
75
155
|
continue;
|
|
76
156
|
const toProps = transition.properties.to || {};
|
|
77
157
|
const fromProps = transition.properties.from || {};
|
|
78
|
-
|
|
79
|
-
if (toProps.visible !== undefined) {
|
|
158
|
+
if (toProps.visible !== undefined)
|
|
80
159
|
meshRef.current.visible = toProps.visible;
|
|
81
|
-
|
|
82
|
-
// numeric: speed, scale
|
|
83
|
-
const CLOUDS_NUMERIC_KEYS = ['speed', 'scale'];
|
|
160
|
+
const KEYS = ['speed', 'scale'];
|
|
84
161
|
const from = {};
|
|
85
162
|
const to = {};
|
|
86
|
-
for (const
|
|
87
|
-
const toVal = toProps[
|
|
163
|
+
for (const k of KEYS) {
|
|
164
|
+
const toVal = toProps[k];
|
|
88
165
|
if (toVal === undefined)
|
|
89
166
|
continue;
|
|
90
|
-
to[
|
|
91
|
-
|
|
167
|
+
to[k] = toVal;
|
|
168
|
+
const sourceFallback = k === 'speed' ? baseSpeed : scale;
|
|
169
|
+
from[k] = fromProps[k] ?? sourceFallback;
|
|
92
170
|
}
|
|
93
171
|
if (Object.keys(to).length > 0) {
|
|
94
172
|
animateNumeric(from, to, (updated) => {
|
|
@@ -100,44 +178,61 @@ const Clouds = ({ settings, timeSettings, }) => {
|
|
|
100
178
|
}
|
|
101
179
|
},
|
|
102
180
|
});
|
|
103
|
-
const handleMouseMove = (mouse) => {
|
|
104
|
-
if (!handlers?.onMouseMove?.enabled)
|
|
105
|
-
return;
|
|
106
|
-
if (!handlers.onMouseMove.properties.length)
|
|
107
|
-
return;
|
|
108
|
-
if (!meshRef.current)
|
|
109
|
-
return;
|
|
110
|
-
handlers.onMouseMove.properties.forEach((cfg) => {
|
|
111
|
-
const { property, propertySettings } = cfg;
|
|
112
|
-
const { min: minValue, max: maxValue, axis, sensitivity = 1, inverted = false } = propertySettings;
|
|
113
|
-
if (property === 'speed' || property === 'scale') {
|
|
114
|
-
const key = property;
|
|
115
|
-
const baseValue = settings[key];
|
|
116
|
-
if (baseValue === undefined)
|
|
117
|
-
return;
|
|
118
|
-
const interpolated = interpolateProperty(baseValue, minValue, maxValue, mouse, axis, sensitivity, inverted);
|
|
119
|
-
mouseOverrideRef.current[key] = interpolated;
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const baseValue = settings.materialSettings?.[property];
|
|
123
|
-
if (baseValue === undefined)
|
|
124
|
-
return;
|
|
125
|
-
const interpolated = interpolateProperty(baseValue, minValue, maxValue, mouse, axis, sensitivity, inverted);
|
|
126
|
-
applySingleProperty(meshRef.current.material, property, interpolated);
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
181
|
useFrame((state) => {
|
|
130
|
-
|
|
182
|
+
const mesh = meshRef.current;
|
|
183
|
+
if (!mesh || !mesh.visible || !mesh.material)
|
|
131
184
|
return;
|
|
132
|
-
const material =
|
|
185
|
+
const material = mesh.material;
|
|
133
186
|
const uniforms = material?.uniforms;
|
|
134
187
|
if (!uniforms)
|
|
135
188
|
return;
|
|
136
|
-
const
|
|
189
|
+
const now = Date.now();
|
|
190
|
+
const pointer = state.pointer;
|
|
191
|
+
// ── PER-DOMAIN ANIMATIONS ────────────────────────────────────────────────
|
|
192
|
+
const mm = settings.mouseMove;
|
|
193
|
+
// const isPerDomain = mm && ('transform' in mm || 'material' in mm || 'edges' in mm || 'light' in mm || 'clouds' in mm);
|
|
194
|
+
// transform: position / rotation / scale
|
|
195
|
+
// const transformAnims = settings.animations?.transform?.animations;
|
|
196
|
+
// if (transformAnims?.length) {
|
|
197
|
+
// handleTransformAnimations(
|
|
198
|
+
// { object: mesh, meshSettings: meshSettings as any, pathIsActive: false },
|
|
199
|
+
// transformAnims,
|
|
200
|
+
// now,
|
|
201
|
+
// false,
|
|
202
|
+
// );
|
|
203
|
+
// }
|
|
204
|
+
// // material: shader uniforms
|
|
205
|
+
// const materialAnims = settings.animations?.material?.animations;
|
|
206
|
+
// if (materialAnims?.length) {
|
|
207
|
+
// handleMaterialAnimations(
|
|
208
|
+
// { object: mesh, materialSettings: materialSettings as any, startValuesCache: materialAnimCacheRef.current },
|
|
209
|
+
// materialAnims,
|
|
210
|
+
// now,
|
|
211
|
+
// false,
|
|
212
|
+
// );
|
|
213
|
+
// }
|
|
214
|
+
// clouds: speed
|
|
215
|
+
applyCloudsKeyframeAnimations(settings.animations?.clouds?.animations, cloudsAnimCacheRef.current, config, animatedOverrideRef.current, now);
|
|
216
|
+
// ── PER-DOMAIN MOUSE-MOVE ─────────────────────────────────────────────────
|
|
217
|
+
if (mm) {
|
|
218
|
+
const perDomain = mm;
|
|
219
|
+
if (perDomain.transform?.enabled && perDomain.transform.properties?.length) {
|
|
220
|
+
handleTransformMouseMove({ object: mesh, meshSettings: meshSettings }, perDomain.transform.properties, pointer);
|
|
221
|
+
}
|
|
222
|
+
if (perDomain.material?.enabled && perDomain.material.properties?.length) {
|
|
223
|
+
handleMaterialMouseMove({ object: mesh, materialSettings: materialSettings }, perDomain.material.properties, pointer);
|
|
224
|
+
}
|
|
225
|
+
applyCloudsMouseMove(perDomain.clouds?.enabled ? perDomain.clouds.properties : undefined, config, mouseOverrideRef.current, pointer);
|
|
226
|
+
}
|
|
227
|
+
// ── EFFECTIVE SPEED + UNIFORM UPDATES ─────────────────────────────────────
|
|
228
|
+
const effectiveSpeed = animatedOverrideRef.current.speed
|
|
229
|
+
?? numericOverrideRef.current?.speed
|
|
137
230
|
?? mouseOverrideRef.current.speed
|
|
138
|
-
??
|
|
231
|
+
?? baseSpeed;
|
|
232
|
+
// console.log(effectiveSpeed)
|
|
233
|
+
// console.log(effectiveSpeed)
|
|
139
234
|
cloudAnimTime.current += 0.02 * effectiveSpeed;
|
|
140
|
-
|
|
235
|
+
// console.log(cloudAnimTime.current)
|
|
141
236
|
if (uniforms.u_time)
|
|
142
237
|
uniforms.u_time.value = cloudAnimTime.current;
|
|
143
238
|
if (uniforms.u_cameraPos) {
|
|
@@ -160,14 +255,16 @@ const Clouds = ({ settings, timeSettings, }) => {
|
|
|
160
255
|
? uniforms.u_sunPosition.value.copy(sunDirection)
|
|
161
256
|
: (uniforms.u_sunPosition.value = sunDirection.clone());
|
|
162
257
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
meshRef.current.scale.setScalar(effectiveScale);
|
|
258
|
+
// Apply scale override (sequence-driven path only — per-domain transform anims
|
|
259
|
+
// already mutate mesh.scale through handleTransformAnimations).
|
|
260
|
+
if (numericOverrideRef.current?.scale !== undefined) {
|
|
261
|
+
mesh.scale.setScalar(numericOverrideRef.current.scale);
|
|
168
262
|
}
|
|
169
263
|
});
|
|
170
|
-
|
|
171
|
-
|
|
264
|
+
return (_jsx("mesh", { ref: meshRef, name: "SkyClouds", userData: { id: '3drise-clouds' },
|
|
265
|
+
// position={[0, height, 0]}
|
|
266
|
+
// rotation={[Math.PI / 2, 0, 0]}
|
|
267
|
+
// scale={scale}
|
|
268
|
+
renderOrder: -1, frustumCulled: false, visible: visible, children: _jsx("planeGeometry", { args: [planeSize[0], planeSize[1], planeSegments, planeSegments] }) }));
|
|
172
269
|
};
|
|
173
270
|
export default Clouds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreatedObject.d.ts","sourceRoot":"","sources":["../../src/components/CreatedObject.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAO,KAAK,EAAG,qBAAqB,EAAkC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"CreatedObject.d.ts","sourceRoot":"","sources":["../../src/components/CreatedObject.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAO,KAAK,EAAG,qBAAqB,EAAkC,MAAM,wBAAwB,CAAC;AAQrG,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAWrD,UAAU,kBAAkB;IAC1B,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvE,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAElH;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA0J9C,CAAC;AAIH,eAAe,aAAa,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef, useEffect, useState, memo } from "react";
|
|
3
3
|
import { DEFAULT_EDGES_SETTINGS } from "@ntalmagor/3drize-core";
|
|
4
4
|
import { useMaterialApplication } from "../hooks/useMaterialApplication.js";
|
|
5
|
+
import { useShadowApplication } from "../hooks/useShadowApplication.js";
|
|
5
6
|
import { useTransformControls } from "../hooks/useTransformControls.js";
|
|
6
7
|
import { RigidBody } from '@react-three/rapier';
|
|
7
8
|
import { cameraManager } from "../utils/CameraSingleton.js";
|
|
@@ -25,9 +26,10 @@ const CreatedObject = memo(({ createdObject, children, shouldApply3driseMaterial
|
|
|
25
26
|
const { controllersRef } = useTransformControls();
|
|
26
27
|
const { handlePointerEnter, handlePointerLeave, hovered } = useFrameEffects(isSelected);
|
|
27
28
|
const [mountedObject, setMountedObject] = useState(null);
|
|
28
|
-
useObjectEdges(
|
|
29
|
+
useObjectEdges(createdObject.id, createdObject.edgesSettings ?? DEFAULT_EDGES_SETTINGS);
|
|
29
30
|
// useObjectGenerativeEffects(mountedObject, createdObject.effects);
|
|
30
31
|
useMaterialApplication(meshRef.current, createdObject.materialSettings, shouldApply3driseMaterial);
|
|
32
|
+
useShadowApplication(meshRef.current, createdObject.meshSettings.castShadow, createdObject.meshSettings.receiveShadow);
|
|
31
33
|
const anchoredPosition = cameraManager.getAnchorPosition(createdObject.meshSettings.anchor?.anchor || 'center', 0, createdObject.meshSettings.anchor?.offset || { y: 0, x: 0, z: 0 }, createdObject.meshSettings.anchor?.padding || 0);
|
|
32
34
|
useEffect(() => {
|
|
33
35
|
if (meshRef.current) {
|
|
@@ -68,7 +70,7 @@ const CreatedObject = memo(({ createdObject, children, shouldApply3driseMaterial
|
|
|
68
70
|
return;
|
|
69
71
|
// e.stopPropagation();
|
|
70
72
|
handlePointerEnter(e);
|
|
71
|
-
if (createdObject.
|
|
73
|
+
if (createdObject.actions?.length || createdObject.mouseMove?.enabled) {
|
|
72
74
|
document.body.style.cursor = 'pointer';
|
|
73
75
|
}
|
|
74
76
|
};
|
|
@@ -83,10 +85,6 @@ const CreatedObject = memo(({ createdObject, children, shouldApply3driseMaterial
|
|
|
83
85
|
e.stopPropagation();
|
|
84
86
|
};
|
|
85
87
|
const anchorEnabled = createdObject.meshSettings.anchor && createdObject.meshSettings.anchor.enabled;
|
|
86
|
-
// console.log("createdObject.meshSettings", createdObject.meshSettings)
|
|
87
|
-
// console.log("Rendered CreatedObject:", createdObject.rigidBodySettings);
|
|
88
|
-
const stateKey = createdObject.meshSettings.name;
|
|
89
|
-
// console.log({stateKey})
|
|
90
88
|
return (_jsx(AnimatedObject
|
|
91
89
|
// animationId={createdObject.animationId || ''}
|
|
92
90
|
, {
|
|
@@ -1,47 +1,51 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { ObjectManager
|
|
4
|
-
// import ObjectManager from "~/utils/ObjectManager";
|
|
5
|
-
import { useMaterialApplication } from "../hooks/useMaterialApplication.js";
|
|
2
|
+
import { useRef, memo } from "react";
|
|
3
|
+
import { ObjectManager } from "@ntalmagor/3drize-core";
|
|
6
4
|
import MaterialLibrary from "./MaterialLibrary.js";
|
|
7
|
-
// import type { AnimatedTransform } from "~/types/mesh";
|
|
8
|
-
import CreatedObject from "./CreatedObject.js";
|
|
9
5
|
const CustomPrimitive = memo(({ createdObject, onObjectReady, handleObjectClick, }) => {
|
|
10
6
|
// const { handleObjectClick } = useSceneClick();
|
|
11
7
|
// console.log("Rendering CustomPrimitive with settings:", createdObject.name, createdObject);
|
|
12
8
|
const meshRef = useRef(null);
|
|
13
|
-
const effectStateRef = useRef(null);
|
|
14
|
-
const [animatedTransform, setAnimatedTransform] = React.useState({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
9
|
+
// const effectStateRef = useRef<EffectState | null>(null);
|
|
10
|
+
// const [animatedTransform, setAnimatedTransform] = React.useState<AnimatedTransform>({
|
|
11
|
+
// position: createdObject.meshSettings.position,
|
|
12
|
+
// rotation: createdObject.meshSettings.rotation,
|
|
13
|
+
// scale: createdObject.meshSettings.scale,
|
|
14
|
+
// });
|
|
19
15
|
// Initialize transform controls
|
|
20
16
|
// const { handlePointerEnter, handlePointerLeave, hovered } = useFrameEffects(true);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, [createdObject.meshSettings.position, createdObject.meshSettings.rotation, createdObject.meshSettings.scale]);
|
|
17
|
+
// useEffect(() => {
|
|
18
|
+
// setAnimatedTransform({
|
|
19
|
+
// position: createdObject.meshSettings.position,
|
|
20
|
+
// rotation: createdObject.meshSettings.rotation,
|
|
21
|
+
// scale: createdObject.meshSettings.scale,
|
|
22
|
+
// });
|
|
23
|
+
// }, [createdObject.meshSettings.position, createdObject.meshSettings.rotation, createdObject.meshSettings.scale]);
|
|
28
24
|
const useDreiMaterials = createdObject.materialSettings.materialType === "advanced";
|
|
29
|
-
const apply3driseMaterials = !useDreiMaterials;
|
|
30
|
-
const willApplyMaterial = apply3driseMaterials && !!createdObject.materialSettings.materialVariant;
|
|
31
|
-
const [materialReady, setMaterialReady] = useState(!willApplyMaterial);
|
|
25
|
+
// const apply3driseMaterials = !useDreiMaterials;
|
|
26
|
+
// const willApplyMaterial = apply3driseMaterials && !!createdObject.materialSettings.materialVariant;
|
|
27
|
+
// const [materialReady, setMaterialReady] = useState(!willApplyMaterial);
|
|
32
28
|
// get initial object from ObjectManager to add to scene with primitive, then use findById to get updated reference with materials applied by useMaterialApplication
|
|
33
29
|
const obj = ObjectManager.getObject(createdObject.id);
|
|
34
|
-
const object = findById(createdObject.id);
|
|
35
|
-
useMaterialApplication(object ?? null, createdObject.materialSettings, apply3driseMaterials, () => setMaterialReady(true));
|
|
30
|
+
// const object = findById(createdObject.id);
|
|
31
|
+
// useMaterialApplication(object ?? null, createdObject.materialSettings, apply3driseMaterials, () => setMaterialReady(true));
|
|
36
32
|
if (!obj) {
|
|
37
33
|
// console.warn(`CustomPrimitive - Object with ID ${createdObject.id} not found.`);
|
|
38
34
|
return null;
|
|
39
35
|
}
|
|
40
36
|
return (
|
|
41
37
|
// <Select enabled={isSelected}>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
// <CreatedObject createdObject={createdObject}
|
|
39
|
+
// shouldApply3driseMaterial={false} // Material is owned by useMaterialApplication above (applied to obj.object directly)
|
|
40
|
+
// handleObjectClick={handleObjectClick}
|
|
41
|
+
// onObjectReady={(object, ref) => {
|
|
42
|
+
// onObjectReady && onObjectReady(object, ref);
|
|
43
|
+
// }}
|
|
44
|
+
// >
|
|
45
|
+
_jsx("primitive", { ref: meshRef, name: obj.name, object: obj.object, visible: createdObject.meshSettings.visible, position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1], children: useDreiMaterials && createdObject.type === 'mesh' && createdObject.meshSettings.visible && (_jsx(MaterialLibrary, { materialSettings: createdObject.materialSettings })) }, obj.id)
|
|
46
|
+
// {/* <LineEdges object={obj.object} />
|
|
47
|
+
// <MeshEdges object={obj.object} /> */}
|
|
48
|
+
// </CreatedObject>
|
|
45
49
|
// {/* </Select> */}
|
|
46
50
|
);
|
|
47
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EffectsGroup.d.ts","sourceRoot":"","sources":["../../src/components/EffectsGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"EffectsGroup.d.ts","sourceRoot":"","sources":["../../src/components/EffectsGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAyB,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG3F,UAAU,iBAAiB;IACzB,aAAa,EAAE,qBAAqB,CAAC;CACtC;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAU7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GEREATIVE_EFFECTS_KEY } from '@ntalmagor/3drize-core';
|
|
2
3
|
import EffectsGenerator from './EffectsGenerator.js';
|
|
3
4
|
const EffectsGroup = ({ createdObject }) => {
|
|
4
5
|
if (!createdObject.effects || createdObject.effects.length === 0)
|
|
5
6
|
return null;
|
|
6
|
-
return (_jsx("group", { name: `${createdObject.id}-effects`, children: createdObject.effects.map((effect, index) => (_jsx(EffectsGenerator, { settings: effect }, index))) }));
|
|
7
|
+
return (_jsx("group", { name: `${createdObject.id}-effects`, userData: { [GEREATIVE_EFFECTS_KEY]: true }, children: createdObject.effects.map((effect, index) => (_jsx(EffectsGenerator, { settings: effect }, index))) }));
|
|
7
8
|
};
|
|
8
9
|
export default EffectsGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Frame.d.ts","sourceRoot":"","sources":["../../src/components/Frame.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAmC,QAAQ,EAAsB,MAAM,OAAO,CAAC;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMrE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,cAAc,EAAE,qBAAqB,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,iBAAiB,CAAC,EAAE,CAClB,aAAa,EAAE,qBAAqB,EACpC,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,GAAG,EACH,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAoB,EACpB,aAAa,EACb,gBAAqB,EACrB,YAAiB,EACjB,cAAc,EACd,IAAI,EACJ,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,GAClB,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"Frame.d.ts","sourceRoot":"","sources":["../../src/components/Frame.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAmC,QAAQ,EAAsB,MAAM,OAAO,CAAC;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMrE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,cAAc,EAAE,qBAAqB,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,iBAAiB,CAAC,EAAE,CAClB,aAAa,EAAE,qBAAqB,EACpC,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,GAAG,EACH,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAoB,EACpB,aAAa,EACb,gBAAqB,EACrB,YAAiB,EACjB,cAAc,EACd,IAAI,EACJ,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,GAClB,EAAE,UAAU,kDAuFZ"}
|
package/dist/components/Frame.js
CHANGED
|
@@ -48,5 +48,7 @@ export default function Frame({ url, isActive, createdObject, position, rotation
|
|
|
48
48
|
};
|
|
49
49
|
if (!texture)
|
|
50
50
|
return null;
|
|
51
|
-
return (_jsx("mesh", { name: url, ref: frameRef, position: position, rotation: rotation, scale: scale, raycast: () => null, onPointerEnter: handlePointerEnter, onPointerLeave: handlePointerLeave, onClick: onClick,
|
|
51
|
+
return (_jsx("mesh", { name: url, ref: frameRef, position: position, rotation: rotation, scale: scale, raycast: () => null, onPointerEnter: handlePointerEnter, onPointerLeave: handlePointerLeave, onClick: onClick, userData: {
|
|
52
|
+
url,
|
|
53
|
+
}, children: children ? children : (_jsxs(_Fragment, { children: [_jsx(FrameGeometry, { shapeType: 'rectangle', layoutSettings: layoutSettings, scale: layoutSettings.outerFrameScale }), _jsx(MaterialLibrary, { materialSettings: materialSettings }), showFront && (_jsx(FrameImage, { ref: imageRef, texture: texture, shapeType: 'rectangle', position: [0, 0, 0.02] })), showBack && (_jsx(FrameImage, { texture: texture, shapeType: 'rectangle', position: [0, 0, -0.02], rotation: [0, Math.PI, 0], isBack: true }))] })) }));
|
|
52
54
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { StarsSettings } from '@ntalmagor/3drize-core';
|
|
2
|
+
import type { StarsSettings, TimeSettings } from '@ntalmagor/3drize-core';
|
|
3
3
|
export interface GalaxyProps {
|
|
4
4
|
settings: StarsSettings;
|
|
5
|
+
timeSettings?: TimeSettings;
|
|
6
|
+
sunSystemEnabled?: boolean;
|
|
5
7
|
}
|
|
6
8
|
declare const Galaxy: React.FC<GalaxyProps>;
|
|
7
9
|
export default Galaxy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Galaxy.d.ts","sourceRoot":"","sources":["../../src/components/Galaxy.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"Galaxy.d.ts","sourceRoot":"","sources":["../../src/components/Galaxy.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI1E,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAajC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import ShootingStars from './ShootingStars.js';
|
|
4
|
-
const Galaxy = ({ settings }) => {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const Galaxy = ({ settings, timeSettings, sunSystemEnabled }) => {
|
|
5
3
|
// if (!settings.visible) return null;
|
|
6
|
-
return (
|
|
4
|
+
return (_jsx(_Fragment, {}));
|
|
7
5
|
};
|
|
8
6
|
export default Galaxy;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CreatedObjectSettings } from '@ntalmagor/3drize-core';
|
|
3
|
+
type LightObjectProps = {
|
|
4
|
+
createdObject: CreatedObjectSettings;
|
|
5
|
+
};
|
|
6
|
+
declare const LightObject: React.FC<LightObjectProps>;
|
|
7
|
+
export default LightObject;
|
|
8
|
+
//# sourceMappingURL=LightObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightObject.d.ts","sourceRoot":"","sources":["../../src/components/LightObject.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAQjD,OAAO,KAAK,EAEV,qBAAqB,EAKtB,MAAM,wBAAwB,CAAC;AAKhC,KAAK,gBAAgB,GAAG;IACtB,aAAa,EAAE,qBAAqB,CAAC;CACtC,CAAC;AA8EF,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAsB3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { useThree } from '@react-three/fiber';
|
|
4
|
+
import { useLightShadow } from '../hooks/useLightShadow.js';
|
|
5
|
+
import { useLightAnimation } from '../hooks/useLightAnimation.js';
|
|
6
|
+
import { useLightMouseMove } from '../hooks/useLightMouseMove.js';
|
|
7
|
+
const DirectionalLightR3F = ({ config, animations, mouseMove }) => {
|
|
8
|
+
const lightRef = useRef(null);
|
|
9
|
+
useLightShadow(lightRef, config.shadow);
|
|
10
|
+
useLightAnimation(lightRef, animations);
|
|
11
|
+
useLightMouseMove(lightRef, mouseMove, { lightConfig: config });
|
|
12
|
+
return (_jsx("directionalLight", { ref: lightRef, color: config.color || '#ffffff', intensity: config.intensity ?? 1 }));
|
|
13
|
+
};
|
|
14
|
+
const SpotLightR3F = ({ config, animations, mouseMove }) => {
|
|
15
|
+
const { scene } = useThree();
|
|
16
|
+
const lightRef = useRef(null);
|
|
17
|
+
const targetRef = useRef(null);
|
|
18
|
+
const [tx, ty, tz] = config.targetPosition ?? [0, 0, 0];
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const light = lightRef.current;
|
|
21
|
+
if (!light)
|
|
22
|
+
return;
|
|
23
|
+
if (!targetRef.current) {
|
|
24
|
+
targetRef.current = light.target;
|
|
25
|
+
scene.add(targetRef.current);
|
|
26
|
+
}
|
|
27
|
+
targetRef.current.position.set(tx, ty, tz);
|
|
28
|
+
targetRef.current.updateMatrixWorld();
|
|
29
|
+
return () => {
|
|
30
|
+
if (targetRef.current) {
|
|
31
|
+
scene.remove(targetRef.current);
|
|
32
|
+
targetRef.current = null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, [scene, tx, ty, tz]);
|
|
36
|
+
useLightShadow(lightRef, config.shadow);
|
|
37
|
+
useLightAnimation(lightRef, animations);
|
|
38
|
+
useLightMouseMove(lightRef, mouseMove, { lightConfig: config });
|
|
39
|
+
return (_jsx("spotLight", { ref: lightRef, color: config.color || '#ffffff', intensity: config.intensity ?? 1, angle: config.angle ?? Math.PI / 4, penumbra: config.penumbra ?? 0.1, decay: config.decay ?? 1, distance: config.distance ?? 0 }));
|
|
40
|
+
};
|
|
41
|
+
const PointLightR3F = ({ config, animations, mouseMove }) => {
|
|
42
|
+
const lightRef = useRef(null);
|
|
43
|
+
useLightShadow(lightRef, config.shadow);
|
|
44
|
+
useLightAnimation(lightRef, animations);
|
|
45
|
+
useLightMouseMove(lightRef, mouseMove, { lightConfig: config });
|
|
46
|
+
return (_jsx("pointLight", { ref: lightRef, color: config.color || '#ffffff', intensity: config.intensity ?? 1, decay: config.decay ?? 1, distance: config.distance ?? 0 }));
|
|
47
|
+
};
|
|
48
|
+
const LightObject = ({ createdObject }) => {
|
|
49
|
+
const config = createdObject.config;
|
|
50
|
+
if (!config || config.enabled === false)
|
|
51
|
+
return null;
|
|
52
|
+
const animations = createdObject.animations?.light?.animations;
|
|
53
|
+
const mouseMove = createdObject.mouseMove?.light;
|
|
54
|
+
switch (config.type) {
|
|
55
|
+
case 'directional':
|
|
56
|
+
return _jsx(DirectionalLightR3F, { config: config, animations: animations, mouseMove: mouseMove });
|
|
57
|
+
case 'spot':
|
|
58
|
+
return _jsx(SpotLightR3F, { config: config, animations: animations, mouseMove: mouseMove });
|
|
59
|
+
case 'point':
|
|
60
|
+
return _jsx(PointLightR3F, { config: config, animations: animations, mouseMove: mouseMove });
|
|
61
|
+
default:
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export default LightObject;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SceneLightConfig } from '@ntalmagor/3drize-core';
|
|
3
3
|
export interface LightsManagerProps {
|
|
4
|
-
|
|
5
|
-
selectedLight?: string | null;
|
|
4
|
+
config: SceneLightConfig;
|
|
6
5
|
}
|
|
7
6
|
declare const LightsManager: React.FC<LightsManagerProps>;
|
|
8
7
|
export default LightsManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightsManager.d.ts","sourceRoot":"","sources":["../../src/components/LightsManager.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LightsManager.d.ts","sourceRoot":"","sources":["../../src/components/LightsManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAS/D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAID,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA4H/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
|