The Function3D height fields again, drawn with three.js in WebGL, so you can move freely: drag to rotate, scroll or pinch to zoom, right-drag (or two fingers) to move the surface. The buttons over the picture look from the front, top or side, zoom, switch a drag from turning to moving (for a touch screen), turn it by itself and reset the view; double-click or double-tap puts a point in the middle. Pick a function, then drag the φ slider or press Play to watch the surface move.
Loading three.js. If this note stays, the browser could not load or start it (WebGL may be switched off: Settings > System > "Use graphics acceleration when available").
The surface is drawn by ElevationGrid (lib/larsi.org/three/elevationgrid.js), a three.js version of the VRML ElevationGrid node, with VRML's own names. It is a grid of heights over the x-z plane, with y up. This page gives it the function: grid.sample((x, z) => height) asks for the height at every vertex, and moving the φ slider just samples again.
Options of the constructor (the same names as the VRML fields, except the last four):
xDimension, zDimension - how many vertices along x and along z (at least 2, default 64). The Grid slider sets both.xSpacing, zSpacing - the distance between neighboring vertices (default 1). The page uses 6 divided by the number of gaps, so the surface is always 6 wide whatever the grid.height - instead of a function, the heights themselves, xDimension * zDimension numbers row by row.solid - VRML's default is true: only the top is drawn, so the surface vanishes seen from below. This page passes false so both sides show.heightScale - multiplies every height, so a tall peak and a gentle ripple fit one picture (the Height slider). Not in VRML.mode - how it is drawn (the Draw as menu). Not in VRML.colorMap - a function from a color value to red, green and blue (the color menu). Not in VRML.background - the color the hidden-line mode paints its surface in, so it matches the page.The five modes. Surface is the lit, colored surface; wire mesh is colored grid lines with the hidden ones removed, the classic mesh plot; surface with grid lines is both. Cubes and columns draw one box per vertex instead of a surface: a cube is centered on the vertex at its height, a column stands on zero and reaches up (or down) to it, like a bar chart. All the boxes are one instanced mesh, one draw call. The count above the controls follows the mode: two triangles per grid cell for a surface, twelve (a box) per vertex for cubes and columns.
Methods. sample(fn, colorMap) evaluates a function at every vertex; fn may return a height, or a height and a separate color value, so a surface can be colored by something other than its height. setHeight(height, colorValue) takes ready arrays. setColorMap(), setHeightScale(), setMode(), setSolid(), setDimension() and setSpacing() change one thing without recomputing the rest, and bounds() gives a box round the surface for the camera. As in VRML, vertex (i, j) sits at (i · xSpacing, j · zSpacing) with the corner, not the middle, at the origin, and row 0 is the one farthest from the camera, so this page shifts its own coordinates to put the function's origin in the middle.
This page was created with Claude Code.