Closed rajhraval closed 4 years ago
Looks like your transformableNode is a local variable in the callback? You will need to make sure that the renderable is assigned to a node available in your fragment.
Yes, I have used transformable node locally in the thenAccept (closure: I am new in Kotlin, using my Swift Knowledge to compare that)
and the model renderable is assigned to the transformableNode renderable.
I have used the same method closures ie: builder(), thenAccept, exceptionally in Main Activity, it worked there.
I tried a workaround.
I replaced class ModelLoader internal constructor(owner: WeakReference<Activity>)
to
class ModelLoader (val fragment: ArFragment)
It works for me and the model is rendered.
I am trying to load a .gltf model remotely using Sceneform by using a reusable class and then creating an instance of the class in
MainActivity
and callingloadModel()
methodModelLoader.kt
The example of the class in use is given in the Link in Java and also it states a Weak Reference of the MainActivity. I want to use
ModelLoader
class for other activities too, so I gave a weak reference type of Activity instead of Main Activity.MainActivity.kt
The result is I can only see the plane renderer visible in the tracking state and the model is not getting rendered. I tried to check using
Log.d
it showed that the model was loaded. But yet not shown on the screen.What is the problem?