当前位置:网站首页>Threejs implements labels and displays labels with custom styles
Threejs implements labels and displays labels with custom styles
2022-07-05 04:00:00 【Zuo Ben】
1, Introduce
Use threejs Realize label display , Here we only introduce how to realize the function of displaying labels , Others can check previous articles .
The renderings are as follows :
2, Main description
Realize the use of labels CSS2DRenderer(2D Renderers ) Rendering .
1, Introduce the renderer and initialize
2, establish dom Element object , Add displayed content and style
3, hold dom The elements are packed into CSS2DObject object , And add it to the scene
4, Use CSS2DRenderer Rendering display
Bring in renderer , And initialization
<script type="text/javascript" src="libs/CSS2DRenderer.js"></script>
var labelRenderer = new THREE.CSS2DRenderer();
labelRenderer.setSize(window.innerWidth, window.innerHeight);
labelRenderer.domElement.style.position = 'absolute';
labelRenderer.domElement.style.top = 0;
document.body.appendChild(labelRenderer.domElement);
Create a label , And add it to the scene
// new label
function createLableObj(text, vector) {
let laberDiv = document.createElement('div');// establish div Containers
laberDiv.className = 'laber_name';
laberDiv.textContent = text + '\n' + " allowance :123";
let pointLabel = new THREE.CSS2DObject(laberDiv);
pointLabel.position.set(vector.x, vector.y, vector.z);
return pointLabel;
}
let pointLabel = createLableObj(text, vector);
scene.add(pointLabel);
Rendering
labelRenderer.render(scene, camera);
If you need a complete code, please leave a message or contact me on wechat :1171053128
边栏推荐
- 在线SQL转Excel(xls/xlsx)工具
- Interview byte, pass the exam and directly work on three sides. As a result, I found an architect to hang me?
- Containerd series - detailed explanation of plugins
- Use threejs to create geometry and add materials, lights, shadows, animations, and axes
- How to make the listbox scroll automatically when adding a new item- How can I have a ListBox auto-scroll when a new item is added?
- Basic function learning 02
- [wp]bmzclub writeup of several questions
- 【PHP特性-变量覆盖】函数的使用不当、配置不当、代码逻辑漏洞
- 【看完就懂系列】一文6000字教你从0到1实现接口自动化
- 输入的查询SQL语句,是如何执行的?
猜你喜欢
技术教程:如何利用EasyDSS将直播流推到七牛云?
Differences among 10 addressing modes
laravel8 导出Excle文件
Clickhouse synchronization MySQL (based on materialization engine)
MindFusion.Virtual Keyboard for WPF
This article takes you to understand the relationship between the past and present of Bi and the digital transformation of enterprises
UI automation test farewell to manual download of browser driver
As soon as I write the code, President Wang talks with me about the pattern all day
Basic function learning 02
“金九银十”是找工作的最佳时期吗?那倒未必
随机推荐
IronXL for .NET 2022.6
@The problem of cross database query invalidation caused by transactional annotation
How about programmers' eyesight| Daily anecdotes
Timing manager based on C #
“金九银十”是找工作的最佳时期吗?那倒未必
How to use jedis of redis
[untitled]
DFS and BFS concepts of trees and graphs
Redis之Jedis如何使用
EasyCVR更改录像存储路径,不生成录像文件如何解决?
【web审计-源码泄露】获取源码方法,利用工具
[vérification sur le Web - divulgation du code source] obtenir la méthode du code source et utiliser des outils
PlasticSCM 企业版Crack
技术教程:如何利用EasyDSS将直播流推到七牛云?
laravel8 导出Excle文件
Online text line fixed length fill tool
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
输入的查询SQL语句,是如何执行的?
grandMA2 onPC 3.1.2.5的DMX参数摸索
北京程序员的真实一天!!!!!