Skip to content

Instantly share code, notes, and snippets.

View kevzettler's full-sized avatar

kev zettler kevzettler

View GitHub Profile
{"meshes":
{"./PS1":
{"Mesh":
{"name":"PS1 Mesh",
"armature_name":"PS1 Boy",
"bounding_box":{"min_corner":[-9.790631,-9.454928,0.023094984],"max_corner":[9.790631,7.682235,55.04781]},
"multi_indexed_vertex_attributes":{
"vertices_in_each_face":[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
@kevzettler
kevzettler / react-regl-interfaces.js
Created September 1, 2018 16:38
React-regl resource interfaces
//The following examples demonstrate the current and potential interfaces for rendering a texture
//1 Current external resource initilization
// Needs a reference to the `regl` object to create `regl.texture`
// results in some weird handshake where `Regl` component needs to initialize and pass `regl` object around
class ThreeDThing extends React.Component{
constructor(){
super(props)
this.state.reglRef = null
}
@kevzettler
kevzettler / replace_img_src_with_imports.js
Last active March 25, 2018 19:18
How to convert html image src into webpack modules. Script to extract html img src attributes and convert to ES6 imports
const fs = require('fs')
const path = require('path');
let replacingFilePath = process.argv[2];
if(!replacingFilePath){
throw "invalid file path to replace"
}
let relativeImageDirPath = path.relative(path.dirname(replacingFilePath), `${__dirname}/../src/images`);
@kevzettler
kevzettler / index.js
Last active December 19, 2017 20:09
requirebin sketch
const regl = require('regl')()
const mat4 = require('gl-matrix').mat4
const vec3 = require('gl-matrix').vec3;
const quat = require('gl-matrix').quat;
const makePrimitiveQuad = require('primitive-quad');
var canvas = document.createElement("canvas");
var textCtx = canvas.getContext("2d");
const playerNameCanvas = makeTextCanvas('player name', 200, 50);
@kevzettler
kevzettler / child-CharacterView.js
Created October 20, 2017 00:06
maptDispatchToProps parent child
import React, { Component } from 'react'
import PropTypes from 'prop-types';
import { connect } from 'react-redux'
import { fetchAssetBinary } from '../../assets/actions.js';
import { sceneTick } from '../../scene/actions';
import reglInit from 'regl';
import { mat4 } from 'gl-matrix';
import { selectPlayerAnim, selectItemAssetNames, memoMissingAssets } from '../../scene/selectors.js';
@kevzettler
kevzettler / ik2fk.sh
Created September 22, 2017 20:26
Ik2fk output
Kevs-MacBook-Pro:qubicle kev$ blender ./add-idle-anim-MERGED.blend --python `ik2fk`
Read new prefs: /Users/kev/Library/Application Support/Blender/2.78/config/userpref.blend
found bundled python: /Applications/Blender.app/Contents/MacOS/../Resources/2.78/python
HELLO KEV
read blend: /Users/kev/code/robotbones/assets/models/mechsniper/blender/qubicle/./add-idle-anim-MERGED.blend
WARNING! More UV layers than 8 allowed, 1 last ones won't be available for render, shaders, etc.
WARNING! More UV layers than 8 allowed, 1 last ones won't be available for render, shaders, etc.
reloading addon: convert-ik-to-fk 1498342349.0 1506111905.0 /Users/kev/Library/Application Support/Blender/2.78/scripts/addons/convert-ik-to-fk.py
Modules Installed from '/Users/kev/.nvm/versions/node/v7.9.0/lib/node_modules/blender-iks-to-fks/convert-ik-to-fk.py' into '/Users/kev/Library/Application Support/Blender/2.78/scripts/addons' ()
Info: Modules Installed from '/Users/kev/.nvm/versions/node/v7.9.0/lib/node_modules/blender-iks-to-fks/conv
@kevzettler
kevzettler / index.js
Created September 22, 2017 16:32
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const uiRoot = document.createElement('div');
uiRoot.id = 'ui-root';
document.body.appendChild(uiRoot);
const Loop = require('fixed-game-loop');

The Three.js Blender exporter has been broken for at least the last 10 releases of Three.js. It's had at least 20 individual authors and contributors, most of whom have left the project never to return. Nevertheless, I have successfully imported animated (both with rigging and morph target) meshes into Three.js. Here's all the things I've encountered which you need to know about:

  • The exporter flips all vertices, faces, etc in the mesh you export. There used to be a "Flip Y/Z" option in the exporter, but it was removed when the exporter was rewritten. Since then speculation is the Blender API changed, or some other change after this one mangled the faces on export. For now we're stuck with it until we track it down.
  • mrdoob/three.js#8723 Invalid json is exported for all files with animations, so you have to delete a key manually from the json
  • mrdoob/three.js#8710 morph target exporting doesn't work with "a
import {
REQUEST_ASSET_BINARY,
RECEIVE_ASSET_BINARY
} from './constants';
export const requestAssetBinary = (path) => ({
type: REQUEST_ASSET_BINARY,
path
});
const traffic_light = [<
off -> red => green => yellow => red;
[red yellow green] ~> off;
>];