Exemplo n.º 1
0
    convertToStaticMesh: function (mesh) {
      if (!mesh.isDynamic) // already static
        return mesh;

      // dynamic to static mesh
      var newMesh = new MeshStatic(mesh.getGL());
      newMesh.setID(mesh.getID());
      newMesh.setTransformData(mesh.getTransformData());
      newMesh.setVertices(mesh.getVertices().subarray(0, mesh.getNbVertices() * 3));
      newMesh.setColors(mesh.getColors().subarray(0, mesh.getNbVertices() * 3));
      newMesh.setMaterials(mesh.getMaterials().subarray(0, mesh.getNbVertices() * 3));
      newMesh.setFaces(mesh.getFaces().subarray(0, mesh.getNbFaces() * 4));
      newMesh.init();
      newMesh.setRenderData(mesh.getRenderData());
      newMesh.initRender();
      return newMesh;
    },
Exemplo n.º 2
0
var createMesh = function (mesh, vertices, faces, colors, materials) {
  var newMesh = new MeshStatic();
  newMesh.setID(mesh.getID());
  newMesh.setVertices(vertices);
  if (colors) newMesh.setColors(colors);
  if (materials) newMesh.setMaterials(materials);
  newMesh.setFaces(faces);

  // small hack
  newMesh.setTransformData(mesh.getTransformData());
  newMesh.setRenderData(mesh.getRenderData());

  Mesh.OPTIMIZE = false;
  newMesh.init();
  Mesh.OPTIMIZE = true;

  return newMesh;
};