Skip to content

Instantly share code, notes, and snippets.

import bpy
from bpy_extras.io_utils import ExportHelper
import os
import sys
import shutil
import struct
import tempfile
import zipfile
bl_info = {
import { Document, NodeIO } from '@gltf-transform/core';
import { DracoMeshCompression } from '@gltf-transform/extensions';
import * as draco3d from 'draco3dgltf';
const decoderModule = draco3d.createDecoderModule({});
const encoderModule = draco3d.createEncoderModule({});
export async function draco_extension_issue () {
const doc = new Document();
import { Document, NodeIO } from '@gltf-transform/core';
import { DracoMeshCompression } from '@gltf-transform/extensions';
import * as draco3d from 'draco3dgltf';
export async function draco_encode_issue (useTimeout = false) {
const doc = new Document();
const buffer = doc.createBuffer('bin');
@timknip
timknip / draco-problem.js
Last active November 26, 2020 20:02
gltf-transform - draco encoding issue
import { Document, NodeIO } from '@gltf-transform/core';
import { DracoMeshCompression } from '@gltf-transform/extensions';
import * as draco3d from 'draco3dgltf';
export async function draco_extension_issue (useTimeout = false) {
const doc = new Document();
const buffer = doc.createBuffer('bin');
@timknip
timknip / ficus.js
Last active August 18, 2020 16:09
Ficus Loterij
/**
* Shuffles array in place using the Fisher-Yates algorithm.
* @see https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
*
* @param {Array} a items An array containing the items.
*/
function shuffle(a) {
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
import openmesh as om
import numpy as np
mesh = om.read_trimesh('earth.obj', vertex_normal=True, vertex_tex_coord=True)
# make mesh handle these attributes
mesh.request_vertex_normals()
mesh.request_vertex_texcoords2D()
# create decimater
cd "$PROGRAMFILES"/nodejs
rm npm npx npm.cmd npx.cmd
mv node_modules/npm node_modules/npm2
node node_modules/npm2/bin/npm-cli.js i -g npm@latest
rm -rf node_modules/npm2/
@timknip
timknip / gist:9f034c4bc8d048a7ae74e977004c8322
Created March 20, 2018 11:52
potrace - transparent png
pngtopnm -mix assign.png > a.pnm && potrace a.pnm -s -o a.svg
(defn trimmed-bounds
[ctx w h]
(let [data (.-data (.getImageData ctx 0 0 w h))]
(loop [y 0 minx Infinity miny Infinity maxx -Infinity maxy -Infinity]
(if (< y h)
(let [yw (* y w)
minx' (loop [x 0]
(when (< x w)
(if (= (aget data (+ (* (+ yw x) 4) 3)) 0)
(recur (inc x))
(defn crop-old
[ctx w h]
(let [data (.-data (.getImageData ctx 0 0 w h))
s (* w h 4)
[a b] (loop [y 0 px [] py []]
(if (< y h)
(let [[x' y']
(loop [x 0 px' px py' py]
(if (< x w)
(let [a? (> (aget data (+ (* (+ (* y w) x) 4) 3)) 0)]