Giter Club home page Giter Club logo

objto3d-tiles's Introduction

objTo3d-tiles

Node command line tool convert obj model file to 3D Tiles, based on obj2gltf.

Online Demonstration

NOTE: Only support .b3dm for now!

Please use Cesium after v1.37, cause this 3d tile use glTF2.0.

Getting Start

Clone this repository to local.

git clone https://github.com/PrincessGod/objTo3d-tiles.git

Navigate in the repository folder.

cd objTo3d-tiles

Make sure you have Node installed, and then

npm install

Basic Usage

  • Convert .obj to .gltf
node ./bin/obj23dtiles.js -i ./bin/barrel/barrel.obj
// Export barrel.gltf at same folder.
  • Convert .obj to .glb
node ./bin/obj23dtiles.js -i ./bin/barrel/barrel.obj -b  
// Export barrel.glb at same folder.

NOTE: More detial to convert .gltf and .glb can find at obj2gltf.

  • Convert .obj to .b3dm with default batch table, which have batchId and name property, and name is model's name.
node ./bin/obj23dtiles.js -i ./bin/barrel/barrel.obj --b3dm
// Export barrel.b3dm at same folder.
  • Convert .obj to .b3dm with default batch table and export default batch table (a JSON file). Maybe get information for custom batch table.
node ./bin/obj23dtiles.js -i ./bin/barrel/barrel.obj --b3dm --outputBatchTable
// Export barrel.b3dm and barrel_batchTable.json at same folder.
  • Convert .obj to .b3dm with custom batch table.
node ./bin/obj23dtiles.js -i ./bin/barrel/barrel.obj -c ./bin/barrel/customBatchTbale.json --b3dm
// Export barrel.b3dm with custom batch table at same folder.

Create Tileset

  • Create a single tileset with .b3dm tile.
node ./bin/obj23dtiles.js -i ./bin/barrel/barrel.obj --tileset
// Export ./Batchedbarrel folder at same folder which is a tileset.
  • Create a single tileset with .b3dm tile and custom tileset options.
node ./bin/obj23dtiles.js -i ./bin/barrel/barrel.obj --tileset -p ./bin/barrel/customTilesetOptions.json
// Export ./Batchedbarrel folder at same folder which is a tileset with custom tileset options.

The customTilesetOptions.json can have options bellow, and these are fake values, if do not have custom tileset config, these value will be auto calculate through .obj file.

{
    "longitude":      -1.31968,     // Tile center's(models' point (0,0,0)) longitude in radian.
    "latitude":       0.698874,     // Tile center's latitude in radian.
    "transHeight":    0.0,          // Model height in meters.
    "minHeight":      0.0,          // BoundingVolume minimum height in meters.
    "maxHeight":      40.0,         // BoundingVolume maximum height in meters.
    "tileWidth":      200.0,        // Tile horizontal(cross longitude) length in meters.
    "tileHeight":     200.0,        // Tile virtical(cross latitude) length in meters.
    "geometricError": 200.0,        // Tile geometric error in meters.
    "region":         true,         // Using region bounding volume.
    "box":            false,        // Using box bounding volume.
    "sphere":         false         // Using sphere bounding volume.
    //"transfrom" : Matrix4         // Using for custom transform.
}

NOTE: If you are not specify the transHeight option, your model will be place at earth ground surface, which means no matter what the height your models are, the lowerest point of your models will be place at height = 0.0 on the earth. But if you want keep origin heigth you just need specify transHeight = 0.0.

Here are different bounding volumes.

Troubleshooting

First, make sure your .obj file is complete, normally include .obj, .mtl and textures like .jpg or .png. You can preview your .obj model via "Mixed Reality Viewer" if your in windows 10. Otherwise you can use this online viewer.

Second, export .glb and check if it display correctly. You can use Cesium or Three.js gltf viewer.

In the end, just export .b3dm or tileset and load in Cesium.

Sample Data

Sample data under the .bin\barrel\ folder.

barrel\
    |
    - barrel.blend              --
    |                             |- Blender project file with texture.
    - barrel.png                --
    |
    - barrel.obj                --
    |                             |- Obj model files.
    - barrel.mtl                --
    |
    - customBatchTable.json     ---- Custom batchtable used in demonstration.
    |
    - customTilesetOptions.json ---- Custom tileset optional parameters.
    |
    - output\                   ---- Export data by using upper files.
        |
        - barrel.glb
        |
        - barrel.gltf
        |
        - barrel_batchTable.json    ---- Default batch table.
        |
        - Batchedbarrel\            ---- Tileset output
        |   |
        |   - tileset.json
        |   |
        |   - barrel.b3dm
        |
        - BatchedTilesets\          ---- Tileset with custom tileset.json
            |
            - tileset.json
            |
            - barrel_withDefaultBatchTable.b3dm
            |
            - barrel_withCustonBatchTable.b3dm

Resources

Credits

Great thanks to Sean Lilley(@lilleyse) for helping and advising.

Thanks AnalyticalGraphicsInc provide a lot of open source project (like Cesium and 3D Tiles) and creat a great GIS environment.

License

Apache License 2.0

objto3d-tiles's People

Contributors

princessgod avatar spatialhast avatar

Watchers

 avatar  avatar

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.