@3driseai/3drise-viewer 0.1.5 → 0.1.7

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.
Files changed (203) hide show
  1. package/README.md +225 -0
  2. package/dist/components/AdvancedGrid.d.ts +16 -0
  3. package/dist/components/AdvancedGrid.d.ts.map +1 -0
  4. package/dist/components/AdvancedGrid.js +63 -0
  5. package/dist/components/AnimatedObject.d.ts.map +1 -1
  6. package/dist/components/AnimatedObject.js +6 -4
  7. package/dist/components/CameraController.d.ts.map +1 -1
  8. package/dist/components/CameraController.js +0 -6
  9. package/dist/components/CircuitGrid.d.ts +22 -0
  10. package/dist/components/CircuitGrid.d.ts.map +1 -0
  11. package/dist/components/CircuitGrid.js +69 -0
  12. package/dist/components/Clouds.d.ts.map +1 -1
  13. package/dist/components/Clouds.js +0 -5
  14. package/dist/components/ContourGrid.d.ts +25 -0
  15. package/dist/components/ContourGrid.d.ts.map +1 -0
  16. package/dist/components/ContourGrid.js +74 -0
  17. package/dist/components/CreatedObject.d.ts.map +1 -1
  18. package/dist/components/CreatedObject.js +3 -6
  19. package/dist/components/CustomPrimitive.d.ts.map +1 -1
  20. package/dist/components/CustomPrimitive.js +1 -6
  21. package/dist/components/EffectsGenerator.d.ts.map +1 -1
  22. package/dist/components/EffectsGenerator.js +0 -2
  23. package/dist/components/EffectsGroup.d.ts +6 -0
  24. package/dist/components/EffectsGroup.d.ts.map +1 -1
  25. package/dist/components/EffectsGroup.js +14 -4
  26. package/dist/components/FractalGrid.d.ts +23 -0
  27. package/dist/components/FractalGrid.d.ts.map +1 -0
  28. package/dist/components/FractalGrid.js +72 -0
  29. package/dist/components/Frame.d.ts.map +1 -1
  30. package/dist/components/Frame.js +2 -3
  31. package/dist/components/GalleryLayout.d.ts.map +1 -1
  32. package/dist/components/GalleryLayout.js +0 -3
  33. package/dist/components/GeometryShape.d.ts.map +1 -1
  34. package/dist/components/GeometryShape.js +19 -7
  35. package/dist/components/Glyphs.d.ts.map +1 -1
  36. package/dist/components/Glyphs.js +0 -1
  37. package/dist/components/GridsGenerator.d.ts +4 -1
  38. package/dist/components/GridsGenerator.d.ts.map +1 -1
  39. package/dist/components/GridsGenerator.js +28 -4
  40. package/dist/components/HdrPlaylistRenderer.d.ts.map +1 -1
  41. package/dist/components/HdrPlaylistRenderer.js +0 -1
  42. package/dist/components/HexGrid.d.ts +25 -0
  43. package/dist/components/HexGrid.d.ts.map +1 -0
  44. package/dist/components/HexGrid.js +72 -0
  45. package/dist/components/ImageGeometry.js +1 -1
  46. package/dist/components/Letter.d.ts.map +1 -1
  47. package/dist/components/Letter.js +1 -6
  48. package/dist/components/MoireGrid.d.ts +23 -0
  49. package/dist/components/MoireGrid.d.ts.map +1 -0
  50. package/dist/components/MoireGrid.js +76 -0
  51. package/dist/components/Moon.d.ts.map +1 -1
  52. package/dist/components/Moon.js +0 -1
  53. package/dist/components/ObjectNode.d.ts +1 -2
  54. package/dist/components/ObjectNode.d.ts.map +1 -1
  55. package/dist/components/ObjectNode.js +18 -29
  56. package/dist/components/ObjectNodeApi.d.ts +1 -2
  57. package/dist/components/ObjectNodeApi.d.ts.map +1 -1
  58. package/dist/components/ObjectNodeApi.js +7 -3
  59. package/dist/components/ObjectsRenderer.d.ts.map +1 -1
  60. package/dist/components/ObjectsRenderer.js +1 -4
  61. package/dist/components/ObjectsRendererApi.d.ts.map +1 -1
  62. package/dist/components/ObjectsRendererApi.js +4 -2
  63. package/dist/components/Ocean.d.ts.map +1 -1
  64. package/dist/components/Ocean.js +1 -4
  65. package/dist/components/ParticlesR3f.d.ts +0 -1
  66. package/dist/components/ParticlesR3f.d.ts.map +1 -1
  67. package/dist/components/ParticlesR3f.js +63 -12
  68. package/dist/components/PathRenderer.d.ts.map +1 -1
  69. package/dist/components/PathRenderer.js +0 -1
  70. package/dist/components/PointCloud.d.ts.map +1 -1
  71. package/dist/components/PointCloud.js +50 -10
  72. package/dist/components/ProjectLoader.d.ts.map +1 -1
  73. package/dist/components/ProjectLoader.js +0 -28
  74. package/dist/components/QuasiGrid.d.ts +22 -0
  75. package/dist/components/QuasiGrid.d.ts.map +1 -0
  76. package/dist/components/QuasiGrid.js +68 -0
  77. package/dist/components/RadarGrid.d.ts +24 -0
  78. package/dist/components/RadarGrid.d.ts.map +1 -0
  79. package/dist/components/RadarGrid.js +71 -0
  80. package/dist/components/SceneBuilder.d.ts.map +1 -1
  81. package/dist/components/SceneBuilder.js +0 -1
  82. package/dist/components/ShootingStar.js +2 -2
  83. package/dist/components/ShootingStars.d.ts.map +1 -1
  84. package/dist/components/ShootingStars.js +0 -1
  85. package/dist/components/SkyController.d.ts.map +1 -1
  86. package/dist/components/SkyController.js +0 -3
  87. package/dist/components/Skybox.d.ts +5 -0
  88. package/dist/components/Skybox.d.ts.map +1 -1
  89. package/dist/components/Skybox.js +0 -1
  90. package/dist/components/SparklesBurst.d.ts.map +1 -1
  91. package/dist/components/SparklesBurst.js +0 -1
  92. package/dist/components/VoronoiGrid.d.ts +21 -0
  93. package/dist/components/VoronoiGrid.d.ts.map +1 -0
  94. package/dist/components/VoronoiGrid.js +67 -0
  95. package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -1
  96. package/dist/components/effects/ShockwaveEffect.js +0 -1
  97. package/dist/components/effects/SmokeRibbon.d.ts.map +1 -1
  98. package/dist/components/effects/SmokeRibbon.js +0 -1
  99. package/dist/components/index.d.ts +19 -2
  100. package/dist/components/index.d.ts.map +1 -1
  101. package/dist/components/index.js +9 -1
  102. package/dist/constants.d.ts +1 -0
  103. package/dist/constants.d.ts.map +1 -1
  104. package/dist/constants.js +6 -0
  105. package/dist/hooks/index.d.ts +4 -1
  106. package/dist/hooks/index.d.ts.map +1 -1
  107. package/dist/hooks/index.js +3 -1
  108. package/dist/hooks/use3driseShader.d.ts.map +1 -1
  109. package/dist/hooks/use3driseShader.js +0 -9
  110. package/dist/hooks/useAnimationEvents.d.ts.map +1 -1
  111. package/dist/hooks/useAnimationEvents.js +0 -19
  112. package/dist/hooks/useCameraAnimation.d.ts.map +1 -1
  113. package/dist/hooks/useCameraAnimation.js +0 -5
  114. package/dist/hooks/useContinuousEffects.d.ts +2 -3
  115. package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
  116. package/dist/hooks/useContinuousEffects.js +16 -61
  117. package/dist/hooks/useFrameAnimations.d.ts.map +1 -1
  118. package/dist/hooks/useFrameAnimations.js +0 -4
  119. package/dist/hooks/useGridSurface.d.ts +46 -0
  120. package/dist/hooks/useGridSurface.d.ts.map +1 -0
  121. package/dist/hooks/useGridSurface.js +66 -0
  122. package/dist/hooks/useGsapAnimation.d.ts.map +1 -1
  123. package/dist/hooks/useGsapAnimation.js +0 -3
  124. package/dist/hooks/useInteraction.d.ts.map +1 -1
  125. package/dist/hooks/useInteraction.js +0 -25
  126. package/dist/hooks/useInteractionEffects.d.ts +2 -2
  127. package/dist/hooks/useInteractionEffects.d.ts.map +1 -1
  128. package/dist/hooks/useInteractionEffects.js +3 -1
  129. package/dist/hooks/useMaterialApplication.d.ts +2 -2
  130. package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
  131. package/dist/hooks/useMaterialApplication.js +9 -21
  132. package/dist/hooks/useMaterialOptions.d.ts +2 -2
  133. package/dist/hooks/useMaterialOptions.d.ts.map +1 -1
  134. package/dist/hooks/useMaterialOptions.js +13 -37
  135. package/dist/hooks/useMeshController.d.ts.map +1 -1
  136. package/dist/hooks/useMeshController.js +0 -16
  137. package/dist/hooks/useObjectAnimation.d.ts +13 -2
  138. package/dist/hooks/useObjectAnimation.d.ts.map +1 -1
  139. package/dist/hooks/useObjectAnimation.js +26 -28
  140. package/dist/hooks/useObjectEdges.d.ts +2 -1
  141. package/dist/hooks/useObjectEdges.d.ts.map +1 -1
  142. package/dist/hooks/useObjectEdges.js +18 -52
  143. package/dist/hooks/useObjectEffects.d.ts.map +1 -1
  144. package/dist/hooks/useObjectEffects.js +0 -4
  145. package/dist/hooks/useRegisterScene.d.ts +17 -0
  146. package/dist/hooks/useRegisterScene.d.ts.map +1 -0
  147. package/dist/hooks/useRegisterScene.js +33 -0
  148. package/dist/hooks/useSequenceAnimation.d.ts +2 -2
  149. package/dist/hooks/useSequenceAnimation.d.ts.map +1 -1
  150. package/dist/hooks/useSequenceAnimation.js +5 -70
  151. package/dist/hooks/useShadowApplication.d.ts +2 -2
  152. package/dist/hooks/useShadowApplication.d.ts.map +1 -1
  153. package/dist/hooks/useShadowApplication.js +6 -2
  154. package/dist/hooks/useSkyAnimation.d.ts.map +1 -1
  155. package/dist/hooks/useSkyAnimation.js +0 -1
  156. package/dist/hooks/useSkySystem.d.ts.map +1 -1
  157. package/dist/hooks/useSkySystem.js +0 -1
  158. package/dist/index.d.ts +3 -1
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +2 -1
  161. package/dist/services/AnimationsManager.d.ts.map +1 -1
  162. package/dist/services/AnimationsManager.js +0 -1
  163. package/dist/shaders/CircuitGridMaterial.d.ts +76 -0
  164. package/dist/shaders/CircuitGridMaterial.d.ts.map +1 -0
  165. package/dist/shaders/CircuitGridMaterial.js +298 -0
  166. package/dist/shaders/ContourGridMaterial.d.ts +80 -0
  167. package/dist/shaders/ContourGridMaterial.d.ts.map +1 -0
  168. package/dist/shaders/ContourGridMaterial.js +259 -0
  169. package/dist/shaders/FractalGridMaterial.d.ts +76 -0
  170. package/dist/shaders/FractalGridMaterial.d.ts.map +1 -0
  171. package/dist/shaders/FractalGridMaterial.js +247 -0
  172. package/dist/shaders/HexGridMaterial.d.ts +73 -0
  173. package/dist/shaders/HexGridMaterial.d.ts.map +1 -0
  174. package/dist/shaders/HexGridMaterial.js +265 -0
  175. package/dist/shaders/MoireGridMaterial.d.ts +79 -0
  176. package/dist/shaders/MoireGridMaterial.d.ts.map +1 -0
  177. package/dist/shaders/MoireGridMaterial.js +271 -0
  178. package/dist/shaders/QuasiGridMaterial.d.ts +76 -0
  179. package/dist/shaders/QuasiGridMaterial.d.ts.map +1 -0
  180. package/dist/shaders/QuasiGridMaterial.js +238 -0
  181. package/dist/shaders/RadarGridMaterial.d.ts +77 -0
  182. package/dist/shaders/RadarGridMaterial.d.ts.map +1 -0
  183. package/dist/shaders/RadarGridMaterial.js +291 -0
  184. package/dist/shaders/VoronoiGridMaterial.d.ts +73 -0
  185. package/dist/shaders/VoronoiGridMaterial.d.ts.map +1 -0
  186. package/dist/shaders/VoronoiGridMaterial.js +266 -0
  187. package/dist/types/gridConfigs.d.ts +202 -0
  188. package/dist/types/gridConfigs.d.ts.map +1 -0
  189. package/dist/types/gridConfigs.js +11 -0
  190. package/dist/types/index.d.ts +1 -0
  191. package/dist/types/index.d.ts.map +1 -1
  192. package/dist/utils/handleGenerativeEffectsAnimations.d.ts +0 -1
  193. package/dist/utils/handleGenerativeEffectsAnimations.d.ts.map +1 -1
  194. package/dist/utils/handleGenerativeEffectsAnimations.js +0 -29
  195. package/dist/utils/pointsMaterialOwnership.d.ts +9 -0
  196. package/dist/utils/pointsMaterialOwnership.d.ts.map +1 -0
  197. package/dist/utils/pointsMaterialOwnership.js +14 -0
  198. package/dist/utils/resolveObject3D.d.ts +20 -0
  199. package/dist/utils/resolveObject3D.d.ts.map +1 -0
  200. package/dist/utils/resolveObject3D.js +9 -0
  201. package/dist/utils/shapes.d.ts.map +1 -1
  202. package/dist/utils/shapes.js +0 -1
  203. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # @3driseai/3drise-viewer
2
+
3
+ React components for embedding [3dRise](https://3drise.ai) scenes in your app.
4
+
5
+ You build in the **3dRise studio** — create objects, apply materials, set up animations, effects and
6
+ interactions — then render the result in React with one component. Nothing about the scene is configured
7
+ in code: geometry, materials, lighting, animations and interactions all come from what you published.
8
+
9
+ There are two components, depending on how much you want to embed:
10
+
11
+ | Component | Embeds |
12
+ | ------------------ | ----------------------------------------------------------------------- |
13
+ | `<ProjectLoader />` | A whole project — scene, camera, lights, environment, animations, cursors. Renders its own canvas. |
14
+ | `<ObjectNodeApi />` | A single object (and its children) from the studio, dropped into a canvas you control. |
15
+
16
+ ---
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @3driseai/3drise-viewer
22
+ ```
23
+
24
+ The package ships as **ESM only** with bundled TypeScript declarations.
25
+
26
+ ### Peer dependencies
27
+
28
+ | Peer dependency | Version |
29
+ | --------------------- | --------------- |
30
+ | `react` | `^18` or `^19` |
31
+ | `three` | `^0.170` |
32
+ | `@react-three/fiber` | `^9` |
33
+ | `@react-three/drei` | `^10` |
34
+ | `@react-three/rapier` | `^2` |
35
+ | `@gsap/react` | `^2.1.2` |
36
+
37
+ npm 7+ and pnpm 8+ install these for you. On Yarn — classic or Berry — you'll need to add them yourself.
38
+
39
+ > **`three` must resolve to a single copy.** Two versions of three.js in one app is the classic React
40
+ > Three Fiber failure — objects silently refuse to render, `instanceof` checks fail. If your app pins a
41
+ > different `three` than the `^0.170` declared here, dedupe it (`npm ls three` to check, `overrides` /
42
+ > `resolutions` to force one version) rather than letting both install.
43
+
44
+ ---
45
+
46
+ ## Embed a whole project
47
+
48
+ `ProjectLoader` fetches a published project by id, renders its own `<Canvas>`, and shows a loading
49
+ indicator until the scene is ready. This is the whole integration:
50
+
51
+ ```tsx
52
+ import { ProjectLoader } from '@3driseai/3drise-viewer';
53
+
54
+ export default function ProjectPage({ projectId }: { projectId: string }) {
55
+ return (
56
+ <div style={{ height: '100svh', position: 'relative' }}>
57
+ <ProjectLoader projectId={projectId} />
58
+ </div>
59
+ );
60
+ }
61
+ ```
62
+
63
+ `ProjectLoader` renders a `<Canvas>` internally, so it needs a sized parent — give the wrapper an
64
+ explicit height (`100svh`, `100%` of a sized container, a fixed pixel value) or nothing will be visible.
65
+
66
+ ### Reacting to the scene
67
+
68
+ Every callback is optional:
69
+
70
+ ```tsx
71
+ import { ProjectLoader } from '@3driseai/3drise-viewer';
72
+ import type { CreatedObjectSettings } from '@3driseai/3drise-core';
73
+ import type { Object3D } from 'three';
74
+
75
+ <ProjectLoader
76
+ projectId={projectId}
77
+ loadingIndicator={<MySpinner />}
78
+ onSceneInitialized={() => setReady(true)}
79
+ onObjectClick={(object: CreatedObjectSettings, ref: Object3D) => {
80
+ openInspector(object.meshSettings.name, ref);
81
+ }}
82
+ onObjectHover={(object, ref) => setHovered(object.id)}
83
+ />;
84
+ ```
85
+
86
+ ### `<ProjectLoader />` props
87
+
88
+ | Prop | Type | Description |
89
+ | -------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
90
+ | `projectId` | `string` **(required)** | Id of the published 3dRise project to load. |
91
+ | `loadingIndicator` | `React.ReactNode` | Replaces the built-in full-screen loader shown while the project is fetched. |
92
+ | `onSceneInitialized` | `() => void` | Fires once the scene has mounted. |
93
+ | `onObjectClick` | `(object: CreatedObjectSettings, ref: Object3D, event: ThreeEvent<MouseEvent>) => void` | A scene object was clicked. |
94
+ | `onObjectHover` | `(object: CreatedObjectSettings, ref: Object3D) => void` | Pointer entered a scene object. |
95
+ | `onElementClick` | `(element: HtmlElement) => void` | A 2D UI element in the project was clicked. |
96
+ | `onElementHover` | `(element: HtmlElement \| null) => void` | Pointer entered/left a 2D UI element. |
97
+ | `onObjectReady` | `(object, ref: Object3D) => void` | Every object in the scene reports its `Object3D` here — see below. |
98
+ | `onObjectDispose` | `(object, ref: Object3D) => void` | The matching teardown event for `onObjectReady`. |
99
+
100
+ ---
101
+
102
+ ## Embed a single object
103
+
104
+ Sometimes you don't want a whole scene — you want one thing you built in the studio, placed in a canvas
105
+ your app already owns.
106
+
107
+ Create the object in the 3dRise studio, give it its material, animations, effects and click
108
+ interactions, publish it, and copy its object id. `ObjectNodeApi` fetches that object's tree and renders
109
+ it — with everything you configured intact:
110
+
111
+ ```tsx
112
+ import { Canvas } from '@react-three/fiber';
113
+ import { OrbitControls } from '@react-three/drei';
114
+ import { ObjectNodeApi } from '@3driseai/3drise-viewer';
115
+ import type { CameraState } from '@3driseai/3drise-core';
116
+
117
+ const cameraSettings: CameraState = {
118
+ position: [0, 2, 8],
119
+ orientation: [0, 0, 0, 1],
120
+ fov: 50,
121
+ near: 0.1,
122
+ far: 1000,
123
+ animations: [],
124
+ mouseMove: { enabled: false, properties: [] },
125
+ controls: { enabled: true, target: [0, 0, 0] },
126
+ };
127
+
128
+ export function Hero({ objectId }: { objectId: string }) {
129
+ return (
130
+ <Canvas camera={{ position: [0, 2, 8], fov: 50 }} style={{ height: '60vh' }}>
131
+ <ambientLight intensity={0.5} />
132
+ <directionalLight position={[5, 10, 5]} intensity={1.5} />
133
+
134
+ <ObjectNodeApi objectId={objectId} cameraSettings={cameraSettings} />
135
+
136
+ <OrbitControls />
137
+ </Canvas>
138
+ );
139
+ }
140
+ ```
141
+
142
+ Because you own the canvas here, you also own everything around the object — **camera, lighting,
143
+ controls and background are yours to provide**. `ObjectNodeApi` contributes only the object itself, so
144
+ an object with no emissive material in an unlit canvas will render black. It renders `null` until the
145
+ fetch resolves, so it's safe to mount immediately.
146
+
147
+ Groups come through whole: if the object has children in the studio, they're rendered as a tree with
148
+ their own materials and animations.
149
+
150
+ ### `<ObjectNodeApi />` props
151
+
152
+ | Prop | Type | Description |
153
+ | ------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
154
+ | `objectId` | `string` **(required)** | Id of the published scene object to load. |
155
+ | `cameraSettings` | `CameraState` **(required)** | The camera the object should assume. Currently only `fov` is read, and only by particle objects — but the full object is required. |
156
+ | `handleObjectClick` | `(object: CreatedObjectSettings, ref: Object3D, event: ThreeEvent<MouseEvent>) => void` | The object was clicked. Note the name differs from `ProjectLoader`'s `onObjectClick`. |
157
+ | `onObjectReady` | `(object, ref: Object3D) => void` | The object reports its `Object3D` here — see below. |
158
+ | `onObjectDispose` | `(object, ref: Object3D) => void` | The matching teardown event. |
159
+
160
+ ---
161
+
162
+ ## Getting at the three.js objects
163
+
164
+ Both components implement the same two props, so you can build a live registry of what's in the scene
165
+ without reaching into refs yourself:
166
+
167
+ ```ts
168
+ type OnObjectReady = (object: ObjectReadySource, ref: Object3D) => void;
169
+ type OnObjectDispose = (object: ObjectReadySource, ref: Object3D) => void;
170
+ ```
171
+
172
+ - **`object`** is the settings the object was built with in the studio. It's a union: scene objects give
173
+ you a `CreatedObjectSettings` (with its studio `id` and `meshSettings`), while effects and cursors give
174
+ you their own config — narrow it before reading fields. Never `null`.
175
+ - **`ref`** is the root `Object3D` that just mounted.
176
+ - Every `onObjectReady` is eventually paired with an `onObjectDispose` for the same ref, on unmount or
177
+ when the component swaps its root — so a `Map` built from these events stays accurate.
178
+
179
+ ```tsx
180
+ const objects = useRef(new Map<string, Object3D>());
181
+
182
+ <ProjectLoader
183
+ projectId={projectId}
184
+ onObjectReady={(object, ref) => objects.current.set(ref.uuid, ref)}
185
+ onObjectDispose={(object, ref) => objects.current.delete(ref.uuid)}
186
+ />;
187
+ ```
188
+
189
+ To key by the studio id instead, narrow first — `if ('meshSettings' in object)` tells you it's a
190
+ `CreatedObjectSettings`.
191
+
192
+ From there it's plain three.js — animate it, raycast against it, attach it to your own logic.
193
+
194
+ ---
195
+
196
+ ## TypeScript
197
+
198
+ Types ship with the package:
199
+
200
+ ```ts
201
+ import type {
202
+ ObjectReadyProps,
203
+ ObjectReadySource,
204
+ OnObjectReady,
205
+ OnObjectDispose,
206
+ } from '@3driseai/3drise-viewer';
207
+ ```
208
+
209
+ Scene and object types come from the core package, which installs alongside this one:
210
+
211
+ ```ts
212
+ import type { CameraState, CreatedObjectSettings } from '@3driseai/3drise-core';
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Notes
218
+
219
+ - **ESM only.** There is no CommonJS build. In Next.js or another SSR framework, render the viewer
220
+ client-side (`'use client'`, or a dynamic import with `ssr: false`) — it touches `window` and WebGL.
221
+ - **One entry point.** Import everything from `@3driseai/3drise-viewer`; there are no deep subpath imports.
222
+
223
+ ## Links
224
+
225
+ - [3dRise](https://3drise.ai)
@@ -0,0 +1,16 @@
1
+ import type { ObjectReadyProps } from '../types/objectReady';
2
+ import type { ThreeElements } from '@react-three/fiber';
3
+ import type { MyGridConfig } from '@3driseai/3drise-core';
4
+ export interface AdvancedGridProps extends ObjectReadyProps {
5
+ config?: MyGridConfig;
6
+ groupProps?: ThreeElements['group'];
7
+ }
8
+ /**
9
+ * MyGridConfig — the single source of truth for a grid instance.
10
+ * Colors are hex strings so they round-trip cleanly through the controller
11
+ * and any preset/serialization layer.
12
+ */
13
+ export declare const defaultMyGridConfig: MyGridConfig;
14
+ export declare function AdvancedGrid({ config, groupProps, onObjectReady, onObjectDispose }: AdvancedGridProps): import("react").JSX.Element;
15
+ export default AdvancedGrid;
16
+ //# sourceMappingURL=AdvancedGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedGrid.d.ts","sourceRoot":"","sources":["../../src/components/AdvancedGrid.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACvD,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACvC;AAKD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAyBjC,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,MAA4B,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,iBAAiB,+BAiE3H;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useObjectReady } from '../hooks/useObjectReady.js';
3
+ import { useGridSurface } from '../hooks/useGridSurface.js';
4
+ import { useMemo, useRef } from 'react';
5
+ import * as THREE from 'three';
6
+ import { MyGridMaterial } from '@3driseai/3drise-core';
7
+ // Side-effect import registers <myGridMaterial> via extend() in MyGridMaterial.ts.
8
+ void MyGridMaterial;
9
+ /**
10
+ * MyGridConfig — the single source of truth for a grid instance.
11
+ * Colors are hex strings so they round-trip cleanly through the controller
12
+ * and any preset/serialization layer.
13
+ */
14
+ export const defaultMyGridConfig = {
15
+ cellSize: 1,
16
+ size: 50,
17
+ segments: undefined,
18
+ flat: true,
19
+ lineMode: 2, // flow
20
+ cellMode: 2, // twinkle
21
+ lineWidth: 1,
22
+ sectionSize: 5,
23
+ sectionWidth: 1.6,
24
+ animSpeed: 1,
25
+ animScale: 0.5,
26
+ animIntensity: 1,
27
+ fadeDistance: undefined,
28
+ fadeStrength: 0.65,
29
+ displace: 0,
30
+ lineColor: '#477fb8',
31
+ sectionColor: '#80c7ff',
32
+ cellColor: '#1a5999',
33
+ glowColor: '#339eff',
34
+ bgColor: '#05080d',
35
+ bgOpacity: 0,
36
+ followMouse: false,
37
+ reveal: 1,
38
+ revealDuration: 0,
39
+ };
40
+ export function AdvancedGrid({ config = defaultMyGridConfig, groupProps, onObjectReady, onObjectDispose }) {
41
+ const matRef = useRef(null);
42
+ const rootRef = useRef(null);
43
+ const meshRef = useRef(null);
44
+ useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
45
+ const { cellSize, size, segments, flat, lineMode, cellMode, lineWidth, sectionSize, sectionWidth, animSpeed, animScale, animIntensity, fadeDistance, fadeStrength, displace, lineColor, sectionColor, cellColor, glowColor, bgColor, bgOpacity, followMouse, reveal, revealDuration, } = config;
46
+ const segs = segments ?? (displace > 0 ? Math.max(64, Math.ceil(size / cellSize) * 2) : 1);
47
+ const fade = fadeDistance ?? size * 0.5;
48
+ // memoize Color objects so we only re-allocate when the hex actually changes
49
+ const colors = useMemo(() => ({
50
+ line: new THREE.Color(lineColor),
51
+ section: new THREE.Color(sectionColor),
52
+ cell: new THREE.Color(cellColor),
53
+ glow: new THREE.Color(glowColor),
54
+ bg: new THREE.Color(bgColor),
55
+ }), [lineColor, sectionColor, cellColor, glowColor, bgColor]);
56
+ // Shared with every other shader-plane grid. This also fixes the pointer
57
+ // projection: it used to assume the XZ plane, so `followMouse` picked
58
+ // against the wrong plane whenever `flat` was false or a parent transform
59
+ // had rotated the grid.
60
+ useGridSurface(matRef, meshRef, { followMouse, reveal, revealDuration });
61
+ return (_jsx("group", { ref: rootRef, ...groupProps, children: _jsxs("mesh", { ref: meshRef, rotation: flat ? [-Math.PI / 2, 0, 0] : [0, 0, 0], children: [_jsx("planeGeometry", { args: [size, size, segs, segs] }), _jsx("myGridMaterial", { ref: matRef, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending, side: THREE.DoubleSide, u_cellSize: cellSize, u_lineWidth: lineWidth, u_sectionSize: sectionSize, u_sectionWidth: sectionWidth, u_lineMode: lineMode, u_cellMode: cellMode, u_animSpeed: animSpeed, u_animScale: animScale, u_animIntensity: animIntensity, u_fadeDistance: fade, u_fadeStrength: fadeStrength, u_displace: displace, u_lineColor: colors.line, u_sectionColor: colors.section, u_cellColor: colors.cell, u_glowColor: colors.glow, u_bgColor: colors.bg, u_bgOpacity: bgOpacity }, MyGridMaterial.key)] }) }));
62
+ }
63
+ export default AdvancedGrid;
@@ -1 +1 @@
1
- {"version":3,"file":"AnimatedObject.d.ts","sourceRoot":"","sources":["../../src/components/AnimatedObject.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAM7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACtG,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,aAAa,EAAE,qBAAqB,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IACjH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACvD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACvD,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAGD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA+DvD,CAAC;AAEH,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"AnimatedObject.d.ts","sourceRoot":"","sources":["../../src/components/AnimatedObject.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAM7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACtG,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,aAAa,EAAE,qBAAqB,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IACjH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACvD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACvD,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAGD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAiEvD,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -32,10 +32,13 @@ visible = true, children, parentRef, handleObjectClick, onPointerEnter, onPointe
32
32
  scale: targetScale ? [...targetScale] : [...scale],
33
33
  rotation: targetRotation ? [...targetRotation] : [...rotation],
34
34
  });
35
+ // Pass the ref itself, not `groupRef.current`: the animation hooks read
36
+ // `.current` inside useFrame, so the group resolves the moment React
37
+ // attaches it — no scene lookup and no extra render needed.
35
38
  useObjectAnimation(createdObject, animateMaterial, {
36
39
  enabled: createdObject.type !== 'gallery', //
37
40
  hovered,
38
- });
41
+ }, groupRef);
39
42
  const { startPathAnimation, updatePathAnimation, isAnimating: isPathAnimating } = usePathAnimation();
40
43
  const syncTransform = useCallback(() => {
41
44
  const obj = groupRef.current;
@@ -60,14 +63,13 @@ visible = true, children, parentRef, handleObjectClick, onPointerEnter, onPointe
60
63
  handleObjectClick(createdObject, groupRef.current, e);
61
64
  }
62
65
  };
63
- // console.log("AnimatedObject render", { name: createdObject.meshSettings.name, id: createdObject.id, hovered, hasHoverFunctionalities })
64
66
  if (createdObject.type === 'particles' || createdObject.type === 'gallery' || (!hasHoverFunctionalities && !hasMouseInteraction)) {
65
67
  return _jsx(_Fragment, { children: _jsxs("group", { ref: groupRef, position: position, scale: scale, rotation: rotation, visible: visible, onClick: onClick,
66
68
  // onPointerEnter={onPointerEnter}
67
69
  // onPointerLeave={onPointerLeave}
68
- name: createdObject.meshSettings.name, userData: { id: createdObject.id }, children: [children, _jsx(EffectsGroup, { createdObject: createdObject, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose })] }) });
70
+ name: createdObject.meshSettings.name, userData: { id: createdObject.id }, children: [children, _jsx(EffectsGroup, { createdObject: createdObject, objectRef: groupRef, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose })] }) });
69
71
  }
70
- return (_jsx(_Fragment, { children: _jsxs("group", { ref: groupRef, position: position, scale: scale, rotation: rotation, visible: visible, onClick: onClick, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, name: createdObject.meshSettings.name, userData: { id: createdObject.id }, children: [children, _jsx(EffectsGroup, { createdObject: createdObject, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose })] }) }));
72
+ return (_jsx(_Fragment, { children: _jsxs("group", { ref: groupRef, position: position, scale: scale, rotation: rotation, visible: visible, onClick: onClick, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, name: createdObject.meshSettings.name, userData: { id: createdObject.id }, children: [children, _jsx(EffectsGroup, { createdObject: createdObject, objectRef: groupRef, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose })] }) }));
71
73
  });
72
74
  AnimatedObject.displayName = 'AnimatedObject';
73
75
  export default AnimatedObject;
@@ -1 +1 @@
1
- {"version":3,"file":"CameraController.d.ts","sourceRoot":"","sources":["../../src/components/CameraController.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQ7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,UAAU,qBAAsB,SAAQ,gBAAgB;IACpD,QAAQ,EAAE,WAAW,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;CAC/C;AAGD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA8J5D,CAAC;AACF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CameraController.d.ts","sourceRoot":"","sources":["../../src/components/CameraController.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQ7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,UAAU,qBAAsB,SAAQ,gBAAgB;IACpD,QAAQ,EAAE,WAAW,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;CAC/C;AAGD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAwJ5D,CAAC;AACF,eAAe,gBAAgB,CAAC"}
@@ -55,7 +55,6 @@ export const CameraController = ({ enableAutoAnimation = true, animationDuration
55
55
  else {
56
56
  cam.rotation.set(orientation[0], orientation[1], orientation[2]);
57
57
  }
58
- console.log("CameraController: Synced position/orientation", position, orientation);
59
58
  }
60
59
  }, [position, orientation]);
61
60
  // Sync controls config changes imperatively via ref (after initial mount)
@@ -104,26 +103,22 @@ export const CameraController = ({ enableAutoAnimation = true, animationDuration
104
103
  // Handle animation events (step-based animations)
105
104
  useAnimationEvents({
106
105
  onStepStart: (event) => {
107
- // console.log('Camera controller - Step started:', event.step);
108
106
  if (event.step?.transitions) {
109
107
  const stepDuration = event.step.duration || 1;
110
108
  event.step.transitions.forEach((transition) => {
111
109
  const { state, properties, pathId } = transition;
112
110
  if (state === 'camera') {
113
- console.log('Camera transition detected. Starting animation to new camera state:', properties);
114
111
  isInAnimatedTransition.current = true;
115
112
  if (pathId) {
116
113
  const offset = camera
117
114
  ? [camera.position.x, camera.position.y, camera.position.z]
118
115
  : [0, 0, 0];
119
- console.log(`Starting path animation with ID ${pathId} and offset`, offset);
120
116
  startPathAnimation(pathId, stepDuration, {
121
117
  offset,
122
118
  applyRotation: false
123
119
  });
124
120
  transformAnimationProgress.current = 0;
125
121
  }
126
- // console.log("Animating camera to:", targetSettings, "over duration:", stepDuration);
127
122
  const startSettings = properties.from ?
128
123
  {
129
124
  position: properties.from.position,
@@ -133,7 +128,6 @@ export const CameraController = ({ enableAutoAnimation = true, animationDuration
133
128
  // orientation: camera.rotation,
134
129
  };
135
130
  const targetSettings = properties.to;
136
- // console.log("Starting camera animation from:", startSettings);
137
131
  // startSettings.position && camera.position.set(startSettings.position[0], startSettings.position[1], startSettings.position[2]);
138
132
  // camera.rotation.set(startSettings.orientation[0], startSettings.orientation[1], startSettings.orientation[2]);
139
133
  animateCamera(targetSettings, stepDuration, event.step?.ease, properties.to.target)
@@ -0,0 +1,22 @@
1
+ import type { ThreeElements } from '@react-three/fiber';
2
+ import type { ObjectReadyProps } from '../types/objectReady';
3
+ import type { CircuitGridConfig } from '../types/gridConfigs';
4
+ export interface CircuitGridProps extends ObjectReadyProps {
5
+ config?: CircuitGridConfig;
6
+ groupProps?: ThreeElements['group'];
7
+ }
8
+ /** CircuitGridConfig — the single source of truth for a circuit grid instance. */
9
+ export declare const defaultCircuitGridConfig: CircuitGridConfig;
10
+ /**
11
+ * A Truchet circuit board on a shader plane.
12
+ *
13
+ * Each tile carries two quarter-arcs and half the tiles are mirrored, which is
14
+ * what chains them into long meandering traces instead of disconnected curves.
15
+ * `lineMode` 2 sends light pulses travelling along those traces; the other
16
+ * modes match the rest of the grid family (static, ripple, scan, pulse).
17
+ * `chipChance` sprinkles IC packages across the board and `sectionSize` lays
18
+ * straight buses over the weave.
19
+ */
20
+ export declare function CircuitGrid({ config, groupProps, onObjectReady, onObjectDispose }: CircuitGridProps): import("react").JSX.Element;
21
+ export default CircuitGrid;
22
+ //# sourceMappingURL=CircuitGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CircuitGrid.d.ts","sourceRoot":"","sources":["../../src/components/CircuitGrid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACtD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,UAAU,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACvC;AAKD,kFAAkF;AAClF,eAAO,MAAM,wBAAwB,EAAE,iBA4BtC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAiC,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,gBAAgB,+BAiE9H;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useRef } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useObjectReady } from '../hooks/useObjectReady.js';
5
+ import { useGridSurface } from '../hooks/useGridSurface.js';
6
+ import { CircuitGridMaterial } from '@3driseai/3drise-core';
7
+ // Side-effect import registers <circuitGridMaterial> via extend().
8
+ void CircuitGridMaterial;
9
+ /** CircuitGridConfig — the single source of truth for a circuit grid instance. */
10
+ export const defaultCircuitGridConfig = {
11
+ cellSize: 1.6,
12
+ size: 50,
13
+ segments: undefined,
14
+ flat: true,
15
+ lineMode: 2, // signal pulses running along the traces
16
+ cellMode: 0,
17
+ lineWidth: 1.6,
18
+ sectionSize: 6,
19
+ sectionWidth: 1.2,
20
+ animSpeed: 1,
21
+ animScale: 1,
22
+ animIntensity: 1,
23
+ fadeDistance: undefined,
24
+ fadeStrength: 0.7,
25
+ displace: 0,
26
+ powered: 0.65,
27
+ chipChance: 0.06,
28
+ padSize: 1,
29
+ lineColor: '#186b5c',
30
+ sectionColor: '#8cf0b4',
31
+ cellColor: '#082420',
32
+ glowColor: '#59ffb8',
33
+ bgColor: '#020806',
34
+ bgOpacity: 0,
35
+ followMouse: false,
36
+ reveal: 1,
37
+ revealDuration: 0,
38
+ };
39
+ /**
40
+ * A Truchet circuit board on a shader plane.
41
+ *
42
+ * Each tile carries two quarter-arcs and half the tiles are mirrored, which is
43
+ * what chains them into long meandering traces instead of disconnected curves.
44
+ * `lineMode` 2 sends light pulses travelling along those traces; the other
45
+ * modes match the rest of the grid family (static, ripple, scan, pulse).
46
+ * `chipChance` sprinkles IC packages across the board and `sectionSize` lays
47
+ * straight buses over the weave.
48
+ */
49
+ export function CircuitGrid({ config = defaultCircuitGridConfig, groupProps, onObjectReady, onObjectDispose }) {
50
+ const matRef = useRef(null);
51
+ const rootRef = useRef(null);
52
+ const meshRef = useRef(null);
53
+ useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
54
+ const { cellSize, size, segments, flat, lineMode, cellMode, lineWidth, sectionSize, sectionWidth, animSpeed, animScale, animIntensity, fadeDistance, fadeStrength, displace, powered, chipChance, padSize, lineColor, sectionColor, cellColor, glowColor, bgColor, bgOpacity, followMouse, reveal, revealDuration, } = config;
55
+ const segs = segments ?? (displace > 0
56
+ ? Math.min(256, Math.max(64, Math.ceil(size / Math.max(cellSize, 1e-4)) * 2))
57
+ : 1);
58
+ const fade = fadeDistance ?? size * 0.5;
59
+ const colors = useMemo(() => ({
60
+ line: new THREE.Color(lineColor),
61
+ section: new THREE.Color(sectionColor),
62
+ cell: new THREE.Color(cellColor),
63
+ glow: new THREE.Color(glowColor),
64
+ bg: new THREE.Color(bgColor),
65
+ }), [lineColor, sectionColor, cellColor, glowColor, bgColor]);
66
+ useGridSurface(matRef, meshRef, { followMouse, reveal, revealDuration });
67
+ return (_jsx("group", { ref: rootRef, ...groupProps, children: _jsxs("mesh", { ref: meshRef, rotation: flat ? [-Math.PI / 2, 0, 0] : [0, 0, 0], children: [_jsx("planeGeometry", { args: [size, size, segs, segs] }), _jsx("circuitGridMaterial", { ref: matRef, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending, side: THREE.DoubleSide, u_cellSize: cellSize, u_lineWidth: lineWidth, u_sectionSize: sectionSize, u_sectionWidth: sectionWidth, u_lineMode: lineMode, u_cellMode: cellMode, u_animSpeed: animSpeed, u_animScale: animScale, u_animIntensity: animIntensity, u_fadeDistance: fade, u_fadeStrength: fadeStrength, u_displace: displace, u_powered: powered, u_chipChance: chipChance, u_padSize: padSize, u_lineColor: colors.line, u_sectionColor: colors.section, u_cellColor: colors.cell, u_glowColor: colors.glow, u_bgColor: colors.bg, u_bgOpacity: bgOpacity }, CircuitGridMaterial.key)] }) }));
68
+ }
69
+ export default CircuitGrid;
@@ -1 +1 @@
1
- {"version":3,"file":"Clouds.d.ts","sourceRoot":"","sources":["../../src/components/Clouds.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQ7D,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACjD,QAAQ,EAAE,qBAAqB,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAmFD,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA2LjC,CAAC;AACF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Clouds.d.ts","sourceRoot":"","sources":["../../src/components/Clouds.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQ7D,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACjD,QAAQ,EAAE,qBAAqB,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAmFD,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAsLjC,CAAC;AACF,eAAe,MAAM,CAAC"}
@@ -94,9 +94,7 @@ const Clouds = ({ settings, timeSettings = defaultTimeSettings, onObjectReady, o
94
94
  const materialSettings = settings.materialSettings;
95
95
  const position = meshSettings.position;
96
96
  const scale = meshSettings.scale;
97
- // console.log(config.speed)
98
97
  const baseSpeed = config.speed ?? 1;
99
- // console.log(baseSpeed)
100
98
  const height = position[1];
101
99
  const planeSize = config?.planeSize || [10000, 10000];
102
100
  const planeSegments = config?.planeSegments || 64;
@@ -236,10 +234,7 @@ const Clouds = ({ settings, timeSettings = defaultTimeSettings, onObjectReady, o
236
234
  ?? numericOverrideRef.current?.speed
237
235
  ?? mouseOverrideRef.current.speed
238
236
  ?? baseSpeed;
239
- // console.log(effectiveSpeed)
240
- // console.log(effectiveSpeed)
241
237
  cloudAnimTime.current += 0.02 * effectiveSpeed;
242
- // console.log(cloudAnimTime.current)
243
238
  if (uniforms.u_time)
244
239
  uniforms.u_time.value = cloudAnimTime.current;
245
240
  if (uniforms.u_cameraPos) {
@@ -0,0 +1,25 @@
1
+ import type { ThreeElements } from '@react-three/fiber';
2
+ import type { ObjectReadyProps } from '../types/objectReady';
3
+ import type { ContourGridConfig } from '../types/gridConfigs';
4
+ export interface ContourGridProps extends ObjectReadyProps {
5
+ config?: ContourGridConfig;
6
+ groupProps?: ThreeElements['group'];
7
+ }
8
+ /** ContourGridConfig — the single source of truth for a contour grid instance. */
9
+ export declare const defaultContourGridConfig: ContourGridConfig;
10
+ /**
11
+ * Topographic iso-lines over a drifting terrain field — minor contours every
12
+ * step, index contours every `sectionSize`.
13
+ *
14
+ * `displace` is literal here rather than decorative: the vertex stage raises the
15
+ * surface to exactly the elevation the contours describe, because both stages
16
+ * evaluate the same terrain function. That is also why the two must stay in
17
+ * sync — any divergence slides the lines off the landform they describe.
18
+ *
19
+ * `cellSize` is the horizontal scale of the terrain, so it is much larger than
20
+ * on the lattice grids; `roughness` runs from rolling to craggy and `warp`
21
+ * bends the contours into ridges and valleys.
22
+ */
23
+ export declare function ContourGrid({ config, groupProps, onObjectReady, onObjectDispose }: ContourGridProps): import("react").JSX.Element;
24
+ export default ContourGrid;
25
+ //# sourceMappingURL=ContourGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContourGrid.d.ts","sourceRoot":"","sources":["../../src/components/ContourGrid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACtD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,UAAU,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACvC;AAKD,kFAAkF;AAClF,eAAO,MAAM,wBAAwB,EAAE,iBA4BtC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAiC,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,gBAAgB,+BAmE9H;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useRef } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useObjectReady } from '../hooks/useObjectReady.js';
5
+ import { useGridSurface } from '../hooks/useGridSurface.js';
6
+ import { ContourGridMaterial } from '@3driseai/3drise-core';
7
+ // Side-effect import registers <contourGridMaterial> via extend().
8
+ void ContourGridMaterial;
9
+ /** ContourGridConfig — the single source of truth for a contour grid instance. */
10
+ export const defaultContourGridConfig = {
11
+ cellSize: 14,
12
+ size: 50,
13
+ segments: undefined,
14
+ flat: true,
15
+ lineMode: 0,
16
+ cellMode: 1, // elevation tint
17
+ lineWidth: 1,
18
+ sectionSize: 5,
19
+ sectionWidth: 2.2,
20
+ animSpeed: 1,
21
+ animScale: 0.5,
22
+ animIntensity: 1,
23
+ fadeDistance: undefined,
24
+ fadeStrength: 0.7,
25
+ displace: 0,
26
+ levels: 16,
27
+ roughness: 0.5,
28
+ warp: 0.35,
29
+ lineColor: '#59d9b3',
30
+ sectionColor: '#bff299',
31
+ cellColor: '#1a5c52',
32
+ glowColor: '#8cffbf',
33
+ bgColor: '#020a0a',
34
+ bgOpacity: 0,
35
+ followMouse: false,
36
+ reveal: 1,
37
+ revealDuration: 0,
38
+ };
39
+ /**
40
+ * Topographic iso-lines over a drifting terrain field — minor contours every
41
+ * step, index contours every `sectionSize`.
42
+ *
43
+ * `displace` is literal here rather than decorative: the vertex stage raises the
44
+ * surface to exactly the elevation the contours describe, because both stages
45
+ * evaluate the same terrain function. That is also why the two must stay in
46
+ * sync — any divergence slides the lines off the landform they describe.
47
+ *
48
+ * `cellSize` is the horizontal scale of the terrain, so it is much larger than
49
+ * on the lattice grids; `roughness` runs from rolling to craggy and `warp`
50
+ * bends the contours into ridges and valleys.
51
+ */
52
+ export function ContourGrid({ config = defaultContourGridConfig, groupProps, onObjectReady, onObjectDispose }) {
53
+ const matRef = useRef(null);
54
+ const rootRef = useRef(null);
55
+ const meshRef = useRef(null);
56
+ useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
57
+ const { cellSize, size, segments, flat, lineMode, cellMode, lineWidth, sectionSize, sectionWidth, animSpeed, animScale, animIntensity, fadeDistance, fadeStrength, displace, levels, roughness, warp, lineColor, sectionColor, cellColor, glowColor, bgColor, bgOpacity, followMouse, reveal, revealDuration, } = config;
58
+ // Terrain needs a far denser mesh than the lattice grids: the silhouette is
59
+ // the whole point, and it is only as good as the tessellation carrying it.
60
+ const segs = segments ?? (displace > 0
61
+ ? Math.min(384, Math.max(128, Math.ceil(size / Math.max(cellSize, 1e-4)) * 48))
62
+ : 1);
63
+ const fade = fadeDistance ?? size * 0.5;
64
+ const colors = useMemo(() => ({
65
+ line: new THREE.Color(lineColor),
66
+ section: new THREE.Color(sectionColor),
67
+ cell: new THREE.Color(cellColor),
68
+ glow: new THREE.Color(glowColor),
69
+ bg: new THREE.Color(bgColor),
70
+ }), [lineColor, sectionColor, cellColor, glowColor, bgColor]);
71
+ useGridSurface(matRef, meshRef, { followMouse, reveal, revealDuration });
72
+ return (_jsx("group", { ref: rootRef, ...groupProps, children: _jsxs("mesh", { ref: meshRef, rotation: flat ? [-Math.PI / 2, 0, 0] : [0, 0, 0], children: [_jsx("planeGeometry", { args: [size, size, segs, segs] }), _jsx("contourGridMaterial", { ref: matRef, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending, side: THREE.DoubleSide, u_cellSize: cellSize, u_lineWidth: lineWidth, u_sectionSize: sectionSize, u_sectionWidth: sectionWidth, u_lineMode: lineMode, u_cellMode: cellMode, u_animSpeed: animSpeed, u_animScale: animScale, u_animIntensity: animIntensity, u_fadeDistance: fade, u_fadeStrength: fadeStrength, u_displace: displace, u_levels: levels, u_roughness: roughness, u_warp: warp, u_lineColor: colors.line, u_sectionColor: colors.section, u_cellColor: colors.cell, u_glowColor: colors.glow, u_bgColor: colors.bg, u_bgOpacity: bgOpacity }, ContourGridMaterial.key)] }) }));
73
+ }
74
+ export default ContourGrid;
@@ -1 +1 @@
1
- {"version":3,"file":"CreatedObject.d.ts","sourceRoot":"","sources":["../../src/components/CreatedObject.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,UAAU,kBAAmB,SAAQ,gBAAgB;IACjD,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACpH;AAGD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmF9C,CAAC;AAEH,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"CreatedObject.d.ts","sourceRoot":"","sources":["../../src/components/CreatedObject.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,UAAU,kBAAmB,SAAQ,gBAAgB;IACjD,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACpH;AAGD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAgF9C,CAAC;AAEH,eAAe,aAAa,CAAC"}