简体   繁体   中英

Will Exporting Meshes in Three.js Improve Performance?

So I am working on a Three.js project and the program seems to lag in some places. Specifically, the most performance lag occurs when rendering the text Meshes I have created like so:

var text1Geo = new THREE.TextGeometry("Hello", {font: font});
text1Mesh = new THREE.Mesh(text1Geo, textMaterial);
text1Mesh.position.set(-6500, 150, -500);
text1Mesh.castShadow = true;
scene.add(text1Mesh);

I am wondering if it would improve performance if I exported the text as an obj using the OBJExporter and then instead of creating a THREE.TextGeometry I could just load the mesh into the scene using an OBJLoader. Would this improve the performance. If you would like to see the entire project and source code please go here . Any other tips or advice on how to improve performance is much appreciated. Thanks!

No.

An experiment is still in order, but the answer is to cache the text geometry.

Instead of having something like

loadText( 'url.obj' , (t)=>{ /*...do stuff...*/});

you can have

computeText(){ 
  var t = new THREE.TextGeometry();
  ...
}

computeText();
//...do stuff...

My assumption is that obj is unfriendly when it comes to parsing, but i might be wrong. A formatted json would perhaps be better, or binary.

So, instead of downloading an .obj, parsing it, indexing, and then doing something, just compute it before you start rendering.

You'd most likely experience lag nonetheless when this thing hits the gpu, be it computed or downloaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM