I have the full code below to display an outline on the plane mesh. However, it is not showing the outline when we look at the back of the Object3D. It works fine on all sides for other geometries. I don’t really want to create another plane, reverse it and merge it with the first plane. Is this a bug with the OutlineEffect?
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Three.js OutlineEffect Example</title>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<script type="module">
import { EffectComposer, RenderPass, EffectPass, OutlineEffect } from 'postprocessing'
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 5;
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const geometry = new THREE.PlaneGeometry(2, 2);
const material = new THREE.MeshNormalMaterial({ side: THREE.DoubleSide });
const plane = new THREE.Mesh(geometry, material);
scene.add(plane);
const composer = new EffectComposer(renderer);
const renderPass = new RenderPass(scene, camera);
composer.addPass(renderPass);
const outlineEffect = new OutlineEffect(scene, camera, { 'visibleEdgeColor': 'gold', 'edgeStrength': 10 });
const effectPass = new EffectPass(camera, outlineEffect);
outlineEffect['selection'].set([plane]);
composer.addPass(effectPass);
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
plane.rotation.y += 0.01;
composer.render();
}
animate();