I want to disable lighting entirely in three.js, and render a 3D object. 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归因
不隶属于 StackOverflow
scroll top