chinedufn / collada-dae-parser

Parse collada .dae 3d animation files into a WebGL friendly JSON format
http://chinedufn.github.io/collada-dae-parser/
MIT License
103 stars 10 forks source link

Supporting multiple geometries #6

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi Francis,

I was wondering if you'd want to support multiple geometries at some point ?

I had a quick look at the source and it looked like it could work by repeating the process once per geometry, I'm happy to have a go at this if it's an addition that you'd like.

Thanks, Alvin

chinedufn commented 7 years ago

Yeah I thought about this recently and I don't think there are any good reasons not to support multiple geometries.

Curious about what you're thinking is here, but mine was to just output an array of meshes to a JSON file.


That would be absolutely fantastic! Want to give it a go and just ping me if you ever get stuck? (Apologies in advance for any under-commented code).

This is exciting!


I know you use Cinema4D, so feel free to use a Cinema4D collada file for your test(s) instead of Blender!

ghost commented 7 years ago

Hey Francis, That's great to hear! Our thinking is probably similar, currently we have :

{
  jointInverseBindPoses: { ... },
  jointNamePositionIndex: { ... },
  keyframes: {...},
  vertexNormalIndices: [...],
  // etc
}

And I'm thinking of either :

{
  'Cube' : {
    keyframes: {...},
    vertexNormalIndices: [...],
    // etc
  },
  'Character' : {
    jointInverseBindPoses: { ... },
    jointNamePositionIndex: { ... },
    keyframes: {...},
    vertexNormalIndices: [...],
    // etc
  }
}

Or

[
  {
    name : 'Cube',
    keyframes: {...},
    vertexNormalIndices: [...],
    // etc
  },
  {
    name : 'Skeleton',
    jointInverseBindPoses: { ... },
    jointNamePositionIndex: { ... },
    keyframes: {...},
    vertexNormalIndices: [...],
    // etc
  }
]

depending on what you prefer (JSON objects or JSON arrays).

I'd be against any sort of arbitrary grouping (like, separating skinned meshes and others) I think of the greatest things about this module is that it's minimal and un-opinionated, and I'd want to keep it this way.

Let me know what your thoughts are, Thanks, Alvin

chinedufn commented 7 years ago

I 100% agree with you on not wanting to group things. Yup - let's keep things as simple as possible. I'm on board!

In terms of the structure, I'm cool with array or object, whichever you prefer. I'm sure if it ends up feeling weird one way or the other it's an easy change.


But otherwise I have no other initial thoughts. I think it just comes down to starting with a very simple test COLLADA file with 2 geometries, setting up the expected JSON result and then making the test pass.

And if there are any common gotchas / issues while exporting would be great to alert the user.


Example error

example error- https://github.com/chinedufn/collada-dae-parser/blob/master/src/library_geometries/parse-library-geometries.js#L6-L10

example test for error - https://github.com/chinedufn/collada-dae-parser/blob/master/test/multiple-meshes/blender/multiple-mesh_blender_test.js#L12-L16


But things like that will just come up whenever we run into problems so likely no need to plan for them ahead of time!