Dynamically create 2D text in three.js

前端 未结 8 2082
醉梦人生
醉梦人生 2020-12-12 19:20

I have 3D model which I have created in three.js. Based on some data, I want to create a set of arrows which is decorated by a small text label. These labels should be in 2D

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 19:48

    I've published a module on NPM that does that for you: https://github.com/gamestdio/three-text2d

    It allows you to have an Sprite or Mesh with the rendered text without dealing with canvas manually.

    Example:

    var Text2D = require('three-text2d').Text2D
    
    var text = new Text2D("Hello world!", { font: '30px Arial', fillStyle: '#000000', antialias: true })
    scene.add(text) 
    

提交回复
热议问题