<p dir="auto"><strong>Describe the bug</strong></p>
<p dir="auto">This bug seems to be related to the bug <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="504824957" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/17701" data-hovercard-type="issue" data-hovercard-url="/mrdoob/three.js/issues/17701/hovercard" href="https://github.com/mrdoob/three.js/issues/17701">#17701</a> but can be reproduced by a completely different approach.</p>
<p dir="auto">Three will throw an error when trying to apply a outline pass on a scene with instanced and normal meshes.</p>
<p dir="auto">Error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="three.module.js:12456 Uncaught TypeError: Cannot read property 'isInterleavedBufferAttribute' of undefined
    at Object.get (three.module.js:12456)
    at setupVertexAttributes (three.module.js:14119)
    at Object.setup (three.module.js:13789)
    at WebGLRenderer.renderBufferDirect (three.module.js:23669)
    at renderObject (three.module.js:24192)
    at renderObjects (three.module.js:24165)
    at WebGLRenderer.render (three.module.js:23959)
    at OutlinePass.render (OutlinePass.js:319)
    at EffectComposer.render (EffectComposer.js:150)
    at init (index.js:108)"><pre class="notranslate"><code class="notranslate">three.module.js:12456 Uncaught TypeError: Cannot read property 'isInterleavedBufferAttribute' of undefined
    at Object.get (three.module.js:12456)
    at setupVertexAttributes (three.module.js:14119)
    at Object.setup (three.module.js:13789)
    at WebGLRenderer.renderBufferDirect (three.module.js:23669)
    at renderObject (three.module.js:24192)
    at renderObjects (three.module.js:24165)
    at WebGLRenderer.render (three.module.js:23959)
    at OutlinePass.render (OutlinePass.js:319)
    at EffectComposer.render (EffectComposer.js:150)
    at init (index.js:108)
</code></pre></div>
<p dir="auto"><strong>To Reproduce</strong></p>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li>Add instanced mesh to the scene</li>
<li>Add normal mesh to scene</li>
<li>Add normal mesh to the scene</li>
<li>Try to apply an outline on the first normal mesh</li>
</ol>
<p dir="auto"><em><strong>Code</strong></em></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import {
    DoubleSide,
    InstancedMesh,
    Matrix4,
    Mesh,
    MeshLambertMaterial,
    MeshPhongMaterial,
    PerspectiveCamera,
    PlaneBufferGeometry,
    Quaternion,
    Scene,
    SphereBufferGeometry,
    TorusBufferGeometry,
    Vector2,
    Vector3,
    WebGLRenderer
} from &quot;three&quot;;
import {EffectComposer} from &quot;three/examples/jsm/postprocessing/EffectComposer&quot;;
import {RenderPass} from &quot;three/examples/jsm/postprocessing/RenderPass&quot;;
import {OutlinePass} from &quot;three/examples/jsm/postprocessing/OutlinePass&quot;;

// issue related to https://github.com/mrdoob/three.js/issues/17701
// code based on https://github.com/mrdoob/three.js/blob/master/examples/webgl_postprocessing_outline.html

function addSpheresInstanced() {
    const geometry = new SphereBufferGeometry(3, 48, 24);
    const material = new MeshLambertMaterial({color: 0xff00aa});

    const instanced = new InstancedMesh(geometry, material, 10);

    const mat = new Matrix4();

    const position = new Vector3();
    const rotation = new Quaternion();
    const scale = new Vector3();

    for (let i = 0; i &lt; 10; i++) {
        position.set(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2);

        const scaleAmount = Math.random() * 0.3 + 0.1;
        scale.set(scaleAmount, scaleAmount, scaleAmount);

        mat.compose(position, rotation, scale);
        instanced.setMatrixAt(i, mat);
    }

    instanced.instanceMatrix.needsUpdate = true;

    return instanced;
}

function addFloor() {
    const floorGeometry = new PlaneBufferGeometry(12, 12);
    const floorMaterial = new MeshLambertMaterial({side: DoubleSide});

    const floorMesh = new Mesh(floorGeometry, floorMaterial);
    floorMesh.rotation.x -= Math.PI * 0.5;
    floorMesh.position.y -= 1.5;
    floorMesh.receiveShadow = true;

    return floorMesh;
}

function addTorus() {
    const torusGeometry = new TorusBufferGeometry(1, 0.3, 16, 100);
    const torusMaterial = new MeshPhongMaterial({color: 0xffaaff});

    const torusMesh = new Mesh(torusGeometry, torusMaterial);
    torusMesh.position.z = -4;
    torusMesh.receiveShadow = true;
    torusMesh.castShadow = true;

    return torusMesh;
}

function init() {
    const width = window.innerWidth;
    const height = window.innerHeight;

    const renderer = new WebGLRenderer();
    renderer.setSize(width, height);
    document.body.appendChild(renderer.domElement);

    const scene = new Scene();

    const camera = new PerspectiveCamera(45, width / height, 0.1, 100);
    camera.position.set(0, 0, 8);

    const spheresInstanced = addSpheresInstanced();
    scene.add(spheresInstanced);

    const torus = addTorus();
    scene.add(torus);

    const floor = addFloor();
    scene.add(floor);

    const composer = new EffectComposer(renderer);

    const renderPass = new RenderPass(scene, camera);
    composer.addPass(renderPass);

    const outlinePass = new OutlinePass(new Vector2(width, height), scene, camera);
    composer.addPass(outlinePass);

    outlinePass.selectedObjects = [torus];

    composer.render();
}

init();"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span>
    <span class="pl-v">DoubleSide</span><span class="pl-kos">,</span>
    <span class="pl-v">InstancedMesh</span><span class="pl-kos">,</span>
    <span class="pl-v">Matrix4</span><span class="pl-kos">,</span>
    <span class="pl-v">Mesh</span><span class="pl-kos">,</span>
    <span class="pl-v">MeshLambertMaterial</span><span class="pl-kos">,</span>
    <span class="pl-v">MeshPhongMaterial</span><span class="pl-kos">,</span>
    <span class="pl-v">PerspectiveCamera</span><span class="pl-kos">,</span>
    <span class="pl-v">PlaneBufferGeometry</span><span class="pl-kos">,</span>
    <span class="pl-v">Quaternion</span><span class="pl-kos">,</span>
    <span class="pl-v">Scene</span><span class="pl-kos">,</span>
    <span class="pl-v">SphereBufferGeometry</span><span class="pl-kos">,</span>
    <span class="pl-v">TorusBufferGeometry</span><span class="pl-kos">,</span>
    <span class="pl-v">Vector2</span><span class="pl-kos">,</span>
    <span class="pl-v">Vector3</span><span class="pl-kos">,</span>
    <span class="pl-v">WebGLRenderer</span>
<span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"three"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-v">EffectComposer</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"three/examples/jsm/postprocessing/EffectComposer"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-v">RenderPass</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"three/examples/jsm/postprocessing/RenderPass"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-v">OutlinePass</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"three/examples/jsm/postprocessing/OutlinePass"</span><span class="pl-kos">;</span>

<span class="pl-c">// issue related to https://github.com/mrdoob/three.js/issues/17701</span>
<span class="pl-c">// code based on https://github.com/mrdoob/three.js/blob/master/examples/webgl_postprocessing_outline.html</span>

<span class="pl-k">function</span> <span class="pl-en">addSpheresInstanced</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">geometry</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">SphereBufferGeometry</span><span class="pl-kos">(</span><span class="pl-c1">3</span><span class="pl-kos">,</span> <span class="pl-c1">48</span><span class="pl-kos">,</span> <span class="pl-c1">24</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">material</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">MeshLambertMaterial</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">color</span>: <span class="pl-c1">0xff00aa</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">instanced</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">InstancedMesh</span><span class="pl-kos">(</span><span class="pl-s1">geometry</span><span class="pl-kos">,</span> <span class="pl-s1">material</span><span class="pl-kos">,</span> <span class="pl-c1">10</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">mat</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Matrix4</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">position</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Vector3</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">rotation</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Quaternion</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">scale</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Vector3</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">10</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">position</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">random</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">*</span> <span class="pl-c1">4</span> <span class="pl-c1">-</span> <span class="pl-c1">2</span><span class="pl-kos">,</span> <span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">random</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">*</span> <span class="pl-c1">4</span> <span class="pl-c1">-</span> <span class="pl-c1">2</span><span class="pl-kos">,</span> <span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">random</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">*</span> <span class="pl-c1">4</span> <span class="pl-c1">-</span> <span class="pl-c1">2</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

        <span class="pl-k">const</span> <span class="pl-s1">scaleAmount</span> <span class="pl-c1">=</span> <span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">random</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">*</span> <span class="pl-c1">0.3</span> <span class="pl-c1">+</span> <span class="pl-c1">0.1</span><span class="pl-kos">;</span>
        <span class="pl-s1">scale</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-s1">scaleAmount</span><span class="pl-kos">,</span> <span class="pl-s1">scaleAmount</span><span class="pl-kos">,</span> <span class="pl-s1">scaleAmount</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

        <span class="pl-s1">mat</span><span class="pl-kos">.</span><span class="pl-en">compose</span><span class="pl-kos">(</span><span class="pl-s1">position</span><span class="pl-kos">,</span> <span class="pl-s1">rotation</span><span class="pl-kos">,</span> <span class="pl-s1">scale</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">instanced</span><span class="pl-kos">.</span><span class="pl-en">setMatrixAt</span><span class="pl-kos">(</span><span class="pl-s1">i</span><span class="pl-kos">,</span> <span class="pl-s1">mat</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>

    <span class="pl-s1">instanced</span><span class="pl-kos">.</span><span class="pl-c1">instanceMatrix</span><span class="pl-kos">.</span><span class="pl-c1">needsUpdate</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>

    <span class="pl-k">return</span> <span class="pl-s1">instanced</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">addFloor</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">floorGeometry</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">PlaneBufferGeometry</span><span class="pl-kos">(</span><span class="pl-c1">12</span><span class="pl-kos">,</span> <span class="pl-c1">12</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">floorMaterial</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">MeshLambertMaterial</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">side</span>: <span class="pl-v">DoubleSide</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">floorMesh</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Mesh</span><span class="pl-kos">(</span><span class="pl-s1">floorGeometry</span><span class="pl-kos">,</span> <span class="pl-s1">floorMaterial</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">floorMesh</span><span class="pl-kos">.</span><span class="pl-c1">rotation</span><span class="pl-kos">.</span><span class="pl-c1">x</span> <span class="pl-c1">-=</span> <span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-c1">PI</span> <span class="pl-c1">*</span> <span class="pl-c1">0.5</span><span class="pl-kos">;</span>
    <span class="pl-s1">floorMesh</span><span class="pl-kos">.</span><span class="pl-c1">position</span><span class="pl-kos">.</span><span class="pl-c1">y</span> <span class="pl-c1">-=</span> <span class="pl-c1">1.5</span><span class="pl-kos">;</span>
    <span class="pl-s1">floorMesh</span><span class="pl-kos">.</span><span class="pl-c1">receiveShadow</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>

    <span class="pl-k">return</span> <span class="pl-s1">floorMesh</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">addTorus</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">torusGeometry</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">TorusBufferGeometry</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">0.3</span><span class="pl-kos">,</span> <span class="pl-c1">16</span><span class="pl-kos">,</span> <span class="pl-c1">100</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">torusMaterial</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">MeshPhongMaterial</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">color</span>: <span class="pl-c1">0xffaaff</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">torusMesh</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Mesh</span><span class="pl-kos">(</span><span class="pl-s1">torusGeometry</span><span class="pl-kos">,</span> <span class="pl-s1">torusMaterial</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">torusMesh</span><span class="pl-kos">.</span><span class="pl-c1">position</span><span class="pl-kos">.</span><span class="pl-c1">z</span> <span class="pl-c1">=</span> <span class="pl-c1">-</span><span class="pl-c1">4</span><span class="pl-kos">;</span>
    <span class="pl-s1">torusMesh</span><span class="pl-kos">.</span><span class="pl-c1">receiveShadow</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
    <span class="pl-s1">torusMesh</span><span class="pl-kos">.</span><span class="pl-c1">castShadow</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>

    <span class="pl-k">return</span> <span class="pl-s1">torusMesh</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">init</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">width</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">innerWidth</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">height</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">innerHeight</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">renderer</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">WebGLRenderer</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">renderer</span><span class="pl-kos">.</span><span class="pl-en">setSize</span><span class="pl-kos">(</span><span class="pl-s1">width</span><span class="pl-kos">,</span> <span class="pl-s1">height</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-c1">body</span><span class="pl-kos">.</span><span class="pl-en">appendChild</span><span class="pl-kos">(</span><span class="pl-s1">renderer</span><span class="pl-kos">.</span><span class="pl-c1">domElement</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">scene</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Scene</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">camera</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">PerspectiveCamera</span><span class="pl-kos">(</span><span class="pl-c1">45</span><span class="pl-kos">,</span> <span class="pl-s1">width</span> <span class="pl-c1">/</span> <span class="pl-s1">height</span><span class="pl-kos">,</span> <span class="pl-c1">0.1</span><span class="pl-kos">,</span> <span class="pl-c1">100</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">camera</span><span class="pl-kos">.</span><span class="pl-c1">position</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-c1">8</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">spheresInstanced</span> <span class="pl-c1">=</span> <span class="pl-en">addSpheresInstanced</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">scene</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span><span class="pl-s1">spheresInstanced</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">torus</span> <span class="pl-c1">=</span> <span class="pl-en">addTorus</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">scene</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span><span class="pl-s1">torus</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">floor</span> <span class="pl-c1">=</span> <span class="pl-en">addFloor</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">scene</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span><span class="pl-s1">floor</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">composer</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">EffectComposer</span><span class="pl-kos">(</span><span class="pl-s1">renderer</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">renderPass</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">RenderPass</span><span class="pl-kos">(</span><span class="pl-s1">scene</span><span class="pl-kos">,</span> <span class="pl-s1">camera</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">composer</span><span class="pl-kos">.</span><span class="pl-en">addPass</span><span class="pl-kos">(</span><span class="pl-s1">renderPass</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">outlinePass</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">OutlinePass</span><span class="pl-kos">(</span><span class="pl-k">new</span> <span class="pl-v">Vector2</span><span class="pl-kos">(</span><span class="pl-s1">width</span><span class="pl-kos">,</span> <span class="pl-s1">height</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s1">scene</span><span class="pl-kos">,</span> <span class="pl-s1">camera</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">composer</span><span class="pl-kos">.</span><span class="pl-en">addPass</span><span class="pl-kos">(</span><span class="pl-s1">outlinePass</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-s1">outlinePass</span><span class="pl-kos">.</span><span class="pl-c1">selectedObjects</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-s1">torus</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

    <span class="pl-s1">composer</span><span class="pl-kos">.</span><span class="pl-en">render</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-en">init</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><em><strong>Live example</strong></em></p>
<p dir="auto"><a href="https://jsfiddle.net/q8e0h7du/" rel="nofollow">https://jsfiddle.net/q8e0h7du/</a></p>
<p dir="auto"><strong>Expected behavior</strong></p>
<p dir="auto">There should be no error and the outline should be rendered around the torus.</p>
<p dir="auto"><strong>Platform:</strong></p>
<ul dir="auto">
<li>Device: Desktop</li>
<li>OS: Windows</li>
<li>Browser: Chrome</li>
<li>Three.js version: r125</li>
</ul>
<h5 dir="auto">Description of the problem</h5>
<p dir="auto"><code class="notranslate">OutlinePass</code> does not appear to properly support <code class="notranslate">InstancedMesh</code>. I've created an example here that uses the same setup of <code class="notranslate">OutlinePass</code> in the example in the docs. The sphere is a regular <code class="notranslate">Mesh</code> and the squares are the instances of <code class="notranslate">InstancedMesh</code>.<br>
<a href="https://jsfiddle.net/anthonysimone/dL8s2qmv/" rel="nofollow">https://jsfiddle.net/anthonysimone/dL8s2qmv/</a></p>
<p dir="auto">It seems like there's a couple things going on here.</p>
<ol dir="auto">
<li>If you hover over the regular mesh first (sphere), then one of the instanced mesh instances, the base position of the <code class="notranslate">InstancedMesh</code> is outlined any time you’re hovering over any of the instances. In the above example all of the instances have been moved from the default position to demonstrate this clearly.</li>
<li>If you first hover over any of the box instances, the entire collection of instances (though not the base position) of the <code class="notranslate">InstancedMesh</code> are outlined, but then hovering over a regular mesh (the sphere) causes an error.</li>
</ol>
<p dir="auto">I dug into <code class="notranslate">OutlinePass</code> a bit and it seems like it might just not be taking into account handling instanced meshes separately from regular meshes. I'm still pretty new to Three.js, so I don't have a potential fix to suggest at this point.</p>
<h5 dir="auto">Three.js version</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> r113</li>
</ul>
<h5 dir="auto">Browser</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Chrome</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Firefox</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Internet Explorer</li>
</ul>
<h5 dir="auto">OS</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Windows</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> macOS</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Linux</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Android</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> iOS</li>
</ul>