3 .js meshBasicMaterial颜色无法识别
three.js meshBasicMaterial color not recognized
这是我渲染一个红色网格(十六进制:0xff0000)到场景的代码。但我的每一次尝试都失败了。我只看到一个黑色的网。如果我把颜色改为蓝色或绿色,效果很好。
<script>
this.initScene = function() {
this.renderer.setSize(innerWidth, innerHeight);
this.renderer.setClearColor(0xd9dadd);
document.getElementById('webgl-container').
appendChild(this.renderer.domElement);
document.addEventListener('mousedown', this.onDocumentMouseDown, false);
document.addEventListener('mousemove', this.onmousemove, false);
document.addEventListener('mouseup', this.onDocumentMouseUp, false);
this.light = new THREE.AmbientLight(0xffffff);
this.camera = new THREE.PerspectiveCamera(75,
(innerWidth) / innerHeight,
1,
1000
);
this.camera.lookAt(this.scene.position);
this.camera.position.z = 8;
this.scene.add(this.camera);
this.scene.add(this.light);
this.plane = new THREE.Mesh(
new THREE.PlaneBufferGeometry(1000, 1000, 8,8),
new THREE.MeshBasicMaterial({color: 0xffffff, visible: false}));
this.plane.name = 'plane';
this.scene.add(this.plane);
this.render();
}
this.newActor = function() {
this.dynamicTexture = new THREEx.DynamicTexture(512, 512);
this.dynamicTexture.context.font = "bolder 110px Verdana";
//this.dynamicTexture.texture.anisotropy = this.renderer.getMaxAnisotropy();
this.dynamicTexture.clear('cyan');
this.dynamicTexture.drawText('this.id', undefined, 256, 'black');
var box = new THREE.Mesh(
new THREE.BoxGeometry(0.8, 0.8, 0),
new THREE.MeshBasicMaterial({
color: 0xff0000,
map :this.dynamicTexture.texture})
);
}
</script>
在three.js中,material.map
被material.color
着色。
在您的例子中,地图的颜色是青色(0x00ffff
),并且您已将材料颜色设置为红色(0xff0000
)。
青色仅在绿色和蓝色通道中具有颜色强度,而红色在这些通道中没有任何颜色强度。因此,最后的颜色是黑色。
在大多数情况下,当给一个材质分配贴图时,你会想让材质的颜色保持默认的白色。
three.js r.80
相关文章:
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何识别我的网站中的慢速设备
- 高亮显示时编辑文本大小和颜色
- Google/html5语音识别JavaScript SDK Chrome网络工具包SpeechRecognition
- 用与线条相同的颜色填充多折线图上的点
- 更改使用Chart.js创建的图表中的轴线颜色
- 如何使用jquery更改html中的背景颜色
- 动态更改高图中的系列颜色
- AngularJS指令只识别双向绑定类型
- php脚本中无法识别ajax传递的值
- jsf中两个字符串的颜色代码差异
- 识别没有ID或特定属性的对象
- 我们如何使用css或JavaScript在i/j上更改句点(点)的颜色
- d3.hexbin插件-动态定义颜色域以适应数据
- JavaScript无法识别图像
- 我如何制作一个JS函数,它可以从相似的原始颜色双向更改为某个颜色
- 如何在 Javascript 中识别颜色
- 语法错误,无法识别的表达式/ASP.NET/颜色框
- Javascript中的颜色猜测反复给出“无法识别颜色”错误
- 3 .js meshBasicMaterial颜色无法识别