treblereel / three4g

Three.js for GWT
Apache License 2.0
25 stars 6 forks source link

Cannot clone GLTF Model Scenes with DracoLoader extension #161

Open tugalsan opened 4 years ago

tugalsan commented 4 years ago

Hello @treblereel

I have learned that I have to clone things to add it again to be efficient. stackoverflow: I found one fast solution (not the most efficient)

I can clone Meshes:

scene.add(boxMesh.clone());

I can clone standard GLTF files:

scene.add(damagedHelmetScene.clone());

But, I cannot clone DracoLoaded GLTF files:

scene.add(LittlestTokyoScene.clone());
console>"(TypeError) : Cannot read property 'update' of undefined"
Ekran Alıntısı

Could you look into it, when you have time?

treblereel commented 4 years ago

interesting ... i have to take a look ...

treblereel commented 4 years ago

yeap, looks like a bug https://github.com/mrdoob/three.js/issues/19419

the possible workaround is:

@InjectJavaScriptFor(elements = {OrbitControls.class, DRACOLoader.class, GLTFLoader.class, SkeletonUtils.class})
public class WebglAnimationScene extends Attachable {
            Scene model2 = Js.uncheckedCast(SkeletonUtils.clone(model));

ps: i ll as cast on return on next version.

tugalsan commented 4 years ago

I am trying to find where SkeletonUtils is located. It make take a while... Are you positive that, SkeletonUtils.java/class is in either three4g-0.102.jar or three4g-extensions-0.102.jar in maven?

Ekran

I know it is not compilable but, for newbies like me, wants to come to this point quickly,
can use the below code, with lazy model loaders functions:

threeJS.zip

treblereel commented 4 years ago

https://github.com/treblereel/three4g/blob/master/extensions/src/main/java/org/treblereel/gwt/three4g/extensions/utils/SkeletonUtils.java

yeap, it's extension, so you need to add this maven dependency, here is a demo setup https://github.com/treblereel/three4g/blob/master/demo/pom.xml

tugalsan commented 4 years ago

@treblereel I am sorry. I feel I am blind :)

Dependency view:

Dep

Import view:

import

checking pom versions...

tugalsan commented 4 years ago

My bad. It wasnot in three4g-extensions-0.102.jar. It was in three4g-extensions-0.105.jar I am trying to figure out why I cannot compile, the very same code, with new three4g-0.105.jar three4g-extensions-0.105.jar libraries....

Update: 1) Updating elemental2-dom to ver 1.1.0 fixed compilation issue. 2) Using SkeletonUtils is successful. image threeJS (20200711).zip

@treblereel Thank you for directions...

treblereel commented 4 years ago

@tugalsan you should use the same core, processor and extensions version