projectObject method
Implementation
void projectObject(Object3D object, Camera camera, int groupOrder, bool sortObjects) {
if (object.visible == false) return;
bool visible = object.layers.test(camera.layers);
if (visible) {
if (object is Group || object.type == "AnimationObject") {
groupOrder = object.renderOrder;
}
else if (object is LOD) {
dynamic u = object;
if (object.autoUpdate == true) u.update(camera);
}
else if (object is Light) {
currentRenderState!.pushLight(object);
if (object.castShadow) {
currentRenderState!.pushShadow(object);
}
}
else if (object is Sprite) {
if (!object.frustumCulled || _frustum.intersectsSprite(object)) {
if (sortObjects) {
_vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(projScreenMatrix);
}
BufferGeometry geometry = objects.update(object);
final material = object.material;
if (material != null && material.visible) {
currentRenderList!.push(object, geometry, material, groupOrder, _vector3.z, null);
}
}
}
else if (object is Mesh || object is Line || object is Points) {
if (object is SkinnedMesh) {
// update skeleton only once in a frame
if (object.skeleton?.frame != info.render["frame"]) {
object.skeleton?.update();
object.skeleton?.frame = info.render["frame"]!;
}
}
// print("object: ${object.type} ${!object.frustumCulled} ${_frustum.intersectsObject(object)} ");
if (!object.frustumCulled || _frustum.intersectsObject(object)) {
if (sortObjects) {
_vector3..setFromMatrixPosition(object.matrixWorld)..applyMatrix4(projScreenMatrix);
}
final geometry = objects.update(object);
final material = object.material;
if (material is GroupMaterial) {
final groups = geometry.groups;
if (groups.isNotEmpty) {
for (int i = 0; i < groups.length; i++) {
Map<String, dynamic> group = groups[i];
if(group["materialIndex"] < material.children.length){
final groupMaterial = material.children[group["materialIndex"]];
if (groupMaterial.visible) {
currentRenderList!.push(object, geometry, groupMaterial, groupOrder, _vector3.z, group);
}
}
}
}
else {
for (final mat in material.children) {
if (material.visible) {
currentRenderList!.push(object, geometry, mat, groupOrder, _vector3.z, null);
}
}
}
}
else if (material != null && material.visible) {
currentRenderList!.push(object, geometry, material, groupOrder, _vector3.z, null);
}
}
}
}
final children = object.children;
for (int i = 0, l = children.length; i < l; i++) {
projectObject(children[i], camera, groupOrder, sortObjects);
}
}