Code Examples - Prograf-UFF/che.js GitHub Wiki

Here you can find some examples of how to initialize and use che.js

Basic mesh loading.

import Che from '@che.js/che.js';
import fs from 'fs'

//Load ply file

let plyFile = fs.readFileSync('sphere.ply', 'utf-8');

let cheMesh = new Che()

cheMesh.loadPly(plyFile).then(() => {
  //do whatever you want
})

Performance comparison of relation00 in multiple levels

cheMesh.loadPly(plyFile).then(() => {
  let start = performance.now()
  let vertexStarOfVertex3 = cheMesh.relation00(3);
  let end = performance.now()
  console.log(`L0 R00: ${end - start}`)
  console.log(vertexStarOfVertex3);

  cheMesh.loadCheL1();
  start = performance.now()
  vertexStarOfVertex3 = cheMesh.relation00(3);
  end = performance.now()
  console.log(`L1 R00: ${end - start}`)
  console.log(vertexStarOfVertex3);


  cheMesh.loadCheL2();
  start = performance.now()
  vertexStarOfVertex3 = cheMesh.relation00(3);
  end = performance.now()
  console.log(`L2 R00: ${end - start}`)
  console.log(vertexStarOfVertex3);
})

Finding the triangles adjacent to triangle 3 of the mesh, using level 1 of CHE.

  cheMesh.loadPly(plyFile).then(() => {
  cheMesh.loadCheL1();
  let triangleStarOfTriangle = cheMesh.relation22(3);
  console.log(triangleStarOfTriangle);
})