1
我正在致力於ThreeJS geometry canvas text。在單擊html按鈕後,文本會變爲另一個文本。但是,它不起作用。如何在點擊事件中更改TextGeometry?Javascript:如何更改點擊事件的TextGeometry?
這裏是我的工作:
var theText = "Hello three.js! :)";
var hash = document.location.hash.substr(1);
if (hash.length !== 0) {
theText = hash;
}
var geometry = new THREE.TextGeometry(theText, {
font: font,
size: 80,
height: 20,
curveSegments: 2
});
geometry.computeBoundingBox();
var centerOffset = -0.5 * (geometry.boundingBox.max.x - geometry.boundingBox.min.x);
var material = new THREE.MultiMaterial([
new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff, overdraw: 0.5 }),
new THREE.MeshBasicMaterial({ color: 0x000000, overdraw: 0.5 })
]);
var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = centerOffset;
mesh.position.y = 100;
mesh.position.z = 0;
mesh.rotation.x = 0;
mesh.rotation.y = Math.PI * 2;
group = new THREE.Group();
group.add(mesh);
scene.add(group);
}
$('.button').on('click', function(e){
theText.dispose();
var menu= new Array('option1', 'option2', 'option3');
theText=menu;
});