@3driseai/3drise-viewer 0.1.4 → 0.1.6
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/README.md +225 -0
- package/dist/components/AdvancedGrid.d.ts +16 -0
- package/dist/components/AdvancedGrid.d.ts.map +1 -0
- package/dist/components/AdvancedGrid.js +63 -0
- package/dist/components/AnimatedObject.d.ts.map +1 -1
- package/dist/components/AnimatedObject.js +6 -4
- package/dist/components/CameraController.d.ts.map +1 -1
- package/dist/components/CameraController.js +0 -6
- package/dist/components/CircuitGrid.d.ts +22 -0
- package/dist/components/CircuitGrid.d.ts.map +1 -0
- package/dist/components/CircuitGrid.js +69 -0
- package/dist/components/Clouds.d.ts.map +1 -1
- package/dist/components/Clouds.js +0 -5
- package/dist/components/ContourGrid.d.ts +25 -0
- package/dist/components/ContourGrid.d.ts.map +1 -0
- package/dist/components/ContourGrid.js +74 -0
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +3 -6
- package/dist/components/CustomPrimitive.d.ts.map +1 -1
- package/dist/components/CustomPrimitive.js +0 -5
- package/dist/components/EffectsGenerator.d.ts.map +1 -1
- package/dist/components/EffectsGenerator.js +0 -2
- package/dist/components/EffectsGroup.d.ts +6 -0
- package/dist/components/EffectsGroup.d.ts.map +1 -1
- package/dist/components/EffectsGroup.js +14 -4
- package/dist/components/FractalGrid.d.ts +23 -0
- package/dist/components/FractalGrid.d.ts.map +1 -0
- package/dist/components/FractalGrid.js +72 -0
- package/dist/components/Frame.d.ts.map +1 -1
- package/dist/components/Frame.js +2 -3
- package/dist/components/GalleryLayout.d.ts.map +1 -1
- package/dist/components/GalleryLayout.js +0 -3
- package/dist/components/GeometryShape.d.ts.map +1 -1
- package/dist/components/GeometryShape.js +0 -4
- package/dist/components/Glyphs.d.ts.map +1 -1
- package/dist/components/Glyphs.js +0 -1
- package/dist/components/GridsGenerator.d.ts +4 -1
- package/dist/components/GridsGenerator.d.ts.map +1 -1
- package/dist/components/GridsGenerator.js +28 -4
- package/dist/components/HdrPlaylistRenderer.d.ts.map +1 -1
- package/dist/components/HdrPlaylistRenderer.js +0 -1
- package/dist/components/HexGrid.d.ts +25 -0
- package/dist/components/HexGrid.d.ts.map +1 -0
- package/dist/components/HexGrid.js +72 -0
- package/dist/components/ImageGeometry.js +1 -1
- package/dist/components/Letter.d.ts.map +1 -1
- package/dist/components/Letter.js +1 -6
- package/dist/components/MoireGrid.d.ts +23 -0
- package/dist/components/MoireGrid.d.ts.map +1 -0
- package/dist/components/MoireGrid.js +76 -0
- package/dist/components/Moon.d.ts.map +1 -1
- package/dist/components/Moon.js +0 -1
- package/dist/components/ObjectNode.d.ts +1 -2
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +17 -20
- package/dist/components/ObjectNodeApi.d.ts +1 -2
- package/dist/components/ObjectNodeApi.d.ts.map +1 -1
- package/dist/components/ObjectNodeApi.js +7 -3
- package/dist/components/ObjectsRenderer.d.ts.map +1 -1
- package/dist/components/ObjectsRenderer.js +1 -4
- package/dist/components/ObjectsRendererApi.d.ts.map +1 -1
- package/dist/components/ObjectsRendererApi.js +4 -2
- package/dist/components/Ocean.d.ts.map +1 -1
- package/dist/components/Ocean.js +1 -4
- package/dist/components/ParticlesR3f.d.ts +0 -1
- package/dist/components/ParticlesR3f.d.ts.map +1 -1
- package/dist/components/PathRenderer.d.ts.map +1 -1
- package/dist/components/PathRenderer.js +0 -1
- package/dist/components/ProjectLoader.d.ts.map +1 -1
- package/dist/components/ProjectLoader.js +0 -28
- package/dist/components/QuasiGrid.d.ts +22 -0
- package/dist/components/QuasiGrid.d.ts.map +1 -0
- package/dist/components/QuasiGrid.js +68 -0
- package/dist/components/RadarGrid.d.ts +24 -0
- package/dist/components/RadarGrid.d.ts.map +1 -0
- package/dist/components/RadarGrid.js +71 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +0 -1
- package/dist/components/ShootingStar.js +2 -2
- package/dist/components/ShootingStars.d.ts.map +1 -1
- package/dist/components/ShootingStars.js +0 -1
- package/dist/components/SkyController.d.ts.map +1 -1
- package/dist/components/SkyController.js +0 -3
- package/dist/components/Skybox.d.ts +5 -0
- package/dist/components/Skybox.d.ts.map +1 -1
- package/dist/components/Skybox.js +0 -1
- package/dist/components/SparklesBurst.d.ts.map +1 -1
- package/dist/components/SparklesBurst.js +0 -1
- package/dist/components/VoronoiGrid.d.ts +21 -0
- package/dist/components/VoronoiGrid.d.ts.map +1 -0
- package/dist/components/VoronoiGrid.js +67 -0
- package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -1
- package/dist/components/effects/ShockwaveEffect.js +0 -1
- package/dist/components/effects/SmokeRibbon.d.ts.map +1 -1
- package/dist/components/effects/SmokeRibbon.js +0 -1
- package/dist/components/index.d.ts +19 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +9 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -1
- package/dist/hooks/index.d.ts +4 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/use3driseShader.d.ts.map +1 -1
- package/dist/hooks/use3driseShader.js +0 -9
- package/dist/hooks/useAnimationEvents.d.ts.map +1 -1
- package/dist/hooks/useAnimationEvents.js +0 -19
- package/dist/hooks/useCameraAnimation.d.ts.map +1 -1
- package/dist/hooks/useCameraAnimation.js +0 -5
- package/dist/hooks/useContinuousEffects.d.ts +2 -3
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.js +16 -61
- package/dist/hooks/useFrameAnimations.d.ts.map +1 -1
- package/dist/hooks/useFrameAnimations.js +0 -4
- package/dist/hooks/useGridSurface.d.ts +46 -0
- package/dist/hooks/useGridSurface.d.ts.map +1 -0
- package/dist/hooks/useGridSurface.js +66 -0
- package/dist/hooks/useGsapAnimation.d.ts.map +1 -1
- package/dist/hooks/useGsapAnimation.js +0 -3
- package/dist/hooks/useInteraction.d.ts.map +1 -1
- package/dist/hooks/useInteraction.js +0 -25
- package/dist/hooks/useInteractionEffects.d.ts +2 -2
- package/dist/hooks/useInteractionEffects.d.ts.map +1 -1
- package/dist/hooks/useInteractionEffects.js +3 -1
- package/dist/hooks/useMaterialApplication.d.ts +2 -2
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +7 -18
- package/dist/hooks/useMaterialOptions.d.ts.map +1 -1
- package/dist/hooks/useMaterialOptions.js +0 -6
- package/dist/hooks/useMeshController.d.ts.map +1 -1
- package/dist/hooks/useMeshController.js +0 -16
- package/dist/hooks/useObjectAnimation.d.ts +13 -2
- package/dist/hooks/useObjectAnimation.d.ts.map +1 -1
- package/dist/hooks/useObjectAnimation.js +26 -28
- package/dist/hooks/useObjectEdges.d.ts +2 -1
- package/dist/hooks/useObjectEdges.d.ts.map +1 -1
- package/dist/hooks/useObjectEdges.js +15 -3
- package/dist/hooks/useObjectEffects.d.ts.map +1 -1
- package/dist/hooks/useObjectEffects.js +0 -4
- package/dist/hooks/useRegisterScene.d.ts +17 -0
- package/dist/hooks/useRegisterScene.d.ts.map +1 -0
- package/dist/hooks/useRegisterScene.js +33 -0
- package/dist/hooks/useSequenceAnimation.d.ts +2 -2
- package/dist/hooks/useSequenceAnimation.d.ts.map +1 -1
- package/dist/hooks/useSequenceAnimation.js +5 -70
- package/dist/hooks/useShadowApplication.d.ts +2 -2
- package/dist/hooks/useShadowApplication.d.ts.map +1 -1
- package/dist/hooks/useShadowApplication.js +6 -2
- package/dist/hooks/useSkyAnimation.d.ts.map +1 -1
- package/dist/hooks/useSkyAnimation.js +0 -1
- package/dist/hooks/useSkySystem.d.ts.map +1 -1
- package/dist/hooks/useSkySystem.js +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/services/AnimationsManager.d.ts.map +1 -1
- package/dist/services/AnimationsManager.js +0 -1
- package/dist/shaders/CircuitGridMaterial.d.ts +76 -0
- package/dist/shaders/CircuitGridMaterial.d.ts.map +1 -0
- package/dist/shaders/CircuitGridMaterial.js +298 -0
- package/dist/shaders/ContourGridMaterial.d.ts +80 -0
- package/dist/shaders/ContourGridMaterial.d.ts.map +1 -0
- package/dist/shaders/ContourGridMaterial.js +259 -0
- package/dist/shaders/FractalGridMaterial.d.ts +76 -0
- package/dist/shaders/FractalGridMaterial.d.ts.map +1 -0
- package/dist/shaders/FractalGridMaterial.js +247 -0
- package/dist/shaders/HexGridMaterial.d.ts +73 -0
- package/dist/shaders/HexGridMaterial.d.ts.map +1 -0
- package/dist/shaders/HexGridMaterial.js +265 -0
- package/dist/shaders/MoireGridMaterial.d.ts +79 -0
- package/dist/shaders/MoireGridMaterial.d.ts.map +1 -0
- package/dist/shaders/MoireGridMaterial.js +271 -0
- package/dist/shaders/QuasiGridMaterial.d.ts +76 -0
- package/dist/shaders/QuasiGridMaterial.d.ts.map +1 -0
- package/dist/shaders/QuasiGridMaterial.js +238 -0
- package/dist/shaders/RadarGridMaterial.d.ts +77 -0
- package/dist/shaders/RadarGridMaterial.d.ts.map +1 -0
- package/dist/shaders/RadarGridMaterial.js +291 -0
- package/dist/shaders/VoronoiGridMaterial.d.ts +73 -0
- package/dist/shaders/VoronoiGridMaterial.d.ts.map +1 -0
- package/dist/shaders/VoronoiGridMaterial.js +266 -0
- package/dist/types/gridConfigs.d.ts +202 -0
- package/dist/types/gridConfigs.d.ts.map +1 -0
- package/dist/types/gridConfigs.js +11 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/handleGenerativeEffectsAnimations.d.ts +0 -1
- package/dist/utils/handleGenerativeEffectsAnimations.d.ts.map +1 -1
- package/dist/utils/handleGenerativeEffectsAnimations.js +0 -29
- package/dist/utils/resolveObject3D.d.ts +20 -0
- package/dist/utils/resolveObject3D.d.ts.map +1 -0
- package/dist/utils/resolveObject3D.js +9 -0
- package/dist/utils/shapes.d.ts.map +1 -1
- package/dist/utils/shapes.js +0 -1
- package/package.json +4 -4
|
@@ -4,12 +4,7 @@ import { AnimationsManager, findById } from '@3driseai/3drise-core';
|
|
|
4
4
|
import { useAnimationEvents } from './useAnimationEvents.js';
|
|
5
5
|
import { usePathAnimation } from './usePathAnimation.js';
|
|
6
6
|
import { snapshotMaterialValues, interpolateMaterialProps } from '../utils/materialUtils.js';
|
|
7
|
-
|
|
8
|
-
const debugLog = (...args) => {
|
|
9
|
-
if (DEBUG_SEQUENCE_ANIMATION) {
|
|
10
|
-
console.log('[useSequenceAnimation]', ...args);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
7
|
+
import { resolveObject3D } from '../utils/resolveObject3D.js';
|
|
13
8
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
14
9
|
// Helpers
|
|
15
10
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -39,15 +34,12 @@ function extractMaterialProps(props) {
|
|
|
39
34
|
* Designed to be called inside useObjectAnimation so that AnimatedObject stays
|
|
40
35
|
* a thin group wrapper.
|
|
41
36
|
*/
|
|
42
|
-
export const useSequenceAnimation = (objectId,
|
|
37
|
+
export const useSequenceAnimation = (objectId, objectSource) => {
|
|
43
38
|
const { startPathAnimation, updatePathAnimation, stopPathAnimation, isAnimating: isPathAnimating } = usePathAnimation();
|
|
44
39
|
const resolveObject = () => {
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
// hasRefArg: !!objectRef,
|
|
49
|
-
// resolved: resolved ? { name: resolved.name, id: resolved.userData?.id } : null,
|
|
50
|
-
// });
|
|
40
|
+
// Called from the frame loop, so a ref resolves as soon as React
|
|
41
|
+
// attaches it. findById stays as a fallback for id-only callers.
|
|
42
|
+
const resolved = resolveObject3D(objectSource) ?? (objectId ? findById(objectId) : null);
|
|
51
43
|
return resolved;
|
|
52
44
|
};
|
|
53
45
|
// Active step state. Null = no sequence step currently animating.
|
|
@@ -56,7 +48,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
56
48
|
const progressRef = useRef(1);
|
|
57
49
|
const updateProgressRef = (p) => {
|
|
58
50
|
progressRef.current = p;
|
|
59
|
-
// console.log('Progress update', { objectId, progress: p });
|
|
60
51
|
};
|
|
61
52
|
const updateStepRef = (state) => {
|
|
62
53
|
stepRef.current = state;
|
|
@@ -65,51 +56,20 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
65
56
|
useAnimationEvents({
|
|
66
57
|
onStepStart: (event) => {
|
|
67
58
|
if (!objectId || !event.step?.transitions) {
|
|
68
|
-
// debugLog('stepStart ignored: missing objectId or transitions', {
|
|
69
|
-
// objectId,
|
|
70
|
-
// hasTransitions: !!event.step?.transitions,
|
|
71
|
-
// sequenceId: event.sequenceId,
|
|
72
|
-
// stepIndex: event.stepIndex,
|
|
73
|
-
// });
|
|
74
59
|
return;
|
|
75
60
|
}
|
|
76
|
-
// debugLog('stepStart received', {
|
|
77
|
-
// objectId,
|
|
78
|
-
// sequenceId: event.sequenceId,
|
|
79
|
-
// stepIndex: event.stepIndex,
|
|
80
|
-
// transitionStates: event.step.transitions.map(t => t.state),
|
|
81
|
-
// resolvedObject: resolvedObject ? {
|
|
82
|
-
// name: resolvedObject.name,
|
|
83
|
-
// id: resolvedObject.userData?.id,
|
|
84
|
-
// } : null,
|
|
85
|
-
// });
|
|
86
61
|
// Find the transition targeting this object
|
|
87
62
|
const transitionIndex = event.step.transitions.findIndex(t => t.state === objectId);
|
|
88
63
|
if (transitionIndex === -1) {
|
|
89
|
-
// debugLog('no matching transition for objectId', {
|
|
90
|
-
// objectId,
|
|
91
|
-
// availableStates: event.step.transitions.map(t => t.state),
|
|
92
|
-
// });
|
|
93
64
|
return;
|
|
94
65
|
}
|
|
95
|
-
console.log('TRANSTITION START', objectId);
|
|
96
66
|
const resolvedObject = resolveObject();
|
|
97
|
-
console.log(objectId, resolvedObject?.name);
|
|
98
67
|
const transition = event.step.transitions[transitionIndex];
|
|
99
68
|
const stagger = event.step.stagger || 0;
|
|
100
69
|
const staggerOffsetMs = transitionIndex * stagger * 1000;
|
|
101
70
|
const d = event.step.duration || 1;
|
|
102
71
|
const ease = event.step.ease || 'linear';
|
|
103
72
|
const { properties, pathId = null } = transition;
|
|
104
|
-
console.log('Starting sequence step', resolvedObject?.name, properties);
|
|
105
|
-
// debugLog('matched transition', {
|
|
106
|
-
// objectId,
|
|
107
|
-
// pathId,
|
|
108
|
-
// duration: d,
|
|
109
|
-
// ease,
|
|
110
|
-
// fromKeys: Object.keys(properties.from || {}),
|
|
111
|
-
// toKeys: Object.keys(properties.to || {}),
|
|
112
|
-
// });
|
|
113
73
|
// Visibility shortcut
|
|
114
74
|
if (properties.to?.visible === false) {
|
|
115
75
|
if (resolvedObject)
|
|
@@ -145,13 +105,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
145
105
|
? snapshotMaterialValues(resolvedObject, missingFromKeys)
|
|
146
106
|
: {};
|
|
147
107
|
const materialFrom = { ...materialFromExplicit };
|
|
148
|
-
// debugLog('material from/to', {
|
|
149
|
-
// objectId,
|
|
150
|
-
// materialFromExplicit,
|
|
151
|
-
// snapshotted,
|
|
152
|
-
// materialFrom,
|
|
153
|
-
// materialToProps,
|
|
154
|
-
// });
|
|
155
108
|
updateStepRef({
|
|
156
109
|
startTime: performance.now() + staggerOffsetMs,
|
|
157
110
|
duration: d,
|
|
@@ -167,10 +120,8 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
167
120
|
visibilityOverride: null,
|
|
168
121
|
pathId,
|
|
169
122
|
});
|
|
170
|
-
// console.log(stepRef.current)
|
|
171
123
|
updateProgressRef(0);
|
|
172
124
|
if (pathId) {
|
|
173
|
-
debugLog('starting path animation', { objectId, pathId, duration: d, ease });
|
|
174
125
|
startPathAnimation(pathId, d, { ease });
|
|
175
126
|
}
|
|
176
127
|
else {
|
|
@@ -184,11 +135,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
184
135
|
const isForThisObject = event.step.transitions.some(t => t.state === objectId);
|
|
185
136
|
if (!isForThisObject)
|
|
186
137
|
return;
|
|
187
|
-
// debugLog('stepEnd received', {
|
|
188
|
-
// objectId,
|
|
189
|
-
// sequenceId: event.sequenceId,
|
|
190
|
-
// stepIndex: event.stepIndex,
|
|
191
|
-
// });
|
|
192
138
|
// Let useFrame finish the last frame at p=1 naturally; just clear step
|
|
193
139
|
// after a microtask so the final interpolated position is applied.
|
|
194
140
|
// Promise.resolve().then(() => {
|
|
@@ -204,7 +150,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
204
150
|
const isForThisObject = event.sequence.steps.some(s => s.transitions.some(t => t.state === objectId));
|
|
205
151
|
if (!isForThisObject)
|
|
206
152
|
return;
|
|
207
|
-
debugLog('sequenceEnd received', { objectId, sequenceId: event.sequenceId });
|
|
208
153
|
updateStepRef(null);
|
|
209
154
|
updateProgressRef(1);
|
|
210
155
|
}
|
|
@@ -213,13 +158,11 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
213
158
|
useFrame((_state, delta) => {
|
|
214
159
|
const resolvedObject = resolveObject();
|
|
215
160
|
// Only skip if truly finished (p>=1). During stagger wait, p=0 and we still need to apply fromPosition.
|
|
216
|
-
// console.log(stepRef.current)
|
|
217
161
|
if (!stepRef.current || !resolvedObject)
|
|
218
162
|
return;
|
|
219
163
|
const step = stepRef.current;
|
|
220
164
|
// Time-based progress drives property interpolation regardless of transform mode.
|
|
221
165
|
const p = AnimationsManager.getProgressFromTime(step.startTime, step.duration, step.ease);
|
|
222
|
-
// console.log(p)
|
|
223
166
|
// updateProgressRef(p);
|
|
224
167
|
// Path-based: delegate to usePathAnimation
|
|
225
168
|
if (step.pathId) {
|
|
@@ -241,14 +184,6 @@ export const useSequenceAnimation = (objectId, objectRef) => {
|
|
|
241
184
|
resolvedObject.rotation.set(...rot);
|
|
242
185
|
resolvedObject.scale.set(...sca);
|
|
243
186
|
}
|
|
244
|
-
if (p === 0 || p >= 0.99) {
|
|
245
|
-
// debugLog('frame progress', {
|
|
246
|
-
// objectId,
|
|
247
|
-
// progress: p,
|
|
248
|
-
// materialKeys: Object.keys(step.materialTo),
|
|
249
|
-
// pathId: step.pathId,
|
|
250
|
-
// });
|
|
251
|
-
}
|
|
252
187
|
// — Material properties —
|
|
253
188
|
interpolateMaterialProps(resolvedObject, step.materialFrom, step.materialTo, p);
|
|
254
189
|
if (p >= 1) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useShadowApplication: (
|
|
1
|
+
import type { Object3DSource } from "../utils/resolveObject3D";
|
|
2
|
+
export declare const useShadowApplication: (source: Object3DSource, castShadow: boolean | undefined, receiveShadow: boolean | undefined, triggerKey?: unknown) => void;
|
|
3
3
|
//# sourceMappingURL=useShadowApplication.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShadowApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useShadowApplication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useShadowApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useShadowApplication.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,oBAAoB,GAAI,QAAQ,cAAc,EAAE,YAAY,OAAO,GAAG,SAAS,EAAE,eAAe,OAAO,GAAG,SAAS,EAAE,aAAa,OAAO,KAAG,IAgBxJ,CAAC"}
|
|
@@ -15,8 +15,12 @@
|
|
|
15
15
|
//
|
|
16
16
|
import { useEffect } from 'react';
|
|
17
17
|
import { traverseSkippingEdgesAndEffects } from '@3driseai/3drise-core';
|
|
18
|
-
|
|
18
|
+
import { resolveObject3D } from "../utils/resolveObject3D.js";
|
|
19
|
+
export const useShadowApplication = (source, castShadow, receiveShadow, triggerKey) => {
|
|
19
20
|
useEffect(() => {
|
|
21
|
+
// Read the ref here, not at the call site: effects run after React has
|
|
22
|
+
// attached refs, so this is the first point the object reliably exists.
|
|
23
|
+
const obj = resolveObject3D(source);
|
|
20
24
|
if (!obj)
|
|
21
25
|
return;
|
|
22
26
|
const cast = castShadow ?? false;
|
|
@@ -27,5 +31,5 @@ export const useShadowApplication = (obj, castShadow, receiveShadow, triggerKey)
|
|
|
27
31
|
child.receiveShadow = receive;
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
|
-
}, [
|
|
34
|
+
}, [source, castShadow, receiveShadow, triggerKey]);
|
|
31
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSkyAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkyAnimation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,MAAM,WAAW,aAAa;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAgB,eAAe,IAAI;IAC3B,oBAAoB,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAClL,
|
|
1
|
+
{"version":3,"file":"useSkyAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkyAnimation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,MAAM,WAAW,aAAa;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAgB,eAAe,IAAI;IAC3B,oBAAoB,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAClL,CA6BJ"}
|
|
@@ -29,7 +29,6 @@ export function useSkyAnimation() {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const animateSkyTransition = useCallback((from, to, onUpdate, onComplete, duration = 3) => {
|
|
32
|
-
console.log('Initiating sky animation', { from, to, duration });
|
|
33
32
|
animRef.current = { from, to, duration, elapsed: 0, onUpdate, onComplete };
|
|
34
33
|
}, []);
|
|
35
34
|
return { animateSkyTransition };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSkySystem.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkySystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAIpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC;CACxC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"useSkySystem.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkySystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAIpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC;CACxC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAqD7E;AACD,eAAe,YAAY,CAAC"}
|
|
@@ -27,7 +27,6 @@ export function useSkySystem(options) {
|
|
|
27
27
|
if (!enabled || !timeSettings.enabled || !timeSettings.autoAnimate)
|
|
28
28
|
return;
|
|
29
29
|
const state = skySystemManager.getState();
|
|
30
|
-
// console.log(state.timeInHours)
|
|
31
30
|
if (previousTimeOfDayRef.current !== null &&
|
|
32
31
|
previousTimeOfDayRef.current !== state.timeOfDay) {
|
|
33
32
|
onTimeOfDayChange?.(state.timeOfDay, state.elapsedTime);
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,10 @@ export { cameraManager } from './utils/CameraSingleton';
|
|
|
8
8
|
export { applyAnchorSettings, createCurves, createSunPosition, randomRange, } from './utils/utils3d';
|
|
9
9
|
export { applyAnchorSettings as applyAnchorSettingsLegacy } from './utils/anchorUtils';
|
|
10
10
|
export * from './utils/shapes';
|
|
11
|
-
export {
|
|
11
|
+
export { applyGenerativeAnimations } from './utils/handleGenerativeEffectsAnimations';
|
|
12
12
|
export { hasHoverAnimation } from './utils/hasHoverAnimation';
|
|
13
13
|
export { findById } from './utils/sceneQuery';
|
|
14
|
+
export { resolveObject3D } from './utils/resolveObject3D';
|
|
15
|
+
export type { Object3DRefLike, Object3DSource } from './utils/resolveObject3D';
|
|
14
16
|
export * from './utils/textEffects';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
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,cAAc,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG1F,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG5F,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGjG,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,GAAG,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,mBAAmB,IAAI,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACvF,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG1F,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG5F,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGjG,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,GAAG,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,mBAAmB,IAAI,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACvF,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/E,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export { cameraManager } from './utils/CameraSingleton.js';
|
|
|
11
11
|
export { applyAnchorSettings, createCurves, createSunPosition, randomRange, } from './utils/utils3d.js';
|
|
12
12
|
export { applyAnchorSettings as applyAnchorSettingsLegacy } from './utils/anchorUtils.js';
|
|
13
13
|
export * from './utils/shapes.js';
|
|
14
|
-
export {
|
|
14
|
+
export { applyGenerativeAnimations } from './utils/handleGenerativeEffectsAnimations.js';
|
|
15
15
|
export { hasHoverAnimation } from './utils/hasHoverAnimation.js';
|
|
16
16
|
export { findById } from './utils/sceneQuery.js';
|
|
17
|
+
export { resolveObject3D } from './utils/resolveObject3D.js';
|
|
17
18
|
export * from './utils/textEffects.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimationsManager.d.ts","sourceRoot":"","sources":["../../src/services/AnimationsManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC3F,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;AAE3F,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;AAEhD;;;;GAIG;AACH,cAAM,iBAAiB;IACnB,OAAO,CAAC,SAAS,CAKd;IACH,OAAO,CAAC,KAAK,CAAa;IAC1B,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAGtD,GAAG,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAGvD,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"AnimationsManager.d.ts","sourceRoot":"","sources":["../../src/services/AnimationsManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC3F,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;AAE3F,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;AAEhD;;;;GAIG;AACH,cAAM,iBAAiB;IACnB,OAAO,CAAC,SAAS,CAKd;IACH,OAAO,CAAC,KAAK,CAAa;IAC1B,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAGtD,GAAG,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAGvD,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IASjC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,MAAiB,GAAG,MAAM;IAIzF,YAAY,CAAC,QAAQ,EAAE,iBAAiB,GAAG,iBAAiB;IAY5D,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAC/B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAC3C,WAAW,IAAI,UAAU,EAAE;IAC3B,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI;IAKtE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAC5B,UAAU,IAAI,IAAI;CACrB;;AACD,wBAAuC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export interface CircuitGridMaterialUniforms {
|
|
3
|
+
u_time: number;
|
|
4
|
+
/** size of one Truchet tile, in world units */
|
|
5
|
+
u_cellSize: number;
|
|
6
|
+
/** trace thickness, in pixels */
|
|
7
|
+
u_lineWidth: number;
|
|
8
|
+
/** unused by the tiling; kept so the section knobs line up with the other grids */
|
|
9
|
+
u_sectionSize: number;
|
|
10
|
+
/** pad/chip outline thickness, in pixels */
|
|
11
|
+
u_sectionWidth: number;
|
|
12
|
+
u_lineColor: THREE.Color;
|
|
13
|
+
u_sectionColor: THREE.Color;
|
|
14
|
+
u_cellColor: THREE.Color;
|
|
15
|
+
u_glowColor: THREE.Color;
|
|
16
|
+
u_bgColor: THREE.Color;
|
|
17
|
+
u_bgOpacity: number;
|
|
18
|
+
u_lineMode: number;
|
|
19
|
+
u_cellMode: number;
|
|
20
|
+
u_animSpeed: number;
|
|
21
|
+
u_animScale: number;
|
|
22
|
+
u_animIntensity: number;
|
|
23
|
+
u_fadeDistance: number;
|
|
24
|
+
u_fadeStrength: number;
|
|
25
|
+
u_focus: THREE.Vector2;
|
|
26
|
+
u_mouse: THREE.Vector2;
|
|
27
|
+
u_displace: number;
|
|
28
|
+
/**
|
|
29
|
+
* 0..1 assemble/dissolve. The build boundary sweeps outward from u_focus
|
|
30
|
+
* with a bright leading edge; 1 is fully built, 0 is gone. Animate it
|
|
31
|
+
* downward to dissolve.
|
|
32
|
+
*/
|
|
33
|
+
u_reveal: number;
|
|
34
|
+
/** 0..1 — fraction of tiles carrying a powered trace */
|
|
35
|
+
u_powered: number;
|
|
36
|
+
/** 0..1 — fraction of tiles replaced by an IC package */
|
|
37
|
+
u_chipChance: number;
|
|
38
|
+
/** solder-pad radius as a fraction of a tile; 0 disables pads */
|
|
39
|
+
u_padSize: number;
|
|
40
|
+
}
|
|
41
|
+
declare module '@react-three/fiber' {
|
|
42
|
+
interface ThreeElements {
|
|
43
|
+
circuitGridMaterial: ThreeElements['shaderMaterial'] & Partial<CircuitGridMaterialUniforms>;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export declare const circuitGridMaterialDefaults: CircuitGridMaterialUniforms;
|
|
47
|
+
export declare const CircuitGridMaterial: import("@react-three/fiber").ConstructorRepresentation<THREE.ShaderMaterial & {
|
|
48
|
+
u_time: number;
|
|
49
|
+
u_cellSize: number;
|
|
50
|
+
u_lineWidth: number;
|
|
51
|
+
u_sectionSize: number;
|
|
52
|
+
u_sectionWidth: number;
|
|
53
|
+
u_lineColor: THREE.Color;
|
|
54
|
+
u_sectionColor: THREE.Color;
|
|
55
|
+
u_cellColor: THREE.Color;
|
|
56
|
+
u_glowColor: THREE.Color;
|
|
57
|
+
u_bgColor: THREE.Color;
|
|
58
|
+
u_bgOpacity: number;
|
|
59
|
+
u_lineMode: number;
|
|
60
|
+
u_cellMode: number;
|
|
61
|
+
u_animSpeed: number;
|
|
62
|
+
u_animScale: number;
|
|
63
|
+
u_animIntensity: number;
|
|
64
|
+
u_fadeDistance: number;
|
|
65
|
+
u_fadeStrength: number;
|
|
66
|
+
u_focus: THREE.Vector2;
|
|
67
|
+
u_mouse: THREE.Vector2;
|
|
68
|
+
u_displace: number;
|
|
69
|
+
u_reveal: number;
|
|
70
|
+
u_powered: number;
|
|
71
|
+
u_chipChance: number;
|
|
72
|
+
u_padSize: number;
|
|
73
|
+
}> & {
|
|
74
|
+
key: string;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=CircuitGridMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircuitGridMaterial.d.ts","sourceRoot":"","sources":["../../src/shaders/CircuitGridMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,2BAA2B;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,aAAa,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC;IACzB,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC;IAC5B,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC;IACzB,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,OAAO,QAAQ,oBAAoB,CAAC;IAChC,UAAU,aAAa;QACnB,mBAAmB,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;KAC/F;CACJ;AAED,eAAO,MAAM,2BAA2B,EAAE,2BA0BzC,CAAC;AAqPF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B/B,CAAC"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { shaderMaterial } from '@react-three/drei';
|
|
3
|
+
import { extend } from '@react-three/fiber';
|
|
4
|
+
export const circuitGridMaterialDefaults = {
|
|
5
|
+
u_time: 0,
|
|
6
|
+
u_cellSize: 1.0,
|
|
7
|
+
u_lineWidth: 1.6,
|
|
8
|
+
u_sectionSize: 5.0,
|
|
9
|
+
u_sectionWidth: 1.4,
|
|
10
|
+
u_lineColor: new THREE.Color(0.09, 0.42, 0.36),
|
|
11
|
+
u_sectionColor: new THREE.Color(0.55, 0.95, 0.7),
|
|
12
|
+
u_cellColor: new THREE.Color(0.03, 0.14, 0.12),
|
|
13
|
+
u_glowColor: new THREE.Color(0.35, 1.0, 0.72),
|
|
14
|
+
u_bgColor: new THREE.Color(0.01, 0.04, 0.03),
|
|
15
|
+
u_bgOpacity: 0.0,
|
|
16
|
+
u_lineMode: 2,
|
|
17
|
+
u_cellMode: 0,
|
|
18
|
+
u_animSpeed: 1.0,
|
|
19
|
+
u_animScale: 0.5,
|
|
20
|
+
u_animIntensity: 1.0,
|
|
21
|
+
u_fadeDistance: 25.0,
|
|
22
|
+
u_fadeStrength: 0.7,
|
|
23
|
+
u_focus: new THREE.Vector2(0, 0),
|
|
24
|
+
u_mouse: new THREE.Vector2(0, 0),
|
|
25
|
+
u_displace: 0.0,
|
|
26
|
+
u_reveal: 1.0,
|
|
27
|
+
u_powered: 0.65,
|
|
28
|
+
u_chipChance: 0.06,
|
|
29
|
+
u_padSize: 1.0,
|
|
30
|
+
};
|
|
31
|
+
const circuitCommon = /*glsl*/ `
|
|
32
|
+
const float PI = 3.14159265359;
|
|
33
|
+
const float TAU = 6.28318530718;
|
|
34
|
+
|
|
35
|
+
float hash21(vec2 p){
|
|
36
|
+
p = fract(p * vec2(123.34, 456.21));
|
|
37
|
+
p += dot(p, p + 45.32);
|
|
38
|
+
return fract(p.x * p.y);
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const vertex = /*glsl*/ `
|
|
42
|
+
uniform float u_time;
|
|
43
|
+
uniform float u_cellSize;
|
|
44
|
+
uniform float u_displace;
|
|
45
|
+
uniform float u_animSpeed;
|
|
46
|
+
uniform float u_animScale;
|
|
47
|
+
|
|
48
|
+
varying vec2 vGridPos;
|
|
49
|
+
|
|
50
|
+
${circuitCommon}
|
|
51
|
+
|
|
52
|
+
void main(){
|
|
53
|
+
vGridPos = position.xy;
|
|
54
|
+
vec3 pos = position;
|
|
55
|
+
if (u_displace > 0.0){
|
|
56
|
+
float t = u_time * u_animSpeed;
|
|
57
|
+
vec2 coord = position.xy / max(u_cellSize, 1e-4);
|
|
58
|
+
// board flex: a slow low-frequency swell rather than per-tile steps, so
|
|
59
|
+
// traces stay continuous across tile borders
|
|
60
|
+
float h = sin(coord.x * u_animScale * 0.5 - t) * cos(coord.y * u_animScale * 0.5 + t * 0.7);
|
|
61
|
+
pos.z += h * u_displace;
|
|
62
|
+
}
|
|
63
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
const fragment = /*glsl*/ `
|
|
67
|
+
precision highp float;
|
|
68
|
+
|
|
69
|
+
uniform float u_time;
|
|
70
|
+
uniform float u_cellSize;
|
|
71
|
+
uniform float u_lineWidth;
|
|
72
|
+
uniform float u_sectionSize;
|
|
73
|
+
uniform float u_sectionWidth;
|
|
74
|
+
uniform vec3 u_lineColor;
|
|
75
|
+
uniform vec3 u_sectionColor;
|
|
76
|
+
uniform vec3 u_cellColor;
|
|
77
|
+
uniform vec3 u_glowColor;
|
|
78
|
+
uniform vec3 u_bgColor;
|
|
79
|
+
uniform float u_bgOpacity;
|
|
80
|
+
uniform float u_lineMode;
|
|
81
|
+
uniform float u_cellMode;
|
|
82
|
+
uniform float u_animSpeed;
|
|
83
|
+
uniform float u_animScale;
|
|
84
|
+
uniform float u_animIntensity;
|
|
85
|
+
uniform float u_fadeDistance;
|
|
86
|
+
uniform float u_fadeStrength;
|
|
87
|
+
uniform vec2 u_focus;
|
|
88
|
+
uniform float u_reveal;
|
|
89
|
+
uniform float u_powered;
|
|
90
|
+
uniform float u_chipChance;
|
|
91
|
+
uniform float u_padSize;
|
|
92
|
+
|
|
93
|
+
varying vec2 vGridPos;
|
|
94
|
+
|
|
95
|
+
${circuitCommon}
|
|
96
|
+
|
|
97
|
+
/** signed distance to a rounded box of half-extent b and corner radius r */
|
|
98
|
+
float sdRoundBox(vec2 p, vec2 b, float r){
|
|
99
|
+
vec2 q = abs(p) - b + r;
|
|
100
|
+
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** straight axis-aligned lines on a lattice, same maths as the square grid */
|
|
104
|
+
float gridLines(vec2 c, float width){
|
|
105
|
+
vec2 d = fwidth(c);
|
|
106
|
+
vec2 g = abs(fract(c - 0.5) - 0.5) / max(d * width, 1e-5);
|
|
107
|
+
return 1.0 - clamp(min(g.x, g.y), 0.0, 1.0);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** IC legs: short lines bridging the package edge to the tile edge */
|
|
111
|
+
float chipPins(vec2 gv, float hw, float px){
|
|
112
|
+
float dy = abs(fract(gv.y * 4.0) - 0.5) * 0.25;
|
|
113
|
+
float dx = abs(fract(gv.x * 4.0) - 0.5) * 0.25;
|
|
114
|
+
float horiz = (1.0 - smoothstep(hw, hw + px, dy)) * step(0.30, abs(gv.x));
|
|
115
|
+
float vert = (1.0 - smoothstep(hw, hw + px, dx)) * step(0.30, abs(gv.y));
|
|
116
|
+
return max(horiz, vert);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
void main(){
|
|
120
|
+
vec2 coord = vGridPos / max(u_cellSize, 1e-4);
|
|
121
|
+
vec2 focus = u_focus / max(u_cellSize, 1e-4);
|
|
122
|
+
float t = u_time * u_animSpeed;
|
|
123
|
+
float px = max(length(fwidth(coord)), 1e-6);
|
|
124
|
+
|
|
125
|
+
vec2 id = floor(coord);
|
|
126
|
+
vec2 gv = fract(coord) - 0.5;
|
|
127
|
+
|
|
128
|
+
float seed = hash21(id);
|
|
129
|
+
// Mirroring half the tiles is what turns isolated quarter-arcs into long
|
|
130
|
+
// meandering paths: the two orientations chain across tile borders.
|
|
131
|
+
if (seed < 0.5) gv.x = -gv.x;
|
|
132
|
+
|
|
133
|
+
bool isChip = hash21(id + 7.77) < u_chipChance;
|
|
134
|
+
bool powered = hash21(id + 11.31) < u_powered;
|
|
135
|
+
|
|
136
|
+
float hw = px * max(u_lineWidth, 0.05) * 0.5;
|
|
137
|
+
|
|
138
|
+
// ---- Truchet traces --------------------------------------------------
|
|
139
|
+
vec2 c1 = vec2( 0.5, 0.5);
|
|
140
|
+
vec2 c2 = vec2(-0.5, -0.5);
|
|
141
|
+
float d1 = abs(length(gv - c1) - 0.5);
|
|
142
|
+
float d2 = abs(length(gv - c2) - 0.5);
|
|
143
|
+
float traceDist = min(d1, d2);
|
|
144
|
+
float trace = isChip ? 0.0 : 1.0 - smoothstep(hw, hw + px, traceDist);
|
|
145
|
+
|
|
146
|
+
// Position along whichever arc we are nearest, normalised over its quarter
|
|
147
|
+
// turn. Arc 1 spans atan in [-PI, -PI/2]; arc 2 spans [0, PI/2].
|
|
148
|
+
bool onA = d1 < d2;
|
|
149
|
+
vec2 rel = onA ? (gv - c1) : (gv - c2);
|
|
150
|
+
float ang = atan(rel.y, rel.x);
|
|
151
|
+
float along = onA ? (ang + PI) / (PI * 0.5) : ang / (PI * 0.5);
|
|
152
|
+
// per-arc offset so the whole board does not pulse in lockstep
|
|
153
|
+
float arcSeed = hash21(id + (onA ? vec2(0.0) : vec2(3.71, 1.09)));
|
|
154
|
+
|
|
155
|
+
// ---- trace animation -------------------------------------------------
|
|
156
|
+
float lineAnim = 1.0;
|
|
157
|
+
float head = 0.0;
|
|
158
|
+
if (u_lineMode > 0.5 && u_lineMode < 1.5){
|
|
159
|
+
float dist = length(coord - focus);
|
|
160
|
+
lineAnim = 0.5 + 0.5 * sin(dist * u_animScale - t);
|
|
161
|
+
} else if (u_lineMode < 2.5){
|
|
162
|
+
// signal pulses running along the traces themselves
|
|
163
|
+
lineAnim = 0.6;
|
|
164
|
+
float phase = fract(arcSeed + along * 0.25 - t * 0.18 * max(u_animScale, 0.05));
|
|
165
|
+
head = pow(phase, 16.0);
|
|
166
|
+
} else if (u_lineMode < 3.5){
|
|
167
|
+
// a data wavefront crossing the board diagonally
|
|
168
|
+
float s = fract((coord.x + coord.y) * 0.05 * u_animScale - t * 0.15);
|
|
169
|
+
lineAnim = 0.25 + smoothstep(0.0, 0.15, s) * (1.0 - smoothstep(0.15, 0.35, s));
|
|
170
|
+
} else if (u_lineMode < 4.5){
|
|
171
|
+
lineAnim = 0.5 + 0.5 * sin(t + seed * TAU);
|
|
172
|
+
}
|
|
173
|
+
if (!powered){ lineAnim *= 0.25; head = 0.0; }
|
|
174
|
+
lineAnim = mix(1.0, lineAnim, u_animIntensity);
|
|
175
|
+
head *= u_animIntensity;
|
|
176
|
+
|
|
177
|
+
// ---- bus lines -------------------------------------------------------
|
|
178
|
+
// Straight power/data buses every sectionSize tiles, cutting across the
|
|
179
|
+
// Truchet weave the way a real board's supply rails do.
|
|
180
|
+
float bus = 0.0;
|
|
181
|
+
if (u_sectionWidth > 0.0 && u_sectionSize > 0.0){
|
|
182
|
+
bus = gridLines(coord / u_sectionSize, u_sectionWidth);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ---- solder pads / vias ---------------------------------------------
|
|
186
|
+
// Every arc terminates on an edge midpoint, so that is where the pads go.
|
|
187
|
+
// Neighbouring tiles draw the same pad twice at the same point, which is
|
|
188
|
+
// exactly right — it is one via shared by both.
|
|
189
|
+
// A via on every junction turns the board into a dot field that drowns out
|
|
190
|
+
// the traces, so only a minority of tiles get one.
|
|
191
|
+
float pad = 0.0;
|
|
192
|
+
if (u_padSize > 0.0 && !isChip && hash21(id + 21.73) < 0.3){
|
|
193
|
+
float dp = min(
|
|
194
|
+
min(length(gv - vec2(0.5, 0.0)), length(gv + vec2(0.5, 0.0))),
|
|
195
|
+
min(length(gv - vec2(0.0, 0.5)), length(gv + vec2(0.0, 0.5)))
|
|
196
|
+
);
|
|
197
|
+
float pr = 0.05 * u_padSize;
|
|
198
|
+
pad = 1.0 - smoothstep(pr, pr + px * 1.5, dp);
|
|
199
|
+
pad *= smoothstep(pr * 0.30, pr * 0.50, dp); // punch the drill hole
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ---- IC packages -----------------------------------------------------
|
|
203
|
+
float chipBody = 0.0, chipEdge = 0.0, chipCore = 0.0, pins = 0.0;
|
|
204
|
+
if (isChip){
|
|
205
|
+
float b = sdRoundBox(gv, vec2(0.30), 0.06);
|
|
206
|
+
chipBody = 1.0 - smoothstep(0.0, px * 2.0, b);
|
|
207
|
+
chipEdge = 1.0 - smoothstep(hw, hw + px, abs(b));
|
|
208
|
+
pins = chipPins(gv, hw, px);
|
|
209
|
+
float beat = 0.5 + 0.5 * sin(t * (1.0 + hash21(id + 2.3) * 2.0));
|
|
210
|
+
chipCore = (1.0 - smoothstep(0.0, px * 2.0, sdRoundBox(gv, vec2(0.10), 0.02))) * beat;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// ---- substrate fill --------------------------------------------------
|
|
214
|
+
float cell = 0.0;
|
|
215
|
+
if (u_cellMode > 0.5 && u_cellMode < 1.5){
|
|
216
|
+
cell = 0.5 + 0.5 * sin(dot(id, vec2(0.7, 0.3)) * u_animScale - t);
|
|
217
|
+
} else if (u_cellMode < 2.5){
|
|
218
|
+
cell = 0.5 + 0.5 * sin(t * (0.6 + seed) + seed * TAU);
|
|
219
|
+
} else if (u_cellMode < 3.5){
|
|
220
|
+
float d = length(id + 0.5 - focus);
|
|
221
|
+
cell = smoothstep(0.6, 1.0, sin(d * u_animScale - t));
|
|
222
|
+
} else if (u_cellMode < 4.5){
|
|
223
|
+
cell = mod(id.x + id.y, 2.0) * (0.5 + 0.5 * sin(t));
|
|
224
|
+
}
|
|
225
|
+
cell *= u_animIntensity;
|
|
226
|
+
vec2 f = abs(gv);
|
|
227
|
+
cell *= smoothstep(0.5, 0.4, max(f.x, f.y));
|
|
228
|
+
|
|
229
|
+
float r = length(vGridPos) / max(u_fadeDistance, 1e-4);
|
|
230
|
+
float fade = 1.0 - smoothstep(1.0 - u_fadeStrength, 1.0, r);
|
|
231
|
+
|
|
232
|
+
vec3 col = u_bgColor * u_bgOpacity;
|
|
233
|
+
float a = u_bgOpacity;
|
|
234
|
+
|
|
235
|
+
col += u_cellColor * (cell + chipBody * 0.8);
|
|
236
|
+
a = max(a, max(cell * 0.9, chipBody * 0.85));
|
|
237
|
+
|
|
238
|
+
float traceI = trace * lineAnim;
|
|
239
|
+
float busI = bus * lineAnim;
|
|
240
|
+
col += u_lineColor * traceI; a = max(a, traceI);
|
|
241
|
+
col += u_glowColor * trace * head * 2.2; a = max(a, trace * head);
|
|
242
|
+
col += u_sectionColor * busI * 0.8; a = max(a, busI * 0.8);
|
|
243
|
+
float padI = pad * 0.7;
|
|
244
|
+
col += u_sectionColor * (padI + chipEdge + pins); a = max(a, max(padI, max(chipEdge, pins)));
|
|
245
|
+
col += u_glowColor * chipCore * 1.5; a = max(a, chipCore);
|
|
246
|
+
col += u_glowColor * traceI * 0.15 * u_animIntensity;
|
|
247
|
+
|
|
248
|
+
col *= fade;
|
|
249
|
+
a *= fade;
|
|
250
|
+
|
|
251
|
+
// ---- reveal ----------------------------------------------------------
|
|
252
|
+
// The build boundary sweeps outward from the focus point. Its leading band
|
|
253
|
+
// mostly brightens whatever is already there rather than painting a solid
|
|
254
|
+
// disc, so the grid reads as assembling itself rather than fading in.
|
|
255
|
+
if (u_reveal < 0.999){
|
|
256
|
+
float rd = length(vGridPos - u_focus) / max(u_fadeDistance, 1e-4);
|
|
257
|
+
// 1.1, not 1.25: the boundary has to clear the fade radius by just the
|
|
258
|
+
// width of its own soft edge. Overshooting further finishes the build
|
|
259
|
+
// before reveal reaches 1 and leaves the tail of the range doing nothing.
|
|
260
|
+
float edge = u_reveal * 1.1;
|
|
261
|
+
float mask = 1.0 - smoothstep(edge - 0.05, edge, rd);
|
|
262
|
+
float front = mask * smoothstep(edge - 0.22, edge - 0.05, rd);
|
|
263
|
+
col = col * mask + u_glowColor * front * (a * 1.8 + 0.08);
|
|
264
|
+
a = max(a * mask, front * 0.10);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (a < 0.002) discard;
|
|
268
|
+
gl_FragColor = vec4(col, a);
|
|
269
|
+
}
|
|
270
|
+
`;
|
|
271
|
+
export const CircuitGridMaterial = shaderMaterial({
|
|
272
|
+
u_time: circuitGridMaterialDefaults.u_time,
|
|
273
|
+
u_cellSize: circuitGridMaterialDefaults.u_cellSize,
|
|
274
|
+
u_lineWidth: circuitGridMaterialDefaults.u_lineWidth,
|
|
275
|
+
u_sectionSize: circuitGridMaterialDefaults.u_sectionSize,
|
|
276
|
+
u_sectionWidth: circuitGridMaterialDefaults.u_sectionWidth,
|
|
277
|
+
u_lineColor: circuitGridMaterialDefaults.u_lineColor.clone(),
|
|
278
|
+
u_sectionColor: circuitGridMaterialDefaults.u_sectionColor.clone(),
|
|
279
|
+
u_cellColor: circuitGridMaterialDefaults.u_cellColor.clone(),
|
|
280
|
+
u_glowColor: circuitGridMaterialDefaults.u_glowColor.clone(),
|
|
281
|
+
u_bgColor: circuitGridMaterialDefaults.u_bgColor.clone(),
|
|
282
|
+
u_bgOpacity: circuitGridMaterialDefaults.u_bgOpacity,
|
|
283
|
+
u_lineMode: circuitGridMaterialDefaults.u_lineMode,
|
|
284
|
+
u_cellMode: circuitGridMaterialDefaults.u_cellMode,
|
|
285
|
+
u_animSpeed: circuitGridMaterialDefaults.u_animSpeed,
|
|
286
|
+
u_animScale: circuitGridMaterialDefaults.u_animScale,
|
|
287
|
+
u_animIntensity: circuitGridMaterialDefaults.u_animIntensity,
|
|
288
|
+
u_fadeDistance: circuitGridMaterialDefaults.u_fadeDistance,
|
|
289
|
+
u_fadeStrength: circuitGridMaterialDefaults.u_fadeStrength,
|
|
290
|
+
u_focus: circuitGridMaterialDefaults.u_focus.clone(),
|
|
291
|
+
u_mouse: circuitGridMaterialDefaults.u_mouse.clone(),
|
|
292
|
+
u_displace: circuitGridMaterialDefaults.u_displace,
|
|
293
|
+
u_reveal: circuitGridMaterialDefaults.u_reveal,
|
|
294
|
+
u_powered: circuitGridMaterialDefaults.u_powered,
|
|
295
|
+
u_chipChance: circuitGridMaterialDefaults.u_chipChance,
|
|
296
|
+
u_padSize: circuitGridMaterialDefaults.u_padSize,
|
|
297
|
+
}, vertex, fragment);
|
|
298
|
+
extend({ CircuitGridMaterial });
|