Billboard through javascript


#1

Hi, it seems that the example in https://cospaces.io/api/#textbillboardsetsize doesn’t work.
I eman: the link to the example itself launch the example in action, but a part the first cretaeTextBillboard command, all the others doesn’t take effect. If i copy the code in my scene, i get the same results…
did you change the syntax and forgot to change the docs, or do i miss some step?

thanks,


#2

Hi mariochiesa,

thanks for pointing that out! There has been a change in the API regarding texts, which has not been reflected in the documentation yet.

Now, the item created by Scene.createTextBillboard() is a Cuboid-Item with a Text-Item attached as a child. There’s also a new method called Scene.createText() to only make the Text-Item itself. Below are some examples:

1. How to make the new text item

let text = Scene.createText(0, 0, 1, "Hello World!");
text.setFontSize(10);
text.setColor(255, 0, 0); 

See this example in action

2. How to make a text billboard item
The item created with Scene.createTextBillboard is simply a Cuboid-Item with a Text-Item as a child. You can call methods on the Cuboid and it will set properties on the Text-Item it has as a child.

let textBillboard: Cuboid = Scene.createTextBillboard(0, 0, 1);
textBillboard.setFontSize(0.3);
textBillboard.setText('CoSpaces!');
textBillboard.setTextColor(255, 255, 255);
textBillboard.setColor(0, 205, 170);

See the example in action

We’ll be updating the documentation page accordingly. Hope this helps!


#3

Thank you so much! Prompt and helpful as usual!