Embedding.js README - Adding datapoints
by Beau Cronin
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r80/three.min.js"></script>
<script src="https://rawgit.com/beaucronin/embedding/master/bundle.js"></script>
JavaScript
var scene, renderer, camera, dataset, embedding;
var N = 50;
var i = 0;
var DELAY = 250;
// initialize the scene, renderer, and camera objects and inject into the DOM
EMBED.initScene();
// create a simple Dataset with x, y, and z attributes
dataset = new EMBED.Dataset();
window.setInterval(function() {
if (i < N) {
dataset.add(
{ _id: i,
x: i / (N / 10) - 5,
y: 4 * Math.sin(i * 2 * Math.PI / N),
z: 0
}
);
i++;
}
}, DELAY);
// create an embedding that will place the points in the Dataset into space
embedding = new EMBED.ScatterEmbedding(
scene, dataset, {pointColor: 0x339933, pointSize: .5});
// start a simple render loop
EMBED.animate();