Three-dimensional earth display method and system based on quadtree structure of threejs
By adopting a three-dimensional earth system with three-dimensional quad-tree structure based on Threejs, the problems of unclear structure, complex tile node management, and clumsy LOD implementation in the existing technology are solved, and efficient LOD functions and performance improvements are achieved.
Patent Information
- Application Number
- CN202411549513.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-11-01
AI Technical Summary
The existing three-dimensional earth system built on WEBGL and Threejs has problems such as unclear structure, complex tile node state management, clumsy LOD implementation, large computing, and affecting performance and user experience.
Using the quad-tree structure based on Threejs, a clear map structure model is built, and the Level of Detail (LOD) function is realized through the splitting and merging of quad-tree nodes, optimize the management of tile nodes, and reduce the amount of calculation.
It realizes more efficient LOD functions, simplifies the management of tile nodes, reduces the amount of computing, improves system performance and user experience, and facilitates the expansion and maintenance of program functions.
Smart Images

Figure CN119478267A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of geographic information technology, and in particular to a method and system for displaying a three-dimensional earth based on a threejs quadtree structure. Background Art
[0002] In virtual 3D earth systems and GIS-based digital twin platforms, the display of 3D earth is one of the core functions. These systems usually rely on WEBGL underlying technology to build and render 3D earth models. Triangular meshes are widely used as the basic elements for building 3D models because they are simple, effective and universal in various systems. Triangular meshes are composed of triangles and can carry vector information to represent the front and back sides of objects. They also support texture mapping, so that complex earth surface features can be presented by mapping image data. In addition, the calculation of model appearance, such as highlights and shadows, also depends on the fine division of triangular meshes and the accurate calculation of light incidence angles.
[0003] As a mature WEBGL development framework, Threejs provides strong support for the development of various 3D applications. However, in the existing technology, the three-dimensional earth system built based on WEBGL and Threejs still has some significant problems. First, the unclear structure caused by the underlying language development makes the state management of tile nodes complicated and difficult. Second, for non-computer professionals, the expansion and maintenance of program functions become particularly difficult. Third, when implementing Level of Detail (LOD), the existing methods are often clumsy, the visual effect is not good when switching levels, and the calculation is large, which affects the system performance and user experience.
[0004] In view of the above problems, the present invention proposes a method and system for three-dimensional earth display based on a quadtree structure of threejs; it aims to optimize the management of tile nodes by constructing a clear quadtree structure, and at the same time realize a more efficient LOD function, so as to solve the technical problems of large amount of calculation, difficult tile node management and unclear structure in the prior art; through the implementation of the present invention, it can be expected that the system performance and user experience can be improved while maintaining high-precision display of the three-dimensional earth. Summary of the invention
[0005] In order to overcome the problems of unclear structure, in the virtual three-dimensional earth system and digital twin GIS platform, the underlying language development based on WEBGL is not conducive to the management of tile node status, nor to the subsequent expansion of program functions by non-computer professionals. In addition, the way to implement Lovel of detail is clumsy, the visual effect is poor when switching levels, and the amount of calculation is large.
[0006] The technical solution of the present invention is: a method for displaying a three-dimensional earth based on a quadtree structure of threejs, first constructing a quadtree node, and then calculating a corresponding grid model of the earth surface according to tile row and column numbers and hierarchical data; comprising the following steps:
[0007] S101: constructing quadtree nodes corresponding to the hierarchical structure of tiles one by one;
[0008] S102: Calculate the latitude and longitude ranges corresponding to the tile geometry managed by the node according to the tile row and column numbers and the level;
[0009] S103: Divide the longitude and latitude corresponding to the tile geometry into a plurality of equal arc ranges, and calculate the coordinates of each point of the geometry on the unit sphere according to the corresponding arcs;
[0010] S104: Calculate the coordinate points of the actual three-dimensional earth in the WGS84 coordinate system according to the coordinates of the geometric body on the unit sphere;
[0011] S105: Calculate the corresponding UV coordinate value according to the actual coordinate point in the geometric body;
[0012] S106: According to the distance from the camera to each tile model, select node splitting of the quadtree structure and merging of leaf nodes, thereby realizing the Level of detail function;
[0013] S107: Display the three-dimensional earth model on the system and display the corresponding tile detail level.
[0014] Preferably, the threejs is an open source WEBGL framework, which provides 3D graphics rendering functions through threejs; the material, texture, mesh and camera functions of threejs are used to create and render a three-dimensional earth model; the mesh model of the earth's surface is created through the Mesh class of threejs, and the ShaderMaterial and MeshBasicMaterial material classes are used to add texture and color to the mesh model, and the tile image is loaded as a texture through the TextureLoader class, and finally the three-dimensional earth model is added to the threejs scene and rendered through the renderer.
[0015] Preferably, a quadtree structure is specifically as follows: there is only one root node, and each non-leaf node has four child nodes; wherein, when constructing the quadtree structure, starting from the root node, child nodes are recursively created according to the level and row and column numbers of the tiles; each non-leaf node contains references to its four child nodes (upper left, upper right, lower left, and lower right); the node data structure contains the node's level, row and column number, and a reference to the corresponding tile geometry.
[0016] Preferably, quadtree nodes are constructed to correspond one-to-one with the hierarchical structure of tiles, specifically: each node has a row and column number and a level attribute; each node corresponds to a unique tile; wherein, when creating a quadtree node, a unique identifier is assigned to each node, and its row and column number and level attribute are set; and tile geometry is associated with the corresponding quadtree node according to the level and row and column number of the tile.
[0017] Preferably, the longitude and latitude limits corresponding to the tile geometry managed by the node are calculated according to the tile row and column numbers and the level, specifically: the width of the corresponding tile at the node level is calculated by the level attributes; the four limits of the tile are calculated by the row and column numbers and the tile width; wherein, the width of the tile is calculated using the plane map width and the current level defined by the Mercator projection coordinate system; the longitude and latitude limits (west, east, south, north) of the tile on the earth's surface are calculated according to the row and column numbers and the width of the tile.
[0018] Preferably, the longitude and latitude corresponding to the tile geometry are divided into a plurality of equal arc ranges, and the coordinates of each point of the geometry on the unit sphere are calculated according to the corresponding arc, specifically: the longitude and latitude are converted into arc representation, and the geometry is divided into equal arcs according to the number of grids; the coordinates of the grid points on the geometry on the unit sphere are calculated according to the arc; the specific steps are as follows:
[0019] S601: Convert the latitude and longitude ranges of the tile into radians;
[0020] S602: Divide the arc range of the tile into multiple small arc ranges according to the number of mesh divisions of the geometric body;
[0021] S603: Using the spherical coordinate formula, the coordinates of the corresponding grid point on the unit sphere are calculated according to the midpoint of each small arc range.
[0022] Preferably, the coordinate points of the actual three-dimensional earth in the WGS84 coordinate system are calculated according to the coordinates of the geometric body on the unit sphere, specifically: the coordinates of each grid point on the geometric body on the unit sphere are multiplied by the earth radius defined by the WGS84 coordinate system; wherein the coordinates on the unit sphere are converted into actual three-dimensional earth coordinates using the earth radius defined by the WGS84 coordinate system (6378137 meters); the corresponding UV coordinate values are calculated according to the actual coordinate points in the geometric body, specifically: the UV coordinate values of the tile image are calculated according to the actual coordinate points of each grid point in the geometric body; wherein, the UV coordinates of each grid point in the geometric body are calculated on the tile image according to its actual coordinates, the UV coordinates are used to map the texture to the three-dimensional model, and the UV coordinate values are calculated according to the resolution of the tile image and the actual coordinates of the grid points.
[0023] Preferably, according to the distance from the camera to each tile model, the node splitting and leaf node merging of the quadtree structure are selected to realize the Level of detail function, specifically: a random point is obtained on the screen in each frame, and then the model intersecting with the ray is calculated by means of rays, and the distance of the model from the camera is calculated, and finally the quadtree nodes are split and merged according to the distance threshold to load the lower layer tiles or the upper layer tiles to realize the Level of detail function; when rendering each frame, a random point is obtained from the screen, and the ray detection function of three.js is used to calculate the tile model intersecting with the point; according to the distance from the camera to the intersecting tile model and the preset distance threshold, it is decided whether to split or merge the quadtree nodes; if the distance is less than the threshold, the node is split and a finer tile is loaded; if the distance is greater than the threshold, the node is merged and a coarser tile is loaded.
[0024] Preferably, the four-dimensional range of the tile is calculated by row and column numbers and tile width, specifically: the width of the tile of each level is calculated by the width of the plane map defined by the Mercator projection coordinate system; the specific steps are as follows:
[0025] S901: Use the half circumference of the earth in the Mercator projection coordinate system and the current level to calculate the width of the tile; the calculation formula is as follows:
[0026] width=2*L / pow(2,z); where L is the half circumference of the earth under Mercator projection, and z is the current level;
[0027] S902: Use the row and column numbers and the tile width to calculate the four boundaries of the tile (latitude and longitude of the west, east, south, and north).
[0028] Preferably, constructing an accurate three-dimensional earth model according to tile row and column numbers and level information specifically includes the following steps:
[0029] A1: Construct a quadtree structure. The tree has only one root node. Each non-leaf node has four child nodes, which correspond to the tile structure hierarchy one by one, facilitating the management of tile nodes and the LOD function of tiles.
[0030] A2: According to the row and column numbers and layer attributes of the tile, calculate the four directions of the tile model, determine the longitude and latitude range of the model, and then convert the longitude and latitude into radians;
[0031] A3: Divide the geometry of the tile model into regular grids, bisect the arc length of the geometry in equal arcs, and calculate the coordinates of each grid point on the unit sphere based on the arc information of the point;
[0032] A4: Multiply the coordinates of each grid point on the unit sphere by the radius of the earth in the WGS84 coordinate system to get the real earth coordinate point;
[0033] A5: Calculate the UV coordinate value of the tile image based on the actual coordinate points of each grid point in the geometry;
[0034] A6: According to the distance between the model and the camera, the ratio relationship with the level is calculated, and finally the quadtree nodes are split and merged according to the threshold to load the lower or upper tiles to realize the Level of Detail function.
[0035] The 3D earth display system based on the quadtree structure of threejs includes:
[0036] The quadtree construction module is responsible for building a quadtree structure that corresponds one-to-one to the tile hierarchy. Each node has a row and column number and a hierarchy attribute, and each non-leaf node has four child nodes.
[0037] The tile range calculation module is used to calculate the latitude and longitude range corresponding to the tile geometry managed by the node according to the row and column numbers and levels of the tile;
[0038] The geometric coordinate calculation module is used to divide the longitude and latitude corresponding to the tile geometry into multiple equal arc ranges, calculate the coordinates of each point of the geometry on the unit sphere according to the corresponding arc, and further convert it into the actual three-dimensional earth coordinate point in the WGS84 coordinate system;
[0039] UV coordinate calculation module, used to calculate the corresponding UV coordinate value according to the actual coordinate point in the geometric body, so as to map the texture map to the geometric body;
[0040] The LOD management module is used to select node splitting and leaf node merging of the quadtree structure according to the distance from the camera to each tile model, thereby realizing the Level of detail function;
[0041] The rendering display module is used to display the three-dimensional earth model on the system and display the corresponding tile detail level.
[0042] Beneficial effects of the present invention:
[0043] 1. Compared with the underlying language development based on WEBGL in the virtual three-dimensional earth system and the digital twin GIS platform, the structure is unclear, which is not conducive to the management of tile node status and the subsequent expansion of program functions by non-computer professionals. In addition, the way to implement Lovel of detail is clumsy, the visual effect is poor when switching levels, and the amount of calculation is large. The present invention constructs a map structure model through a quadtree structure, the data structure is clear, it is conducive to node management, and there is no need to care about the camera cone, which is convenient for the expansion of program functions, the LOD process is faster, and the amount of calculation is greatly reduced;
[0044] 2. A quadtree structure is used to construct a three-dimensional earth model. This structure has a clear hierarchy and node relationship. Each node corresponds to a specific area on the earth's surface, and a non-leaf node has four child nodes, which correspond to the hierarchy of the tile structure. This structure makes the management of tile nodes simpler and more intuitive, which is conducive to subsequent program development and maintenance.
[0045] 3. The Level of Detail (LOD) function is implemented by calculating the proportional relationship between the model and the level according to the distance from the camera, and splitting and merging the quadtree nodes according to the threshold. This method enables the loading of lower or upper tiles more quickly when switching levels, thereby improving the efficiency of LOD. At the same time, due to the clarity of the quadtree structure, unnecessary complexity is reduced in the calculation process, greatly reducing the amount of calculation.
[0046] 4. The modular program structure facilitates the expansion and modification of subsequent functions. For non-computer professionals, this structured approach also makes it easier for them to understand and participate in program development. In addition, by optimizing the LOD process and reducing the amount of calculation, the invention also enhances the user experience when using the three-dimensional earth system, making the system smoother and more efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 What is shown is a simplified schematic diagram of the method for displaying a three-dimensional earth based on a threejs quadtree structure of the present invention;
[0048] Figure 2 Shown is a detailed flow chart of a method for displaying a three-dimensional earth based on a threejs quadtree structure of the present invention;
[0049] Figure 3 The module structure diagram of the three-dimensional earth display system based on the threejs quadtree structure of the present invention is shown;
[0050] Figure 4What is shown is a schematic diagram of a tile image structure of a method for displaying a three-dimensional earth based on a threejs quadtree structure of the present invention. DETAILED DESCRIPTION
[0051] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0052] See also Figure 1-4 The present invention provides an embodiment: a method and system for displaying a three-dimensional earth based on a quadtree structure of threejs. The method for displaying a three-dimensional earth based on a quadtree structure of threejs first constructs a quadtree node, and then calculates a grid model of the corresponding earth surface according to tile row and column numbers and level data; the method comprises the following steps:
[0053] S101: constructing quadtree nodes corresponding to the hierarchical structure of tiles one by one;
[0054] S102: Calculate the latitude and longitude ranges corresponding to the tile geometry managed by the node according to the tile row and column numbers and the level;
[0055] S103: Divide the longitude and latitude corresponding to the tile geometry into a plurality of equal arc ranges, and calculate the coordinates of each point of the geometry on the unit sphere according to the corresponding arcs;
[0056] S104: Calculate the coordinate points of the actual three-dimensional earth in the WGS84 coordinate system according to the coordinates of the geometric body on the unit sphere;
[0057] S105: Calculate the corresponding UV coordinate value according to the actual coordinate point in the geometric body;
[0058] S106: According to the distance from the camera to each tile model, select node splitting of the quadtree structure and merging of leaf nodes, thereby realizing the Level of detail function;
[0059] S107: Display the three-dimensional earth model on the system and display the corresponding tile detail level.
[0060] Preferably, the threejs is an open source WEBGL framework, which provides 3D graphics rendering functions through threejs; the material, texture, mesh and camera functions of threejs are used to create and render a three-dimensional earth model; the mesh model of the earth's surface is created through the Mesh class of threejs, and the ShaderMaterial and MeshBasicMaterial material classes are used to add texture and color to the mesh model, and the tile image is loaded as a texture through the TextureLoader class, and finally the three-dimensional earth model is added to the threejs scene and rendered through the renderer.
[0061] Preferably, a quadtree structure is specifically as follows: there is only one root node, and each non-leaf node has four child nodes; wherein, when constructing the quadtree structure, starting from the root node, child nodes are recursively created according to the level and row and column numbers of the tiles; each non-leaf node contains references to its four child nodes (upper left, upper right, lower left, and lower right); the node data structure contains the node's level, row and column number, and a reference to the corresponding tile geometry.
[0062] Preferably, quadtree nodes are constructed to correspond one-to-one with the hierarchical structure of tiles, specifically: each node has a row and column number and a level attribute; each node corresponds to a unique tile; wherein, when creating a quadtree node, a unique identifier is assigned to each node, and its row and column number and level attribute are set; and tile geometry is associated with the corresponding quadtree node according to the level and row and column number of the tile.
[0063] Preferably, the longitude and latitude limits corresponding to the tile geometry managed by the node are calculated according to the tile row and column numbers and the level, specifically: the width of the corresponding tile at the node level is calculated by the level attributes; the four limits of the tile are calculated by the row and column numbers and the tile width; wherein, the width of the tile is calculated using the plane map width and the current level defined by the Mercator projection coordinate system; the longitude and latitude limits (west, east, south, north) of the tile on the earth's surface are calculated according to the row and column numbers and the width of the tile.
[0064] Preferably, the longitude and latitude corresponding to the tile geometry are divided into a plurality of equal arc ranges, and the coordinates of each point of the geometry on the unit sphere are calculated according to the corresponding arc, specifically: the longitude and latitude are converted into arc representation, and the geometry is divided into equal arcs according to the number of grids; the coordinates of the grid points on the geometry on the unit sphere are calculated according to the arc; the specific steps are as follows:
[0065] S601: Convert the latitude and longitude ranges of the tile into radians;
[0066] S602: Divide the arc range of the tile into multiple small arc ranges according to the number of mesh divisions of the geometric body;
[0067] S603: Using the spherical coordinate formula, the coordinates of the corresponding grid point on the unit sphere are calculated according to the midpoint of each small arc range.
[0068] Preferably, the coordinate points of the actual three-dimensional earth in the WGS84 coordinate system are calculated according to the coordinates of the geometric body on the unit sphere, specifically: the coordinates of each grid point on the geometric body on the unit sphere are multiplied by the earth radius defined by the WGS84 coordinate system; wherein the coordinates on the unit sphere are converted into actual three-dimensional earth coordinates using the earth radius defined by the WGS84 coordinate system (6378137 meters); the corresponding UV coordinate values are calculated according to the actual coordinate points in the geometric body, specifically: the UV coordinate values of the tile image are calculated according to the actual coordinate points of each grid point in the geometric body; wherein, the UV coordinates of each grid point in the geometric body are calculated on the tile image according to its actual coordinates, the UV coordinates are used to map the texture to the three-dimensional model, and the UV coordinate values are calculated according to the resolution of the tile image and the actual coordinates of the grid points.
[0069] Preferably, according to the distance from the camera to each tile model, the node splitting and leaf node merging of the quadtree structure are selected to realize the Level of detail function, specifically: a random point is obtained on the screen in each frame, and then the model intersecting with the ray is calculated by means of rays, and the distance of the model from the camera is calculated, and finally the quadtree nodes are split and merged according to the distance threshold to load the lower layer tiles or the upper layer tiles to realize the Level of detail function; when rendering each frame, a random point is obtained from the screen, and the ray detection function of three.js is used to calculate the tile model intersecting with the point; according to the distance from the camera to the intersecting tile model and the preset distance threshold, it is decided whether to split or merge the quadtree nodes; if the distance is less than the threshold, the node is split and a finer tile is loaded; if the distance is greater than the threshold, the node is merged and a coarser tile is loaded.
[0070] Preferably, the four-dimensional range of the tile is calculated by row and column numbers and tile width, specifically: the width of the tile of each level is calculated by the width of the plane map defined by the Mercator projection coordinate system; the specific steps are as follows:
[0071] S901: Use the half circumference of the earth in the Mercator projection coordinate system and the current level to calculate the width of the tile; the calculation formula is as follows:
[0072] width=2*L / pow(2,z); where L is the half circumference of the earth under Mercator projection, and z is the current level;
[0073] S902: Use the row and column numbers and the tile width to calculate the four boundaries of the tile (latitude and longitude of the west, east, south, and north).
[0074] Preferably, constructing an accurate three-dimensional earth model according to tile row and column numbers and level information specifically includes the following steps:
[0075] A1: Construct a quadtree structure. The tree has only one root node. Each non-leaf node has four child nodes, which correspond to the tile structure hierarchy one by one, facilitating the management of tile nodes and the LOD function of tiles.
[0076] A2: According to the row and column numbers and layer attributes of the tile, calculate the four directions of the tile model, determine the longitude and latitude range of the model, and then convert the longitude and latitude into radians;
[0077] A3: Divide the geometry of the tile model into regular grids, bisect the arc length of the geometry in equal arcs, and calculate the coordinates of each grid point on the unit sphere based on the arc information of the point;
[0078] A4: Multiply the coordinates of each grid point on the unit sphere by the radius of the earth in the WGS84 coordinate system to get the real earth coordinate point;
[0079] A5: Calculate the UV coordinate value of the tile image based on the actual coordinate points of each grid point in the geometry;
[0080] A6: According to the distance between the model and the camera, the ratio relationship with the level is calculated, and finally the quadtree nodes are split and merged according to the threshold to load the lower or upper tiles to realize the Level of Detail function.
[0081] The 3D earth display system based on the quadtree structure of threejs includes:
[0082] The quadtree construction module is responsible for building a quadtree structure that corresponds one-to-one to the tile hierarchy. Each node has a row and column number and a hierarchy attribute, and each non-leaf node has four child nodes.
[0083] The tile range calculation module is used to calculate the latitude and longitude range corresponding to the tile geometry managed by the node according to the row and column numbers and levels of the tile;
[0084] The geometric coordinate calculation module is used to divide the longitude and latitude corresponding to the tile geometry into multiple equal arc ranges, calculate the coordinates of each point of the geometry on the unit sphere according to the corresponding arc, and further convert it into the actual three-dimensional earth coordinate point in the WGS84 coordinate system;
[0085] UV coordinate calculation module, used to calculate the corresponding UV coordinate value according to the actual coordinate point in the geometric body, so as to map the texture map to the geometric body;
[0086] The LOD management module is used to select node splitting and leaf node merging of the quadtree structure according to the distance from the camera to each tile model, thereby realizing the Level of detail function;
[0087] The rendering display module is used to display the three-dimensional earth model on the system and display the corresponding tile detail level.
[0088] Example 1
[0089] Optionally, calculating the image UV value includes the following steps:
[0090] A101: Construct a quadtree structure that corresponds one-to-one with the hierarchical structure of the image;
[0091] A102: Calculate the four-dimensional information of the node, i.e. the longitude and latitude range of the east, west, south and north, according to the row and column numbers and layer connection attributes of the node;
[0092] A103: Divide the geometry into multiple equally spaced grid points and calculate the true 3D coordinates in the WGS84 coordinate system based on the arc value of each point;
[0093] A104: Calculate the UV value of the image corresponding to the point according to the three-dimensional coordinates calculated in step A103;
[0094] The map structure model is constructed through the quadtree structure, with a clear data structure, which is conducive to node management. There is no need to worry about the camera cone, which is convenient for the expansion of program functions. The LOD process is faster and the amount of calculation is greatly reduced.
[0095] Example 2
[0096] Optionally, when constructing a quadtree structure and performing quadtree structure splitting and merging, the following steps are included:
[0097] A201: Construct a quadtree structure that corresponds to the hierarchical structure of the image. Each non-leaf node has four child nodes. The child nodes are saved in an array, which are the upper left child node, the upper right child node, the lower left child node, and the lower right child node. Each node has row and column values and hierarchical attributes, which are represented by x, y, and z respectively.
[0098] A202: Calculate the four boundaries of the grid, that is, calculate the four latitude and longitude limits of the grid, namely, the east, south, west and north. The calculation formula is as follows:
[0099] The half circumference of the earth under the Mercator projection is: L = 20037508.342789244, and the radius of the earth under the WGS84 coordinate system is: R = 6378137.0;
[0100] width=2*L / pow(2,z)
[0101] west=(-L+x*width) / R
[0102] east=(-L+(x+1)*width) / R
[0103] north=atan(sinh((Ly*width) / R))
[0104] south=atan(sinh((L-(y+1)*width) / R))
[0105] A203: Calculate the actual coordinates of each grid point. First, convert the four-dimensional information calculated by A202 into radian values. Then, according to the number of segments, calculate the coordinates vetex (x, y, z) of each grid point. The calculation formula is as follows:
[0106] vetex.x=R*cos(west+i)*sin(south+j);
[0107] vetex.y = R*cos(south+j);
[0108] vetex.z=R*sin(west+i)*sin(south+j);
[0109] A204: Calculate the UV value of the image. After calculating the actual coordinates of each grid point, it is necessary to determine the corresponding UV value of each point and the image. The calculation formula is as follows:
[0110] len = length(vetex);
[0111] lat = asin(vetex.y / len);
[0112] lon=atan2(-vetex.z,vetex.x);
[0113] mercator_x = len * longitude;
[0114] mercator_y=len*log(tan(PI / 4.0+lat / 2.0));
[0115] v=(mercator_y-south) / width;
[0116] u=(mercator_x-west) / pow(2,z);
[0117] A205: Load tile image, load satellite image according to the row and column number and level attributes of the current quadtree node, the corresponding attributes are x, y, z;
[0118] A206: Display the 3D earth and add the quadtree structure to the threejs scene;
[0119] A207: Calculate the distance from the model to the camera, and split and merge the quadtree structure; the calculation formula is as follows:
[0120] threshold=distance / pow(2,maxZ-z)
[0121] If the value is greater than the defined threshold, a split operation is performed. The node splitting formula is as follows:
[0122] left_top=Node(2x,2y,z+1)
[0123] right_top=Node(2x+1,2y,z+1)
[0124] left_bottom=Node(2x,2y+1,z+1)
[0125] right_bottom=Node(2x+1,2y+1,z+1)
[0126] Put the split nodes into the array managed by the parent node in sequence;
[0127] If it is less than the defined threshold range, a merge operation is performed. The node notifies the parent node to perform a merge operation, first setting the four child nodes to be invisible, and then reclaiming the memory and data;
[0128] The map structure model is constructed through the quadtree structure, with a clear data structure, which is conducive to node management. There is no need to worry about the camera cone, which is convenient for the expansion of program functions. The LOD process is faster and the amount of calculation is greatly reduced.
[0129] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge scope of those skilled in the art without departing from the spirit of the present invention.
Claims
1. A method for displaying a three-dimensional earth based on a quadtree structure of threejs, characterized in that: First, construct a quadtree node, and then calculate the corresponding grid model of the earth's surface according to the tile row and column numbers and level data; including the following steps: S101: constructing quadtree nodes corresponding to the hierarchical structure of tiles one by one; S102: Calculate the latitude and longitude ranges corresponding to the tile geometry managed by the node according to the tile row and column numbers and the level; S103: Divide the longitude and latitude corresponding to the tile geometry into a plurality of equal arc ranges, and calculate the coordinates of each point of the geometry on the unit sphere according to the corresponding arcs; S104: Calculate the coordinate points of the actual three-dimensional earth in the WGS84 coordinate system according to the coordinates of the geometric body on the unit sphere; S105: Calculate the corresponding UV coordinate value according to the actual coordinate point in the geometric body; S106: According to the distance from the camera to each tile model, select node splitting of the quadtree structure and merging of leaf nodes, thereby realizing the Level of detail function; S107: Display the three-dimensional earth model on the system and display the corresponding tile detail level.
2. The method for displaying a three-dimensional earth based on a quadtree structure of threejs according to claim 1, characterized in that: The threejs is an open source WEBGL framework that provides 3D graphics rendering functions through threejs; the material, texture, mesh and camera functions of threejs are used to create and render a three-dimensional earth model; the mesh model of the earth's surface is created through the Mesh class of threejs, the ShaderMaterial and MeshBasicMaterial material classes are used to add texture and color to the mesh model, the tile image is loaded as a texture through the TextureLoader class, and finally the three-dimensional earth model is added to the threejs scene and rendered through the renderer.
3. The method and system for displaying a three-dimensional earth based on a threejs quadtree structure according to claim 2, characterized in that: The quadtree structure is specifically as follows: there is only one root node, and each non-leaf node has four child nodes; when constructing the quadtree structure, starting from the root node, child nodes are recursively created according to the level and row and column numbers of the tile; each non-leaf node contains references to its four child nodes (upper left, upper right, lower left, and lower right); the node data structure contains the node's level, row and column number, and a reference to the corresponding tile geometry.
4. The method for displaying a three-dimensional earth based on a quadtree structure of threejs according to claim 1, characterized in that: Construct quadtree nodes that correspond to the tile hierarchy one by one, specifically: each node has a row and column number and a level attribute; each node corresponds to a unique tile; wherein, when creating a quadtree node, a unique identifier is assigned to each node, and its row and column number and level attributes are set; and according to the level and row and column number of the tile, the tile geometry is associated with the corresponding quadtree node.
5. The method for displaying a three-dimensional earth based on a quadtree structure of threejs according to claim 1, characterized in that: According to the tile row and column numbers and levels, the longitude and latitude boundaries corresponding to the tile geometry managed by the node are calculated. Specifically, the width of the corresponding tile at the node level is calculated through the level attributes; the four boundaries of the tile are calculated through the row and column numbers and the tile width; among them, the width of the tile is calculated using the plane map width defined by the Mercator projection coordinate system and the current level; according to the row and column numbers and width of the tile, the longitude and latitude boundaries (west, east, south, north) of the tile on the earth's surface are calculated.
6. The method for displaying a three-dimensional earth based on a quadtree structure of threejs according to claim 1, characterized in that: The longitude and latitude of the tile geometry are divided into multiple equal arc ranges, and the coordinates of each point of the geometry on the unit sphere are calculated according to the corresponding arcs. Specifically, the longitude and latitude are converted into arcs, and the geometry is divided into equal arcs according to the number of grids; the coordinates of the grid points on the geometry on the unit sphere are calculated according to the arcs. The specific steps are as follows: S601: Convert the latitude and longitude ranges of the tile into radians; S602: Divide the arc range of the tile into multiple small arc ranges according to the number of mesh divisions of the geometric body; S603: Using the spherical coordinate formula, the coordinates of the corresponding grid point on the unit sphere are calculated according to the midpoint of each small arc range.
7. The method for displaying a three-dimensional earth based on a quadtree structure of threejs according to claim 1, characterized in that: According to the coordinates of the geometric body on the unit sphere, the coordinate points of the actual three-dimensional earth in the WGS84 coordinate system are calculated, specifically: the coordinates of each grid point on the geometric body on the unit sphere are multiplied by the earth radius defined by the WGS84 coordinate system; wherein, the coordinates on the unit sphere are converted into actual three-dimensional earth coordinates using the earth radius defined by the WGS84 coordinate system (6378137 meters); according to the actual coordinate points in the geometric body, the corresponding UV coordinate values are calculated, specifically: the UV coordinate values of the tile image are calculated according to the actual coordinate points of each grid point in the geometric body; wherein, according to the actual coordinates of each grid point in the geometric body, its UV coordinates on the tile image are calculated, and the UV coordinates are used to map the texture to the three-dimensional model, and the UV coordinate values are calculated according to the resolution of the tile image and the actual coordinates of the grid points.
8. The method for displaying a three-dimensional earth based on a threejs quadtree structure according to claim 1, characterized in that: According to the distance from the camera to each tile model, the node splitting and leaf node merging of the quadtree structure are selected to realize the Level of detail function. Specifically, a random point is obtained on the screen in each frame, and then the model intersecting with the ray is calculated by ray, and the distance of the model from the camera is calculated. Finally, the quadtree nodes are split and merged according to the distance threshold to load the lower or upper tiles to realize the Level of detail function; when rendering each frame, a random point is obtained from the screen, and the ray detection function of three.js is used to calculate the tile model intersecting with the point; according to the distance from the camera to the intersecting tile model and the preset distance threshold, it is decided whether to split or merge the quadtree nodes; if the distance is less than the threshold, the node is split to load a finer tile; If the distance is greater than the threshold, the nodes are merged and a coarser tile is loaded.
9. The method for displaying a three-dimensional earth based on a quadtree structure of threejs according to claim 1, characterized in that: The bounds of the tile are calculated by row and column numbers and tile widths. Specifically, the width of the flat map defined by the Mercator projection coordinate system is used to calculate the tile width of each level. The specific steps are as follows: S901: Use the half circumference of the earth in the Mercator projection coordinate system and the current level to calculate the width of the tile; the calculation formula is as follows: width=2*L / pow(2,z); where L is the half circumference of the earth under Mercator projection, and z is the current level; S902: Use the row and column numbers and the tile width to calculate the four boundaries of the tile (latitude and longitude of the west, east, south, and north).
10. A three-dimensional earth display system based on the quadtree structure of threejs, characterized by: Included are: The quadtree construction module is responsible for building a quadtree structure that corresponds one-to-one to the tile hierarchy. Each node has a row and column number and a hierarchy attribute, and each non-leaf node has four child nodes. The tile range calculation module is used to calculate the latitude and longitude range corresponding to the tile geometry managed by the node according to the row and column numbers and levels of the tile; The geometric coordinate calculation module is used to divide the longitude and latitude corresponding to the tile geometry into multiple equal arc ranges, calculate the coordinates of each point of the geometry on the unit sphere according to the corresponding arc, and further convert it into the actual three-dimensional earth coordinate point in the WGS84 coordinate system; UV coordinate calculation module, used to calculate the corresponding UV coordinate value according to the actual coordinate point in the geometric body, so as to map the texture map to the geometric body; The LOD management module is used to select node splitting and leaf node merging of the quadtree structure according to the distance from the camera to each tile model, thereby realizing the Level of detail function; The rendering display module is used to display the three-dimensional earth model on the system and display the corresponding tile detail level.
Citation Information
Patent Citations
Three-dimensional digital earth-space data organizing and rendering method based on quad-tree index
CN101887595A
SGOG tile-based large region true three-dimensional geographic scene adaptive construction method
CN106898045A
Dynamic dispatching and displaying method, device and equipment of massive data and storage medium
CN108363808A
Real-scene three-dimensional road reconstruction method and device, storage medium and electronic device
CN113706698A
Fusion display method and device of aerial video on digital earth
CN114494563A