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").

  Δφ/frame  

The helper: ElevationGrid

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):

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.