2016-05-01 9 views
0

AxisHelperで回転するラベルを追加したいと思います。このlinkから、私はこのスニペットコードを使用:Three.js - AxisHelperにラベルを追加する - 四肢の頂点を取得できない

// Axes 
    axes2 = new THREE.AxisHelper(70); 

    // Axes labels 
    addLabelAxes(); 

    // Add axes to zoomScene 
    zoomScene.add(axes2); 


function addLabelAxes() { 

    // Axes label 
    var loader = new THREE.FontLoader(); 
    loader.load('js/helvetiker_regular.typeface.js', function (font) { 

    textGeo = new THREE.TextGeometry('Example label', { 
    font: font, 
    size: 15, 
     height: 5, 
    curveSegments: 10, 
    }); 

    var color = new THREE.Color(); 
    color.setRGB(255, 0, 0); 
    textMaterial = new THREE.MeshBasicMaterial({ color: color }); 
    meshText = new THREE.Mesh(textGeo, textMaterial); 

    // Position of first axis 
    meshText.position.x = axes2.geometry.vertices[1].x; 
    meshText.position.y = axes2.geometry.vertices[1].y; 
    meshText.position.z = axes2.geometry.vertices[1].z; 

    meshText.rotation = zoomCamera.rotation; 
    zoomScene.add(meshText); 

    }); 

をしかし、私は、コンソールログに次のエラーを取得する:

TypeError: axes2.geometry.vertices is undefined 
addLabelAxes/<() 
sphere_dev.js:230 
THREE.FontLoader.prototype.load/<() 
three.min.js:382 
THREE.XHRLoader.prototype.load/<() 

誰かが一目で間違っているものを見ることができれば、これはいいだろう。 AxisHelper

おかげ

答えて

0

形状はタイプBufferGeometryの、ないタイプGeometryです。

あなたはそうのようなAxisHelperのジオメトリの位置要素にアクセスすることができます。

var axes = new THREE.AxisHelper(20); 

var position = axes.geometry.attributes.position; 

positionBufferAttributeです。その内容を勉強すれば、その構造ははっきりしているはずです。

あなたは、このようなパターンを使用して属性の要素にアクセスすることができます。

var x = position.getX(index); // or getY, getZ 

+0

r.76 three.jsおかげで、それは働きます! – youpilat13