Note that there are some explanatory texts on larger screens.

plurals
  1. PO3-D semi-circle with canvas
    primarykey
    data
    text
    <p>I have a library of shapes with indicies and vertices that are functions and want to create a 3-D semi-sphere. But I am Having trouble with this. See below of sample 3-D sphere function. How can I create a 3-D semi-sphere function the same way? Please help!</p> <pre><code>sphere: function (spherical) { var radius = 0.5, theta = Math.PI, phi = 2 * Math.PI, latLines = 30, longLines = 30, currentLat, currentLong, currentVertex, currentIndex, vertices = [], indices = [], finalResult = {}, i, j, t, m; for (i = 0; i &lt; (latLines + 1); i += 1) { currentLat = i * theta / latLines; for (j = 0; j &lt; (longLines + 1); j += 1) { currentVertex = latLines * i + j; vertices[currentVertex] = []; currentLong = j * phi / longLines; vertices[currentVertex][0] = radius * Math.sin(currentLat) * Math.cos(currentLong); vertices[currentVertex][1] = radius * Math.cos(currentLat); vertices[currentVertex][2] = radius * Math.sin(currentLat) * Math.sin(currentLong); if (spherical) { vertices[currentVertex][0] *= (currentLat * spherical); vertices[currentVertex][2] *= (currentLat * spherical); } } } for (t = 0; t &lt; (latLines + 1); t += 1) { for (m = 0; m &lt; (longLines + 1); m += 1) { currentIndex = 2 * ((latLines + 1) * t + m); indices[2 * ((latLines + 1) * t + m)] = []; indices[2 * ((latLines + 1) * t + m) + 1] = []; indices[currentIndex][0] = longLines * t + m; indices[currentIndex][1] = longLines * t + m + 1; indices[currentIndex][2] = longLines * (t + 1) + m; currentIndex += 1; indices[currentIndex][0] = longLines * (t + 1) + m; indices[currentIndex][1] = longLines * (t + 1) + m + 1; indices[currentIndex][2] = longLines * t + m + 1; } } finalResult.vertices = vertices; finalResult.indices = indices; return finalResult; }, </code></pre>
    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