Research on Lightweight Method of Ancient Building Information Model Based on WebGL

. Aiming at the large amount of component data in the 3D dynamic display of the ancient building BIM model, which caused difficulties in information exchange during the protection of the ancient building, a lightweight method of the ancient building BIM model combining with WebGL and IFC standards was proposed. Using WebGL technology to extend the 3D visualization method of BIM models of ancient buildings, providing new technical support for the protection and research of ancient buildings. First define the JSON intermediate file, design the Revit-JSON data interface, make the model support .html and .js format, and improve the visual display method of the web side; use JavaScript to directly call the JSON interactive program of the underlying GPU to improve the web-side rendering effect of the model; Three.js framework realizes the display and interaction of 3D models of ancient buildings on the Web. Taking a typical ancient building as an example to carry out experiments, the method in this paper can reduce the storage volume by more than 70% on the basis of ensuring that the model information is complete, and has a good rendering effect in the browser. The experimental results verify the effectiveness and feasibility of the method.


Introduction
Ancient architecture is an important part of traditional historical culture, a witness to history, and a carrier of culture. However, a large amount of scattered information remains in ancient buildings, and communication between different information storage methods is difficult. In the information age today, we urgently need to carry out optimization combing [1] .
There are many domestic and foreign studies on BIM. Wang Ru et al. used graphic database to store data and related information of ancient buildings, and built an information model of ancient buildings in Ming and Qing Dynasties based on BIM Technology [2] .Xu Zhao et al. Proposed a research analysis method of building information model visualization based on WebGL and IFC [3] . At present, there are few researches on the combination of BIM technology and WebG L technology. The existing research focuses only on the application of WebG L technology itself [4][5] , ignoring the interactive function of BIM model. At the same time, the IFC standard is widely used in the data exchange format research of building information models [6][7] . This paper is mainly to realize the visualization of BIM models of ancient buildings on the Web and to provide new technical means for the protection of ancient buildings. The visualization of BIM model of ancient buildings mainly includes two aspects: model file conversion and model re-interaction on the web side. Extract the triangle patches of the model. Extract the normal data of the model. Extract the material and texture of the model. The design of the process of extracting data from the BIM model is shown in Figure 1:

Presentation of BIM model of historic building based on WebGL
Presentation of BIM model of historic building based on WebGL mainly divides into two parts: reconstruction and interaction on the Web terminal, This section requires the use of WebGL technology.

Process of the presentation of model reconstruction.
Choose Three.js program block to proceed web refactoring for 3D model of historic building after demand analysis of 3D presentation of performance and functionality of historic building on web internal and deep analysis of all WebGL frames.
When using three.js for development, you need to use the renderer, the scene, the object to be displayed, and the camera. When rendering three-dimensional models with Three.js, first create a Scene Scene to store other model data. Use JavaScript's asynchronous instructions on the browser to call the JS object notation, parse the geometric attributes and collocations existing in the 3D model established, and output them to the Geometry file. Finally, a discrete model is generated and loaded into the scene object so that it can be rendered on the web page.

Design of the interaction process of the model.
The most important part of this function is the model picking, which mainly includes the bounding box algorithm and the ray intersection algorithm, which is to obtain the two-dimensional coordinates of the point by clicking the mouse. The two-dimensional coordinates of T (x,y) are obtained by a series of inverse transformations of the rendering pipeline and projected into the 3d scene to form a ray. Then the component elements intersecting the ray and the 3d model are the elements to be acquired by clicking the mouse. After obtaining the corresponding two-dimensional coordinates, the depth of z-axis is set as 0.5 for the convenience of calculation. Then, the conversion formula for converting the two-dimensional coordinates to the projection space coordinates is The matrix transformation is carried out in formula 2-1, and the transformation matrix obtained is as follows  3 Analysis and presentation of case.
In order to verify the practical application effect of the historical building lightweighting method based on WebGL BIM model proposed in this paper, the lightweight testing of the typical ancient building BIM model was carried out. The display in the browser when no material texture is added is shown in Figure 4. Import model materials and surface treatment information, add background to the scene, and render the completed image in the browser as shown in Figure 5. At the same time, in order to verify the effectiveness of the method, the method was compared with the traditional custom memory parser to test the parsing speed of IFC data files and the size before and after the conversion of the storage format. Select three sets of highly representative historical building models for lightweight processing. Table 1 shows the document size before and after model processing, and Figure 6 shows the document parsing time. The experimental results show that the BIM of the ancient building is effectively displayed on the Wed side and the components can be selected and interacted with, and it is completely consistent with the original BIM model data information.

Conclusion
This article uses the Revit application programming interface to make the BIM model data of ancient buildings compatible on the web page. Realize the conversion of Revit model data file format, effectively improve the efficiency of IFC data file parsing; use Three.js module to parse the intermediate file to realize the operation of 3D model rendering and reconstruction in the browser, and complete the query of model attributes, etc. The interactive function finally achieved the lightweight of the BIM model and efficient browsing on the Web side. Applying this method to the protection of ancient buildings greatly improves the efficiency and accuracy of work. Finally, the validity of this research method and good development prospects are verified by an example. It is hoped that in the subsequent work, the rendering efficiency of large scenes and the display effect on the Web can be optimized.