Exemple #1
0
 public Vector3 unprojectVector(Vector3 vector, Camera camera) {
   camera.projectionMatrix.getInverse(camera.projectionMatrix);
   viewProjectionMatrix.multiplyMatrices(camera.matrixWorld, camera.projectionMatrixInverse);
   return vector.applyProjection(viewProjectionMatrix);
 }
Exemple #2
0
  private void projectObject(Object3D parent) {

    for (Object3D object : parent.children) {

      if (object.visible == false) continue;

      if (object instanceof Light) {

        renderData.lights.add((Light) object);

      } else if (object instanceof Mesh || object instanceof Line) {

        if (object.frustumCulled == false || frustum.intersectObject(object) == true) {

          this.object = getNextObjectInPool();
          this.object.object = object; // TODO fix casting here.

          if (object.renderDepth != Float.NaN) {

            this.object.z = object.renderDepth;

          } else {

            vector3.getPositionFromMatrix(object.matrixWorld);
            vector3.applyProjection(viewProjectionMatrix);
            this.object.z = vector3.z;
          }

          renderData.objects.add(this.object);
        }

      } else if (object instanceof Sprite || object instanceof Particle) {

        this.object = getNextObjectInPool();
        this.object.object = object;

        if (object.renderDepth != Float.NaN) {

          this.object.z = object.renderDepth;

        } else {

          vector3.getPositionFromMatrix(object.matrixWorld);
          vector3.applyProjection(viewProjectionMatrix);
          this.object.z = vector3.z;
        }

        renderData.sprites.add(this.object);

      } else {

        this.object = getNextObjectInPool();
        this.object.object = object;

        if (object.renderDepth != Float.NaN) {

          this.object.z = object.renderDepth;

        } else {

          vector3.getPositionFromMatrix(object.matrixWorld);
          vector3.applyProjection(viewProjectionMatrix);
          this.object.z = vector3.z;
        }
      }
    }

    projectObject(object);
  }