Home > front end >  Three. Js loading large OBJ model memory footprint
Three. Js loading large OBJ model memory footprint

Time:10-20

I use the following code to load a obj model (1 gb), load not only shows that the whole loading process was conducted in closure, why are large load memory back? Don't run out, the closure function memory should fall?
 


<meta charset="utf-8" & gt;
Title

<body>

The import * as THREE from '../build/three. The module. Js';
Import {MTLLoader} from "./JMS/loaders/MTLLoader js ";
Import {OBJLoader2} from "./JMS/loaders/OBJLoader2 js ";
Import from {MtlObjBridge} "./JMS/loaders/obj2/bridge/MtlObjBridge js ";
(function () {
Let objLoader2=new objLoader2 ();
Let the request=null;
Let callbackOnLoad=function (object3d) {

Let the axis=new THREE. Vector3 (1, 0, 0).//vector axis
Object3d. RotateOnAxis (axis, Math. PI/2);
The console. The log (' Loading complete: test ');
The console. The log (" cache ", THREE. Cache. Files).
The console. The log (" contentRef, "objLoader2. Parser. ContentRef);
Request=null;
};
Let mtlLoader=new mtlLoader ();
Let onl oadMtl=function (mtlParseResult) {

ObjLoader2. SetModelName (" modelName ");
ObjLoader2. SetLogging (true, true);
ObjLoader2. AddMaterials (MtlObjBridge addMaterialsFromMtlLoader (mtlParseResult), true);
Request=objLoader2. Load (' test_model/test2. Obj, callbackOnLoad, null, null, null);
MtlLoader=null;

};
MtlLoader. Load (' test_model/test2. MTL, onl oadMtl);
}) ();
</script>



This is the memory of the Chrome task manager shows that "TAB page Title" is the result of the above code to run, memory accounted for almost 2 g

  • Related