Skip to content

Instantly share code, notes, and snippets.

View beauterre's full-sized avatar
💭
now creating a parallax scanner

Belle Beauterre-Babbillard beauterre

💭
now creating a parallax scanner
View GitHub Profile
@beauterre
beauterre / binary_stl_writer.js
Created March 7, 2020 10:19 — forked from paulkaplan/binary_stl_writer.js
Writing binary and ascii STL files in Javascript
// Written by Paul Kaplan
var BinaryStlWriter = (function() {
var that = {};
var writeVector = function(dataview, offset, vector, isLittleEndian) {
offset = writeFloat(dataview, offset, vector.x, isLittleEndian);
offset = writeFloat(dataview, offset, vector.y, isLittleEndian);
return writeFloat(dataview, offset, vector.z, isLittleEndian);
};
//(copy freely, but include credits)
//whitelisted htmlEntities in javascript by Hjalmar Snoep
function htmlEntities(str) {
var whitelist="<=>©€£×÷−═‘’“”“”„¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
for(var x=str.length-1; x>=0; x--)
{
if(whitelist.indexOf(str[x])!=-1)
{
str=str.substr(0,x)+'&#'+str.charCodeAt(x)+';'+str.substr(x);
}