Published
Edited
Aug 31, 2019
Insert cell
Insert cell
test_x3dom = {
// x3dom
let fromVector = new x3dom.fields.SFVec3f(0, 1, 0);
let toVector = new x3dom.fields.SFVec3f(vx, vy, vz);
let qDir = x3dom.fields.Quaternion.rotateFromTo(fromVector, toVector);
let rot = qDir.toAxisAngle();
let rotation = [rot[0].x, rot[0].y, rot[0].z, rot[1]].join(' ');
return rotation;
}
Insert cell
test_mathGl = {
// math.gL
let fromVector = new mathGl.Vector3(0, 1, 0);
let toVector = new mathGl.Vector3(vx, vy, vz);
let qDir = new mathGl.Quaternion().rotationTo(toVector, fromVector);
let rotation = qDir.x + " " + qDir.y + " " + qDir.z + " " + qDir.w;
return rotation;
}
Insert cell
test_glMatrix = {
// gl-matrix
let fromVector = glMatrix.vec3.fromValues(0, 1, 0);
let toVector = glMatrix.vec3.fromValues(vx, vy, vz);
glMatrix.vec3.normalize(toVector, toVector); // rotationTo requires unit vectors
let quat = glMatrix.quat.create();
glMatrix.quat.rotationTo(quat, fromVector, toVector);
let out = glMatrix.vec3.create();
let ang = glMatrix.quat.getAxisAngle(out, quat);
return [...out, ang].join(' ');
}
Insert cell
Insert cell
Insert cell
Insert cell
x3dom = require('https://x3dom.org/download/dev/x3dom-full.js').catch(() => window.x3dom)
Insert cell
mathGl = require('https://bundle.run/math.gl@2.3.3')
Insert cell
glMatrix = require('https://bundle.run/gl-matrix@3.1.0')
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