1 line
47 KiB
Plaintext
1 line
47 KiB
Plaintext
|
|
{"version":3,"file":"TeapotGeometry.cjs","sources":["../../src/geometries/TeapotGeometry.js"],"sourcesContent":["import { BufferAttribute, BufferGeometry, Matrix4, Vector3, Vector4 } from 'three'\n\n/**\n * Tessellates the famous Utah teapot database by Martin Newell into triangles.\n *\n * Parameters: size = 50, segments = 10, bottom = true, lid = true, body = true,\n * fitLid = false, blinn = true\n *\n * size is a relative scale: I've scaled the teapot to fit vertically between -1 and 1.\n * Think of it as a \"radius\".\n * segments - number of line segments to subdivide each patch edge;\n * 1 is possible but gives degenerates, so two is the real minimum.\n * bottom - boolean, if true (default) then the bottom patches are added. Some consider\n * adding the bottom heresy, so set this to \"false\" to adhere to the One True Way.\n * lid - to remove the lid and look inside, set to true.\n * body - to remove the body and leave the lid, set this and \"bottom\" to false.\n * fitLid - the lid is a tad small in the original. This stretches it a bit so you can't\n * see the teapot's insides through the gap.\n * blinn - Jim Blinn scaled the original data vertically by dividing by about 1.3 to look\n * nicer. If you want to see the original teapot, similar to the real-world model, set\n * this to false. True by default.\n * See http://en.wikipedia.org/wiki/File:Original_Utah_Teapot.jpg for the original\n * real-world teapot (from http://en.wikipedia.org/wiki/Utah_teapot).\n *\n * Note that the bottom (the last four patches) is not flat - blame Frank Crow, not me.\n *\n * The teapot should normally be rendered as a double sided object, since for some\n * patches both sides can be seen, e.g., the gap around the lid and inside the spout.\n *\n * Segments 'n' determines the number of triangles output.\n * Total triangles = 32*2*n*n - 8*n [degenerates at the top and bottom cusps are deleted]\n *\n * size_factor # triangles\n * 1 56\n * 2 240\n * 3 552\n * 4 992\n *\n * 10 6320\n * 20 25440\n * 30 57360\n *\n * Code converted from my ancient SPD software, http://tog.acm.org/resources/SPD/\n * Created for the Udacity course \"Interactive Rendering\", http://bit.ly/ericity\n * Lesson: https://www.udacity.com/course/viewer#!/c-cs291/l-68866048/m-106482448\n * YouTube video on teapot history: https://www.youtube.com/watch?v=DxMfblPzFNc\n *\n * See https://en.wikipedia.org/wiki/Utah_teapot for the history of the teapot\n *\n */\n\nclass TeapotGeometry extends BufferGeometry {\n constructor(size, segments, bottom, lid, body, fitLid, blinn) {\n // 32 * 4 * 4 Bezier spline patches\n const teapotPatches = [\n /*rim*/\n 0,\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 3,\n 16,\n 17,\n 18,\n 7,\n 19,\n 20,\n 21,\n 11,\n 22,\n 23,\n 24,\n 15,\n 25,\n 26,\n 27,\n 18,\n 28,\n 29,\n 30,\n 21,\n 31,\n 32,\n 33,\n 24,\n 34,\n 35,\n 36,\n 27,\n 37,\n 38,\n 39,\n 30,\n 40,\n 41,\n 0,\n 33,\n 42,\n 43,\n 4,\n 36,\n 44,\n 45,\n 8,\n 39,\n 46,\n 47,\n 12,\n /*body*/\n 12,\n 13,\n 14,\n 15,\n 48,\n 49,\n 50,\n 51,\n 52,\n 53,\n 54,\n 55,\n 56,\n 57,\n 58,\n 59,\n 15,\n 25,\n 26,\n 27,\n 51,\n 60,\n 61,\n 62,\n 55,\n 63,\n 64,\n 65,\n 59,\n 66,\n 67,\n 68,\n 27,\n 37,\n 38,\n 39,\n 62,\n 69,\n 70,\n 71,\n 65,\n 72,\n 73,\n 74,\n 68,\n 75,\n 76,\n 77,\n 39,\n 46,\n 47,\n 12,\n 71,\n 78,\n 79,\n 48,\n
|