You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug seems to be related to the bug #17701 but can be reproduced by a completely different approach.
Three will throw an error when trying to apply a outline pass on a scene with instanced and normal meshes.
Error:
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)
To Reproduce
Steps to reproduce the behavior:
Add instanced mesh to the scene
Add normal mesh to scene
Add normal mesh to the scene
Try to apply an outline on the first normal mesh
Code
import{DoubleSide,InstancedMesh,Matrix4,Mesh,MeshLambertMaterial,MeshPhongMaterial,PerspectiveCamera,PlaneBufferGeometry,Quaternion,Scene,SphereBufferGeometry,TorusBufferGeometry,Vector2,Vector3,WebGLRenderer}from"three";import{EffectComposer}from"three/examples/jsm/postprocessing/EffectComposer";import{RenderPass}from"three/examples/jsm/postprocessing/RenderPass";import{OutlinePass}from"three/examples/jsm/postprocessing/OutlinePass";// 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.htmlfunctionaddSpheresInstanced(){constgeometry=newSphereBufferGeometry(3,48,24);constmaterial=newMeshLambertMaterial({color: 0xff00aa});constinstanced=newInstancedMesh(geometry,material,10);constmat=newMatrix4();constposition=newVector3();constrotation=newQuaternion();constscale=newVector3();for(leti=0;i<10;i++){position.set(Math.random()*4-2,Math.random()*4-2,Math.random()*4-2);constscaleAmount=Math.random()*0.3+0.1;scale.set(scaleAmount,scaleAmount,scaleAmount);mat.compose(position,rotation,scale);instanced.setMatrixAt(i,mat);}instanced.instanceMatrix.needsUpdate=true;returninstanced;}functionaddFloor(){constfloorGeometry=newPlaneBufferGeometry(12,12);constfloorMaterial=newMeshLambertMaterial({side: DoubleSide});constfloorMesh=newMesh(floorGeometry,floorMaterial);floorMesh.rotation.x-=Math.PI*0.5;floorMesh.position.y-=1.5;floorMesh.receiveShadow=true;returnfloorMesh;}functionaddTorus(){consttorusGeometry=newTorusBufferGeometry(1,0.3,16,100);consttorusMaterial=newMeshPhongMaterial({color: 0xffaaff});consttorusMesh=newMesh(torusGeometry,torusMaterial);torusMesh.position.z=-4;torusMesh.receiveShadow=true;torusMesh.castShadow=true;returntorusMesh;}functioninit(){constwidth=window.innerWidth;constheight=window.innerHeight;constrenderer=newWebGLRenderer();renderer.setSize(width,height);document.body.appendChild(renderer.domElement);constscene=newScene();constcamera=newPerspectiveCamera(45,width/height,0.1,100);camera.position.set(0,0,8);constspheresInstanced=addSpheresInstanced();scene.add(spheresInstanced);consttorus=addTorus();scene.add(torus);constfloor=addFloor();scene.add(floor);constcomposer=newEffectComposer(renderer);constrenderPass=newRenderPass(scene,camera);composer.addPass(renderPass);constoutlinePass=newOutlinePass(newVector2(width,height),scene,camera);composer.addPass(outlinePass);outlinePass.selectedObjects=[torus];composer.render();}init();
Describe the bug
This bug seems to be related to the bug #17701 but can be reproduced by a completely different approach.
Three will throw an error when trying to apply a outline pass on a scene with instanced and normal meshes.
Error:
To Reproduce
Steps to reproduce the behavior:
Code
Live example
https://jsfiddle.net/q8e0h7du/
Expected behavior
There should be no error and the outline should be rendered around the torus.
Platform:
The text was updated successfully, but these errors were encountered: