MCPcopy Create free account
hub / github.com/collidingScopes/iron-interface / createWave

Function createWave

geometry.js:171–199  ·  view source on GitHub ↗
(i, count)

Source from the content-addressed store, hash-verified

169}
170
171function createWave(i, count) {
172 // Wave/ocean parameters
173 const width = 60; // Total width of the wave field
174 const depth = 60; // Total depth of the wave field
175 const waveHeight = 10; // Maximum height of waves
176 const waveDensity = 0.1; // Controls wave frequency
177
178 // Create a grid of points (similar to your grid function but for a 2D plane)
179 const gridSize = Math.ceil(Math.sqrt(count));
180 const spacingX = width / gridSize;
181 const spacingZ = depth / gridSize;
182
183 // Calculate 2D grid position
184 const ix = i % gridSize;
185 const iz = Math.floor(i / gridSize);
186
187 // Convert to actual coordinates with proper spacing
188 const halfWidth = width / 2;
189 const halfDepth = depth / 2;
190 const x = ix * spacingX - halfWidth;
191 const z = iz * spacingZ - halfDepth;
192
193 // Create wave pattern using multiple sine waves for a more natural look
194 // We use the x and z coordinates to create a position-based wave pattern
195 const y = Math.sin(x * waveDensity) * Math.cos(z * waveDensity) * waveHeight +
196 Math.sin(x * waveDensity * 2.5) * Math.cos(z * waveDensity * 2.1) * (waveHeight * 0.3);
197
198 return new THREE.Vector3(x, y, z);
199}
200
201function createMobius(i, count) {
202 // Möbius strip parameters

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected