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) {
    final material = object.material;

    if (material != null) {
      if (material is GroupMaterial) {
        for (final material2 in material.children) {
          getProgram(material2, scene, object);
        }
      }
      else {
        getProgram(material, scene, object);
      }
    }
  });

  renderStateStack.removeLast();
  currentRenderState = null;
}