@ntalmagor/3drize-viewer 0.1.24 → 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/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 +0 -4
- package/dist/components/Frame.d.ts.map +1 -1
- package/dist/components/Frame.js +3 -1
- package/dist/components/Galaxy.js +2 -4
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +34 -14
- package/dist/components/ObjectsRenderer.d.ts.map +1 -1
- package/dist/components/ObjectsRenderer.js +2 -0
- 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/SkySystem.js +1 -4
- package/dist/components/Skybox.d.ts.map +1 -1
- package/dist/components/Skybox.js +5 -1
- package/dist/components/Stars.d.ts +2 -2
- package/dist/components/Stars.d.ts.map +1 -1
- package/dist/components/Stars.js +25 -26
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- 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/useMaterialApplication.js +1 -1
- package/dist/hooks/useMaterialOptions.d.ts.map +1 -1
- package/dist/hooks/useMaterialOptions.js +2 -0
- package/dist/hooks/useParticlesTextures.js +1 -1
- 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/package.json +2 -2
|
@@ -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;AAQrG,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;A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0J9C,CAAC;AAIH,eAAe,aAAa,CAAC"}
|
|
@@ -85,10 +85,6 @@ const CreatedObject = memo(({ createdObject, children, shouldApply3driseMaterial
|
|
|
85
85
|
e.stopPropagation();
|
|
86
86
|
};
|
|
87
87
|
const anchorEnabled = createdObject.meshSettings.anchor && createdObject.meshSettings.anchor.enabled;
|
|
88
|
-
// console.log("createdObject.meshSettings", createdObject.meshSettings)
|
|
89
|
-
// console.log("Rendered CreatedObject:", createdObject.rigidBodySettings);
|
|
90
|
-
const stateKey = createdObject.meshSettings.name;
|
|
91
|
-
// console.log({stateKey})
|
|
92
88
|
return (_jsx(AnimatedObject
|
|
93
89
|
// animationId={createdObject.animationId || ''}
|
|
94
90
|
, {
|
|
@@ -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,C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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,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Stars from './Stars.js';
|
|
3
|
-
import ShootingStars from './ShootingStars.js';
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
4
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectNode.d.ts","sourceRoot":"","sources":["../../src/components/ObjectNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAA6D,cAAc,
|
|
1
|
+
{"version":3,"file":"ObjectNode.d.ts","sourceRoot":"","sources":["../../src/components/ObjectNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAA6D,cAAc,EAAyC,MAAM,wBAAwB,CAAC;AAEnM,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAiBrD,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;IAC5B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvE,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC7G,CAAC;AA+CF,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA0JzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
3
|
import CustomPrimitive from "./CustomPrimitive.js";
|
|
4
4
|
import CreatedObject from "./CreatedObject.js";
|
|
@@ -11,7 +11,18 @@ import ParticlesR3f from "./ParticlesR3f.js";
|
|
|
11
11
|
import Lines from "./Lines.js";
|
|
12
12
|
import GridHelper from "./GridHelper.js";
|
|
13
13
|
import LightObject from "./LightObject.js";
|
|
14
|
-
|
|
14
|
+
import Ocean from "./Ocean.js";
|
|
15
|
+
import Stars from "./Stars.js";
|
|
16
|
+
import Clouds from "./Clouds.js";
|
|
17
|
+
import Rain from "./Rain.js";
|
|
18
|
+
// const EffectsLayer: React.FC<{ effects: CreatedObjectSettings['effects'] }> = ({ effects }) =>
|
|
19
|
+
// effects?.length ? (
|
|
20
|
+
// <>
|
|
21
|
+
// {effects.map((effect, index) => (
|
|
22
|
+
// <EffectsGenerator key={index} settings={effect} />
|
|
23
|
+
// ))}
|
|
24
|
+
// </>
|
|
25
|
+
// ) : null;
|
|
15
26
|
const GroupWithChildren = ({ createdObject, children, cameraSettings, onObjectReady, handleObjectClick, renderObject }) => {
|
|
16
27
|
const isGroup = createdObject.type === 'group';
|
|
17
28
|
return (_jsxs(CreatedObject, { createdObject: createdObject, onObjectReady: onObjectReady, handleObjectClick: handleObjectClick, shouldApply3driseMaterial: !isGroup, children: [!isGroup && renderObject(createdObject, handleObjectClick), children.map(childNode => (_jsx(ObjectNode, { node: childNode, cameraSettings: cameraSettings, handleObjectClick: handleObjectClick, onObjectReady: onObjectReady }, childNode.objectId)))] }, createdObject.id));
|
|
@@ -22,8 +33,11 @@ const ObjectNode = ({ node, cameraSettings, onObjectReady, handleObjectClick })
|
|
|
22
33
|
// Specialized renderers for each object type
|
|
23
34
|
const renderers = useMemo(() => ({
|
|
24
35
|
group: () => null,
|
|
25
|
-
mesh: (obj, cameraSettings, onObjectReady) => (_jsx(
|
|
26
|
-
|
|
36
|
+
mesh: (obj, cameraSettings, onObjectReady) => (_jsx(CustomPrimitive, { createdObject: obj, onObjectReady: onObjectReady, handleObjectClick: handleObjectClick }, obj.id)),
|
|
37
|
+
water: (obj, cameraSettings, onObjectReady) => (_jsx(Ocean, { settings: obj })),
|
|
38
|
+
stars: (obj, cameraSettings, onObjectReady) => (_jsx(Stars, { settings: obj })),
|
|
39
|
+
clouds: (obj, cameraSettings, onObjectReady) => (_jsx(Clouds, { settings: obj })),
|
|
40
|
+
model: (obj, cameraSettings, onObjectReady) => (_jsx(CustomPrimitive, { createdObject: obj, onObjectReady: onObjectReady, handleObjectClick: handleObjectClick }, obj.id)),
|
|
27
41
|
// custom_primitive: (obj: CreatedObjectSettings, cameraSettings: CameraState, onObjectReady?: (object: CreatedObjectSettings, ref: Object3D) => void) => (
|
|
28
42
|
// <CustomPrimitive
|
|
29
43
|
// key={obj.id}
|
|
@@ -34,22 +48,23 @@ const ObjectNode = ({ node, cameraSettings, onObjectReady, handleObjectClick })
|
|
|
34
48
|
// ),
|
|
35
49
|
text: (obj, cameraSettings, onObjectReady) => {
|
|
36
50
|
const renderMode = obj.config?.renderMode ?? 'bitmap';
|
|
37
|
-
return (_jsx(
|
|
51
|
+
return (_jsx(_Fragment, { children: renderMode === 'text3d'
|
|
38
52
|
? _jsx(Text3D, { textSettings: obj })
|
|
39
|
-
: _jsx(Text2D, { textSettings: obj }) }
|
|
53
|
+
: _jsx(Text2D, { textSettings: obj }) }));
|
|
40
54
|
},
|
|
41
55
|
particles: (obj, cameraSettings, onObjectReady) => {
|
|
42
56
|
const particlesSettings = obj;
|
|
43
|
-
return (_jsxs(
|
|
57
|
+
return (_jsxs(_Fragment, { children: [particlesSettings.config?.particles && (_jsx(ParticlesR3f, { particlesSettings: particlesSettings, cameraFov: cameraSettings.fov, duration: 1, transitionSettings: particlesSettings.meshSettings })), particlesSettings.config?.paths && (_jsx(Lines, { createdObject: particlesSettings }))] }));
|
|
44
58
|
},
|
|
45
|
-
path: (obj, cameraSettings, onObjectReady) => (_jsx(
|
|
46
|
-
grid: (obj, cameraSettings, onObjectReady) => (_jsx(
|
|
59
|
+
path: (obj, cameraSettings, onObjectReady) => (_jsx(PathRenderer, { pathSettings: obj.config, showCurve: false, showLine: false, showPoints: false }, obj.id)),
|
|
60
|
+
grid: (obj, cameraSettings, onObjectReady) => (_jsx(GridHelper, { ...obj.config })),
|
|
47
61
|
effect: (obj) => (_jsx(EffectsGenerator, { settings: {
|
|
48
62
|
enabled: true,
|
|
49
63
|
config: obj.config,
|
|
50
64
|
} }, obj.id)),
|
|
51
|
-
gallery: (obj, cameraSettings, onObjectReady) => (_jsx(
|
|
52
|
-
light: (obj, cameraSettings, onObjectReady) => (_jsx(
|
|
65
|
+
gallery: (obj, cameraSettings, onObjectReady) => (_jsx(GalleryLayout, { createdObject: obj, handleObjectClick: handleObjectClick })),
|
|
66
|
+
light: (obj, cameraSettings, onObjectReady) => (_jsx(LightObject, { createdObject: obj })),
|
|
67
|
+
rain: (obj, cameraSettings, onObjectReady) => (_jsx(Rain, { settings: obj })),
|
|
53
68
|
}), [handleObjectClick]);
|
|
54
69
|
if (!createdObject) {
|
|
55
70
|
console.warn(`createdObject not found.`);
|
|
@@ -59,14 +74,19 @@ const ObjectNode = ({ node, cameraSettings, onObjectReady, handleObjectClick })
|
|
|
59
74
|
const hasChildren = children.length > 0;
|
|
60
75
|
const shouldRenderAsGroup = hasChildren || createdObject.type === 'group' || createdObject.type === 'effect';
|
|
61
76
|
const renderObject = useCallback((obj, handleObjectClick) => {
|
|
77
|
+
console.log('Rendering object:', obj);
|
|
62
78
|
const renderer = renderers[obj.type];
|
|
63
79
|
return renderer?.(obj, cameraSettings, onObjectReady) ?? null;
|
|
64
80
|
}, [cameraSettings, onObjectReady, renderers]);
|
|
65
81
|
const renderedObject = shouldRenderAsGroup
|
|
66
82
|
? _jsx(GroupWithChildren, { createdObject: createdObject, children: children, cameraSettings: cameraSettings, onObjectReady: onObjectReady, handleObjectClick: handleObjectClick, renderObject: renderObject })
|
|
67
|
-
: createdObject.
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
: _jsx(CreatedObject, { createdObject: createdObject, onObjectReady: onObjectReady, handleObjectClick: handleObjectClick, children: renderObject(createdObject) }, createdObject.id);
|
|
84
|
+
// createdObject.effects
|
|
85
|
+
// ? <>
|
|
86
|
+
// {renderObject(createdObject)}
|
|
87
|
+
// {/* <EffectsLayer effects={createdObject.effects} /> */}
|
|
88
|
+
// </>
|
|
89
|
+
// : renderObject(createdObject);
|
|
70
90
|
return renderedObject;
|
|
71
91
|
};
|
|
72
92
|
export default ObjectNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectsRenderer.d.ts","sourceRoot":"","sources":["../../src/components/ObjectsRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO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KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC1G,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA8DlD,CAAC;AAIH,eAAe,eAAe,CAAC"}
|
|
@@ -24,6 +24,8 @@ const ObjectsRenderer = memo(({ cameraSettings, createdObjects, generalObjectSet
|
|
|
24
24
|
sequences,
|
|
25
25
|
});
|
|
26
26
|
const handleObjectClickHandler = (createdObject, ref, event) => {
|
|
27
|
+
console.log('Object clicked:', createdObject.meshSettings.name);
|
|
28
|
+
console.log('Object ref:', ref);
|
|
27
29
|
const clickInteractions = filterInteractionsByEvent(createdObject.actions, "click");
|
|
28
30
|
clickInteractions.forEach((interaction) => {
|
|
29
31
|
executeInteraction({ interaction, ref, createdObject });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { CreatedObjectSettings } from '@ntalmagor/3drize-core';
|
|
3
3
|
export interface OceanProps {
|
|
4
|
-
settings:
|
|
4
|
+
settings: CreatedObjectSettings;
|
|
5
5
|
}
|
|
6
6
|
declare const Ocean: React.FC<OceanProps>;
|
|
7
7
|
export default Ocean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ocean.d.ts","sourceRoot":"","sources":["../../src/components/Ocean.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Ocean.d.ts","sourceRoot":"","sources":["../../src/components/Ocean.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAQhD,OAAO,EAQL,qBAAqB,EAEtB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,qBAAqB,CAAC;CACjC;AAED,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAqL/B,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/dist/components/Ocean.js
CHANGED
|
@@ -5,28 +5,32 @@ import { useFrame } from '@react-three/fiber';
|
|
|
5
5
|
import { useMaterialApplication } from '../hooks/useMaterialApplication.js';
|
|
6
6
|
import { useWaterEnvironment } from '../hooks/useWaterEnvironment.js';
|
|
7
7
|
import { useWaterReflections } from '../hooks/useWaterReflections.js';
|
|
8
|
-
import { useMouseHandlers } from '../hooks/useMouseHandlers.js';
|
|
9
8
|
import { useAnimationEvents } from '../hooks/useAnimationEvents.js';
|
|
10
9
|
import { useNumericAnimation } from '../hooks/useNumericAnimation.js';
|
|
11
|
-
import {
|
|
10
|
+
import { handleTransformAnimations, handleMaterialAnimations, handleTransformMouseMove, handleMaterialMouseMove, } from '@ntalmagor/3drize-core';
|
|
12
11
|
const Ocean = ({ settings }) => {
|
|
13
12
|
const meshRef = useRef(null);
|
|
14
13
|
const uniformOverrideRef = useRef(null);
|
|
14
|
+
const matAnimCacheRef = useRef({});
|
|
15
15
|
const [meshVisible, setMeshVisible] = useState(null);
|
|
16
|
+
const { meshSettings, materialSettings, animations, mouseMove } = settings;
|
|
16
17
|
const { animateNumeric } = useNumericAnimation();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const config = settings.config || {
|
|
19
|
+
planeSize: [10000, 10000],
|
|
20
|
+
planeSegments: 64,
|
|
21
|
+
};
|
|
22
|
+
const planeSize = config?.planeSize || [10000, 10000];
|
|
23
|
+
const planeSegments = config?.planeSegments || 64;
|
|
24
|
+
const position = meshSettings.position || [0, -1, 0];
|
|
25
|
+
const rotation = meshSettings.rotation || [-Math.PI / 2, 0, 0];
|
|
26
|
+
const scale = meshSettings.scale || 1;
|
|
27
|
+
useMaterialApplication(meshSettings.visible ? meshRef.current : null, materialSettings);
|
|
28
|
+
useWaterEnvironment(meshSettings.visible ? meshRef : { current: null });
|
|
29
|
+
useWaterReflections(meshSettings.visible ? meshRef : { current: null }, {
|
|
26
30
|
waterPosition: new THREE.Vector3(...position),
|
|
27
31
|
resolution: 256,
|
|
28
32
|
updateFrequency: 1,
|
|
29
|
-
enabled:
|
|
33
|
+
enabled: meshSettings.visible,
|
|
30
34
|
});
|
|
31
35
|
useAnimationEvents({
|
|
32
36
|
onStepStart: (event) => {
|
|
@@ -90,26 +94,11 @@ const Ocean = ({ settings }) => {
|
|
|
90
94
|
}
|
|
91
95
|
},
|
|
92
96
|
});
|
|
93
|
-
const handleMouseMove = (mouse) => {
|
|
94
|
-
// Mouse-move property handlers
|
|
95
|
-
if (handlers?.onMouseMove?.enabled && handlers.onMouseMove.properties.length && meshRef.current) {
|
|
96
|
-
handlers.onMouseMove.properties.forEach((props) => {
|
|
97
|
-
const { property, propertySettings } = props;
|
|
98
|
-
const { min: minValue, max: maxValue, axis, sensitivity = 1, inverted = false } = propertySettings;
|
|
99
|
-
const baseValue = settings.materialSettings[property];
|
|
100
|
-
if (!baseValue)
|
|
101
|
-
return;
|
|
102
|
-
const interpolatedValue = interpolateProperty(baseValue, minValue, maxValue, mouse, axis, sensitivity, inverted);
|
|
103
|
-
if (meshRef.current) {
|
|
104
|
-
applySingleProperty(meshRef.current.material, property, interpolatedValue);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
97
|
useFrame((state) => {
|
|
110
|
-
|
|
98
|
+
const mesh = meshRef.current;
|
|
99
|
+
if (!mesh?.material || !(meshVisible ?? meshSettings.visible))
|
|
111
100
|
return;
|
|
112
|
-
const material =
|
|
101
|
+
const material = mesh.material;
|
|
113
102
|
const uniforms = material?.uniforms;
|
|
114
103
|
if (!uniforms)
|
|
115
104
|
return;
|
|
@@ -123,10 +112,7 @@ const Ocean = ({ settings }) => {
|
|
|
123
112
|
uniforms.u_resolution.value.set(window.innerWidth, window.innerHeight);
|
|
124
113
|
if (uniforms.u_mouse)
|
|
125
114
|
uniforms.u_mouse.value.set(mouse.x, mouse.y);
|
|
126
|
-
//
|
|
127
|
-
// update3driseShaderUniforms(uniforms, settings.effects, u_time, mouse);
|
|
128
|
-
// }
|
|
129
|
-
// Apply animated uniform overrides
|
|
115
|
+
// Sequence-driven uniform overrides
|
|
130
116
|
if (uniformOverrideRef.current) {
|
|
131
117
|
for (const [key, val] of Object.entries(uniformOverrideRef.current)) {
|
|
132
118
|
if (!uniforms[key])
|
|
@@ -148,8 +134,36 @@ const Ocean = ({ settings }) => {
|
|
|
148
134
|
}
|
|
149
135
|
}
|
|
150
136
|
}
|
|
151
|
-
|
|
137
|
+
// ── PER-DOMAIN ANIMATIONS ───────────────────────────────────────────────
|
|
138
|
+
const now = Date.now();
|
|
139
|
+
const transformAnims = animations?.transform?.animations;
|
|
140
|
+
if (transformAnims?.length) {
|
|
141
|
+
handleTransformAnimations({ object: mesh, meshSettings: meshSettings, pathIsActive: false }, transformAnims, now, false);
|
|
142
|
+
}
|
|
143
|
+
const materialAnims = animations?.material?.animations;
|
|
144
|
+
if (materialAnims?.length) {
|
|
145
|
+
handleMaterialAnimations({ object: mesh, materialSettings: materialSettings, startValuesCache: matAnimCacheRef.current }, materialAnims, now, false);
|
|
146
|
+
}
|
|
147
|
+
// ── PER-DOMAIN MOUSE-MOVE ───────────────────────────────────────────────
|
|
148
|
+
const mm = mouseMove;
|
|
149
|
+
const isPerDomain = mm && ('transform' in mm || 'material' in mm);
|
|
150
|
+
if (isPerDomain) {
|
|
151
|
+
const md = mm;
|
|
152
|
+
if (md.transform?.enabled && md.transform.properties?.length) {
|
|
153
|
+
handleTransformMouseMove({ object: mesh, meshSettings: meshSettings }, md.transform.properties, mouse);
|
|
154
|
+
}
|
|
155
|
+
if (md.material?.enabled && md.material.properties?.length) {
|
|
156
|
+
handleMaterialMouseMove({ object: mesh, materialSettings: materialSettings }, md.material.properties, mouse);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
152
159
|
});
|
|
153
|
-
|
|
160
|
+
console.log(rotation);
|
|
161
|
+
return (_jsx("mesh", { ref: meshRef,
|
|
162
|
+
// name={settings.meshSettings.name || 'Water'}
|
|
163
|
+
// position={position}
|
|
164
|
+
// rotation={rotation}
|
|
165
|
+
// scale={scale}
|
|
166
|
+
// visible={meshVisible ?? meshSettings.visible}
|
|
167
|
+
userData: { id: '3drise-water' }, children: _jsx("planeGeometry", { args: [planeSize[0], planeSize[1], planeSegments, planeSegments] }) }));
|
|
154
168
|
};
|
|
155
169
|
export default Ocean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParticlesR3f.d.ts","sourceRoot":"","sources":["../../src/components/ParticlesR3f.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,wBAAwB,CAAC;AAQ7F,UAAU,iBAAiB;IACzB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C;AAMD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ParticlesR3f.d.ts","sourceRoot":"","sources":["../../src/components/ParticlesR3f.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,wBAAwB,CAAC;AAQ7F,UAAU,iBAAiB;IACzB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C;AAMD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA0J7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|