# vtkBillboardTextActor3D objects stacking when added to vtkAssembly - SetPosition has no effect

**URL:** <https://discourse.vtk.org/t/vtkbillboardtextactor3d-objects-stacking-when-added-to-vtkassembly-setposition-has-no-effect/15947>\
**Category:** Development\
**Created:** [August 11, 2025, 10:41am UTC](https://discourse.vtk.org/t/vtkbillboardtextactor3d-objects-stacking-when-added-to-vtkassembly-setposition-has-no-effect/15947 "2025-08-11T10:41:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seuhf321](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seuhf321/32/10207_2.png) [@seuhf321](https://discourse.vtk.org/u/seuhf321)\
**Post date:** [August 11, 2025, 10:41am UTC](https://discourse.vtk.org/t/vtkbillboardtextactor3d-objects-stacking-when-added-to-vtkassembly-setposition-has-no-effect/15947/1 "2025-08-11T10:41:30Z")

</div>

I’m encountering an issue when using `vtkAssembly` to group multiple `vtkBillboardTextActor3D` objects. Despite calling `SetPosition()` on individual text actors, all labels appear stacked at the same location (typically the assembly’s origin). This occurs even though I’m setting distinct positions programmatically.

```auto
#include <vtkSmartPointer.h>
#include <vtkAssembly.h>
#include <vtkBillboardTextActor3D.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkTextProperty.h>

int main() {
    vtkSmartPointer<vtkAssembly> assembly = vtkSmartPointer<vtkAssembly>::New();
    assembly->SetPosition(0, 0, 0); // 装配体位于原点，排除整体偏移干扰
	assembly->SetScale(1.0, 1.0, 1.0); // 确保装配体没有缩放
    assembly->SetOrigin(0.0, 0.0, 0.0); // 确保装配体没有缩放
    
    // 添加第一个文本（X+方向）
    vtkSmartPointer<vtkBillboardTextActor3D> text1 = vtkSmartPointer<vtkBillboardTextActor3D>::New();
    text1->SetInput("X+ Text + 100");
    text1->SetPosition(5.0, 0.0, 0.0); // 明显偏移
    text1->GetTextProperty()->SetColor(1, 0, 0);
    assembly->AddPart(text1);

    // 添加第二个文本（Y+方向）
    vtkSmartPointer<vtkBillboardTextActor3D> text2 = vtkSmartPointer<vtkBillboardTextActor3D>::New();
    text2->SetInput("Y+ Text + 200");
    text2->SetPosition(0.0, 5.0, 0.0); // 明显偏移
    text2->GetTextProperty()->SetColor(0, 1, 0);
    assembly->AddPart(text2);

    // 渲染设置
    vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
    ren->AddActor(assembly);
    ren->SetBackground(0.1, 0.1, 0.1);

    vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
    renWin->AddRenderer(ren);
    renWin->SetSize(800, 600);

    vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
    iren->SetRenderWindow(renWin);

    ren->ResetCamera();
    ren->GetActiveCamera()->Azimuth(45);
    ren->GetActiveCamera()->Elevation(30);
    renWin->Render();
    iren->Start();

    return 0;
}

```

---

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [August 12, 2025, 5:55am UTC](https://discourse.vtk.org/t/vtkbillboardtextactor3d-objects-stacking-when-added-to-vtkassembly-setposition-has-no-effect/15947/2 "2025-08-12T05:55:01Z")

</div>

I don’t think you need `vtkAssembly` Have a look at this example, where I have added a cone for orientation. Here you will see that the `vtkBillboardTextActors` are positioned correctly. I’ll probably add this to the [vtk-examples](https://examples.vtk.org/site/) website.  
Here is the code: [BillboardTextActor.tar.gz](https://discourse.vtk.org/uploads/short-url/y6S1DTckr6AfS8u5KEfAMhTilX9.gz) (1.4 KB) and a screenshot:

 ![Screenshot_20250812_154846](https://discourse.vtk.org/uploads/default/original/2X/4/46a1c25794e9c34ebb38cb3e1c7a7692b4dc1158.png)

---

<div class="post-metadata">

**Author:** ![seuhf321](https://discourse.vtk.org/user_avatar/discourse.vtk.org/seuhf321/32/10207_2.png) [@seuhf321](https://discourse.vtk.org/u/seuhf321)\
**Post date:** [August 13, 2025, 4:04am UTC](https://discourse.vtk.org/t/vtkbillboardtextactor3d-objects-stacking-when-added-to-vtkassembly-setposition-has-no-effect/15947/4 "2025-08-13T04:04:57Z")

</div>

Thank you so much for your response!

However, my specific need is to design a 3D label similar to `vtkBillboardTextActor3D`, but one that supports **multi-line text with varying styles**. As shown in the image below, I want the first line of text to be red and the second line to be green.

My initial approach was to wrap multiple `vtkBillboardTextActor3D` instances within a `vtkAssembly`, hoping it would behave like a single multi-style label.

Unfortunately, after testing, I found that the resulting `vtkAssembly` **doesn’t handle depth properly** in the 3D scene like a single `vtkBillboardTextActor3D` does, so it doesn’t achieve the desired effect.

If you have any suggestions on how to approach this, I’d greatly appreciate your input!

 ![image](https://discourse.vtk.org/uploads/default/original/2X/c/c720da47ef5da89e76dc2314ba0477c8ffd28ab0.png)

---

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [August 13, 2025, 11:29pm UTC](https://discourse.vtk.org/t/vtkbillboardtextactor3d-objects-stacking-when-added-to-vtkassembly-setposition-has-no-effect/15947/5 "2025-08-13T23:29:59Z")

</div>

Have a look at [TestBillboardTextActor3D.cxx](https://gitlab.kitware.com/vtk/vtk/-/blob/v9.5.0/Rendering/FreeType/Testing/Cxx/TestBillboardTextActor3D.cxx), you can use something like:`setupBillboardTextActor3D()` to position and colour the actors.
