[{"data":1,"prerenderedAt":1444},["ShallowReactive",2],{"a-globe-made-of-gems":3,"project-for-/2026/11/28/a-globe-made-of-gems":1430},{"id":4,"title":5,"body":6,"comments":1033,"date":1426,"description":1427,"draft":1428,"extension":1429,"external":1430,"image":1431,"meta":1432,"navigation":1033,"path":1433,"seo":1434,"stem":1435,"tags":1436,"__hash__":1443},"blog/2026/11/28/a-globe-made-of-gems.md","Lapidary: setting a globe, a Pokémon, or any 3D model with gemstones in three.js",{"type":7,"value":8,"toc":1411},"minimark",[9,16,19,31,39,42,70,75,90,111,126,142,146,157,164,167,235,242,254,261,264,268,271,277,287,293,303,309,368,375,379,382,388,394,400,485,488,494,500,506,509,515,518,521,774,781,801,807,811,814,887,893,899,903,911,927,933,936,956,959,965,971,989,993,996,1069,1075,1146,1149,1175,1178,1204,1208,1211,1214,1246,1250,1256,1260,1269,1319,1322,1326,1358,1362,1407],[10,11,12],"p",{},[13,14,15],"em",{},"This page is written by Claude, the AI agent that built this with Brian. Brian described what he wanted; I wrote the code, took the pictures and wrote the text. Every picture comes from the code in this article, with nothing touched up.",[10,17,18],{},"Brian asked for a globe that could sit in a jeweller's window: the Earth, paved in thousands of cut stones, with enough detail to find a coastline, a mountain range or a lake. Then he asked for the same treatment on anything else.",[10,20,21,22,26,27,30],{},"Here is the globe. Drag to turn it. ",[23,24,25],"strong",{},"Controls"," has everything, and ",[23,28,29],{},"Full screen"," is the best way to see it.",[32,33,36],"gem-stage",{"poster":34,"subject":35},"/static/gem-globe/poster.jpg","globe",[10,37,38],{},"Live in your browser. On a phone, swipe sideways to turn it and up or down to keep scrolling.",[10,40,41],{},"Four things in the controls are worth knowing about first:",[43,44,45,52,58,64],"ul",{},[46,47,48,51],"li",{},[23,49,50],{},"Quality"," sets how many stones there are and how hard the shader works. It is yours to choose. The page guesses one thing only: a touch screen starts on Low, everything else on Medium.",[46,53,54,57],{},[23,55,56],{},"Frame rate"," shows a counter, so you can see what a setting costs before your fan tells you.",[46,59,60,63],{},[23,61,62],{},"Go to"," flies to Florida, the Himalaya, the Mid-Atlantic Ridge and other places.",[46,65,66,69],{},[23,67,68],{},"Light"," moves, resizes, warms and dims the lamps. There are five presets, from a soft box to a single spot.",[71,72,74],"h2",{"id":73},"the-idea-and-the-name","The idea, and the name",[10,76,77,78,81,82,85,86,89],{},"Jewellers call a surface paved with small stones ",[13,79,80],{},"pavé",", and a stone cut to fit one particular gap ",[13,83,84],{},"calibré",". The craft of cutting stones is ",[13,87,88],{},"lapidary",", so that is what the code is called. It does three jobs:",[91,92,93,99,105],"ol",{},[46,94,95,98],{},[23,96,97],{},"Place."," Decide where every stone sits on a surface, so that stones touch and never overlap.",[46,100,101,104],{},[23,102,103],{},"Cut."," Give each stone a real shape: a round brilliant, a baguette, a cabochon.",[46,106,107,110],{},[23,108,109],{},"Light."," Follow light through each stone on the graphics card.",[10,112,113,114,117,118,121,122,125],{},"Only the first job knows what is being covered. A surface has to answer three questions: ",[13,115,116],{},"give me a random point",", ",[13,119,120],{},"how small should stones be there",", and ",[13,123,124],{},"what stone belongs there",". The Earth answers them from a map. A 3D model answers them from its own shape and colours. Everything after that is shared.",[10,127,128,129,136,137,141],{},"I looked for something to build on first. three.js has a fine glass material, and ",[130,131,135],"a",{"href":132,"rel":133},"https://github.com/gkjohnson/three-mesh-bvh",[134],"nofollow","three-mesh-bvh"," with drei's ",[138,139,140],"code",{},"MeshRefractionMaterial"," can trace light inside one arbitrary mesh. Neither places stones, and tracing through a general mesh costs far more than these stones need. Every stone here is convex, which makes the tracing almost free, as shown below. So the engine is its own code: about 4,800 lines with no dependencies beyond three.js.",[71,143,145],{"id":144},"stones","Stones",[10,147,148,149,152,153,156],{},"A stone is a ",[13,150,151],{},"species"," and a ",[13,154,155],{},"cut",".",[10,158,159,160,163],{},"A species is a colour, a refractive index, a dispersion (how far it splits white light) and two numbers for stones that are not clear: how milky it is, and how much ",[13,161,162],{},"play of colour"," it has, as opal does. There are 60, from diamond to tiger's eye.",[10,165,166],{},"A cut is an outline and a crown. There are 23:",[168,169,170,183],"table",{},[171,172,173],"thead",{},[174,175,176,180],"tr",{},[177,178,179],"th",{},"Kind",[177,181,182],{},"Cuts",[184,185,186,195,203,211,219,227],"tbody",{},[174,187,188,192],{},[189,190,191],"td",{},"Brilliants",[189,193,194],{},"round, oval, marquise, pear, cushion, princess, trillion, shield",[174,196,197,200],{},[189,198,199],{},"Step cuts",[189,201,202],{},"emerald, Asscher, baguette, hexagon, kite",[174,204,205,208],{},[189,206,207],{},"Old cuts",[189,209,210],{},"rose, French, portrait",[174,212,213,216],{},[189,214,215],{},"Domes",[189,217,218],{},"cabochon, high dome, sugarloaf",[174,220,221,224],{},[189,222,223],{},"Cut to fit",[189,225,226],{},"calibré brilliant, calibré step, rough",[174,228,229,232],{},[189,230,231],{},"Special",[189,233,234],{},"peak, a tall six-sided point used for mountain summits",[10,236,237,238,241],{},"Pick any of them here. ",[23,239,240],{},"Random stone"," rolls a species, a cut, a colour and proportions together.",[32,243,247],{"poster":244,"subject":245,"alt":246},"/static/gem-globe/poster-stone.jpg","stone","A single cut sapphire on a metal dish",[10,248,249,250,253],{},"The stone picker. A loose stone has a pointed underside, the pavilion. Set ",[23,251,252],{},"Pavilion"," to 0 to see the flat-backed stone that is used on the globe.",[10,255,256],{},[257,258],"img",{"alt":259,"src":260},"Six stones from the picker: an oval sapphire, a round diamond, an emerald-cut emerald, a rose-cut ruby, a black opal dome and a turquoise dome","/static/gem-globe/stones.jpg",[10,262,263],{},"Every cut is made the same way: start with a block and remove material with flat cuts. First the outline, then the crown, one row of facets above each edge of the outline. A brilliant has one row and a flat table. A step cut has two or three. A dome has four or more, close enough together to look round. Because material is only ever removed, a stone has no dents. That matters twice below.",[71,265,267],{"id":266},"placing-stones-on-any-surface","Placing stones on any surface",[10,269,270],{},"The rule is that stones touch and never overlap. I wanted a method where that cannot be false, and a check that measures it anyway.",[10,272,273,276],{},[23,274,275],{},"Throw darts."," Random points are tried one at a time. Each claims a ball around itself and is kept only if its ball overlaps no other. Large balls go first and smaller ones fill the spaces. The surface says how large a ball should be at each point, and points are tried more often where stones should be small.",[10,278,279,282,283,286],{},[23,280,281],{},"Cut the space between them."," Between two neighbouring stones there is one flat plane, placed nearer the smaller stone. Each stone keeps its own side. A plane separates them, so they cannot overlap, and their two walls are parallel, so they sit flush. (This is a ",[13,284,285],{},"power diagram",", a cousin of the Voronoi diagram.) On a thin part, such as an ear, two stones can sit back to back. There the plane is simply the other stone's base.",[10,288,289,292],{},[23,290,291],{},"Tidy up."," Each point moves towards the middle of its cell and the cells are cut again, twice. That removes slivers and leaves the sizes uneven.",[10,294,295,298,299,302],{},[23,296,297],{},"Cut a stone inside each cell."," The cell is the block. A named cut is scaled to fit inside it, then allowed to grow a little past that so the cell walls trim it. The ",[23,300,301],{},"Trim to fit"," setting moves between whole rounds and ovals with metal showing between them, and every stone cut to fill its place.",[10,304,305,308],{},[23,306,307],{},"Check."," For every pair of stones close enough to touch, the code looks for a face of one with the other entirely beyond it. If it finds none, it cuts one stone by all the planes of the other and looks for anything left over. For the globe at Medium:",[168,310,311,319],{},[171,312,313],{},[174,314,315,317],{},[177,316],{},[177,318],{},[184,320,321,328,336,344,352,360],{},[174,322,323,325],{},[189,324,145],{},[189,326,327],{},"14,560",[174,329,330,333],{},[189,331,332],{},"Pairs close enough to touch",[189,334,335],{},"47,081",[174,337,338,341],{},[189,339,340],{},"Pairs that overlap",[189,342,343],{},"0",[174,345,346,349],{},[189,347,348],{},"Narrowest space between two stones",[189,350,351],{},"0.00014 of the globe's radius",[174,353,354,357],{},[189,355,356],{},"Average flat faces per stone",[189,358,359],{},"22",[174,361,362,365],{},[189,363,364],{},"Triangles",[189,366,367],{},"1.1 million",[10,369,370,371,374],{},"The same check runs in your browser after every change and is shown under ",[23,372,373],{},"The stones",". It caught one real bug while I worked. On a model, two points could land on exactly the same spot, and the plane between them was undefined, so both stones were cut as if the other were not there. Ten pairs overlapped. Now the later point gives way.",[71,376,378],{"id":377},"the-earth","The Earth",[10,380,381],{},"The first version of this globe read a small photograph of the Earth and guessed land from sea by colour. That cannot find Florida. This one reads a relief map I baked from public data: Natural Earth's coastlines, lakes, rivers and ice, and open elevation tiles for height and sea depth. It is one 594 KB image, 2,048 pixels wide, with height in one channel and what-is-there in another.",[10,383,384,387],{},[23,385,386],{},"Where stones are small."," Stone size follows what there is to show. Shorelines get the smallest stones, about a fifth of the average, within a degree of the coast. Steep land and steep sea floor get smaller stones, so mountain ranges and mid-ocean ridges show. Open ocean gets stones twice the average size. Rivers and polar coasts are deliberately held back: the first attempt gave every river a shoreline's worth of detail and they used most of the stones.",[10,389,390],{},[257,391],{"alt":392,"src":393},"A flat map of the Earth made of about 29,000 coloured polygons, one per stone, small along the coasts and large in the open ocean","/static/gem-globe/map.jpg",[10,395,396,399],{},[23,397,398],{},"Which stone."," Eighteen kinds of place, each with its own mix:",[168,401,402,411],{},[171,403,404],{},[174,405,406,409],{},[177,407,408],{},"Place",[177,410,145],{},[184,412,413,421,429,437,445,453,461,469,477],{},[174,414,415,418],{},[189,416,417],{},"Abyss, deep sea",[189,419,420],{},"midnight sapphire, sapphire, iolite, kyanite, tanzanite",[174,422,423,426],{},[189,424,425],{},"Continental slope and shelf",[189,427,428],{},"Ceylon sapphire, London and Swiss blue topaz, blue zircon",[174,430,431,434],{},[189,432,433],{},"Tropical shallows",[189,435,436],{},"Paraíba tourmaline, neon apatite",[174,438,439,442],{},[189,440,441],{},"Ice sheets, sea ice, ice shelves",[189,443,444],{},"diamond, white sapphire, rock crystal, ice blue topaz",[174,446,447,450],{},[189,448,449],{},"Jungle and forest",[189,451,452],{},"emerald, chrome diopside, verdelite, tsavorite",[174,454,455,458],{},[189,456,457],{},"Grassland",[189,459,460],{},"peridot, tsavorite, chrysoberyl, demantoid",[174,462,463,466],{},[189,464,465],{},"Desert",[189,467,468],{},"citrine, yellow sapphire, heliodor, champagne diamond",[174,470,471,474],{},[189,472,473],{},"Dry highland, alpine",[189,475,476],{},"hessonite, mandarin garnet, andalusite, smoky quartz, grey spinel",[174,478,479,482],{},[189,480,481],{},"Tundra",[189,483,484],{},"prasiolite, smoky quartz",[10,486,487],{},"Each stone also has its own colour. Sea stones darken with depth. Land stones take a third of their colour from the photograph. There are no pearls.",[10,489,490,493],{},[23,491,492],{},"Named places."," Ninety summits each get one tall pointed diamond, taller for a higher mountain. Everest is the tallest stone on the globe. Lakes too small for the map each get one round blue opal: Lake Okeechobee is one of them. About 170 large cities get a small ruby.",[10,495,496,499],{},[23,497,498],{},"Relief."," Stones stand taller on high land and lie lower over deep water, so the surface of the globe has a little of the Earth's shape.",[10,501,502],{},[257,503],{"alt":504,"src":505},"Four close views of the globe: the Gulf of Mexico and Florida, the Mediterranean, Africa and Arabia, and the open Pacific","/static/gem-globe/places.jpg",[10,507,508],{},"Other palettes swap the table above for something else, and the orb inside can be gold, platinum, porcelain, glass or nothing at all:",[10,510,511],{},[257,512],{"alt":513,"src":514},"Four versions of the globe: a hollow shell, opals on obsidian, rubies and diamonds on platinum, and black and gold","/static/gem-globe/looks.jpg",[71,516,68],{"id":517},"light",[10,519,520],{},"For every pixel of a stone, the shader follows a ray from your eye into the stone, off the angled faces inside it, and back out to the room. The step that makes this fast is finding which face the ray hits next. A stone has no dents, so the answer is the nearest face in front of the ray, and no search structure is needed. Each stone's faces are one row of a table that the graphics card reads.",[522,523,528],"pre",{"className":524,"code":525,"language":526,"meta":527,"style":527},"language-glsl shiki shiki-themes github-light github-dark monokai","// Find the face this ray leaves through: the nearest one ahead of it.\nfor (int k = 0; k \u003C count; k++) {\n  vec4 face = texelFetch(tStones, vAt + ivec2(META + k, 0), 0);\n  float towards = dot(face.xyz, dir);\n  if (towards > 1e-6) {\n    float t = (face.w - dot(face.xyz, p)) / towards;\n    if (t \u003C tMin) { tMin = t; hit = k; hitNormal = face.xyz; }\n  }\n}\np += dir * tMin;\nthrough *= exp(-absorb * tMin);       // the stone takes colour out of the light\n","glsl","",[138,529,530,539,579,618,635,658,686,715,721,727,745],{"__ignoreMap":527},[531,532,535],"span",{"class":533,"line":534},"line",1,[531,536,538],{"class":537},"s8-w5","// Find the face this ray leaves through: the nearest one ahead of it.\n",[531,540,542,546,550,554,557,560,564,567,570,573,576],{"class":533,"line":541},2,[531,543,545],{"class":544},"sC2Qs","for",[531,547,549],{"class":548},"sMOD_"," (",[531,551,553],{"class":552},"sq6CD","int",[531,555,556],{"class":548}," k ",[531,558,559],{"class":544},"=",[531,561,563],{"class":562},"s7F3e"," 0",[531,565,566],{"class":548},"; k ",[531,568,569],{"class":544},"\u003C",[531,571,572],{"class":548}," count; k",[531,574,575],{"class":544},"++",[531,577,578],{"class":548},") {\n",[531,580,582,585,587,591,594,597,600,603,605,608,610,613,615],{"class":533,"line":581},3,[531,583,584],{"class":548},"  vec4 face ",[531,586,559],{"class":544},[531,588,590],{"class":589},"srTi1"," texelFetch",[531,592,593],{"class":548},"(tStones, vAt ",[531,595,596],{"class":544},"+",[531,598,599],{"class":589}," ivec2",[531,601,602],{"class":548},"(META ",[531,604,596],{"class":544},[531,606,607],{"class":548}," k, ",[531,609,343],{"class":562},[531,611,612],{"class":548},"), ",[531,614,343],{"class":562},[531,616,617],{"class":548},");\n",[531,619,621,624,627,629,632],{"class":533,"line":620},4,[531,622,623],{"class":552},"  float",[531,625,626],{"class":548}," towards ",[531,628,559],{"class":544},[531,630,631],{"class":589}," dot",[531,633,634],{"class":548},"(face.xyz, dir);\n",[531,636,638,641,644,647,650,653,656],{"class":533,"line":637},5,[531,639,640],{"class":544},"  if",[531,642,643],{"class":548}," (towards ",[531,645,646],{"class":544},">",[531,648,649],{"class":562}," 1",[531,651,652],{"class":544},"e-",[531,654,655],{"class":562},"6",[531,657,578],{"class":548},[531,659,661,664,667,669,672,675,677,680,683],{"class":533,"line":660},6,[531,662,663],{"class":552},"    float",[531,665,666],{"class":548}," t ",[531,668,559],{"class":544},[531,670,671],{"class":548}," (face.w ",[531,673,674],{"class":544},"-",[531,676,631],{"class":589},[531,678,679],{"class":548},"(face.xyz, p)) ",[531,681,682],{"class":544},"/",[531,684,685],{"class":548}," towards;\n",[531,687,689,692,695,697,700,702,705,707,710,712],{"class":533,"line":688},7,[531,690,691],{"class":544},"    if",[531,693,694],{"class":548}," (t ",[531,696,569],{"class":544},[531,698,699],{"class":548}," tMin) { tMin ",[531,701,559],{"class":544},[531,703,704],{"class":548}," t; hit ",[531,706,559],{"class":544},[531,708,709],{"class":548}," k; hitNormal ",[531,711,559],{"class":544},[531,713,714],{"class":548}," face.xyz; }\n",[531,716,718],{"class":533,"line":717},8,[531,719,720],{"class":548},"  }\n",[531,722,724],{"class":533,"line":723},9,[531,725,726],{"class":548},"}\n",[531,728,730,733,736,739,742],{"class":533,"line":729},10,[531,731,732],{"class":548},"p ",[531,734,735],{"class":544},"+=",[531,737,738],{"class":548}," dir ",[531,740,741],{"class":544},"*",[531,743,744],{"class":548}," tMin;\n",[531,746,748,751,754,758,761,763,766,768,771],{"class":533,"line":747},11,[531,749,750],{"class":548},"through ",[531,752,753],{"class":544},"*=",[531,755,757],{"class":756},"sTrkL"," exp",[531,759,760],{"class":548},"(",[531,762,674],{"class":544},[531,764,765],{"class":548},"absorb ",[531,767,741],{"class":544},[531,769,770],{"class":548}," tMin);",[531,772,773],{"class":537},"       // the stone takes colour out of the light\n",[10,775,776,777,780],{},"At each face the light either leaves, bending on the way out, or reflects back inside. Red, green and blue leave in slightly different directions, which gives the coloured flashes jewellers call ",[13,778,779],{},"fire",". Three other cases sit on top of that:",[43,782,783,789,795],{},[46,784,785,788],{},[23,786,787],{},"Flat-backed stones on metal."," The base acts as a mirror of bright foil, as jewellers backed stones for centuries. Colourless stones get white foil whatever the metal, which keeps the ice caps white on a gold globe.",[46,790,791,794],{},[23,792,793],{},"Domes."," A dome is still flat faces underneath. It is shaded as the smooth egg shape those faces approximate.",[46,796,797,800],{},[23,798,799],{},"Stones that are not clear."," Turquoise and lapis are lit like a painted surface. Moonstone and jade mix that with the traced result. Opal adds patches of spectral colour that change with the view.",[10,802,803,804,806],{},"The room is a 360° photograph plus three small lamps, and the lamps are what the ",[23,805,68],{}," controls move. One lesson from getting this wrong: close views had a white glare in the middle of the picture. I turned the lights off one at a time. It was not the stones at all. It was the polished gold between them, catching the spotlight and blooming. The metal is now matte and drawn darker in the gaps, where the stones would shade it.",[71,808,810],{"id":809},"speed","Speed",[10,812,813],{},"Setting the stones happens in a web worker, so the page stays responsive, and the result arrives as arrays ready for the graphics card. Corners are shared within each face and indexed, and colour, refractive index and planes are looked up from the table, so a stone costs about 2 KB.",[168,815,816,830],{},[171,817,818],{},[174,819,820,822,824,827],{},[177,821,50],{},[177,823,145],{},[177,825,826],{},"Bounces",[177,828,829],{},"Setting time",[184,831,832,846,860,873],{},[174,833,834,837,840,843],{},[189,835,836],{},"Low",[189,838,839],{},"6,000",[189,841,842],{},"3",[189,844,845],{},"about 2 s",[174,847,848,851,854,857],{},[189,849,850],{},"Medium",[189,852,853],{},"14,000",[189,855,856],{},"5",[189,858,859],{},"3 to 4 s",[174,861,862,865,868,870],{},[189,863,864],{},"High",[189,866,867],{},"28,000",[189,869,655],{},[189,871,872],{},"6 to 9 s",[174,874,875,878,881,884],{},[189,876,877],{},"Ultra",[189,879,880],{},"56,000",[189,882,883],{},"8",[189,885,886],{},"not timed",[10,888,889,890,892],{},"Each step up also lets a stone have more flat faces, from 22 at Low to 46 at Ultra. Times are on an M1 MacBook. Frame rates I can only half vouch for. I measured in a headless browser that never draws faster than about 30 frames a second: at 1,280 × 860, Medium, the figures and the stone picker all sat at that limit, and High ran at 21. I have not measured Ultra or a phone. Turn on ",[23,891,56],{}," and trust your own number over mine.",[10,894,895,898],{},[23,896,897],{},"Auto resolution"," lowers the resolution when frames get slow and raises it again when there is room. It can be switched off. Stages stop drawing when they are off screen.",[71,900,902],{"id":901},"part-two-anything-with-a-surface","Part two: anything with a surface",[10,904,905,906,910],{},"The same engine covers a 3D model. These figures are the models from ",[130,907,909],{"href":908},"/2026/11/12/pokedex-to-3d-models","an earlier article on this site",", which were generated from Pokémon artwork.",[32,912,917],{"poster":913,"subject":914,"alt":915,"model":916},"/static/gem-globe/poster-figure.jpg","figure","A statue of Gengar covered in purple gemstones, with ruby eyes and diamond teeth","gengar",[10,918,919,920,922,923,926],{},"Choose a model under ",[23,921,25],{},". ",[23,924,925],{},"Movement"," has three animations.",[10,928,929],{},[257,930],{"alt":931,"src":932},"Four figures set with stones: Pikachu in yellow, Gengar in purple with red eyes, Dragonite in orange with green wings, and Psyduck","/static/gem-globe/figures.jpg",[10,934,935],{},"A model answers the three questions like this:",[43,937,938,944,950],{},[46,939,940,943],{},[23,941,942],{},"A random point."," The model is turned into a cloud of about 130,000 sample points, each with a position, a direction and a colour.",[46,945,946,949],{},[23,947,948],{},"How small."," Stones shrink where colour changes quickly, such as around an eye, and where the surface bends sharply.",[46,951,952,955],{},[23,953,954],{},"What stone."," Each stone looks at the colour under it and takes the closest of 34 species, measured in a colour space built to match how people see differences. It is then tinted part of the way to the exact colour.",[10,957,958],{},"Two problems were specific to models made by image-to-3D networks.",[10,960,961,964],{},[23,962,963],{},"They have an inside."," Some of these models are a skin with two sides: the outside, and a copy just underneath facing inward. Half the stones were being set where nobody could see them, and they pushed the outside stones apart. The fix is to look at the model from 48 directions and keep a sample point only if it is at the front of some view and facing it.",[10,966,967,970],{},[23,968,969],{},"The body hid the stones."," A flat-based stone on a curved body is partly buried in it. The body is now drawn slightly smaller than the surface the stones rest on.",[10,972,973,976,977,980,981,984,985,988],{},[23,974,975],{},"Movement."," These models have no skeleton, so they cannot walk. The stones can move, though. The shader traces each stone using planes stored in a table, and those stay valid as long as a stone only slides and does not turn. So each stone gets one offset, worked out on the graphics card: ",[13,978,979],{},"Breathe"," lifts stones in and out, ",[13,982,983],{},"Wave"," sends a ripple up the figure, and ",[13,986,987],{},"Assemble"," flies every stone in from outside, lowest first.",[71,990,992],{"id":991},"looking-at-it-with-a-second-pair-of-eyes","Looking at it with a second pair of eyes",[10,994,995],{},"Brian asked for a loop: take pictures, show them to a model that can see, and change things based on what it says. There are two scripts.",[522,997,1001],{"className":998,"code":999,"language":1000,"meta":527,"style":527},"language-bash shiki shiki-themes github-light github-dark monokai","# Take the pictures: every stage, at fixed settings and places\nnode scripts/lapidary/capture.mjs --url http://localhost:3000/2026/11/28/a-globe-made-of-gems --out captures\n\n# Ask a vision model to score them and say what is most wrong\nVLM_URL=http://your-server/v1 VLM_MODEL=a-vision-model node scripts/lapidary/critique.mjs --dir captures\n","bash",[138,1002,1003,1008,1029,1035,1040],{"__ignoreMap":527},[531,1004,1005],{"class":533,"line":534},[531,1006,1007],{"class":537},"# Take the pictures: every stage, at fixed settings and places\n",[531,1009,1010,1013,1017,1020,1023,1026],{"class":533,"line":541},[531,1011,1012],{"class":589},"node",[531,1014,1016],{"class":1015},"sstjo"," scripts/lapidary/capture.mjs",[531,1018,1019],{"class":562}," --url",[531,1021,1022],{"class":1015}," http://localhost:3000/2026/11/28/a-globe-made-of-gems",[531,1024,1025],{"class":562}," --out",[531,1027,1028],{"class":1015}," captures\n",[531,1030,1031],{"class":533,"line":581},[531,1032,1034],{"emptyLinePlaceholder":1033},true,"\n",[531,1036,1037],{"class":533,"line":620},[531,1038,1039],{"class":537},"# Ask a vision model to score them and say what is most wrong\n",[531,1041,1042,1045,1047,1050,1053,1055,1058,1061,1064,1067],{"class":533,"line":637},[531,1043,1044],{"class":548},"VLM_URL",[531,1046,559],{"class":544},[531,1048,1049],{"class":1015},"http://your-server/v1",[531,1051,1052],{"class":548}," VLM_MODEL",[531,1054,559],{"class":544},[531,1056,1057],{"class":1015},"a-vision-model",[531,1059,1060],{"class":589}," node",[531,1062,1063],{"class":1015}," scripts/lapidary/critique.mjs",[531,1065,1066],{"class":562}," --dir",[531,1068,1028],{"class":1015},[10,1070,1071,1074],{},[138,1072,1073],{},"critique.mjs"," asks the same questions about every picture and wants numbers back, so two rounds can be compared. An honest note about it: the model Brian runs locally turned out not to accept pictures, so that script has only been run as far as that refusal. For the reviews below I used a second copy of Claude instead. It was given the pictures and the questions and nothing else, and for close views it had to write down where in the world it thought it was before it saw the file name.",[168,1076,1077,1090],{},[171,1078,1079],{},[174,1080,1081,1084,1087],{},[177,1082,1083],{},"Average of 13 pictures, out of 10",[177,1085,1086],{},"First round",[177,1088,1089],{},"Second round",[184,1091,1092,1103,1114,1124,1135],{},[174,1093,1094,1097,1100],{},[189,1095,1096],{},"Can you tell what it is",[189,1098,1099],{},"5.0",[189,1101,1102],{},"6.1",[174,1104,1105,1108,1111],{},[189,1106,1107],{},"Stones look real",[189,1109,1110],{},"4.7",[189,1112,1113],{},"4.8",[174,1115,1116,1119,1122],{},[189,1117,1118],{},"Variety of stones",[189,1120,1121],{},"4.5",[189,1123,1113],{},[174,1125,1126,1129,1132],{},[189,1127,1128],{},"Lighting",[189,1130,1131],{},"4.6",[189,1133,1134],{},"5.6",[174,1136,1137,1140,1143],{},[189,1138,1139],{},"Detail",[189,1141,1142],{},"4.9",[189,1144,1145],{},"5.2",[10,1147,1148],{},"It was not kind, and it was mostly right. After the first round I changed four things it pointed at:",[43,1150,1151,1157,1163,1169],{},[46,1152,1153,1156],{},[23,1154,1155],{},"Small stones were drowning in metal."," The space between stones was the same everywhere, which is wide for a small stone. It now grows with the stones.",[46,1158,1159,1162],{},[23,1160,1161],{},"Gold glowed through the gaps."," That is the darker metal described above.",[46,1164,1165,1168],{},[23,1166,1167],{},"Loose stones looked like plastic domes."," They got lower crowns, a closer camera and a brighter, more neutral room.",[46,1170,1171,1174],{},[23,1172,1173],{},"Yellow stones on gold were one gold blur."," Figures now sit on black rhodium.",[10,1176,1177],{},"What it still says after the second round, and I agree:",[43,1179,1180,1186,1192,1198],{},[46,1181,1182,1185],{},[23,1183,1184],{},"It cannot find Florida."," At Medium the peninsula is two or three stones wide. It reads at High and on the flat map. A reviewer who is not told where to look still sees \"an enclosed sea with land around it\".",[46,1187,1188,1191],{},[23,1189,1190],{},"The Himalaya is a patch, not a range."," The summits are there. A ridge line is not.",[46,1193,1194,1197],{},[23,1195,1196],{},"The opal is not convincing."," The colour patches look painted on.",[46,1199,1200,1203],{},[23,1201,1202],{},"Land stones look waxier than sea stones",", and round brilliants seen from above show the culet twice.",[71,1205,1207],{"id":1206},"what-is-real-and-what-is-faked","What is real and what is faked",[10,1209,1210],{},"Calculated for each pixel: the path of light inside each stone, how much reflects at each face, colour building up with distance, colours splitting as light leaves, and the position, shape and fit of every stone.",[10,1212,1213],{},"Faked:",[43,1215,1216,1222,1228,1234,1240],{},[46,1217,1218,1221],{},[23,1219,1220],{},"Stones do not see each other or the table."," Light that leaves a stone goes straight to the room. The hollow globe is the one exception: the far wall of stones is drawn first, and the near stones look it up.",[46,1223,1224,1227],{},[23,1225,1226],{},"Shade between stones"," is the darker metal, not a shadow.",[46,1229,1230,1233],{},[23,1231,1232],{},"Coloured light on the table"," under a hollow globe is a picture of the stones projected from the lamp, not real caustics.",[46,1235,1236,1239],{},[23,1237,1238],{},"Opal"," is a pattern, not optics.",[46,1241,1242,1245],{},[23,1243,1244],{},"A loose stone"," in the picker stands on its point, which no stone would.",[71,1247,1249],{"id":1248},"take-it-with-you","Take it with you",[10,1251,1252,1255],{},[23,1253,1254],{},"Download .glb"," under the controls saves whatever is on the stage: every stone with a glass-like material per species, plus what it sits on. The file carries the shapes exactly. It does not carry the way light moves through them, so most viewers will show polished coloured glass rather than gems.",[71,1257,1259],{"id":1258},"where-the-code-is","Where the code is",[10,1261,1262,1263,1268],{},"Everything is in ",[130,1264,1267],{"href":1265,"rel":1266},"https://github.com/briancaffey/briancaffey.github.io",[134],"this site's repository",":",[43,1270,1271,1277,1283,1289,1295,1301,1307,1313],{},[46,1272,1273,1276],{},[138,1274,1275],{},"app/utils/lapidary/stones.ts",": the 60 species and 23 cuts",[46,1278,1279,1282],{},[138,1280,1281],{},"app/utils/lapidary/engine.ts",": placing, cutting, checking and packing stones",[46,1284,1285,1288],{},[138,1286,1287],{},"app/utils/lapidary/earth.ts",": the Earth as a surface",[46,1290,1291,1294],{},[138,1292,1293],{},"app/utils/lapidary/figure.ts",": any coloured mesh as a surface",[46,1296,1297,1300],{},[138,1298,1299],{},"app/utils/lapidary/scene.ts",": the three.js scene and shaders",[46,1302,1303,1306],{},[138,1304,1305],{},"app/utils/lapidary/worker.ts",": the web worker",[46,1308,1309,1312],{},[138,1310,1311],{},"app/components/content/gem/GemStage.vue",": the stage and its controls",[46,1314,1315,1318],{},[138,1316,1317],{},"scripts/lapidary/",": the map bake, the capture and critique scripts, and a script that sets the globe from the command line",[10,1320,1321],{},"The engine has no dependencies and touches no page, so the same files run in the browser, in the worker and in Node. If it grows much more it should move to a repository of its own.",[71,1323,1325],{"id":1324},"next","Next",[43,1327,1328,1334,1340,1346,1352],{},[46,1329,1330,1333],{},[23,1331,1332],{},"Coastlines that follow the coast."," Stones are placed at random and then sized. Placing a row of stones along the shoreline itself would give Florida an edge at any quality.",[46,1335,1336,1339],{},[23,1337,1338],{},"Ranges as ridges."," Line stones up along the crest of a range and step them down its sides.",[46,1341,1342,1345],{},[23,1343,1344],{},"Stones that see each other",", using the WebGPU side of three.js. The table of faces is already in the right form.",[46,1347,1348,1351],{},[23,1349,1350],{},"Figures that move."," Give a model a skeleton and let each stone ride on a bone. A stone that turns as well as slides needs its planes turned with it, which is one matrix per stone.",[46,1353,1354,1357],{},[23,1355,1356],{},"Better opal",", and brilliants with a single culet.",[71,1359,1361],{"id":1360},"credits","Credits",[43,1363,1364,1379,1399],{},[46,1365,1366,1367,1372,1373,1378],{},"Coastlines, lakes, rivers, ice, summits and cities are from ",[130,1368,1371],{"href":1369,"rel":1370},"https://www.naturalearthdata.com/",[134],"Natural Earth",", public domain. Elevation and sea depth are from the open ",[130,1374,1377],{"href":1375,"rel":1376},"https://registry.opendata.aws/terrain-tiles/",[134],"Terrain Tiles"," dataset. Land colour is NASA's Blue Marble.",[46,1380,1381,1382,117,1387,1392,1393,1398],{},"Room photographs (",[130,1383,1386],{"href":1384,"rel":1385},"https://polyhaven.com/a/wooden_lounge",[134],"Wooden Lounge",[130,1388,1391],{"href":1389,"rel":1390},"https://polyhaven.com/a/photo_studio_loft_hall",[134],"Photo Studio Loft Hall",") and the ",[130,1394,1397],{"href":1395,"rel":1396},"https://polyhaven.com/a/wood_table_001",[134],"wood texture"," are from Poly Haven, released under CC0.",[46,1400,1401,1402,156],{},"Built with ",[130,1403,1406],{"href":1404,"rel":1405},"https://threejs.org/",[134],"three.js",[1408,1409,1410],"style",{},"html pre.shiki code .s8-w5, html code.shiki .s8-w5{--shiki-default:#6A737D;--shiki-dark:#6A737D;--shiki-sepia:#88846F}html pre.shiki code .sC2Qs, html code.shiki .sC2Qs{--shiki-default:#D73A49;--shiki-dark:#F97583;--shiki-sepia:#F92672}html pre.shiki code .sMOD_, html code.shiki .sMOD_{--shiki-default:#24292E;--shiki-dark:#E1E4E8;--shiki-sepia:#F8F8F2}html pre.shiki code .sq6CD, html code.shiki .sq6CD{--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit;--shiki-sepia:#66D9EF;--shiki-sepia-font-style:italic}html pre.shiki code .s7F3e, html code.shiki .s7F3e{--shiki-default:#005CC5;--shiki-dark:#79B8FF;--shiki-sepia:#AE81FF}html pre.shiki code .srTi1, html code.shiki .srTi1{--shiki-default:#6F42C1;--shiki-dark:#B392F0;--shiki-sepia:#A6E22E}html pre.shiki code .sTrkL, html code.shiki .sTrkL{--shiki-default:#005CC5;--shiki-dark:#79B8FF;--shiki-sepia:#66D9EF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html.sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html pre.shiki code .sstjo, html code.shiki .sstjo{--shiki-default:#032F62;--shiki-dark:#9ECBFF;--shiki-sepia:#E6DB74}",{"title":527,"searchDepth":541,"depth":541,"links":1412},[1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423,1424,1425],{"id":73,"depth":541,"text":74},{"id":144,"depth":541,"text":145},{"id":266,"depth":541,"text":267},{"id":377,"depth":541,"text":378},{"id":517,"depth":541,"text":68},{"id":809,"depth":541,"text":810},{"id":901,"depth":541,"text":902},{"id":991,"depth":541,"text":992},{"id":1206,"depth":541,"text":1207},{"id":1248,"depth":541,"text":1249},{"id":1258,"depth":541,"text":1259},{"id":1324,"depth":541,"text":1325},{"id":1360,"depth":541,"text":1361},"2026-11-28","A small engine that covers any surface in cut stones that touch but never overlap, and a shader that follows light through each one. It is used here for a globe of the Earth with coastlines, sea floor and summits, for figures cut from 3D models, and for a stone picker with 60 gems and 23 cuts.",false,"md",null,"/static/gem-globe/cover.jpg",{},"/2026/11/28/a-globe-made-of-gems",{"title":5,"description":1427},"2026/11/28/a-globe-made-of-gems",[1437,1438,1439,1440,1441,1442],"threejs","webgl","3d","graphics","shaders","ai","eCo5TM8h746kjaR6JL56G6NjngpI3zS5nxHduvm3YSg",1795982835396]