Published
Edited
Apr 18, 2020
2 forks
Importers
1 star
Insert cell
Insert cell
Insert cell
{
const threelet = new Threelet({
canvas: document.getElementById('canvas'),
optAxes: false,
optVR: true,
optVRAppendButtonTo: div,
});
// https://github.com/observablehq/stdlib#invalidation
invalidation.then(() => threelet.dispose());

threelet.setup('mod-controls', THREE.OrbitControls);

threelet.scene.add(new THREE.GridHelper(10, 20));

const cube = new THREE.Mesh(
new THREE.BoxGeometry(0.5, 0.5, 0.5),
new THREE.MeshBasicMaterial({color: 0xff00ff}));
cube.position.set(0, 1, -2);
threelet.scene.add(cube);
threelet.render(); // first time; passive rendering per mouse interaction
return threelet;
}
Insert cell
THREE = {
const THREE = window.THREE = await require("three@0.112/build/three.min.js");
await require("three@0.112/examples/js/controls/OrbitControls.js").catch(() => {});
return THREE;
}
Insert cell
Threelet = {
const _THREE = THREE; // this ensures THREE is resolved first.
return (await require(`threelet@0.10.0/dist/threelet.esm.min.js`)).default;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more