Three.js API手册

动画
AnimationAction AnimationClip AnimationMixer AnimationObjectGroup AnimationUtils KeyframeTrack PropertyBinding PropertyMixer
动画 / 轨道
BooleanKeyframeTrack ColorKeyframeTrack NumberKeyframeTrack QuaternionKeyframeTrack StringKeyframeTrack VectorKeyframeTrack
音频
Audio AudioAnalyser AudioContext AudioListener PositionalAudio
摄像机
ArrayCamera Camera CubeCamera OrthographicCamera PerspectiveCamera StereoCamera
常量
Animation Core CustomBlendingEquation DrawModes Materials Renderer Textures
核心
BufferAttribute BufferGeometry Clock DirectGeometry EventDispatcher Face3 Geometry InstancedBufferAttribute InstancedBufferGeometry InstancedInterleavedBuffer InterleavedBuffer InterleavedBufferAttribute Layers Object3D Raycaster Uniform
核心 / BufferAttributes
BufferAttribute_Types
弃用列表
DeprecatedList
附件
Earcut ShapeUtils
附件 / 核心
Curve CurvePath Font Interpolations Path Shape ShapePath
附件 / 曲线
ArcCurve CatmullRomCurve3 CubicBezierCurve CubicBezierCurve3 EllipseCurve LineCurve LineCurve3 QuadraticBezierCurve QuadraticBezierCurve3 SplineCurve
附件 / 物体
ImmediateRenderObject
几何体
BoxBufferGeometry BoxGeometry CircleBufferGeometry CircleGeometry ConeBufferGeometry ConeGeometry CylinderBufferGeometry CylinderGeometry DodecahedronBufferGeometry DodecahedronGeometry EdgesGeometry ExtrudeBufferGeometry ExtrudeGeometry IcosahedronBufferGeometry IcosahedronGeometry LatheBufferGeometry LatheGeometry OctahedronBufferGeometry OctahedronGeometry ParametricBufferGeometry ParametricGeometry PlaneBufferGeometry PlaneGeometry PolyhedronBufferGeometry PolyhedronGeometry RingBufferGeometry RingGeometry ShapeBufferGeometry ShapeGeometry SphereBufferGeometry SphereGeometry TetrahedronBufferGeometry TetrahedronGeometry TextBufferGeometry TextGeometry TorusBufferGeometry TorusGeometry TorusKnotBufferGeometry TorusKnotGeometry TubeBufferGeometry TubeGeometry WireframeGeometry
辅助对象
ArrowHelper AxesHelper BoxHelper Box3Helper CameraHelper DirectionalLightHelper FaceNormalsHelper GridHelper PolarGridHelper PositionalAudioHelper HemisphereLightHelper PlaneHelper PointLightHelper RectAreaLightHelper SkeletonHelper SpotLightHelper VertexNormalsHelper
灯光
AmbientLight DirectionalLight HemisphereLight Light PointLight RectAreaLight SpotLight
灯光 / 阴影
DirectionalLightShadow LightShadow SpotLightShadow
加载器
AnimationLoader AudioLoader BufferGeometryLoader Cache CompressedTextureLoader CubeTextureLoader DataTextureLoader FileLoader FontLoader ImageBitmapLoader ImageLoader Loader LoaderUtils MaterialLoader ObjectLoader TextureLoader
加载器 / 管理器
DefaultLoadingManager LoadingManager
材质
LineBasicMaterial LineDashedMaterial Material MeshBasicMaterial MeshDepthMaterial MeshDistanceMaterial MeshLambertMaterial MeshMatcapMaterial MeshNormalMaterial MeshPhongMaterial MeshPhysicalMaterial MeshStandardMaterial MeshToonMaterial PointsMaterial RawShaderMaterial ShaderMaterial ShadowMaterial SpriteMaterial
数学库
Box2 Box3 Color Cylindrical Euler Frustum Interpolant Line3 Math Matrix3 Matrix4 Plane Quaternion Ray Sphere Spherical Triangle Vector2 Vector3 Vector4
数学库 / 插值
CubicInterpolant DiscreteInterpolant LinearInterpolant QuaternionLinearInterpolant
物体
Bone Group Line LineLoop LineSegments LOD Mesh Points Skeleton SkinnedMesh Sprite
渲染器
WebGLMultisampleRenderTarget WebGLRenderer WebGLRenderTarget WebGLRenderTargetCube
渲染器 / 着色器
ShaderChunk ShaderLib UniformsLib UniformsUtils
场景
Fog FogExp2 Scene
纹理贴图
CanvasTexture CompressedTexture CubeTexture DataTexture DataTexture3D DepthTexture Texture VideoTexture

文本缓冲几何体(TextBufferGeometry)

一个用于将文本生成为单一的几何体的类。 它是由一串给定的文本,以及由加载的Font(字体)和该几何体ExtrudeGeometry父类中的设置所组成的参数来构造的。 请参阅Font、FontLoader和Creating_Text页面来查看更多详细信息。

// iOS iframe auto-resize workaround 
if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) { 
  var scene = document.getElementById( 'scene' ); 
  scene.style.width = getComputedStyle( scene ).width; 
  scene.style.height = getComputedStyle( scene ).height; 
  scene.setAttribute( 'scrolling', 'no' ); 
}

示例

geometry / text

var loader = new THREE.FontLoader(); 
loader.load( 'fonts/helvetiker_regular.typeface.json', function ( font ) { 
  var geometry = new THREE.TextBufferGeometry( 'Hello three.js!', { 
    font: font, 
    size: 80, 
    height: 5, 
    curveSegments: 12, 
    bevelEnabled: true, 
    bevelThickness: 10, 
    bevelSize: 8, 
    bevelSegments: 5 
  } ); 
} );

构造器

TextBufferGeometry(text : String, parameters : Object)

text — 将要显示的文本。
parameters — 包含有下列参数的对象:

  • font — THREE.Font的实例。
  • size — Float。字体大小,默认值为100。
  • height — Float。挤出文本的厚度。默认值为50。
  • curveSegments — Integer。(表示文本的)曲线上点的数量。默认值为12。
  • bevelEnabled — Boolean。是否开启斜角,默认为false。
  • bevelThickness — Float。文本上斜角的深度,默认值为20。
  • bevelSize — Float。斜角与原始文本轮廓之间的延伸距离。默认值为8。
  • bevelSegments — Integer。斜角的分段数。默认值为3。

可用的字体

文本几何体使用 typeface.json所生成的字体。 一些已有的字体可以在/examples/fonts中找到,且必须在页面中引入。

字体

字重

风格

文件路径

helvetiker

normal

normal

/examples/fonts/helvetiker_regular.typeface.json

helvetiker

bold

normal

/examples/fonts/helvetiker_bold.typeface.json

optimer

normal

normal

/examples/fonts/optimer_regular.typeface.json

optimer

bold

normal

/examples/fonts/optimer_bold.typeface.json

gentilis

normal

normal

/examples/fonts/gentilis_regular.typeface.json

gentilis

bold

normal

/examples/fonts/gentilis_bold.typeface.json

droid sans

normal

normal

/examples/fonts/droid/droid_sans_regular.typeface.json

droid sans

bold

normal

/examples/fonts/droid/droid_sans_bold.typeface.json

droid serif

normal

normal

/examples/fonts/droid/droid_serif_regular.typeface.json

droid serif

bold

normal

/examples/fonts/droid/droid_serif_bold.typeface.json

属性

# .parameters : Object

一个包含着构造函数中每个参数的对象。在对象实例化之后,对该属性的任何修改都不会改变这个几何体。

源代码

src/geometries/TextBufferGeometry.js