Dynamically create 2D text in three.js

前端 未结 8 2088
醉梦人生
醉梦人生 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 20:13

    You can create a 2d canvas and use css to position it to the top of your webgl canvas. Then you can draw text on it using the ctx.fillText(text,x,y) or ctx.strokeText(text,x,y) methods provided by the 2d canvas context. By using this method you can draw other things besides text, such as arrows and meters.

    You can use the method as suggested by @kronuus to convert a point from 3d to 2d space.

提交回复
热议问题