Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (72 sloc) 2.12 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, shrink-to-fit=no">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>Embedding.js basic example</title>
<script type="text/javascript" src="js/embedding.js"></script>
<style>
/* Ensures that the canvas fills the entire window, and that there are no scrollbars */
body {
width: 100%;
height: 100%;
background-color: #000;
color: #fff;
margin: 0px;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script>
const { scene, camera, manager, effect, cameraControls } = EMBED.initScene({ room: true });
var dataset, embedding;
var N = 1;
var c = 0;
initEmbedding();
EMBED.startAnimation();
function initEmbedding() {
dataset = new EMBED.Dataset();
var f = function() {
for (let i = 0; i < N; i++) {
let dp = { _id: c,
x: -4 + 8*Math.random(),
y: -4 + 8*Math.random(),
z: -4 + 8*Math.random() };
dataset.add(dp);
c++;
// console.log('added', dp);
}
};
window.setInterval(f, 200);
var g = function() {
let ids = Object.keys(dataset.datapoints);
M = ids.length;
let i = Math.floor(Math.random() * M);
let id = ids[i];
dataset.remove(id);
}
window.setInterval(g, 500);
var h = function() {
let ids = Object.keys(dataset.datapoints);
M = ids.length;
let i = Math.floor(Math.random() * M);
let id = ids[i];
dataset.update(id, 'x', -4 + 8*Math.random());
dataset.update(id, 'y', -4 + 8*Math.random());
dataset.update(id, 'z', -4 + 8*Math.random());
}
window.setInterval(h, 200);
// var embedding = new EMBED.RandomEmbedding(scene, dataset);
embedding = new EMBED.ScatterEmbedding(
scene, dataset, {
position: {y: 2}, pointSize: 0.2, pointColor: 0x993333, moveSpeed: 3});
EMBED.register(embedding);
}
</script>
</body>
</html>