compile method

void compile(
  1. Object3D scene,
  2. Camera camera
)

Implementation

void compile(Object3D scene, Camera camera) {
  currentRenderState = renderStates.get(scene);
  currentRenderState!.init();

  renderStateStack.add(currentRenderState!);

  scene.traverseVisible((object) {
    if (object is Light && object.layers.test(camera.layers)) {
      currentRenderState!.pushLight(object);

      if (object.castShadow) {
        currentRenderState!.pushShadow(object);
      }
    }
  });

  currentRenderState!.setupLights(physicallyCorrectLights);

  scene.traverse((object) {
    var material = object.material;

    if (material != null) {
      if (material is List) {
        for (var i = 0; i < material.length; i++) {
          var material2 = material[i];

          getProgram(material2, scene, object);
        }
      } else {
        getProgram(material, scene, object);
      }
    }
  });

  renderStateStack.removeLast();
  currentRenderState = null;
}