Creating text

很多时候我们需要在three.js应用中用到文字,这里有几种方法可以这样做。

1. DOM+CSS

用HTML来添加文字通常是最简单快捷的方式。这种方法是介绍three.js覆盖例子中最常用的。
添加内容到一个div

<div id="info">Description</div>

用css来绝对定位文字到一个位置。如果是全屏展示three.js应用,那么你需要使用z-index来确保文字展示在所有元素之上。

#info {
    position: absolute;
    top: 10px;
    width: 100%;
    text-align: center;
    z-index: 100;
    display:block;
}

2. 使用Textuer在canvas上绘制文字

如果你希望在three.js场景中的平面上轻松绘制文本,请使用此方法。

3. 在您最喜欢的3D应用程序中创建一个模型并导出到three.js

如果您喜欢使用3d应用程序并将模型导入到three.js,请使用此方法。

4. 程序几何文本

如果你只想使用纯粹的three.js或者是创建一个程序化的动态的文字几何体,你可以使用THREE.TextGeometry的实例

new THREE.TextGeometry( text, parameters );

为了能让上面的代码工作,你的TextGeometry需要一个THREE.Font的实例来设置”font”参数。请前往TextGeometry了解为什么这样做,其他参数的描述,以及three.js本身自带的JSON字体列表。

例子:
WebGL / geometry / text
canvas / geometry / text
WebGL / shadowmap

如果这些字体让你不满意,或者您想要使用的字体不在,这儿有一个教程,其中包含一个用于混合器的python脚本,它可以将文本导出为Three.js的JSON格式:http://www.jaanga.com/2012/03/blender-to-threejs-create-3d-text-with.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
There are many areas of computing that require the creating or editing and manipulating of text. We may need to author or edit plain-text documents for software development, building a website, or even just writing a blog post. While other options exist, Sublime Text 2 is a fast, feature-filled option that allows you to efficiently and rapidly manipulate and author your content or software with ease. The "Sublime Text Starter" book is a practical guide that provides numerous step-by-step instructions detailing some of the many features Sublime Text 2 provides to streamline your text editing. This starter can also serve as a reference guide to many of the great features Sublime Text 2 has to offer. This book looks at the various features Sublime Text 2 offers in order to increase the efficiency and ease of text manipulation and creation with a focus on programming related topics. It will take you through basic tasks from opening and saving documents all the way up to defining your own snippets and macros. You will learn these topics by way of easy to reference, stand-alone, step-by-step tutorial sections. You will also learn about some of the innovative features Sublime Text 2 has to offer, such as multiple cursors for editing in more than one place at a time, the preview pane, the command palette, and the Goto Anything features, among others. With the Sublime Text 2 Starter, you will learn everything you need to know to begin using Sublime Text 2 and some of its more advanced features. This will provide you an excellent start on utilizing Sublime Text 2’s powerful features and give you a good foundation to move on to its most advanced features on your own.
Follow these 10 easy steps to build the OutLookRichEdit control: Insert a rich edit control into the dialog. Call AfxInitRichEdit() in the InitInstance of the App class or in InitDialog. If it does not exist, copy OutLookRichEdit.cpp and OutLookRichEdit.h to the project directory. Click the menu choice Project-Add to Project-Files and select the above-copied files to add the wrapper class to your project. Import the hand cursor into the resource and rename it "IDC_LINK". Use Classwizard to add a member variable of the rich edit control (CRichEditCtrl). Include the OutLookRichEdit.h file in the dialog's header file and change the declaration of rich edit member variable, as in CRichEditCtrl m_ctrlText1; to COutLookRichEdit m_ctrlText1; In InitDialog(), add the following code. Post a comment Email Article Print Article Share Articles Digg del.icio.us Newsvine Facebook Google LinkedIn MySpace Reddit Slashdot StumbleUpon Technorati Twitter Windows Live YahooBuzz FriendFeed m_ctrlText1.SetRawHyperText(_T("Click <%$here$#100#%> to see the about box.")); At this level, if you build the project and run it, you can see the rich edit control with linked text, but nothing would happen if you clicked on the link. To Show a dialog while the link is clicked, you have to add some more code in the dialog class. Before that, have a closer look at the preceding code and hypertext syntax. The link text is enclosed between the "$" symbols and the corresponding dialog's resource value 100 (About Box), enclosed in "#" symbols. You can find the #define values of dialogs in the resource.h file. Use ClassWizard to map OnNotify of the dialog and write the corresponding implementation code in .cpp file, like: BOOL CDEMODlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { NMHDR* pNmHdr = (NMHDR*) lParam; if(IDC_RICHEDIT1 == pNmHdr->idFrom){ switch(pNmHdr->code) { case IDD_ABOUTBOX: CAboutDlg oDlg; oDlg.DoModal (); break; } } return CDialog::OnNotify(wParam, lParam, pResult); } Now, build and run the project. It is recommended that you set the read-only attribute to the rich edit control.
Preface Natural Language Processing is used everywhere—in search engines, spell checkers, mobile phones, computer games, and even in your washing machine. Python's Natural Language Toolkit (NLTK) suite of libraries has rapidly emerged as one of the most efficient tools for Natural Language Processing. You want to employ nothing less than the best techniques in Natural Language Processing—and this book is your answer. Python Text Processing with NLTK 2.0 Cookbook is your handy and illustrative guide, which will walk you through all the Natural Language Processing techniques in a step-by-step manner. It will demystify the advanced features of text analysis and text mining using the comprehensive NLTK suite. This book cuts short the preamble and lets you dive right into the science of text processing with a practical hands-on approach. Get started off with learning tokenization of text. Receive an overview of WordNet and how to use it. Learn the basics as well as advanced features of stemming and lemmatization. Discover various ways to replace words with simpler and more common (read: more searched) variants. Create your own corpora and learn to create custom corpus readers for data stored in MongoDB. Use and manipulate POS taggers. Transform and normalize parsed chunks to produce a canonical form without changing their meaning. Dig into feature extraction and text classification. Learn how to easily handle huge amounts of data without any loss in efficiency or speed. This book will teach you all that and beyond, in a hands-on learn-by-doing manner. Make yourself an expert in using the NLTK for Natural Language Processing with this handy companion. Preface 2 What this book covers Chapter 1, Tokenizing Text and WordNet Basics, covers the basics of tokenizing text and using WordNet. Chapter 2, Replacing and Correcting Words, discusses various word replacement and correction techniques. The recipes cover the gamut of linguistic compression, spelling correction, and text normalization. Chapter 3, Creating Custom Corpora, covers how to use corpus readers and create custom corpora. At the same time, it explains how to use the existing corpus data that comes with NLTK. Chapter 4, Part-of-Speech Tagging, explains the process of converting a sentence, in the form of a list of words, into a list of tuples. It also explains taggers, which are trainable. Chapter 5, Extracting Chunks, explains the process of extracting short phrases from a part-of-speech tagged sentence. It uses Penn Treebank corpus for basic training and testing chunk extraction, and the CoNLL 2000 corpus as it has a simpler and more flexible format that supports multiple chunk types. Chapter 6, Transforming Chunks and Trees, shows you how to do various transforms on both chunks and trees. The functions detailed in these recipes modify data, as opposed to learning from it. Chapter 7, Text Classification, describes a way to categorize documents or pieces of text and, by examining the word usage in a piece of text, classifiers decide what class label should be assigned to it. Chapter 8, Distributed Processing and Handling Large Datasets, discusses how to use execnet to do parallel and distributed processing with NLTK. It also explains how to use the Redis data structure server/database to store frequency distributions. Chapter 9, Parsing Specific Data, covers parsing specific kinds of data, focusing primarily on dates, times, and HTML. Appendix, Penn Treebank Part-of-Speech Tags, lists a table of all the part-of-speech tags that occur in the treebank corpus distributed with NLTK.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值