0

How can I center my Node containing a ModelRenderable? I'm using a SceneView because I don't want AR.

<com.google.ar.sceneform.SceneView
    android:id="@+id/popup_overview_model_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
private void addModelToViewer(ModelRenderable model) {
    if (popupOverviewSceneView != null) {
        Node modelNode = new Node();
        modelNode.setRenderable((Renderable) model);
        modelNode.setParent(popupOverviewSceneView.getScene());
        modelNode.setLocalPosition(new Vector3(0f, 0f, 0f));
        modelNode.setWorldScale(new Vector3(1f, 1f, 1f));
        popupOverviewSceneView.getScene().addChild(modelNode);
    }
}

As you can see the 3D model of the car is way too big and not centered. There's multiple 3D models with different sizes. How can I center the 3D model?

enter image description here

DaniLecx
  • 93
  • 10
  • 1
    If the world scale is set to 1, 1, 1 then the center of the world would be 0.5,0.5,0.5 right? Therefore I would suggest to try `modelNode.setLocalPosition(new Vector3(0.5f, 0.5f, 0.5f));` – Bruno Bieri Aug 05 '20 at 15:54
  • Got it working by trial and error :) `modelNode.setLocalPosition(new Vector3(0f, -1f, -5f));` – DaniLecx Aug 05 '20 at 17:52
  • 1
    I'm glad it was the right direction and works now. – Bruno Bieri Aug 05 '20 at 18:10

0 Answers0