# objTo3d-tiles
Node command line tool and module convert obj model file to 3D Tiles, based on [obj2gltf](https://github.com/AnalyticalGraphicsInc/obj2gltf).
[Online Demonstration](https://princessgod.github.io/plc/batchedTileset.html)
[简体中文](README_CN.md)
>NOTE: Only support `.b3dm` and `.i3dm` for now!
>
>Please use Cesium after v1.37, cause this 3d tile use glTF2.0.
## Getting Start
Make sure you have [Node](https://nodejs.org/en/) installed, and then
```
npm install -g obj23dtiles
```
### Basic Usage
* Convert `.obj` to `.gltf`
```
obj23dtiles -i ./bin/barrel/barrel.obj
// Export barrel.gltf at obj folder.
```
* Convert `.obj` to `.glb`
```
obj23dtiles -i ./bin/barrel/barrel.obj -b
// Export barrel.glb at obj folder.
```
>NOTE: More detial to convert `.gltf` and `.glb` can find at [obj2gltf](https://github.com/AnalyticalGraphicsInc/obj2gltf).
>NOTE: If your model have tarnsparency texture please add `--checkTransparency` parameter.
>NOTE: If your model using blinn-phong material, and use occlusion when convert to PBR material, the model will looks darker.
>The `useOcclusion` default is false, remember adding `--useOcclusion` if your model using PBR material. Here are some showcase about it.
<p align="center"><img src ="./pics/useOcclusion.png" /></p>
* Convert `.obj` to `.b3dm` with default [BatchTable](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/BatchTable/README.md), which have `batchId` and `name` property, and `name` is model's name.
```
obj23dtiles -i ./bin/barrel/barrel.obj --b3dm
// Export barrel.b3dm at obj folder.
```
* Convert `.obj` to `.b3dm` with default [BatchTable](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/BatchTable/README.md) and export default BatchTable (a JSON file). Maybe get information for custom BatchTable.
```
obj23dtiles -i ./bin/barrel/barrel.obj --b3dm --outputBatchTable
// Export barrel.b3dm and barrel_batchTable.json at obj folder.
```
* Convert `.obj` to `.b3dm` with custom [BatchTable](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/BatchTable/README.md).
```
obj23dtiles -i ./bin/barrel/barrel.obj -c ./bin/barrel/customBatchTable.json --b3dm
// Export barrel.b3dm with custom batch table at obj folder.
```
* Convert `.obj` to `.i3dm` width [FeatureTable](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/Instanced3DModel/README.md#feature-table).
```
obj23dtiles -i ./bin/barrel/barrel.obj -f ./bin/barrel/customFeatureTable.json --i3dm
// Export barrel.i3dm at obj folder.
```
* Convert `.obj` to `.i3dm` with [FeatureTable](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/Instanced3DModel/README.md#feature-table) and [BatchTable](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/Instanced3DModel/README.md#batch-table).
```
obj23dtiles -i ./bin/barrel/barrel.obj -f ./bin/barrel/customFeatureTable.json
-c ./bin/barrel/customI3dmBatchTable.json --i3dm
// Export barrel.i3dm with BatchTable at obj folder.
```
FeatureTable support following parameters : `position`, `orientation`, `scale`.
### Create Tileset
* Create a single tileset with `.b3dm` tile.
```
obj23dtiles -i ./bin/barrel/barrel.obj --tileset
// Export ./Batchedbarrel folder at obj folder which is a tileset.
```
* Create a single tileset with `.b3dm` tile and custom tileset options, custom BatchTable.
```
obj23dtiles -i ./bin/barrel/barrel.obj --tileset
-p ./bin/barrel/customTilesetOptions.json -c ./bin/barrel/customBatchTable.json
// Export ./Batchedbarrel folder at obj folder which is a tileset with custom tileset options.
```
* Create a single tileset with `.i3dm` tile.
```
obj23dtiles -i ./bin/barrel/barrel.obj --tileset --i3dm
-f ./bin/barrel/customFeatureTable.json
// Export ./Instancedbarrel folder at obj folder which is a tileset.
```
* Create a single tileset with `.i3dm` tile and custom tileset options, custom BatchTable.
```
obj23dtiles -i ./bin/barrel/barrel.obj --tileset --i3dm
-f ./bin/barrel/customFeatureTable.json -p ./bin/barrel/customTilesetOptions.json
-c ./bin/barrel/customI3dmBatchTable.json
// Export ./Instancedbarrel folder at obj folder which is a tileset.
```
The `customTilesetOptions.json` can have options bellow, and these are fake values, please only add properties you need, other value will be auto calculate through `.obj` file.
```
{
"longitude": -1.31968, // Tile origin's(models' point (0,0,0)) longitude in radian.
"latitude": 0.698874, // Tile origin's latitude in radian.
"transHeight": 0.0, // Tile origin's height in meters.
"region": true, // Using region bounding volume.
"box": false, // Using box bounding volume.
"sphere": false // Using sphere bounding volume.
}
```
>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.
<p align="center"><img src ="./pics/boundingvolume.png" /></p>
### Combine tilesets
You can combine tilesets into one `tileset.json` as external tileset.
```
obj23dtiles combine -i ./bin/barrel/output
```
## Using as node module
If you want to use this tool in node or debug, check out [how to use as node module](NODEUSAGE.md).
## 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 you are in windows 10.
Otherwise you can use this [online viewer](https://3dviewer.net/).
<br />
<br />
Second, export `.glb` and check if it display correctly. You can use
[Cesium](https://www.virtualgis.io/gltfviewer/) or [Three.js](https://gltf-viewer.donmccurdy.com/) gltf viewer.
<br />
<br />
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 for b3dm.
|
- customTilesetOptions.json ---- Custom tileset optional parameters.
|
- customFeatureTable.json ---- Custom FeatureTable for i3dm.
|
- customI3dmBatchTable.json ---- Custom BatchTable for i3dm.
|
- output\ ---- Export data by using upper files.
|
- barrel.glb
|
- barrel.gltf
|
- barrel_batchTable.json ---- Default batch table.
|
- Batchedbarrel\ ---- Tileset use b3dm
| |
| - tileset.json
| |
| - barrel.b3dm
|
- Instancedbarrel\ ---- Tileset use i3dm
| |
| - tileset.json
| |
| - barrel.i3dm
|
- BatchedTilesets\ ---- Tileset with custom tileset.json
|
- tileset.json
|
- barrel_withDefaultBatchTable.b3dm
|
- barrel_withCustonBatchTable.b3dm
```
## Resources
* Online glTF viewer, make sure your glTF is correct. [Cesium](https://www.virtualgis.io/gltfviewer/), [Three.js](https://gltf-viewer.donmccurdy.com/).
* [Cesium](https://github.com/AnalyticalGraphicsInc/cesium)
* [3D Tiles](https://github.com/AnalyticalGraphicsInc/3d-tiles)
* [glTF](https://github.com/KhronosGroup/glTF)
## Credits
Great thanks to Sean Lilley([@lilleyse](https://github.com/lilleyse)) for helping and advising.
Thank
没有合适的资源?快使用搜索试试~ 我知道了~
objTo3dtiles将obj模型文件转换为三维瓦片
共54个文件
js:26个
json:10个
md:3个
3星 · 超过75%的资源 需积分: 45 93 下载量 132 浏览量
2019-08-12
04:12:21
上传
评论 2
收藏 2.03MB ZIP 举报
温馨提示
objTo3d-tiles:将obj模型文件转换为三维瓦片
资源推荐
资源详情
资源评论
收起资源包目录
objTo3dtiles将obj模型文件转换为三维瓦片.zip (54个子文件)
PrincessGod-objTo3d-tiles-165af85
.gitignore 918B
package.json 900B
package-lock.json 46KB
bin
barrel
customFeatureTable.json 663B
barrel.mtl 250B
customBatchtable.json 813B
output
BatchedTilesets
barrel_withCustomBatchTable.b3dm 362KB
tileset.json 2KB
barrel_withDefaultBatchTable.b3dm 362KB
barrel.glb 350KB
Batchedbarrel
barrel.b3dm 363KB
tileset.json 816B
barrel_batchTable.json 388B
Instancedbarrel
tileset.json 815B
barrel.i3dm 351KB
barrel.gltf 472KB
customTilesetOptions.json 321B
barrel.blend 904KB
barrel.png 165KB
customI3dmBatchTable.json 336B
barrel.obj 352KB
obj23dtiles.js 9KB
LICENSE 11KB
_config.yml 47B
NODEUSAGE.md 6KB
.eslintrc.js 98B
README.md 8KB
README_CN.md 8KB
lib
getBufferPadded.js 608B
tilesetOptionsUtility.js 495B
obj2Tileset.js 9KB
Texture.js 372B
obj2gltf.js 10KB
createB3dm.js 5KB
readLines.js 734B
createGltf.js 14KB
loadMtl.js 27KB
obj2b3dm.js 2KB
getJsonBufferPadded.js 764B
gltfToGlb.js 2KB
writeGltf.js 6KB
loadObj.js 24KB
combineTileset.js 4KB
getJsonBufferPadded8Byte.js 1KB
createSingleTileset.js 5KB
loadTexture.js 4KB
createI3dm.js 2KB
ArrayStorage.js 3KB
getBufferPadded8Byte.js 979B
outsideDirectory.js 426B
obj23dtiles.js 7KB
obj2I3dm.js 10KB
pics
useOcclusion.png 141KB
boundingvolume.png 446KB
共 54 条
- 1
资源评论
- gisspringer2021-03-03不是太好用
weixin_39840588
- 粉丝: 448
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功