📗 A mesh (not THREE.Mesh, more like THREE.Geometry) is a collection of triangles (called faces). For example, the sphere geometry is approximated by a lot of triangles: Doc.
📗 Given a list of vertices [x0, y0, z0, x1, y1, z1, ...], the triangles are constructed using an index set [v0, v1, v2, v3, v4, v5, ...] where [v0, v1, v2] are the indices of the first triangle, [v3, v4, v5] are the indices of the second triangle, ...
📗 For example, to create the mesh for let geometry = new THREE.BufferGeometry();,
➩ let vertices = new Float32Array([x0, y0, z0, x1, y1, z1, ...]);
➩ geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
➩ geometry.setIndex(v0, v1, v2, v3, v4, v5, ...);
➩ Non-index geometries are ones where vertices are repeated and the index array is assumed to be 0, 1, 2, 3, 4, 5, ....
📗 Attributes for color and normal can be set in a similar way.
📗 The "midpoint" of an edge \(AB\) is not always \(\dfrac{1}{2} A + \dfrac{1}{2} B\), for interior edges, where two triangles \(ABC\) and \(ABD\) share the edge \(AB\), the "midpoint" is defined as \(\dfrac{3}{8} A + \dfrac{3}{8} B + \dfrac{1}{8} C + \dfrac{1}{8} D\).
📗 For each vertex \(v\), it is updated to the weighted average of its neighbors \(v_{1}, v_{2}, ..., v_{n}\) (i.e. vertices with an edge connecting to \(v\)), by \(v' = \left(1 - n \beta\right) v + \beta \displaystyle\sum_{i=1}^{n} v_{i}\). Examples of \(\beta\):
➩ \(\beta = \dfrac{3}{16}\) if \(n = 3\) and \(\beta = \dfrac{3}{8 n}\) otherwise.
➩ \(\beta = \dfrac{1}{n} \left(\dfrac{5}{8} - \left(\dfrac{3}{8} + \dfrac{1}{4} \cos\left(\dfrac{2 \pi}{n}\right)\right)^{2}\right)\), in Loop's original paper.
📗 The "midpoint" of an edge \(AB\) for interior edges between \(ABCD\) and \(ABEF\) is \(\dfrac{1}{4} \left(A + B + \dfrac{1}{4} \left(A + B + C + D\right) + \dfrac{1}{4} \left(A + B + E + F\right)\right.\).
📗 The vertex update formula (Catmull-Clark formula) is \(v' = \dfrac{f + 2 r + \left(n - 3\right) v}{n}\) where \(f\) is the face average and \(r\) is the edge average.
📗 Blending between multiple different meshes (sets of vertices) is called morphing: Wikipedia.
📗 Multiple meshes can be stored in the same geometry as morph targets.
📗 All meshes are sent to the hardware, and vertex interpolation is done between targets by changing the weights: \(p = w_{1} p_{1} + w_{2} p_{2} + w_{3} p_{3} + ...\) is the position of a vertex given the positions of the same vertex in 3 (or more) morph targets.
📗 In THREE.js, THREE.Mesh has properties THREE.Mesh.morphTargetDictionary (list of morph targets) and THREE.Mesh.morphTargetInfluences (weights on each morph target). An example: Link.
📗 In Three.js a Bone represents the endpoint of a bone segment, and Three.js allows a maximum of 4 Bones to influence any vertex.
➩ The weights can be assigned manually based on vertex positions.
➩ The weights can be assigned automatically based on the distances to the Bones (the nearest 4 Bones), for example, \(w_{i} = \dfrac{\dfrac{1}{d_{i} + \varepsilon}}{\dfrac{1}{d_{1} + \varepsilon} + \dfrac{1}{d_{2} + \varepsilon} + \dfrac{1}{d_{3} + \varepsilon} + \dfrac{1}{d_{4} + \varepsilon}}\) for Bone i. The \(\varepsilon\) is added in case \(d_{i} = 0\).
📗 Notes and code adapted from the course taught by Professor Michael Gleicher.
📗 Please use Ctrl+F5 or Shift+F5 or Shift+Command+R or Incognito mode or Private Browsing to refresh the cached JavaScript: Code.
📗 You can expand all the examples and demos: , or print the notes: .
📗 If there is an issue with TopHat during the lectures, please submit your answers on paper (include your Wisc ID and answers) or this Google Form at the end of the lecture.