Note that there are some explanatory texts on larger screens.

plurals
  1. POSome faces of a THREE.Mesh object are not displayed
    primarykey
    data
    text
    <p>I use the three.js librairy to code in WebGL, and I would like use shaders. My objects are THREE.Mesh objects.</p> <p>To use shaders I create three buffer to transmit to informations to shaders.</p> <ul> <li>VerticesArray which contains all vertices of the object.</li> <li>NormalsArray which contains all normals of points.</li> <li>IndicesArray which contains the rank of vertices in verticesArray. (faces are triangles, so three indices link three vertices of a same face).</li> </ul> <p>To create theses array I do this :</p> <pre><code> this.mesh = new THREE.Mesh( new THREE.SphereGeometry( 15, 15, 15 ), new THREE.MeshLambertMaterial( { color: 0xF40029 } ) ); this.vertices = new Array(); for(var i = 0 ; i &lt; this.mesh.geometry.vertices.length ; i++){ this.vertices.push(this.mesh.geometry.vertices[i].x); this.vertices.push(this.mesh.geometry.vertices[i].y); this.vertices.push(this.mesh.geometry.vertices[i].z); } this.normals = new Array(); for(var i = 0 ; i &lt; this.mesh.geometry.faces.length ; i++){ this.normals[this.mesh.geometry.faces[i].a*3] = this.mesh.geometry.faces[i].vertexNormals[0].x; this.normals[this.mesh.geometry.faces[i].a*3+1] = this.mesh.geometry.faces[i].vertexNormals[0].y; this.normals[this.mesh.geometry.faces[i].a*3+2] = this.mesh.geometry.faces[i].vertexNormals[0].z; this.normals[this.mesh.geometry.faces[i].b*3] = this.mesh.geometry.faces[i].vertexNormals[1].x; this.normals[this.mesh.geometry.faces[i].b*3+1] = this.mesh.geometry.faces[i].vertexNormals[1].y; this.normals[this.mesh.geometry.faces[i].b*3+2] = this.mesh.geometry.faces[i].vertexNormals[1].z; this.normals[this.mesh.geometry.faces[i].c*3] = this.mesh.geometry.faces[i].vertexNormals[2].x; this.normals[this.mesh.geometry.faces[i].c*3+1] = this.mesh.geometry.faces[i].vertexNormals[2].y; this.normals[this.mesh.geometry.faces[i].c*3+2] = this.mesh.geometry.faces[i].vertexNormals[2].z; } this.indices = new Array(); for(var i = 0 ; i &lt; this.mesh.geometry.faces.length ; i++){ this.indices.push(this.mesh.geometry.faces[i].a); this.indices.push(this.mesh.geometry.faces[i].b); this.indices.push(this.mesh.geometry.faces[i].c); } this.vertexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.vertices), gl.STATIC_DRAW); this.normalBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.normals), gl.STATIC_DRAW); this.indexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), gl.STREAM_DRAW); this.indexCount = this.indices.length; </code></pre> <p>At this step, I have a strange problem, on the display I can see my two subjects but some Faces are not displayed.</p> <p>Do you have an idea to solve my problem ?</p> <p>We can see my problem on the following picture. I display two balls. <a href="http://img341.imageshack.us/img341/1094/ballsk.jpg" rel="nofollow">http://img341.imageshack.us/img341/1094/ballsk.jpg</a></p> <p>Thanks for your response.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload