Last active
November 6, 2016 21:32
-
-
Save evejweinberg/58972e792890f46e1f70b2d005d0b7e5 to your computer and use it in GitHub Desktop.
3js load a font
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//make sure you have a hel.json font to reference | |
function loadfont() { | |
var loader = new THREE.FontLoader(); | |
//font json file loaded in header | |
loader.load('hel.json', function(font) { | |
var textGeo = new THREE.TextGeometry("whatever you want to say", { | |
font: font, | |
size: textSize, | |
height: .3, | |
curveSegments: 12, | |
bevelThickness: 0, | |
bevelSize: 0, | |
bevelEnabled: true | |
}); | |
textGeo.computeBoundingBox(); | |
var centerOffset = -.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x ); | |
var centerOffsetY = -.5 * ( textGeo.boundingBox.max.y - textGeo.boundingBox.min.y ); | |
var textMaterial = new THREE.MeshPhongMaterial({ | |
color: 0xff0000, | |
metalness: 0.5, | |
roughness: 0.5, | |
// emissive: 0x000000, | |
// emissiveIntensity:.1 | |
}); | |
type = new THREE.Mesh(textGeo, textMaterial); | |
type.position.x = 0 | |
type.position.y = 10.5 | |
type.position.z = 4 | |
type.geometry.translate(centerOffset, centerOffsetY, 0 ); | |
scene.add(type); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment