An example of Loading Large Games with TWaver and an example of twaver
In games, there are often some large outdoor scenarios, such as a small town or an ancient city. Generally, this type of scenario contains many elements such as buildings, roads, and bridges. the 3D model is large and complex. When loading with TWaver, you can use some tips to make loading faster and display smoother.
TWaver 3D supports importing 3D scenes in json or obj format. If it is in obj format, you can upload the obj file, mtl file, and all texture files as string parameters to TWaver for loading. Of course, these files can also be URL strings on the network.
?
12 |
var loader = new mono.OBJMTLLoader(); loader.load(obj, mtl, images); |
TWaver supports further processing of each object during loading. For example, material textures and features. The following code forces each loaded object to be displayed in white mode:
?
123456 |
var loader = new mono.OBJMTLLoader(); loader.load(obj, mtl, images, function (object) { box.addByDescendant(object); box.forEach( function (element){ element.setStyle( 'm.texture.image' , null ); }); |
Alternatively, you can directly use wireframe to ignore the object surface and directly display the line shape of the object:
?
123456 |
var loader = new mono.OBJMTLLoader(); loader.load(obj, mtl, images, function (object) { box.addByDescendant(object); box.forEach( function (element){ element.setStyle( 'm.wireframe' , true ); }); |
The obj file exceeds 16 MB, and the TWaver parsing process cannot exceed 5 seconds. However, in practical applications, resource files may exist on the network, and network transmission takes some time. You can compress obj files or json files to accelerate transmission efficiency. You can also reduce the accuracy of materials. After the scene is displayed, you can load the texture with high precision or dynamically change the texture as needed.