简体   繁体   English

使用three.js在特定点上编写2D文本

[英]Write 2d Text on specific point using three.js

var sourcePos=new THREE.Vector3(-5,0,0);
var targetPos=new THREE.Vector3(-5,2,0);
var direction=new THREE.Vector3().sub(targetPos,sourcePos);
var arrow=newTHREE.ArrowHelper(direction.clone().normalize(),sourcePos,direction.length(),0x00ff00);
scene.add(arrow);

At Point sourcePos and targetPos I want give a label Like 'A' and 'B'. 在Point sourcePos和targetPos上,我想给一个标签,例如'A'和'B'。 How can I achieve this in three.js? 如何在three.js中实现?

Three.js has a TextGeometry . Three.js具有TextGeometry When you set the height to 1, it is getting flat like 2d text and you can set it to a specific point in your scene: 将高度设置为1时,它会像2d文字一样变得平坦,可以将其设置为场景中的特定点:

loader.load( 'helvetiker_bold.typeface.json', function ( font ) {

        var textGeo = new THREE.TextGeometry( content, {

            font: font,
            size: size,
            height: 1 

    });


    textMesh = new THREE.Mesh( textGeo, textMaterial );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM