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

infterrain

v1.0.1

Published

Procedural, infinitely-streaming terrain for Babylon.js — chunked heightmap terrain with splat-mapped materials, fogged water, and forest scattering.

Readme

infterrain

Procedural, infinitely-streaming terrain for Babylon.js — chunked heightmap terrain with triplanar splat-mapped materials (grass/road/rock/snow), a fogged water plane, and billboard/mesh forest scattering. Chunks build and dispose automatically as the camera moves.

Install

npm install infterrain

Peer dependencies

This package does not bundle Babylon.js — it expects your project to already have it installed:

npm install @babylonjs/core @babylonjs/loaders

Requires @babylonjs/core and @babylonjs/loaders version >=9.0.0.

Quick start

import { Scene, Color3 } from '@babylonjs/core'
import { createOpenWorld } from 'infterrain'

const scene = new Scene(engine)

// infterrain's terrain and water shaders read the scene's fog settings.
// Set these before calling createOpenWorld, or they'll fall back to defaults.
scene.fogMode  = Scene.FOGMODE_LINEAR
scene.fogColor = new Color3(0.65, 0.78, 0.88)
scene.fogStart = 400
scene.fogEnd   = 1400

const { chunks, mat } = await createOpenWorld(scene)

createOpenWorld sets up terrain, water, and forest scattering together, and starts streaming chunks in around the world's spawn point (SPAWN_X, SPAWN_Z). Call it once, after your scene exists.

createOpenWorld(scene, treePaths?, fakeTreePath?, options?)

| Param | Type | Default | Description | |---|---|---|---| | scene | Scene | — | Your Babylon.js scene. | | treePaths | string[3] | DEFAULT_TREE_PATHS | [healthyTree, deadTreeVariantA, deadTreeVariantB] glb paths. | | fakeTreePath | string | DEFAULT_FAKE_TREE_PATH | Cutout image used for billboard impostor trees. | | options.showStatsUI | boolean | false | Overlay showing chunk/build stats. | | options.verts | number | 17 | Vertices per chunk edge (mesh resolution). | | options.viewRadius | number | 2 | Chunk radius kept built around the camera. | | options.unloadRadius | number | viewRadius + 2 | Chunk radius before a chunk is disposed. | | options.onChunkBuilt | (mesh) => void | — | Called after each terrain chunk mesh is built (e.g. to attach physics). | | options.onChunkDisposed | (mesh) => void | — | Called just before a chunk mesh is disposed. |

Returns { chunks, mat }chunks is the live Map of currently-built chunk meshes, mat is the shared terrain ShaderMaterial.

Individual exports

For custom setups you don't have to use createOpenWorld — the pieces are exported separately:

import {
  createInfiniteTerrain, sampleTerrainSurfaceHeight,
  createWater,
  createForest, DEFAULT_TREE_PATHS, DEFAULT_FAKE_TREE_PATH,
  createOpenWorldGrass,
  runPreloads,
  terrainHeight, backgroundTerrainHeight, roadDistance, getMountainFactor,
  SPAWN_X, SPAWN_Z, WATER_LEVEL,
} from 'infterrain'
  • createInfiniteTerrain(scene, options) — just the streaming terrain mesh/material (same options as above minus tree/water/forest concerns).
  • sampleTerrainSurfaceHeight(x, z, verts) — height of the rendered terrain surface at a world position, matching the mesh's own bilinear interpolation (use this instead of raw terrainHeight when you need a position flush with what's drawn, e.g. spawning something on the surface).
  • createWater(scene) — the fogged water plane at WATER_LEVEL.
  • createForest(scene, treePaths, fakeTreePath, verts) / createOpenWorldGrass(...) — vegetation scattering.
  • terrainHeight(x, z) / backgroundTerrainHeight(x, z, hillSize) — raw procedural height sampling.
  • roadDistance(x, z), getMountainFactor(x, z) — world-shape queries used for splat/vegetation placement, useful if you're placing your own objects.
  • SPAWN_X, SPAWN_Z, WATER_LEVEL — world constants.

Logging

infterrain logs sanity-check messages prefixed with [infterrain] (texture load status, first chunk built, missing scene fog config, etc.) via console.log/console.warn/console.error, so integration issues are visible without a debugger attached.

License

ISC