To successfully implement the outlined pass feature, both Composer and Outline Pass are essential components. Below is a simplified version of the official example that can be found at
<!DOCTYPE html>
<html lang="en">
<head>
<title>Implementing three.js webgl - post processing with Outline Pass</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<script src="three.js"></script>
<script src="CopyShader.js"></script>
<script src="FXAAShader.js"></script>
<script src="EffectComposer.js"></script>
<script src="RenderPass.js"></script>
<script src="ShaderPass.js"></script>
<script src="OutlinePass.js"></script>
<div id="info">
<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - Detailed information on Outline Pass by <a href="http://eduperiment.com" target="_blank" rel="noopener">Prashant Sharma</a> and <a href="https://clara.io" target="_blank" rel="noopener">Ben Houston</a><br/><br/>
</div>
<script>
var container, camera, scene, renderer, composer, effectFXAA, outlinePass;
var raycaster = new THREE.Raycaster();
var mouse = new THREE.Vector2();
initSetup();
initiateAnimation();
function initSetup() {
container = document.createElement('div');
document.body.appendChild(container);
var width = window.innerWidth || 1;
var height = window.innerHeight || 1;
renderer = new THREE.WebGLRenderer({antialias: false});
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement);
camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
camera.position.z = 8;
camera.position.x = 0;
scene = new THREE.Scene();
var light = new THREE.DirectionalLight(0xddffdd, 0.4);
light.position.z = 1;
light.position.y = 1;
light.position.x = 1;
scene.add(light);
var floorMaterial = new THREE.MeshLambertMaterial();
floorMaterial.side = THREE.DoubleSide;
var floorGeometry = new THREE.PlaneBufferGeometry(12, 12);
var floorMesh = new THREE.Mesh(floorGeometry, floorMaterial);
floorMesh.rotation.x -= Math.PI * 0.5;
floorMesh.position.y -= 1.5;
scene.add(floorMesh);
// Setting up post processing
composer = new THREE.EffectComposer(renderer);
var renderPass = new THREE.RenderPass(scene, camera);
composer.addPass(renderPass);
outlinePass = new THREE.OutlinePass(new THREE.Vector2(window.innerWidth, window.innerHeight), scene, camera);
composer.addPass(outlinePass);
effectFXAA = new THREE.ShaderPass(THREE.FXAAShader);
effectFXAA.uniforms['resolution'].value.set(1 / window.innerWidth, 1 / window.innerHeight);
effectFXAA.renderToScreen = true;
composer.addPass(effectFXAA);
window.addEventListener('mousemove', handleMouseMove);
window.addEventListener('touchmove', handleMouseMove);
function handleMouseMove(event) {
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = -( event.clientY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
var intersections = raycaster.intersectObjects([scene], true);
if (intersections.length > 0) {
var selectedObject = intersections[0].object;
outlinePass.selectedObjects = [selectedObject];
}
}
}
function initiateAnimation() {
requestAnimationFrame(initiateAnimation);
composer.render();
}
</script>
</body>
</html>