SciProgCentre / visionforge

Visualization module for dataforge
Apache License 2.0
35 stars 8 forks source link

Threejs loaders example request #41

Open lobis opened 3 years ago

lobis commented 3 years ago

I am trying to call three.js in the browser using Kotlin.

In my first attempt, I used the original three.js wrapper from Lars Ivar Hatledal, which this project also includes. I started from the examples in https://laptrinhx.com/kotlin-wrappers-for-three-js-2366010328/, but I quickly found out the newest version of Kotlin (1.4.32) does not work out of the box with it (problems with kotlin.browser.* vs kotlinx.browser.*) so I used the version distributed by visionforge instead.

I managed to render a simple cube successfully (based on the first example in the linked page).

However, I cannot get the Loaders to work, I failed to load an .stl model and an Object3D model. The code compiles correctly but I get the following errors in the browser:

For Object3D loader: image

For JSON loader (Object3D): image This seems to be related to the fact that JSONLoader was removed in the r99 release of three.js (https://discourse.threejs.org/t/objectloader-not-loading-json-file/5213)

For the STL something similar happens.

To me it looks like there are some problems with the three.js wrapper, please correct me if I am wrong. I would appreciate an example on how to correctly call this methods. Also I couldn't get the dat.gui or stats to work following the example.

Here you can find an example project which reproduces this issues.

Thank you.

Luis.

altavir commented 3 years ago

Three-JS has several modules and they need to be loaded into the webpack bundle in order to be accessible. I will research this option.