Web toon: three.js 0.186.1 for style B in the browser (2026-11-01, #194)
Question: what the page needs from three.js to draw style B (docs/model-notes.md) from Blender’s GLB: the pin and its
integrity hashes, a two-step toon shadow with one highlight band, silhouette outlines and crease lines at the
pictures’ 2.5 px, the look numbers carried in glTF extras, and the gestures through AnimationMixer. Rule: newest
release at least two weeks old.
Sources: the three.js files at https://cdn.jsdelivr.net/npm/three@0.186.1/ (B/ below), the npm registry, MDN’s
browser-compat-data (html/elements/script.json) and Blender 5.2’s bundled io_scene_gltf2, all read 2026-11-01.
Pin: three 0.186.1
Section titled “Pin: three 0.186.1”npm view three time: 0.186.1 published 2026-09-24 (38 days old); 0.187.0 is 2026-10-30, under the two-week rule.B/build/three.module.jsimports./three.core.js, so both need a hash. The addons import the barethreeand their siblings:examples/jsm/loaders/GLTFLoader.jsimports../utils/BufferGeometryUtils.jsand../utils/SkeletonUtils.js;lines/LineSegments2.jsimports./LineSegmentsGeometry.jsand./LineMaterial.js;controls/OrbitControls.jsandloaders/DRACOLoader.jsonlythree. Ten files in all, each hashed withopenssl dgst -sha384 -binary <file> | base64(the values are in web/index.html’s import map).- Import maps carry
integrityper URL: Chrome 127, Firefox 138, Safari 18 (MDN BCDhtml.elements.script.type.importmap.integrity); every module the page imports, directly or through an addon, is checked against it. Older browsers ignore the key and load unchecked. DRACOLoaderfetches its decoder (draco_wasm_wrapper.js,draco_decoder.wasm) withFileLoaderfromsetDecoderPath(B/examples/jsm/loaders/DRACOLoader.js#_loadLibrary), so no integrity check reaches it; the wasm path needs only those two (draco_decoder.jsis the no-WebAssembly fallback). sha256 of 0.186.1’slibs/draco/gltf/copies: wrapper8bb2952d...d76f6, wasma680d927...df8ac(shasum -a 256; full values in web/build.py).
Toon shading: MeshToonMaterial and its gradientMap
Section titled “Toon shading: MeshToonMaterial and its gradientMap”gradientmap_pars_fragment:coord = dot(normal, lightDir) * 0.5 + 0.5; with a gradient map the irradiance istexture2D(gradientMap, coord).r(without one, a built-in 0.7/1.0 step at coord 0.7). ADataTexturewithNearestFiltergives hard steps.lights_toon_pars_fragment:RE_Direct_Toonaddsgradient * light.color * diffuse / PI, so a singleDirectionalLightof intensityPIand no ambient light yieldcolour * gradientexactly: Blender’s toon pass (base colour times a constant ramp) in the browser.- What the pictures actually show (a probe:
model/render/blender.py’ssetup()andmaterial()on a smooth UV sphere, orthographic, the key light placed as the pictures place it, pixels read back against N.L and N.H): the final colour over the part colour, linear, is 0.40 where N.L <= 0 and rises smoothly to 0.76 at N.L 0.95, i.e.TOON * SHADOW + (1 - TOON) * (SUN / PI) * N.Lwithin 1% (0.396 + 0.378 N.L). The toon ramp never reaches its lit step: the 0.8 grey Diffuse BSDF under sun 2.6 peaks at 0.8 * 2.6 / PI = 0.66, underSHADOW_AT0.7; and the world (strength 0.4) adds under 1% in the background render. The highlight band sets in between N.H 0.978 and 0.984. So the page’s gradient map is that curve, sampled from Blender’s numbers at export time, not a two-texel step. - No specular term: a highlight band needs a few lines through
onBeforeCompilebefore#include <opaque_fragment>, whereoutgoingLight,normal,geometryViewDir(lights_fragment_begin) anddirectionalLights[0]are in scope.
Outlines and creases
Section titled “Outlines and creases”examples/jsm/effects/OutlineEffect.jscalculateOutlineoffsets each vertex bynormalize(pos - projectionMatrix * modelViewMatrix * (position + normal)), i.e. it adds a unit normal in the object’s own units. Our GLBs are in metres and the Mech is 0.1 m, so that point lands a metre away, behind the camera for close views; the effect assumes scenes in larger units. An inverted hull of our own (back faces, black, pushed out along the view-space normal by a pixel width in clip space) is a few shader lines.- The parts carry split normals at sharp edges (weighted normals, sharp from 35 degrees): a hull pushed along them
opens at every hard corner.
BufferGeometryUtils.mergeVertices(tolerance 1e-4) on positions only, thencomputeVertexNormals, gives the hull smooth normals. EdgesGeometry(geometry, thresholdAngle): an edge is kept when the angle between its faces’ normals exceedsthresholdAngledegrees (default 1); vertices are matched on positions rounded to 4 decimals (0.1 mm in metres), so split-normal seams join. 60 is Freestyle’s crease rule (crease_angle120 degrees between the faces).LineBasicMaterial.linewidthis 1 px on WebGL;lines/LineSegments2withLineMaterialdraws widths in pixels (linewidth, needsresolution).LineSegmentsGeometry.fromEdgesGeometrytakes the crease edges.
glTF extras and animation
Section titled “glTF extras and animation”- Blender exporter (
io_scene_gltf2/blender/exp/gather.py__gather_extras): withexport_extras=Truethe scene’s custom properties become the glTF scene’sextras(also objects’, materials’ and meshes’). GLTFLoaderassignExtrasToUserDatacopiesextrasintouserDatafor scenes, nodes, meshes, materials and animations, so the scene’s look isgltf.scene.userData. A material’sbaseColorFactorarrives asmaterial.color(linear), the part colour Blender already exports.AnimationMixer:clipAction(clip),setLoop(LoopOnce),clampWhenFinished, and the mixer dispatchesfinishedwith{action}when a finite action ends (three.core.jsAnimationAction._updateTime).
Measured against wink.gif (2026-11-01, #211)
Section titled “Measured against wink.gif (2026-11-01, #211)”The page and a fresh Blender frame at wink.gif frame 0’s camera (600x450, the page’s camera set to the GIF’s), each part masked by a flat-colour ID render, light = linear pixel / linear part colour; W1 is the Wasserstein distance of a part’s light to the Blender frame’s, pixel-weighted over the lids, eyeballs, base plate, boards and lid linkage.
| image | W1 | on the 0.40 plateau | lit (>= 0.5) |
|---|---|---|---|
| wink.gif frame 0 (64 colours) | 0.010 | ||
| Blender, no cast shadows | 0.033 | 21.4% | 61.7% |
| Blender, no world light | 0.013 | ||
| page before #211 | 0.036 | 21.3% | 59.4% |
| page with the key light’s shadows | 0.023 | 32.9% | 48.4% |
| Blender frame (the GIF’s source) | 0 | 29.7% | 51.4% |
- The form shading per part already matched (upper lids W1 0.01): no toon step fires, as above. The GIF’s second tone is cast shadow (lids on the eyeballs, the eyes and linkage on the base plate), a flat 0.40 like N.L <= 0; the page without shadows measured as Blender without them. The GIF’s 64-colour palette adds little (0.010).
- What is left: the page’s shadows are harder than Eevee’s 12-degree sun (the eyeballs, W1 0.03; three.js’s PCF radius 1 to 10 moved no part’s mean), and the world light Blender adds (0.013 of the 0.023).
noggin v0.2.26-6-g09bf9b7 · 09bf9b7