Public
Edited
Mar 16, 2021
3 forks
Importers
14 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
egg = {
if (!tiling) return cube
const s = 1;
const geometry = new THREE.Geometry();
const uvs = flatten(tiling.map(tr => tr.uv))
const u_extent = d3.extent(uvs.map(uv => uv[0]))
const v_extent = d3.extent(uvs.map(uv => uv[1]))
const u = d3.scaleLinear().domain(u_extent).range([0,1])
const v = d3.scaleLinear().domain(v_extent).range([0,1])
tiling.forEach((tr, i) => {
const [ a, b, c ] = tr;
geometry.vertices.push(new THREE.Vector3(a[0]*s, a[1]*s, a[2]*s));
geometry.vertices.push(new THREE.Vector3(b[0]*s, b[1]*s, b[2]*s));
geometry.vertices.push(new THREE.Vector3(c[0]*s, c[1]*s, c[2]*s));
geometry.faces.push(new THREE.Face3(3*i, 3*i+1, 3*i+2));
const [ [au, av], [bu, bv], [cu, cv] ] = tr.uv;
geometry.faceVertexUvs[0].push([
new THREE.Vector2(u(au), v(av)),
new THREE.Vector2(u(bu), v(bv)),
new THREE.Vector2(u(cu), v(cv)),
]);
});
geometry.uvsNeedUpdate = true;
geometry.computeFaceNormals();
geometry.computeVertexNormals();

const material = normal_colors
? new THREE.MeshNormalMaterial({ side: THREE.DoubleSide, wireframe: false })
//: new THREE.MeshBasicMaterial({ map: texture }) /*
: b ? new THREE.MeshLambertMaterial({ color: 0xf4f4ed, side: THREE.DoubleSide })
: new THREE.MeshPhongMaterial({
color: 0xf4f4ed,//0xf4f4dc,
side: THREE.DoubleSide,
// map: texture,
bumpMap: use_bump ? texture : undefined,
// specularMap: texture,
bumpScale: 1,
});

const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more