Why MeshMatcapMaterial is renderer as MeshBasicMaterial?

Hello.
In examples(link or link) meshes are rendered correct (illuminates with shadow) but in my snippet, the mesh is rendered without lights or shadows (flat). How to reach results in examples?

// Simple three.js example

import * as THREE from "https://cdn.skypack.dev/three@0.136.0/build/three.module.js";
import { OrbitControls } from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/controls/OrbitControls.js";

var mesh, renderer, scene, camera, controls;

init();
animate();
const API = {
   color: 0xffffff, // sRGB
   exposure: 1.0
   };
function init() {

    // renderer
    renderer = new THREE.WebGLRenderer();
    renderer.setSize( window.innerWidth, window.innerHeight );
    renderer.setPixelRatio( window.devicePixelRatio );
    renderer.setClearColor( 0xffffff, 1 );
    renderer.toneMapping = THREE.ACESFilmicToneMapping;
    renderer.outputEncoding = THREE.sRGBEncoding;
    document.body.appendChild( renderer.domElement );

    // scene
    scene = new THREE.Scene();
    
    // camera
    camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
    camera.position.set( 40, 40, 40 );

    // controls
    controls = new OrbitControls( camera, renderer.domElement );
    
    // ambient
    scene.add( new THREE.AmbientLight( 0x222222 ) );
    
    // light
    var light = new THREE.DirectionalLight( 0xffffff, 1 );
    light.position.set( 20,20, 0 );
    scene.add( light );
    
    // axes
    scene.add( new THREE.AxesHelper( 20 ) );
    let size = 200;
    let divisions = 10;

    var gridHelper = new THREE.GridHelper(size, divisions);
    scene.add(gridHelper);

    // geometry
    var geometry = new THREE.SphereGeometry( 15, 12, 8 );
    
    // material
    var material = new THREE.MeshMatcapMaterial( {
        color: 0xc8c8c8, 
        flatShading: true
        } );
    
    // mesh
    mesh = new THREE.Mesh( geometry, material );
    scene.add( mesh );
    
}

function animate() {

    requestAnimationFrame( animate );
    
    //controls.update();

    renderer.render( scene, camera );
    mesh.rotation.y += 0.01;

}

window.addEventListener( 'resize', onWindowResize, false );

function onWindowResize(){

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize( window.innerWidth, window.innerHeight );
}

Jsfiddle.
Screenshot:

you haven’t set any matcap texture.

my example : MeshMatcapMaterial - Three.js Tutorials (sbcode.net)
official docs : MeshMatcapMaterial – three.js docs (threejs.org)

1 Like

This is r137 feature (in fact, I would like to know how to turn it off, lol), and you use r136

edit: found corresponding PR