简体   繁体   English

Three.js禁用照明

[英]Three.js disable lighting

I want to disable lighting entirely in three.js, and render a 3D object. 我想完全禁用three.js中的照明,并渲染3D对象。 Currently, since lighting is active in some form, the object appears completely black. 当前,由于照明以某种形式处于活动状态,因此该对象看起来完全是黑色的。 I have no calls to any sort of lighting currently in my program, and I have been unable to find a solution with searching. 我的程序中目前没有任何照明的呼叫,并且无法通过搜索找到解决方案。

Edit: Code 编辑:代码

var white = 0xFFFFFF;

var facemat = new THREE.MeshBasicMaterial( { color: white, opacity: 1.0, shading: THREE.FlatShading } );

vrmlLoader.addEventListener('load', function ( event ) {
    var object = event.content;
    object.material = facemat;
    scene.add(object);
});

vrmlLoader.load("ship.wrl");

My questions for this particular post have mostly been answered. 我对这个特定职位的问题已基本得到回答。 If I am to ask more I will drive this post off topic. 如果我想问更多,我将把这个话题排除在外。

Shading / lighting take care of drawing an object in such a way that you can perceive its depth . 阴影/照明会以可以感知物体深度的方式进行绘制。 In your example picture, shading is disabled - there is no depth, the object is the same everywhere - you cannot differentiate parts of it. 在示例图片中,阴影被禁用-没有深度,对象到处都是相同的-您无法区分部分阴影。

Now, it should be pretty obvious that you can't draw stuff without colour - just like you can't draw on a piece of paper without pencils or any other tool. 现在,很明显,没有颜色就不能画东西-就像没有铅笔或任何其他工具就不能在纸上画画一样。 What you are seeing is simply your object drawn with black colour. 您所看到的只是用黑色绘制的对象。 What you want to see is your object drawn in white, which is almost the same but if you do that currently, you'll see nothing since your background is white! 您想要看到的是用白色绘制的对象,这几乎是相同的,但是如果当前执行此操作,则由于背景是白色,您将看不到任何东西!

Anyway, after those clarifications, here is a how-to: 无论如何,经过这些澄清之后,这里有一个方法:

  1. Change the background colour of your renderer to white: 将渲染器的背景颜色更改为白色:

    renderer.setClearColor(0, 1)

  2. Change the colour of your object by changing its material: 通过更改其材质来更改对象的颜色:

    object.material = new THREE.MeshBasicMaterial(0xFFFFFF)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM