opensourceBIM / BIMsurfer-before2019

This is the repository of the v1 and v2 version of BIM Surfer. It is not maintained anymore. Find the most recent version on https://github.com/opensourceBIM/BIMsurfer
MIT License
432 stars 195 forks source link

BimServerClient is not a constructor #225

Open alilouchka opened 6 years ago

alilouchka commented 6 years ago

I'm getting this error in chrome 64 when i try to connect BimSurfer to BIMServer. 2017-12-04_15h16_57

Any solutions please ??

Thanks !

bdamay commented 6 years ago

I ran into the same type of error while trying to execute the example_BIMServer.html demo.

While debugging in dev tools, it looks like the BimServerClient and the BimServerApiPromise constructors lie in the default attribute of the module returned by the promise. so to make it work my lines 53 and 54 became :

            bimserverapi.BimServerClient = BimServerClient.default;
            bimserverapi.BimServerApiPromise = BimServerApiPromise.default;

And the model appears. I didn't investigate much further and it seems that there are some other errors on click events. So this solution i give seems to be a workaround that may be incorrect.

Guess everything is not OK but hope this helps.

Versions: Bimserver 1.5.92 Bimsurfer git clone from revision 33b2877

alilouchka commented 6 years ago

Thank you bdamay, it's working !! but i have some problems: Its not showing the object details when i select it. I have an other question, how can I test it in chrome 62 and other browsers?

Thank you : )

bdamay commented 6 years ago

Glad to know it shows you a model.
As I said i don't think my solution is the right one because according to documentation BimServerClient.BimServerClient should be a constructor. (same for BimServerApiPromise.BimServerApiPromise). Sure @rubendel or another guru can help on this matter better than me.

BimSurfer demo doesn't work in Chrome 62 due to Ecma6 script syntax used for importing libraries. So you get a syntax error in Chrome62. (Other browsers i don't know)

bdamay commented 6 years ago

I finally got a bit deeper in the comprehension of what is bugging the demo.

First: Bimsurfer is obviously waiting for a roid in the querystring that is not provided by index.html. So i added the parameter in the link on line 61 of index.html, it becomes: a.setAttribute("href", "docs/example_BIMServer.html?address=" + encodeURIComponent(address) + "&token=" + client.token + "&poid=" + project.oid+"&roid="+project.lastRevisionId);

It works with projects without subproject. I actually didn't manage to get the right revision id for subproject yet. I think that it's not that important in a purpose of a demo on object selection .

Second: While looking for metadata it fails because on line 196 of MetaDataRenderer.js, The script seems to expect data in a variable models[oid[0]].model.objects but fails. I found something in apiModel attribute. So i modified the line 196 with.
var o = models[oid[0]].apiModel.objects[oid[1]];

I'm not that sure it is that correct but with these 2 steps i got the demo working without console errors.

If for some reason i was answering the wrong way, please note i'm pretty new on the platform. I'm ready to hear any advised comment.

I hope this helps. (Anyway, it helped me understand better how all this is behaving... thanks the demo :-))

alilouchka commented 6 years ago

Hi bdamay, Thanks for your answers . I am new too to the plateform , I'm trying to do my own demo to test the bimsurfer but i'm getting some errors when i load the librairies:

I am trying to test a client wab app using BimServerClient api.

Everything is Ok when i load the librairies like in the demo:

2017-12-20_14h16_47

I got in the console :

image

But when i try to load them locally from :

2017-12-20_14h17_33

or from my local host :

image

I get the unexpected token error and BimServerClient is not defined :

image

Can you help me please !?

Thanks

rubendel commented 6 years ago

Your script tag needs type="module".

alilouchka commented 6 years ago

Thank you rubendel for your answer. I got less errors now :

2017-12-21_17h20_46

2017-12-21_17h12_29

I think it doesn't find the file geometry.js or maybe it's beacause of an other issue ?

Thanks for your answer

bdamay commented 6 years ago

Your BimServerClient is still not defined. You might try to import it with import BimServerClient from js/bimserverclient.js

alilouchka commented 6 years ago

Thabks bdamay for your answer, i did all of this but it stills not working :

2017-12-22_13h16_03

Result:

2017-12-22_13h18_17

2017-12-22_13h18_25

Any solution please ? : )

Thanks

bdamay commented 6 years ago

Did you try

<script type="module"> import BimServerClient from 'PATH_TO_JS/bimserverclient.js'; ... ? It worked for me