renderObject method

void renderObject(
  1. Object3D object,
  2. Camera camera,
  3. Camera shadowCamera,
  4. Light light,
  5. int type,
)

Implementation

void renderObject(Object3D object, Camera camera, Camera shadowCamera,
    Light light, int type) {
  if (object.visible == false) return;

  var visible = object.layers.test(camera.layers);

  if (visible && (object is Mesh || object is Line || object is Points)) {
    if ((object.castShadow ||
            (object.receiveShadow && type == VSMShadowMap)) &&
        (!object.frustumCulled || _frustum.intersectsObject(object))) {
      object.modelViewMatrix.multiplyMatrices(
          shadowCamera.matrixWorldInverse, object.matrixWorld);

      var geometry = _objects.update(object);
      var material = object.material;

      if (material is List) {
        var groups = geometry.groups;

        for (var k = 0, kl = groups.length; k < kl; k++) {
          var group = groups[k];
          var groupMaterial = material[group["materialIndex"]];

          if (groupMaterial != null && groupMaterial.visible) {
            var depthMaterial = getDepthMaterial(object, groupMaterial, light,
                shadowCamera.near, shadowCamera.far, type);

            _renderer.renderBufferDirect(
                shadowCamera, null, geometry, depthMaterial, object, group);
          }
        }
      } else if (material.visible) {
        var depthMaterial = getDepthMaterial(object, material, light,
            shadowCamera.near, shadowCamera.far, type);

        // print("WebGLShadowMap object: ${object} light: ${light} depthMaterial: ${depthMaterial} ");

        _renderer.renderBufferDirect(
            shadowCamera, null, geometry, depthMaterial, object, null);
      }
    }
  }

  var children = object.children;

  for (var i = 0, l = children.length; i < l; i++) {
    renderObject(children[i], camera, shadowCamera, light, type);
  }
}