在我的代码中,我定义了一个圆圈:
var material1 = new THREE.LineBasicMaterial( { color: 0x000000, opacity: contentionopacity} );
scene.add(circle);
var resolution1 = 100;
var amplitude1 = 60;
var size1 = 360 / resolution1;
geometry1 = new THREE.Geometry();
for(var i = 0; i <= resolution1; i++) {
var segment1 = ( i * size1 ) * Math.PI / 180;
geometry1.vertices.push(new THREE.Vertex(
new THREE.Vector3(
(Math.cos(segment1) * amplitude1) ,
400,
(Math.sin(segment1) * amplitude1) -100 )
)
);
}
feetcircle = new THREE.Line( geometry1, material1 );
scene.add(feetcircle)
在我使用'contentionopacity'定义不透明度的部分。
问题是......是否仍有可能在渲染时,我可以改变它的不透明度(因此通过“按下按钮”使其显得/消失?:
'渲染部分':
if (circleX1 == undefined) circleX1 = (neckcoords[0][1] -100 )//( ((neckcoords[0][1])-305) * Math.cos(rad) - (neckcoords[0][2] * Math.sin(rad)) ) +330 ;
if (circleY1 == undefined) circleY1 = (neckcoords[0][2] -530) //( neckcoords[0][2] * Math.cos(rad) + neckcoords[0][1] * Math.sin(rad) ) ;
// if (circleZ1 == undefined) circleZ1 = ( neckcoords[0][0] -90) ;
for(var i = 0; i <= 100; i++) {
feetcircle.geometry.vertices[i].x += (neckcoords[0][1] - circleX1 ) //(neckcoords[0][1] * Math.cos(rad) - neckcoords[0][2] * Math.sin(rad)) - circleX ;
feetcircle.geometry.vertices[i].z += ( neckcoords[0][2] - circleY1) //- ( neckcoords[0][2] * Math.cos(rad) + neckcoords[0][1] * Math.sin(rad) - circleY);
//feetcircle.geometry.vertices[i].y += ( neckcoords[0][0] - circleZ1);
}
circleX1 = neckcoords[0][1] //* Math.cos(rad) - neckcoords[0][2] * Math.sin(rad) ;
circleY1 = neckcoords[0][2] //* Math.cos(rad) + neckcoords[0][1] * Math.sin(rad);
//circleZ1 = neckcoords[0][0] //* Math.cos(rad) + neckcoords[0][0] * Math.sin(rad);
feetcircle.geometry.verticesNeedUpdate = true;
'按下按钮':
document.addEventListener('keypress', function (e) {
if (e.keyCode == '17') { contentionopacity=contentionopacity+0.1}
console.log(contentionopacity)
},
false)
document.addEventListener('keypress', function (e) {
if (e.keyCode == '61') { contentionopacity=contentionopacity-0.1}
console.log(contentionopacity)
},
false)
目前,控制台日志显示'contentionopacity'越来越高,但它根本不会改变圆圈的不透明度。
提前致谢!