npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@scenoco-three/terrain

v1.4.0

Published

Terrain for SceNoCo: Unity-shaped Terrain and TerrainData on three.js — a compact heightmap and ground layers splatted by weight, blended by height.

Readme

@scenoco-three/terrain

Ground from a heightmap, textured by layers, in the shape of Unity's terrain. Part of SceNoCo.

npm install @scenoco-three/terrain

Everything is in metres: x and z from the terrain's centre, heights from its node. Made in code from a height function — the same one the game can call to place things on the ground:

// ground.ts
export const hill = (x: number, z: number) => 4 * Math.exp(-(x * x + z * z) / 200);
export const ground = new TerrainData();
ground.width = 80;                              // metres along x
ground.depth = 80;                              // metres along z
ground.heightmapResolution = 129;               // 2^k + 1 samples a side
ground.setHeights(hill);
ground.terrainLayers = [
  new TerrainLayer({ diffuseTexture: sharedTexture(grassUrl), tileSize: 2 }),
  new TerrainLayer({ color: new Color('#8a8070') }),       // no texture: a plain colour
];
ground.setAlphamaps((x, z) => (ground.steepnessAt(x, z) > 30 ? [0, 1] : [1, 0]));
<Group>
  <Terrain terrainData={ground} />
  <TerrainCollider terrainData={ground} />      {/* @scenoco-three/rapier */}
</Group>

Or loaded from a .terrain file, its layer textures found by name among the URLs given:

export const meadow = new TerrainData(meadowUrl, import.meta.glob('./meadow/layers/*', { query: '?url', import: 'default', eager: true }));
// main.ts: await loadAssets(meadow);
  • TerrainData — the heights and each layer's weights: setHeights/getHeights, setAlphamaps/getAlphamaps, getInterpolatedHeight, getInterpolatedNormal, getSteepness, size, heightmapResolution, alphamapResolution, terrainLayers, and a changed event after any edit. Up to 8 layers.
  • TerrainLayer — a texture tiled every tileSize metres, with an optional normal map whose blue channel can carry the layer's height.
  • Terrain — draws the data under its node in chunks, each as detailed as heightmapPixelError asks from where the camera is (Martini), rebuilt once a frame after a change; sampleHeight(worldPosition), castShadows, materialTemplate, tileScale — every layer's tile size times it — and sideProjection, both changeable while the game runs.
  • TerrainMaterial — the two heaviest layers of each pixel blended by height, tiling broken up, ground steeper than 45° textured from the side instead of from above, with no extra reads (off with sideProjection); a small, fixed amount of work per pixel, so it suits phones. Three's standard material underneath, so lights and shadows are three's.

A .terrain file is small: the heights are predicted from their neighbours and gzipped, the weights are a byte each. Its layout is written down above decode in TerrainData.ts.