projectVertex method

void projectVertex(
  1. RenderableVertex vertex
)

Implementation

void projectVertex(RenderableVertex vertex) {
  Vector3 position = vertex.position;
  Vector3 positionWorld = vertex.positionWorld;
  Vector4 positionScreen = vertex.positionScreen;
  positionWorld.copy(position).applyMatrix4(_modelMatrix);
  positionScreen.copyFromVector3(positionWorld).applyMatrix4(_viewProjectionMatrix);
  double invW = 1 / positionScreen.w;
  positionScreen.x *= invW;
  positionScreen.y *= invW;
  positionScreen.z *= invW;
  vertex.visible = positionScreen.x >= -1 &&
      positionScreen.x <= 1 &&
      positionScreen.y >= -1 &&
      positionScreen.y <= 1 &&
      positionScreen.z >= -1 &&
      positionScreen.z <= 1;
}