3D text

34 views
Skip to first unread message

Bruce Sherwood

unread,
Jul 2, 2016, 12:02:56 AM7/2/16
to Glowscript Users
Thanks to excellent work by Kadir Haldenbilen, it became possible to implement 3D text in GlowScript. Here is documentation:


And here is an example of its use:


This is not yet available in Jupyter VPython but will be in the near future.
Message has been deleted

Joe Heafner

unread,
Jul 2, 2016, 5:53:02 PM7/2/16
to glowscri...@googlegroups.com
On July 2, 2016 at 09:59:53, Bruce Sherwood (bruce.s...@gmail.com) wrote:
> For some reason, in the Help the image accompanying the documentation of
> the new text object isn't being displayed. Here is what it looks like:
>
> http://www.glowscript.org/#/user/Bruce_Sherwood/folder/My_Programs/program/Text3D
>

For some reason, the program won’t load in Safari 9.1.1 (running under OS X 10.11.4) or on iOS (9.2.x). It also won’t load in Firefox 47.0.1 but does give an error message saying 

RferenceError: process is not defined
null

It seems to work only in Chrome. Any suggestions?


Joe Heafner
Sent from one of my Macs

Bruce Sherwood

unread,
Jul 2, 2016, 6:48:01 PM7/2/16
to Glowscript Users
Very strange. At least it works in Chrome on the Mac, but on my iPad NONE of the GlowScript programs work. I have no idea what the problem is -- thanks for reporting it.

It works on Windows with Chrome, Firefox, and Edge.

It works on my Android phone with Chrome, Firefox, and Opera.

Bruce Sherwood

unread,
Jul 3, 2016, 10:22:59 AM7/3/16
to Glowscript Users
My Mac died (I'm getting a new one this afternoon) so I wasn't able to see what the problem was. Steve Spicklemire gave me the critical feedback, "Strict mode does not allow function declarations in a lexically nested statement". I've temporarily turned off "strict mode" in one file and OSX/iOS both work again. Yay Steve!

As far as I know, "strict mode" is basically an aid to the developer in catching certain kinds of errors. Turning it off in just one file (the file associated with starting the program) won't hurt anyone. I will look into restructuring that file to be able to turn strict mode back on.

What changed in the file was the addition of code to access font files if you have a 3D "text" object in your file.

Bruce Sherwood

unread,
Jul 5, 2016, 1:19:13 PM7/5/16
to Glowscript Users
All my tests, including with 3D text, now work on Windows and Mac and Android and iOS.

Also, programs that use the new 3D text object can be exported to your own web page (this hadn't worked previously).

Technical notes: After restructuring I was able to re-enable strict mode. If your program contains a 3D text object, we have to fetch the font files from which the shapes are extracted. This file fetching is now done in parallel with compiling your program, so the short time delay between clicking "Run this program" and seeing it run is now hardly different from working with a program that doesn't use the text object.

Bruce Sherwood

unread,
Jul 5, 2016, 11:32:27 PM7/5/16
to Glowscript Users
Take a look at this "billboarding" of 3D text, a graphics term meaning "keep the object facing forward when you rotate the camera":

The billboarding of the 3D text is currently done in the CPU very simply. For every render I go through a list of text objects that have billboard = True and adjust their axis and up attributes. Obviously this could be in the GPU, but typically there will be very few 3D text objects in a view, so it's not really a performance issue. A similar scheme is used for leaving a trail automatically behind a moving object.

The value of billboarding is that one might have 3D text objects attached to moving objects and would wish to keep the text forward.

Typically as in this example it makes sense to set emissive = True, which means "ignore lighting", since when you rotate the camera the text might otherwise sometimes be very dark.

Here are the specs on the 3D text object now:

Reply all
Reply to author
Forward
0 new messages