• Stars
    star
    103
  • Rank 326,916 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Parse collada .dae 3d animation files into a WebGL friendly JSON format

collada-dae-parser npm version Build Status

Parse collada .dae file vertex positions, textures, normals and animations

View live animated model demo

image

View demo source

What does it do?

collada-dae-parser parses a collada file and outputs JSON. This is useful for displaying skeletal animations in the browser.

collada-dae-parser is only concerned with giving you JSON. An animation system is outside of this modules scope, but skeletal-animation-system could be a useful start.

To Install

# API
$ npm install --save collada-dae-parser
# CLI
$ npm install -g collada-dae-parser

Making use of the parser

If you're unfamiliar with skeletal animation, the demo is a good starting point. Here's where we're parsing our collada file and buffering our graphics data. We're parsing at runtime in the demo, but in a real application you'd want to parse your collada files during a build step.

# Run the demo locally. Changes to the `src` and `demo` directories will live reload in your browser
# PRs and issues are welcome!
git clone https://github.com/chinedufn/collada-dae-parser
cd collada-dae-parser
npm install
npm run demo

Collada Support

collada-dae-parser tries to be useful for WebGL games and interactive demos, but does not try to support the entire collada spec. If you're trying to parse a model that is not supported, collada-dae-parser will try to let you know how to tweak it.

image

CLI

Output stringified JSON to stdout

# parse from stdin
cat my-3d-model.dae | dae2json > parsed-model.json

# parse from file
dae2json my-3d-modal.dae > parsed-model.json

API

parseDae(xmlFile) -> object

This function returns the parsed collada object.

xmlFile

Required

Type: string or Buffer

Your collada file data. Not the filename, the file contents.

Returned Object

TODO: Document this

var parseDae = require('collada-dae-parser')
var parsedCollada = parseDae(fs.readFileSync(fileName))
console.log(parsedCollada)
/*
  {
    armatureName: 'MyRig',
    jointNamePositionIndex: {...},
    jointInverseBindPoses: {...},
    keyframes: {...},
    vertexNormalIndices: [...],
    vertexNormals: [...],
    vertexPositionIndices: [...],
    vertexPositions: [...],
    vertexUVIndices: [...],
    vertexUVs: [...]
  }
*/
jointNamePositionIndex

Type: Object

lorem ipsum

jointInverseBindPoses

Type: Object

lorem ipsum

keyframes

Type: Object

lorem ipsum

vertexNormalIndices

Type: Array

lorem ipsum

vertexNormals

Type: Array

lorem ipsum

vertexPositionIndices

Type: Array

lorem ipsum

vertexPositions

Type: Array

lorem ipsum

vertexUVIndices

Type: Array

lorem ipsum

vertexUVs

Type: Array

lorem ipsum

TODO:

  • src: basic cli (potentially pull into own repo, but start here)
  • src: Allow file buffer to be passed in
  • src: Factor in bind shape matrix
  • src: Stop exporting bind shape matrix
  • demo: fix normals in demo lighting
  • demo: toggle between 2 animations
  • src: Remove callback from API
  • warning: Throw descriptive error message if user attempts to export multiple geometries
  • A separate package that uses collada-dae-parser to implement a stateless skeletal animation system
  • src / demo: add a textured demo model
  • src: rounding values. Currently lots of .999999 and 1.000001
  • src: All of the TODO: statements in code
  • demo: full screen demo with controls overlay
  • demo: Support mobile touch events
  • demo: allow zoom in, zoom out in demo
  • doc: Add a GIF of every test fixture animation and demo
  • doc: Documentation
  • warning: Somehow let the user know if their joints use non rigid transforms - until we actually support this
  • warning: You didn't export a geometry. Link them to the documentation
  • warning: If the base model or armature's location, translation and scale aren't 1.0 let user know that we don't support that. They should apply location, translation and scale before exporting
  • research: Look into supporting library materials

References

See Also

Credits

License

MIT

More Repositories

1

percy

Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
Rust
2,244
star
2

swift-bridge

swift-bridge facilitates Rust and Swift interop.
Rust
745
star
3

webgl-water-tutorial

The source code for a tutorial on rendering water using WebGL + Rust + WebAssembly
Rust
475
star
4

psd

A Rust API for parsing and working with PSD files.
Rust
261
star
5

dipa

dipa makes it easy to efficiently delta encode large Rust data structures.
Rust
257
star
6

skeletal-animation-system

A standalone, stateless, dual quaternion based skeletal animation system built with interactive applications in mind
JavaScript
248
star
7

landon

A collection of tools, data structures and methods for exporting Blender data (such as meshes and armatures) and preparing it for your rendering pipeline.
Rust
146
star
8

cross-compile-rust-from-mac-to-linux

An example of how to cross compile Rust from `macOS` to Linux `x86_64-unknown-linux-gnu`
Shell
89
star
9

rectangle-pack

A general purpose, deterministic bin packer designed to conform to any two or three dimensional use case.
Rust
70
star
10

blender-iks-to-fks

A Blender script that takes a mesh and armature that use IKs and other non-deformation bones and creates a new mesh and armature that uses only FK bones.
Python
43
star
11

hot-app-replacement

Like hot module replacement but... yeah you'll see
JavaScript
26
star
12

blender-webgl-hot-reload-experiment

An experiment in hot reloading 3d models from Blender into a WebGL scene
JavaScript
23
star
13

webgl-particle-effect-tutorial

A tutorial for creating a WebGL fire particle effect using billboarded quads
JavaScript
17
star
14

wavefront-obj-parser

An api and cli for parsing wavefront .obj files into JSON
JavaScript
17
star
15

blender-actions-to-json

Write the joint data for all of a `.blend` file's actions to a JSON file
Python
16
star
16

webgl-shadow-mapping-tutorial

A WebGL shadow mapping tutorial
JavaScript
16
star
17

mat4-to-dual-quat

Convert a 4x4 matrix into a dual quaternion. Useful for skeletal animation (dual quaternion linear blending)
JavaScript
13
star
18

virtual-progress-bar

virtual-dom progress bar component
JavaScript
11
star
19

virtual-loading-dots

virtual-dom loading dots component
JavaScript
9
star
20

solid-state

Trigger listener functions when your state changes
JavaScript
8
star
21

webgl-skeletal-animation-tutorial

A quick tutorial on WebGL skeletal animation using small modules
JavaScript
8
star
22

watertight-ray-triangle-intersection

An implementation of the Watertight Ray/Triangle Intersection algorithm
JavaScript
8
star
23

blender-webgl-skinned-hot-reload-experiment

An experiment in hot reloading skinned models from Blender to WebGL
JavaScript
7
star
24

dom-filenameify

Add filenames as attributes to your DOM elements to help locate them in code by inspect-elementing them in the browser
JavaScript
7
star
25

webgl-unit-test-tutorial

The source code for a tutorial on unit testing WebGL components
JavaScript
7
star
26

image-to-heightmap

Convert a JPG or PNG image into a heightmap array
JavaScript
7
star
27

webgl-wield-item-tutorial

A tutorial for positioning items on top of bones using WebGL and 3d math
JavaScript
6
star
28

webgl-to-img-stream

Use a WebGL context to write the canvas's contents to a image file. Meant to be used in Node.js
JavaScript
5
star
29

load-collada-dae

Load the WebGL graphics buffer data from a collada .dae model and return a draw command that accepts options
JavaScript
5
star
30

create-keyframe

Create css keyframes using JSON
JavaScript
5
star
31

app-world

A framework agnostic approach to managing frontend application state.
Rust
4
star
32

make-component

A code generator for virtual-dom component files
JavaScript
3
star
33

client-ketchup

A simple interface for keeping remote clients up to date with their authoritative state
JavaScript
3
star
34

neighborhood-pathfinder

An A* implementation that accepts a function to detect neighboring tiles
JavaScript
3
star
35

webgl-skeletal-animation-sound-tutorial

A tutorial for playing sound effects during skeletal animations
JavaScript
2
star
36

expand-vertex-data

Expand vertex, normal and uv indices into vertex normal and uv data that is ready for your array buffers
JavaScript
2
star
37

minimal-object-diff

Create and apply a tiny representation of diffs between two objects. Useful for sending diffs over a network
JavaScript
2
star
38

generate-keyframe-animation-tutorial

A tutorial on generating CSS keyframes during runtime
JavaScript
2
star
39

branching-dialogue

A stateless API for modeling branching dialogue in role-playing games
JavaScript
2
star
40

conformer

conformer helps you write and visualize conformance test suites.
Rust
2
star
41

create-hover-class

Turn a JSON object into :hover class to use with inline styled components
JavaScript
2
star
42

load-wavefront-obj

Load the graphics buffer data from a wavefront .obj model and return a draw command that accepts options
JavaScript
2
star
43

get-attributes-uniforms

Get the attributes and uniforms from a GLSL shader string
JavaScript
2
star
44

keyframes-to-dual-quats

Convert a set of keyframe matrices into dual quaternions
JavaScript
1
star
45

knowledge

Concepts, solutions and links that I want to remember
1
star
46

angular-video-time

AngularJS Filter for displaying a video's current time
JavaScript
1
star
47

create-shader-program

Compiles, links and returns a shader program from a give vertex and fragment shader
JavaScript
1
star
48

webgl-blend-map-tutorial

A tutorial on multitexturing a WebGL terrain using a blend map
JavaScript
1
star
49

epoch-to-timeago

Get a string representation of a time difference
JavaScript
1
star
50

create-orbit-camera

Create a camera that orbits a target
JavaScript
1
star
51

blender-rustlang-docker

Docker image with Blender 2.80 and Rust
Dockerfile
1
star
52

create-draw-function

Create a WebGL draw call based on user provided data
JavaScript
1
star
53

donutjs-skeletal-animation-slides

Skeletal Animation in Your Browser via WebGL - the accompanying slides for a talk at Portland's Donut.js meetup
JavaScript
1
star