Published
Edited
Jan 19, 2022
Insert cell
Insert cell
Insert cell
viewof x3dxml = Inputs.file({label: "x3d xml file"})
Insert cell
Insert cell
xmlNodes = x3dfile.querySelectorAll('CoordinateInterpolator')
Insert cell
Insert cell
Insert cell
Insert cell
buffer = {
let offsets = [];
let offset = 0;
const total = typedArrays.reduce( (a, v) => {
offsets.push(offset, offset + v[0].length);
offset += v[0].length + v[1].length;
return a + v[0].length + v[1].length
}, 0);
const buffer = new typedArrays[0][0].constructor(total);
typedArrays.forEach( (v, i) => {
buffer.set(v[0], offsets[i*2]);
buffer.set(v[1], offsets[i*2+1]);
});
return {"buffer":buffer, "offsets":offsets}
}
Insert cell
bufferFile = new File([buffer.buffer], "interpolatorBuffer.bin", {type: "application/binary"})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function keyFromElement( e ) {
const key = parseMFFloat(e.getAttribute('key'));
return new Float32Array(key)
}
Insert cell
function keyValueFromElement( e ) {
const keyValue = parseMFFloat(e.getAttribute('keyValue'));
return new Float32Array(keyValue)
}
Insert cell
Insert cell
import {x3dom} from "@andreasplesch/x3dom"
Insert cell
MFFloat = x3dom, window.x3dom.fields.MFFloat
Insert cell
parseMFFloat = x3dom, window.x3dom.fields.MFFloat.parse
Insert cell
parseMFVec3f = x3dom, window.x3dom.fields.MFVec3f.parse
Insert cell
saveAs = {
await require('file-saver@2.0.5/dist/FileSaver.min.js');
return window.saveAs
}
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