thedworak / dfg_3dviewer

2 stars 2 forks source link

Bug: Integration with DFG-Viewer breaks because of absolute paths #26

Closed sebastian-meyer closed 1 year ago

sebastian-meyer commented 1 year ago

In main/main.js all but one includes are handled as relative paths and work fine when integrating with the DFG-Viewer. But this include uses an absolute path which is only valid in Drupal/WissKI and therefore breaks integration: https://github.com/thedworak/dfg_3dviewer/blob/72368981a5b6ca4f10e54db1d5678acb82aa141a/main/main.js#L27 Is there a reason for this being an absolute path or could it be a relative path as well?

I suggest changing it like: import { GUI } from './node_modules/lil-gui/dist/lil-gui.esm.min.js';

Furthermore, when I change this locally, there are multiple additional absolute include paths in the library files (e. g. three.module.js and GLTFLoader.js) which also break integration.

thedworak commented 1 year ago

There is no problem to do this this way, probably I just missed this library when changing paths import { GUI } from './node_modules/lil-gui/dist/lil-gui.esm.min.js';

The problem with three.js newest version is they started using importmap which is not supported by Drupal we are using. I stared implementation with default paths but it's not possible inside Drupal yet.

sebastian-meyer commented 1 year ago

So maybe the best option for us would be to use the original release of three.js in the DFG-Viewer and combine that with your main.js file? If I put all the original files in the correct locations given in the "include"s in main.js that should work, right?

sebastian-meyer commented 1 year ago

I just saw that three.js includes an lil-gui library. So maybe we could make things even easier and use

include { GUI } from './js/jsm/libs/lil-gui.module.min.js';

instead of the import from node_modules directory?

thedworak commented 1 year ago

Perfect, it works with three.js version of lil-gui. I didn't notice it before. Thanks.

sebastian-meyer commented 1 year ago

Now I got a bit further:

So far this seems to work. But there are still paths in your main.js that are only valid in the Drupal context and don't work in the DFG-Viewer. Currently you are passing paths like module/dfg_3dviewer/main/* to some of the three.js modules, which don't exist in the DFG-Viewer. Instead, there the paths should be like typo3conf/ext/dlf/Resources/Public/Javascript/3DViewer/*. Can we find a way of making at least the prefix configurable? If you like, I can provide a pull request.

thedworak commented 1 year ago

Great to hear it. Could you please check the newest code then? I just added some more things and made code cleanup.

sebastian-meyer commented 1 year ago

Your latest code is now deployed here (without any changes): https://3dtest.dfg-viewer.de/viewer?tx_dlf[id]=https://4dcity.org/modelupload/70ef075a31ef44ac97bc1459baee7a18/70ef075a31ef44ac97bc1459baee7a18metsmods.xml&no_cache=1

sebastian-meyer commented 1 year ago

Now I deployed my code with the changes from #27 and configured CONFIG.basePath according to my environment. Good news is: the viewer gets to the point where it tries to load the gltf file, now. Bad news: this fails, but I don't know why (the errors point to three.module.js and GLTFLoader.js). Could you please take it from here? (I get the same errors when using your latest code and just search/replace the Drupal paths, so it probably isn't caused by my changes in #27.)

ClemensBeck commented 1 year ago

@thedworak Have you made any progress in solving the problem?

sebastian-meyer commented 1 year ago

No, but I also didn't investigate this any further. I debugged the code as far as integration with the DFG-Viewer is concerned. Now it seems to be issues with the viewer itself, so you are the expert for that. ;o)

ClemensBeck commented 1 year ago

Discussion on jour fixe: @thedworak will solve this in coming weeks

ClemensBeck commented 1 year ago

@sebastian-meyer Daniel solved the problem. Could you please check it?

sebastian-meyer commented 1 year ago

Unfortunately it's still not working.

The viewer still tries to load something from the Mainz repository even when loading a model from Jena. According to the JS console it tries to access https://3d-repository.hs-mainz.de/export_xml_single/?page=0&_format=xml (which results in a 500 error) and then calls for https://4dcity.org/modelupload/600db4895c834276a4f667609fec89a4/metadata/600db4895c834276a4f667609fec89a4.gltf_viewer (which doesn't exist either). Subsequentely loading fails completely and nothing is shown.

I tested with this example. The model itself seems fine, because it works with model-viewer (apart from missing support for glossy materials).

Again: I think we still need to get rid of all the code inside the viewer which is specific for the Mainz repository. This should be placed into a separate module which then can be used in WissKI, but omitted in the DFG-Viewer.

thedworak commented 1 year ago

Did you try to use lightweight version of the viewer?

sebastian-meyer commented 1 year ago

I am using this one: https://github.com/thedworak/dfg_3dviewer/blob/main/viewer/main.js

Where do I find the lightweight version?

thedworak commented 1 year ago

Please change the ligthweight to true inside CONFIG variable const CONFIG = { ... "lightweight": true };

sebastian-meyer commented 1 year ago

Looks good! With lightweight: true it's working!

There is still an error, because fetchSettings in main.js tries to load https://3dtest.dfg-viewer.de/null, but this seems to not prevent display of model. Maybe save the settings in a cookie or disable settings in lightweight mode?

ClemensBeck commented 1 year ago

@thedworak Will do this until next week

thedworak commented 1 year ago

I think it should be resolved

ClemensBeck commented 1 year ago

@sebastian-meyer Could you please check it?

sebastian-meyer commented 1 year ago

Unfortunately the latest changes seem to be a step backwards, because now nothing is shown at all. There are no errors in the console, but also no model shown. The loading indicator stays at 0%.

Examples:

@thedworak Could you please have a look again?

sebastian-meyer commented 1 year ago

The main.js I use can be found here: https://3dtest.dfg-viewer.de/typo3conf/ext/dlf/Resources/Public/Javascript/3DViewer/main.js

thedworak commented 1 year ago

Could you please @sebastian-meyer take a look right now?

sebastian-meyer commented 1 year ago

@thedworak Now the viewer displays the base reference system, but no model. There is an error in the console, which may be related?

thedworak commented 1 year ago

It's really hard to debug what is wrong when there is no output in the console. Maybe you could try this time, I just pushed some changes

sebastian-meyer commented 1 year ago

Ignore my last (deleted) comment! I forgot to purge the cache...

Now it's working! Thank you very much! I'll close this issue.

ClemensBeck commented 1 year ago

That's great!