如何呈现TextGeometry?

时间:2019-06-14 09:42:06

标签: three.js

TextGoemetry未呈现

我在互联网上尝试了很多教程,在stackoverflow上也尝试了很多教程,但是都没有用。

    var text;
    var scene = new THREE.Scene();
    var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

    var renderer = new THREE.WebGLRenderer({antialias: true});
    renderer.setSize(window.innerWidth, window.innerHeight );
    renderer.setClearColor(0xCCCCCC);
    document.body.appendChild(renderer.domElement);

    var controls = new THREE.OrbitControls(camera, renderer.domElement);

    var light = new THREE.PointLight(0xFFFFFF, 1, 100);
    light.position.set(1, 0, 50);

    var loader = new THREE.FontLoader();
    loader.load('Fonts/helvetiker_regular.typeface.js', function (response) {
         var textGeometry = new TextGeometry('Hello', {
            font:font,
            size: 80,
            height: 10
        });
    });


    var textMaterial = new THREE.MeshLambertMaterial({color:0xFF00FF});
    var textMesh = new THREE.Mesh(textGeometry, textMaterial);
    scene.add(textMesh, light);
    camera.position.z = 20;

    renderer.render(scene, camera);

    function update() {
        requestAnimationFrame(update);
        renderer.render(scene, camera);
    }
    update();

我希望代码能渲染出文本,但事实并非如此

0 个答案:

没有答案