Published
Edited
May 11, 2022
Insert cell
Insert cell
renderer.domElement
Insert cell
myText = {
// Create:
const myText = new TROICA.Text();
scene.add(myText);

// Set properties to configure:
myText.text = "Hello world!";
myText.fontSize = 1;
myText.position.y = 1;
myText.color = "white";
myText.sync();
return myText;
}
Insert cell
// Continuously updates
{
while (true) {
// Update the rendering:

renderer.render(scene, camera);
yield null;
}
}
Insert cell
height = 600
Insert cell
scene = {
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x001b42);
return scene;
}
Insert cell
camera = {
const fov = 45;
const aspect = width / height;
const near = 1;
const far = 1000;
const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
camera.position.set(2, 2, -2)
camera.lookAt(new THREE.Vector3(0, 0, 0));
return camera;
}
Insert cell
renderer = {
const renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(width, height);
renderer.setPixelRatio(devicePixelRatio);
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.addEventListener("change", () => renderer.render(scene, camera));
invalidation.then(() => (controls.dispose(), renderer.dispose()));
return renderer;
}
Insert cell
Insert cell
TROICA = import(
"https://unpkg.com/troika-three-text@0.45.0/dist/troika-three-text.esm.js?module"
)
Insert cell
THREE = {
const THREE = window.THREE = await require("three@0.130.0/build/three.min.js");
await require("three@0.130.0/examples/js/controls/OrbitControls.js").catch(() => {});
return THREE;
}
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