Giter Site home page Giter Site logo

w0rm / elm-obj-file Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 4.0 3.3 MB

Encode and decode 3D geometry in the OBJ file format

Home Page: https://package.elm-lang.org/packages/w0rm/elm-obj-file/latest

License: BSD 3-Clause "New" or "Revised" License

Elm 99.30% Shell 0.55% Nix 0.15%
elm 3d wavefront-obj

elm-obj-file's People

Contributors

w0rm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elm-obj-file's Issues

Encoding to OBJ format

A support for encoding Obj files might be useful top. For example one could generate geometry using some existing helper functions from TriangularMesh and export it for Blender.

What the API could look like?

Autogenerate tangents

Tangents would allow rendering with normal mapping. Tangent can be calculated from positions and uv of three vertices from a face.

TBD: a tangent probably needs to store an additional value (1 or -1) that is needed to compute the direction of bitangent, so a Vector3d type might not be enough to store the value.

This depends on elm-3d-scene support for normal maps.

Parsing fails with Elm Debugger if too large

Just wanted to open this to save someone an hour or two some day in the future.

Above a certain number of vertices seems to run into the "Too much recursion" bug when developing locally.

Uploads were working just fine on your example site: https://unsoundscapes.com/elm-obj-file/examples/viewer/ but then when I went to use them in development it would blow up 😞.

Workaround

Turning off the elm debugger (using Vite this was: elmPlugin({ debug: false})) fixes it.

Autogenerate normals

This can potentially happen under the hood for Obj.Decode.faces and Obj.Decode.texturedFaces. Right now they would fail if the normals are missing.

Not sure how big of a deal this actually is. One could potentially create an OBJ file that has all the normals in it. In Blender this is as easy as checking “Write Normals” when exporting a file.

If we decide to generate normals in elm-obj-file, we need to consider supporting smoothing groups too. This may increase computational complexity of the code quite a bit. So it might be worth benchmarking loading a file with normals in it and a file where the normals are autogenerated.

Reindex when encoding

Currently, when encoding to OBJ, all the positions/normals/uvs are written unmodified. We could reindex them to get more compressed data.

A possible implementation might take rounded and serialised positions/normals/uvs as stings, and use them for the reverse index calculation.

Because this is a tradeoff between the size and performance, a new encoding option needs to be introduced.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.