Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model not loading since upgraded from 4.0.* #6763

Closed
lijiayi0921 opened this issue May 27, 2024 · 4 comments
Closed

Model not loading since upgraded from 4.0.* #6763

lijiayi0921 opened this issue May 27, 2024 · 4 comments

Comments

@lijiayi0921
Copy link

Hi,

I upgraded my https://github.com/iTwin packages to latest version (4.6.0 as of today), from @itwin/web-viewer-react@4.0.3 and most of the rest 4.0.2.
With the same frontend code, the viewer no longer loads the imodel.
The sign-in, as well as the display of all widgets are working. Custom 3D sprites are loaded, only the imodel is missing.

With Firefox i'm getting this error :

Loading Worker from “[http://localhost:3001/viewer/itwin/scripts/parse-imdl-worker.js”]
(http://localhost:3001/viewer/itwin/scripts/parse-imdl-worker.js%E2%80%9D) was blocked because of a disallowed MIME type (“text/html”).

With Chrome this error :

Uncaught SyntaxError: Unexpected token '<'
at handleError (http://localhost:3001/static/js/bundle.js:774837:58)
at http://localhost:3001/static/js/bundle.js:774856:7

Below is my implementation :

 {isLoggedIn || redirectUrl.pathname !== window.location.pathname ?
            (<Viewer
                key={'viewer'}
                iTwinId={props.file?.platformBucket}
                iModelId={props.file?.platformModel!}
                authClient={authClient}
                onIModelAppInit={onIModelAppInit}
                onIModelConnected={onIModelConnected}
                additionalI18nNamespaces={['safe', 'safeTools']}
                uiProviders={[
                    new ViewerNavigationToolsProvider(),
                    new ViewerContentToolsProvider({
                        vertical: {
                            measureGroup: false,
                        },
                    }),
                    new ViewerStatusbarItemsProvider(),
                    new TreeWidgetUiItemsProvider(),
                    new PropertyGridUiItemsProvider(),
                    new MeasureToolsUiItemsProvider(),
                    ...(safeExt?.uiProviders ?? [])
                ]}
                viewCreatorOptions={viewCreatorOptions}
                enablePerformanceMonitors={true}
            />
            ) : null}

Any help will be appreciated !
Thank you

Jiayi

@pmconne
Copy link
Member

pmconne commented May 27, 2024

You need to copy the public assets from @itwin/core-frontend. #6591

@lijiayi0921
Copy link
Author

lijiayi0921 commented May 27, 2024

Thank you @pmconne, but I didn't fully understand.
Do you mean to copy all subdirs of @itwin/core-frontend/lib/public (assets, cursor, scripts, ...) into my frontend's public folder ?
Just tried and this did'nt solve my problem.

Also what's the reason of copying them?
They don't appear in the public folder of the sample app :
https://developer.bentley.com/tutorials/web-application-quick-start/

---------------- Edit -------------------
Instead of the public folder, I copied them into public/viewer/itwin based on my error. The models loads again !

Loading Worker from “[http://localhost:3001/viewer/itwin/scripts/parse-imdl-worker.js”]
(http://localhost:3001/viewer/itwin/scripts/parse-imdl-worker.js%E2%80%9D) was blocked because of a disallowed MIME type (“text/html”).

However I still don't understand why this is a necessity.
Why it was not required in my previous implementation (4.0.*), and in the sample app ?

@pmconne
Copy link
Member

pmconne commented May 27, 2024

Why it was not required in my previous implementation (4.0.*), and in the sample app ?

The worker script was introduced in 4.2.0.

Presumably the viewer package sets IModelApp.publicPath to "viewer/itwin".

@lijiayi0921
Copy link
Author

Thank you @pmconne for your help & explanation !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants