Public
Edited
Jan 29
Importers
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function meshFromShapeModel( model ) {

const geometries = {};
model.shapes.forEach( (shape) => {
const geometry = new THREE.Geometry();
geometry.vertices = shape.vertices.map(
({x, y, z}) => new THREE.Vector3(x, y, z));
geometry.faces = shape.faces.map(
({vertices: [a, b, c]}) => new THREE.Face3(a, b, c));
geometry.computeFaceNormals();
geometries[ shape.id ] = geometry;
} );

const group = new THREE.Object3D()
model.instances.forEach( (instance) => {
const material = new THREE.MeshLambertMaterial({ color: instance.color });
const geometry = geometries[ instance.shape ];
if ( geometry ) {
const mesh = new THREE.Mesh( geometry, material );
mesh.position .set( ...Object.values( instance.position ) )
if ( instance.rotation )
mesh.quaternion .set( ...Object.values( instance.rotation ) )
group.add( mesh );
}
});
return group
}
Insert cell
Insert cell
greatRhombiRoot2 = fetch(
"https://gist.githubusercontent.com/vorth/51c7216a7d9f57e790de87b4e17cce8c/raw/95fe859dcd20581e9367f62e70b772285d7745dd/great-rhombi-root2.json" ) .then( response => response.json() )
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