iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
606 stars 210 forks source link

Reality Mesh(.3xm, .3sm) file support #110

Closed namsancow closed 3 years ago

namsancow commented 4 years ago

If .3sm file is publised as iModel files, the empty is only viewed. I also read the unclosed issue "Converting a file from .3mx to .imodel" Does iModel 2.5.5 support Scalable Reality mesh(.3xm, .3sm)? I have read "Model Appearance Overrides" of 2.5.0 Change Notes in which "Overrides can be applied to the "contextual" reality models" is described.

RBBentley commented 4 years ago

iModelJS supports reality models (meshes or point clouds) through 3D Tiles . If a 3MX or a point cloud (POD) file is attached to a DGN file when it is bridged to an iModel then the reality model is converted to 3D tiles and uploaded to the ContextShare associated with the project. The reality model display may be off by default, but can be turned on in Design Review using the Reality Data panel. If a 3SM file is already "Web Ready" then it is already represented as a 3D tileset and will be linked directly to the iModel -- If it is not "Web Ready" then it will be converted to 3D tiles and the 3D tile set will be linked. If reality models exist in ContextShare for the project then they will be available in the Reality Data if they spatially intersect the models footprint - even if they were not attached when the file was bridged (these are what are referred to as "contextual" reality models in the 2.5.0 change notes.

namsancow commented 4 years ago

Many thanks, RBBentley. Does iModelJS need some plug-in for 3D Tiles ? Is there any method to upload reality models without using ContextShare? Can iModelJS directly upload the local Scalable Reality mesh model file(.3xm, .3sm) save in server?

RBBentley commented 4 years ago

No plugin is required to display 3D tiles - this is part of iModelJS core. The uploading is currently performed automatically when ta DGN with attached reality model is bridged. iModelJS can display any 3D Tileset - it doesn't need to be located on ContextShare -- See the DisplayStyleState.attachRealityModel method --- All that is really required is the URL for the tileset root file.

namsancow commented 4 years ago

Dear RBBentley I don't understand the exact meaning "URL" for the tileset root file. I also checked the "imodeljs/core/frontend/src/DisplayStyleState.ts" and could find "attachRealityModel" in 178 line. Does URL means the "Web Ready" output of ContextCapture or the URL address of "ContextShare" server?

I have tested ContexCapture, Microstation, iTwnSynchronizer, imodel-desktop-starter. However, I heard for the first time from you that the URL address in the file.

I made the reality model and test in imodel-desktop-starter as followings:

1) Make reality model in ContextCapture and save the file named as "aaa.3mx" as .3mx format. 2) Make new 3D file name as "bbb.dgn" in MicroStation and attach reference "aaa.3mx". 3) Merge the attached reference "aaa.3mx" in reference dialog and resave "bbb.dgn" file. 4) Open iTwin Synchronizer and choose the option "create snapshot". 5) In "Create Snapshot" dialog, define snapshot name as "ccc", and add the file "bbb.dgn". 6) After check "create", I can find the "ccc.bim" in designated folder. 7) After type npm start on console, imodel-desktop-starter pops up. 8) Select home button and choose the file "ccc.bim". 9) And there is nothing. only skybox with grid is displayed. reality model is not displayed. However, the all elements drawed in MicroStation is perfectly shown in imodel-desktop-starter.

Although I check the all files created with "ccc.bim", there is no URL information. Where is the URL information and how can I display the reality model in imodel-desktop-starter?

I also checked the source code of imodel-desktop-starter. And I could find "AttachedRealtiyMode" and "ContextRealityModel" in 0.chunk.js. However the context reality model is not appeared in imodel-desktop-starter.

Instead of desktop-starter, can I check realtiy model from imodeljs-samples?

pmconne commented 4 years ago

attachRealityModel is here.

The URL should point to a web-ready tileset produced by the synchronizer from your .3mx file. Open the .bim file in a sqlite viewer such as this one and inspect the bis_Model table. Look for a row with a tilesetUrl property in its JsonProperties column. If no such row exists there may be a problem with the synchronizer. If such a row does exist, monitor network activity while viewing the iModel to determine if it's trying to load the tileset from that URL and if so, any errors in doing so.

RBBentley commented 4 years ago

Yes - Thanks... As Paul mentions 3MX files should be automatically converted to "Web Ready Scalable Mesh" (which essentially means 3D TileSet). -- The URL that is included will be on the contextshare -- and will point to a tileset.json file that is the root of the tileset. I'm not very familiar with ContextCapture - but best to avoid the 3MX format completely and just produce the reality model as a "Web Ready Scalable Mesh" on ContextShare within MicroStation -- Then the upload should just use that URL directly. - Sorry for the confusion here -- I'll get someone here to validate and document this workflow more carefully.

namsancow commented 4 years ago

Dear pmconne In the meantime, many trials and errors have confirmed that json files and url files describing 3D tiles are recorded in bim/bis_models/JsonProperties as your kind explanation.

image

I also confirmed that these files can only be created through Web-based ContextShare and iModelHub. The 3D tile policy of imodeljs is very similar to that of Cesium, but clearly differs in that ContextShare and iModelHub are essential.

RBBentley commented 3 years ago

ContextShare is not actually required, although that is where most users store their 3D tilesets. The URL can point to the tileset root for a tileset that is on a file server, just like Cesium.

namsancow commented 3 years ago

ContextShare is not actually required, although that is where most users store their 3D tilesets. The URL can point to the tileset root for a tileset that is on a file server, just like Cesium.

Thanks to your advice, I can understand 3D tileset. However, I honestly don't understand the description of "a tileset that is on a file server" in your advice. For Cesium, you can setup a simple server for 3D tileset, such as the "3d-tiles-samples" of the Github. (https://github.com/CesiumGS/3d-tiles-samples) However, for imodeljs, no 3D tileset server can be found. It would be very helpful if I could get a simple 3D tileset server information for imodeljs. And I wonder if the "frontend-sample-showcase" of Github/imodeljs is described in response to the "3d-tiles-samples" of Github/Cesium.

pmconne commented 3 years ago

Cesium's 3d-tiles-samples is just serving sample 3d tilesets from your local machine. If you have 3d tilesets on your machine that you want to serve locally and access from iModel.js:

If your 3d tileset is on some other server, skip the first two steps and just give iModel.js the tileset's URL.

I must admit I am becoming confused as to what you're specifically trying to accomplish. Can you clarify please?

RBBentley commented 3 years ago

The code to attach the 3D tileset from (https://github.com/CesiumGS/3d-tiles-samples) would be...

const vp = IModelApp.viewManager.selectedView;
if (undefined !== vp)
  vp.displayStyle.attachRealityModel({ tilesetUrl: 'http://localhost:8003/tilesets/TilesetWithDiscreteLOD/tileset.json'});

This produces a similar display to Cesium... (pardon the garish lighting)...

CesiumTileSetExample

namsancow commented 3 years ago

Cesium's 3d-tiles-samples is just serving sample 3d tilesets from your local machine. If you have 3d tilesets on your machine that you want to serve locally and access from iModel.js:

If your 3d tileset is on some other server, skip the first two steps and just give iModel.js the tileset's URL.

I must admit I am becoming confused as to what you're specifically trying to accomplish. Can you clarify please?

Dear, Paul (pmconne) Thank you for your kind explanation.

I would like to display a overlapped view of the 3D model and Reality Mesh (ContextCapture) on the web via the local server.

The cloud-based iTwin service is easy to use. However it's very inconvenient because it's too slow to use, and users must have their own account.

I would like to show off my model to my friends, but it would be too difficult if they had to know about iTwin, iModelHub, ProjectWise, ContextShare, and so on.

For this reason, I use the imodeljs, but it's very difficult because it's too complicated and has few tutorials.

Is there more simple way to display my model right away, like "3d-tile-samples" of GitHub's Cesium which only requires for user to type a few lines of code.

namsancow commented 3 years ago

Dear Paul(pmconne) and RBBentley According to your guide, I finally solved the problem !!!! Many thanks to all your kind help.

pmconne commented 3 years ago

Glad to hear it @namsancow.