Documentation is work in progress and not completeEditor
3D System

MaterialSystem

MaterialSystem creates and updates Three.js materials from a MaterialConfig, and handles texture loading, caching and disposal. Six material types are available.

Standard

The default PBR material (MeshStandardMaterial). Supports the roughness/metalness workflow, emission and all standard texture maps.

PropertyRangeDefault
colorhex'#3B82F6'
roughness0-10.5
metalness0-10.1
emissivehex'#000000'
emissiveIntensity0-30
opacity0-11
flatShadingfalse
envMapIntensity0-31

Physical (Glass)

MeshPhysicalMaterial extends Standard with transmission, clearcoat, sheen and iridescence.

PropertyRangeDefault
transmission0-10
ior1-2.51.5
thickness0-100.5
clearcoat0-10
clearcoatRoughness0-10
sheen0-10
sheenColorhex'#ffffff'
sheenRoughness0-10.5
iridescence0-10
iridescenceIOR1-2.51.5
iridescenceThicknessMin / Max100 / 400
specularIntensity0-11
specularColorhex'#ffffff'
When transmission is greater than 0, transparent is set to true automatically.

Lambert and Phong

Lambert (MeshLambertMaterial) is a non-physically-based material using Lambertian reflectance. It is cheaper to render and supports color, emissive, opacity and the color and alpha maps only.

Phong (MeshPhongMaterial) uses the classic Blinn-Phong shading model with specular highlights, and also supports normal and bump maps.

Phong PropertyRangeDefault
phongSpecularhex'#ffffff'
shininess0-100030

Toon and Wireframe

Toon (MeshToonMaterial) is a cel-shading material with discrete shading steps. toonSteps accepts 2, 3 or 5, defaulting to 3. A DataTexture gradient map is built by buildToonGradient() using NearestFilter, which is what produces hard transitions between bands rather than a smooth ramp.

Wireframe uses MeshStandardMaterial with wireframe: true, and supports roughness and metalness for specular response on the wire lines.

Common Properties

PropertyDefaultDescription
transparentfalseEnables alpha blending
depthWritetrueWhether to write to the depth buffer. Disable for transparent objects to prevent z-fighting
side'double'Which face sides to render — front, back or double
wireframefalseOverlay wireframe on any material type

Material Switching

When the user switches material type, only color, opacity and transparent are preserved. Everything else resets to DEFAULT_MATERIAL_CONFIG:

handleMaterial({
  ...DEFAULT_MATERIAL_CONFIG,
  type,
  color: prev.color,
  opacity: prev.opacity,
  transparent: prev.transparent
});
All PBR-specific, Phong-specific and Toon-specific properties are lost when switching away from those types. Switching to compare looks is therefore destructive.

Texture Cache

MaterialSystem keeps a module-level Map<string, THREE.Texture> keyed by URL, so the same texture is not loaded twice across objects. The cache must be cleared manually via disposeTextureByUrl() when a texture is removed.