Skip to content

Instantly share code, notes, and snippets.

@1polygon
1polygon / glsl.js
Created November 21, 2022 19:33
vite plugin for importing glsl files
const fileRegex = /\.(frag|vert|fs|vs|glsl)$/
import fs from "fs";
import path from "path";
function processShader(src, id) {
const lines = src.split("\n");
let result = "";
for (const line of lines) {
if (line.startsWith("#include ")) {
const relativeFile = line.split(" ")[1];
@a-nooj
a-nooj / panda_jacobian.py
Last active April 26, 2024 04:55
Jacobian matrix for the Franka Emika Panda robot arm
import numpy as np
def get_tf_mat(i, dh):
a = dh[i][0]
d = dh[i][1]
alpha = dh[i][2]
theta = dh[i][3]
q = theta
@1polygon
1polygon / webgl-objloader.js
Created November 14, 2022 21:54
webgl convert obj to indexed mesh
import { Mesh } from "../mesh";
export async function loadOBJ(url) {
const res = await fetch(url);
if (res.status == 200) {
const text = await res.text();
const vertices = [];
const uv = [];
@muneebahmed26301
muneebahmed26301 / index.html
Created April 9, 2020 15:41
Three.js - Load .OBJ and .MTL file
<canvas id="c"></canvas>
<script src="https://threejsfundamentals.org/threejs/resources/threejs/r105/three.min.js"></script>
<script src="https://threejsfundamentals.org/threejs/resources/threejs/r105/js/controls/OrbitControls.js"></script>
<script src="https://threejsfundamentals.org/threejs/resources/threejs/r105/js/loaders/LoaderSupport.js"></script>
<script src="https://threejsfundamentals.org/threejs/resources/threejs/r105/js/loaders/OBJLoader2.js"></script>
<script src="https://threejsfundamentals.org/threejs/resources/threejs/r105/js/loaders/MTLLoader.js"></script>
@gnilekaw
gnilekaw / reduce-object.js
Created August 25, 2016 20:16
reduce obj to array of keypaths and values
import { forEach as _forEach } from 'lodash/collection';
import {
isObject as _isObject,
isString as _isString,
isInteger as _isInteger
} from 'lodash/lang';
function _reduce(collection, keypath, accumulator) {
_forEach(collection, (value, key) => {
if (_isObject(value)) {
@davidchase
davidchase / README.md
Last active April 26, 2024 04:53
cookie obj from the folks at MDN, awesome!

Mozilla Developer Network

Cookies object

Forked from here

A complete cookies reader/writer framework with full unicode support.

This framework is released under the GNU Public License, version 3 or later.

@logicaroma
logicaroma / Element.js
Last active April 26, 2024 04:53
some extra utils on the Element obj
Element.prototype.hasClass = function (className) {
return new RegExp(' ' + className + ' ').test(' ' + this.className + ' ');
};
Element.prototype.addClass = function (className) {
if (!this.hasClass(className)) {
this.className += ' ' + className;
}
};
@optimizedaway
optimizedaway / pdb_compilands.cpp
Created December 13, 2018 20:14
List compilands (OBJ files) in PDB file
HRESULT hot_init(hot_ctx **out)
{
*out = nullptr;
std::unique_ptr<hot_ctx> ctx(new hot_ctx);
// Obtain base address of main executable
// 1. Module info
//MODULEINFO mod_info;
//GetModuleInformation(GetCurrentProcess(), hmod, &mod_info, sizeof(mod_info));
//void *baseaddr = mod_info.lpBaseOfDll;
@sungho1114
sungho1114 / gist:c784d80d318f3be728b56900a160fd89
Created July 22, 2020 23:10
Maya Easy Mesh OBJ/FBX Exporter
# move selected mesh into the middle, export as fbx or obj, and bring it back to original location
from maya import cmds
import pymel.core as pm
pm.loadPlugin("fbxmaya") # LOAD PLUGIN
#UI Function
def main():
#before adding window
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active April 26, 2024 04:52
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).