naver / egjs-view3d

Fast & customizable 3D model viewer for everyone
https://naver.github.io/egjs-view3d
MIT License
198 stars 30 forks source link

how to use plugins in vanilla javascript #55

Open ctxwing opened 1 year ago

ctxwing commented 1 year ago

Description

I'm just coding in vanilla javascript. as for plugins, I've followed link below: https://naver.github.io/egjs-view3d/docs/options/miscellaneous/plugins

it says using import but not available in vanilla javascript. at present I am using `

<script src="js/jquery-3.5.1.min.js"></script>

`

is it impossible in vanilla javascript or am I lost ? or using mixing jQuery and egjs-view3d can cause problem?

in short, how to use plugins in vanilla javascript ?

thanks in advance for good solution..

Steps to check or reproduce

WoodNeck commented 1 year ago

Hello @ctxwing! If you're importing View3D with a script tag, every component in View3D is exported like this:

View3D.XXX

So, try using it like this:

const viewer = new View3D("#el", {
  plugins: [new View3D.LoadingBar()]
})

Or...

const viewer = new View3D("#el");

viewer.loadPlugins(new View3D.LoadingBar());
ctxwing commented 1 year ago

@WoodNeck Thanks for quick response.. it works ! as for me,viewer.loadPlugins(new View3D.LoadingBar()); works fine. ( viewer.addPlugins(new View3D.LoadingBar()); does not work)

would you please update this in docs for it? if it is possible. thanks again.

WoodNeck commented 1 year ago

@ctxwing That's my mistake, loadPlugins is right!