A method and device for batch dynamic switching of building white model textures for a web end
Patent Information
- Application Number
- CN202311373096.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-23
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-10-23
AI Technical Summary
[0003]现有在web端展示带有纹理的建筑物白模时,如果要切换不同的风格纹理时,需要后端对建筑物矢量文件Shapefile 重新进行3dtiles切片,每次切片都需要文件存储,占用了存储空间,同时进行3dtiles切片也较为耗时,不能实现秒级重新渲染效果,用户体验差;另外,建筑物矢量文件Shapefile 进行3dtiles切片时,需要不断调整纹理图片大小和位置以便生成的带有纹理的白模切片可以有更好的效果,但是一般3dtiles切片使用C++程序编写,每次重新编译时,耗时较久,大大延长了开发时间
[0016] The method and apparatus for batch dynamic switching of architectural white model textures for web-based applications, as described in this invention, generate 3D tiles of the building in a single batch on the backend. This enables dynamic switching of the white model rendering style and dynamic adjustment of texture image size and position on the web. When switching architectural white model textures, this not only significantly reduces file storage space usage and avoids resource waste, but also allows for more efficient adjustment of rendering results and stronger real-time performance. The effect after switching can be seen in just a few seconds, making it suitable for application and promotion in the 3D rendering of architectural white models on the web.
Smart Images

Figure CN117523074B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of remote sensing satellite image processing, and in particular relates to a method and apparatus for batch dynamic switching of architectural white model textures for web-based applications. Background Technology
[0002] In smart city scenario demonstrations, 3D building white models can help city managers better understand the layout and development trends of urban space, thereby enabling them to better formulate urban planning and management policies. Currently, there are three ways to display 3D building white models in smart city demonstrations: the first is to directly display the white model, which has a relatively average display effect; the second is to give the white model different colors or dynamic apertures based on its attributes; and the third is to use textured building white models, which can further enhance the materiality and realism of the entire scene.
[0003] When displaying textured white models of buildings on the web, switching between different texture styles requires the backend to re-slice the building vector file (Shapefile) into 3dtiles. Each slice requires file storage, consuming storage space. Furthermore, 3dtiles slicing is time-consuming, failing to achieve sub-second re-rendering and resulting in a poor user experience. Additionally, during 3dtiles slicing of the building vector file, the size and position of texture images need continuous adjustment to achieve better textured white model slices. However, 3dtiles slicing is typically written in C++, and each recompilation is time-consuming, significantly extending development time. To reduce the time spent switching white model rendering styles, corresponding 3dtiles slices can be pre-processed and generated, but this still inevitably consumes additional storage space. Summary of the Invention
[0004] The present invention aims to solve the above problems and provides a method and apparatus for batch dynamic switching of architectural white model textures with less storage space and less rendering time for web-based applications.
[0005] In a first aspect, the present invention provides a method for batch dynamic switching of architectural white model textures on a web-based platform, comprising: Retrieve the Shapefile building surface file containing the Height field; Read each face feature from the Shapefile building face file and calculate the bounding rectangle of each face feature; The quadtree algorithm is used to process the bounding rectangle of each face feature to generate a box-type bounding box. The opposite element is stretched along the Z-axis using the height field to construct a geometric triangulation. After stretching, an extruded volume with one top face and multiple side faces is generated, along with a thin sheet containing only the top face. All vertex coordinates, vertex indices, normals, and the height field (Height) of the extruded volume, as well as all vertex coordinates, vertex indices, and normals of the top sheet, are stored. The extruded volume is primarily used for rendering side face textures, while the top sheet is used for rendering the top face. The height field is used by the web application to adjust the texture style of the white model rendering.
[0006] Perform texture settings; the images field of the white model texture image array for the building retains only one image information, including the image name and path, and the image is a white image in ktx2 format; at the same time, perform KHR_texture_basisu extended settings, and establish a relationship with the images field through index; the coordinates of the aforementioned extruded body and the top surface sheet are respectively bound to the texture units TEXTURE0 and TEXTURE1; according to the vertex coordinates, the initial values of the texture coordinates of the extruded body and the top surface sheet are given respectively, and the texture coordinates are bound to the texture units TEXTURE0 and TEXTURE1 respectively; According to the 3dtiles standard, organize and generate other data to generate 3dtiles tiles; organize all vertex coordinates, vertex indices, normal vectors, texture coordinates, texture units and height field Height to generate a b3dm file, and organize the bounding box and b3dm file path to generate a tilesset.json file; Create a configuration file to set texture image information for different styles; Based on the configuration file, white model rendering is performed; when switching between different styles of white model textures, the existing white model and its occupied memory are cleared, and then the white model of the currently selected style is loaded.
[0007] Furthermore, the method for batch dynamic switching of architectural white model textures for web clients described in this invention includes the following steps for rendering the white model based on the configuration file: the web client loads and parses the b3dm file in the corresponding 3dtiels slice file according to the visualization range, dynamically loads the configuration file, obtains the corresponding style and texture image path according to the current style of the configuration file, matches the stored vertex index, vertex coordinates, normal vector and height fields with the texture image, and implements white model texture rendering through a shader.
[0008] Furthermore, the method for batch dynamic switching of architectural white model textures for web-based applications described in this invention, specifically includes the following steps for rendering the white model texture through shaders: First, in the vertex shader, the model normal vector is passed to the fragment shader. Then, in the fragment shader, the texture, texture coordinates, and specular reflection are processed. The method determines whether the x-coordinate of the texture coordinate texCoord_1 corresponding to the texture unit TEXTURE1 is 0 to distinguish whether the rendering is of a top surface sheet or an extruded body. If the x-coordinate of texCoord_1 is not 0, it indicates that a top surface sheet is being rendered, and the top surface needs to be rendered. Conversely, if an extruded body is being rendered, it indicates that the side surfaces need to be rendered. No processing is performed on the bottom surface. For top-side rendering, diffuse reflection processing is performed. Given the diffuse reflection color of the top surface of the model, the sampling result of the top surface texture image is used, and the corresponding texture image is tiled onto the top surface. For side rendering, the top surface rendering is discarded first, and only the side texture is rendered. Given the correspondence between the horizontal and vertical directions of the model's side and the texture coordinates, if the normal vector of the model's internal point is perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1]. If the normal vector of the model's internal point is not perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1], and the angle between the two vectors is rotated. At the same time, the scaling ratio of the texture image is set according to the size of the texture image and the range of the model's horizontal and vertical coordinates. After matching, the sampled texture result color is assigned to the diffuse color. Specular reflection is given. Style variables are defined and mapped to the style fields in the configuration file to determine the current rendering style type. 0 is the default white texture style, and other styles start from 1 and correspond to the style fields in the configuration file in sequence.
[0009] Furthermore, in the method for batch dynamic switching of architectural white model textures for Web clients described in this invention, when calculating the bounding rectangle range of each face feature, the point with the minimum x value, the point with the maximum x value, the point with the minimum y value, and the point with the maximum y value are first found, and then the x and y values of the points with the minimum x and y values are combined into a corner point.
[0010] Furthermore, the method for batch dynamic switching of architectural white model textures for web-based applications described in this invention includes white model texture style information, current style, whether specular reflection is used, specular reflection value, scaling factor of the texture image upsampling point coordinates on the texture image x-axis, and texture image paths for the top and sides of the building under each style.
[0011] Secondly, this invention provides a system for batch dynamic switching of architectural white model textures on a web-based platform, comprising: The Shapefile acquisition module is used to obtain building shapefiles that include the height field (Height). The Shapefile processing module is used to read each face feature of the Shapefile building face file and calculate the bounding rectangle of each face feature; The quadtree algorithm is used to process the bounding rectangle of each face feature to generate a box-type bounding box. The opposite features are stretched along the Z-axis using the height field to construct a geometric triangulation. After stretching, an extruded body with one top face and multiple side faces is generated, along with a thin sheet containing only the top face. All vertex coordinates, vertex indices, normals, and the height field of the extruded body, as well as all vertex coordinates, vertex indices, and normals of the top face thin sheet, are stored. The texture setting slice module is used for texture settings; the images field of the building white model texture image array retains only one image information, including the image name and path, and the image is a white image in ktx2 format; at the same time, KHR_texture_basisu extended settings are performed, and the association is established with the images field through index; the coordinates of the aforementioned extruded body and the top surface sheet are respectively bound to the texture units TEXTURE0 and TEXTURE1; according to the vertex coordinates, the initial values of the texture coordinates of the extruded body and the top surface sheet are given respectively, and the texture coordinates are bound to the texture units TEXTURE0 and TEXTURE1 respectively; According to the 3dtiles standard, organize and generate other data to generate 3dtiles tiles; organize all vertex coordinates, vertex indices, normal vectors, texture coordinates, texture units and height field Height to generate a b3dm file, and organize the bounding box and b3dm file path to generate a tilesset.json file; The file configuration module is used to create configuration files and set texture image information for different styles. The white model rendering module is used to render white models according to the configuration file. When switching between different styles of white model textures, it clears the existing white models and the memory they occupy, and then loads the white model of the currently selected style.
[0012] Furthermore, the system for batch dynamic switching of architectural white model textures for web clients described in this invention includes the following steps when rendering the white model according to the configuration file: the web client loads and parses the b3dm file in the corresponding 3dtiels slice file according to the visualization range, dynamically loads the configuration file, obtains the corresponding style and texture image path according to the current style of the configuration file, matches the stored vertex index, vertex coordinates, normal vector and height fields with the texture image, and implements white model texture rendering through the shader.
[0013] Furthermore, the system for batch dynamic switching of architectural white model textures for web-based applications, as described in this invention, specifically includes the following steps for rendering the white model texture through shaders: First, in the vertex shader, the model normal vector is passed to the fragment shader. Then, in the fragment shader, the texture, texture coordinates, and specular reflection are processed. The system determines whether the x-coordinate of the texture coordinate texCoord_1 corresponding to the texture unit TEXTURE1 is 0 to distinguish whether the rendering is of a top surface sheet or an extruded body. If the x-coordinate of texCoord_1 is not 0, it indicates that a top surface sheet is being rendered, and the top surface needs to be rendered. Conversely, if an extruded body is being rendered, it indicates that the side surfaces need to be rendered. The bottom surface is not processed. For top-side rendering, diffuse reflection processing is performed. Given the diffuse reflection color of the top surface of the model, the sampling result of the top surface texture image is used, and the corresponding texture image is tiled onto the top surface. For side rendering, the top surface rendering is discarded first, and only the side texture is rendered. Given the correspondence between the horizontal and vertical directions of the model's side and the texture coordinates, if the normal vector of the model's internal point is perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1]. If the normal vector of the model's internal point is not perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1], and the angle between the two vectors is rotated. At the same time, the scaling ratio of the texture image is set according to the size of the texture image and the range of the model's horizontal and vertical coordinates. After matching, the sampled texture result color is assigned to the diffuse color. Specular reflection is given. Style variables are defined and mapped to the style fields in the configuration file to determine the current rendering style type. 0 is the default white texture style, and other styles start from 1 and correspond to the style fields in the configuration file in sequence.
[0014] Thirdly, the present invention provides an apparatus for batch dynamic switching of architectural white model textures on a web-based platform, comprising a processor and a memory electrically connected to each other; the memory is used to store a computer program; when the processor executes the aforementioned computer program, it can realize the method for batch dynamic switching of architectural white model textures on a web-based platform as described in the first aspect above.
[0015] Fourthly, the present invention provides a computer-readable storage medium storing a computer program; when the computer program is executed, it can implement the method for batch dynamic switching of architectural white model textures for Web-based applications as described in the first aspect above.
[0016] The method and apparatus for batch dynamic switching of architectural white model textures for web-based applications, as described in this invention, generate 3D tiles of the building in a single batch on the backend. This enables dynamic switching of the white model rendering style and dynamic adjustment of texture image size and position on the web. When switching architectural white model textures, this not only significantly reduces file storage space usage and avoids resource waste, but also allows for more efficient adjustment of rendering results and stronger real-time performance. The effect after switching can be seen in just a few seconds, making it suitable for application and promotion in the 3D rendering of architectural white models on the web. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the method for batch dynamic switching of building white model textures on the Web side according to an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the rendering effect of a white texture according to an embodiment of the present invention; Figure 3 This is a schematic diagram illustrating the rendering of daytime texture effects according to an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the rendering of a nighttime texture effect according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the system structure for batch dynamic switching of building white model textures on the Web side, as described in an embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Example 1 This embodiment discloses a method for batch dynamic switching of architectural white model textures on a web-based platform, such as... Figure 1 As shown, it includes the following steps: S01, Obtain building surface file; Generate 3D Tiles from Shapefile; First, obtain the Shapefile building surface file containing the Height field, so that the surface features can be stretched into geometry later.
[0020] S02, Calculate the bounding rectangle of the polygon feature; Read each polygon feature from the Shapefile file and calculate the bounding rectangle of each polygon feature using the following steps: First, find the point with the minimum x value, find the point with the maximum x value, find the point with the minimum y value, find the point with the maximum y value, and then combine the x and y values of the points with the minimum x and y values into a corner point.
[0021] S03, Bounding Box Generation; 3D Tiles provides three types of bounding boxes: Region, Box, and Sphere. For white-model 3D Tiles, the Box type bounding box is used in this embodiment. The bounding rectangle of each face is processed using a quadtree algorithm, with each bounding rectangle as a node in the quadtree. These nodes are then processed using the quadtree algorithm to generate a Box type bounding box. Specifically, when a rectangular area (box) needs to be added to the quadtree, it is first checked whether the box intersects with the rectangular area of the current node. If the box does not intersect with the rectangular area of the current node, no processing is done. If the box has already been added to a node, no processing is done either. Otherwise, if the rectangular area of the current node intersects with the box, and the width of the rectangular area of the current node is greater than a certain threshold (metric), the function will split the current node into four child nodes (if it has not yet been split), and then attempt to add the box to these four child nodes.
[0022] S04, Generation of the Extruded Body and Top Sheet: The face features are extruded along the Z-axis, and a geometric triangulation is constructed based on the height field. This process generates an extruded body containing a top face and multiple side faces, and a sheet containing only the top face. The extruded body is mainly used to render the side face textures, while the top sheet is used to render the top face. The method described in this embodiment only performs simple extrusion modeling on the face features. In practical applications, if more complex modeling is required, more faces can be created as needed. All vertex coordinates, vertex indices, and normal vectors of the extruded body and top sheet are stored. In addition, the height field is also stored, mainly for adjusting the texture style of the white model rendering on the web based on the height field.
[0023] S05, Texture Settings; Set the default white image texture white.ktx2 for the building's white model. In this embodiment, the ktx2 format is used. It is a next-generation material format used in web3D to store GPU texture data and supports Basis Universal super compression technology. The ktx2 format can reduce GPU memory size and improve rendering speed.
[0024] The `images` field of the white model texture image array for the building retains only one image record, including the image name and path. `texture.extensions` is set to `KHR_texture_basisu`, and `source` of `KHR_texture_basisu` is set to 0. An association is established between the `images` field and the index. The coordinates of the extruded body and the top surface sheet are bound to texture units `TEXTURE0` and `TEXTURE1`, respectively. Initial values for the texture coordinates of the extruded body and the top surface sheet are given based on the vertex coordinates, and these texture coordinates are then bound to texture units `TEXTURE0` and `TEXTURE1`, respectively.
[0025] The `materials` field of the building's white model is an array containing all material information; two materials are used here. Each material has a name and a PBR (Physical Roughness Model). The PBR metal roughness model uses a base color texture, with texture units of 0 and 1, indicating that the two materials use different textures.
[0026] S06, 3dtiles tile generation; Based on the 3dtiles standard, organize and generate other data to further generate 3dtiles tiles. Specifically, organize all vertex coordinates, vertex indices, normal vectors, texture coordinates, texture units, and the height field to generate a b3dm file, and organize the bounding box and b3dm file path to generate a tileset.json file.
[0027] S07, create a configuration file to set relevant information for texture images under different styles; this includes white model texture style information, current style, whether specular reflection is used, specular reflection value, scaling factor of texture image upsampling point coordinates on the texture image x-axis, texture image paths for the building's top and sides under each style, maximum model height, etc. This configuration file is loaded on the web interface before loading 3dTiels so that the white model texture style information can be obtained when loading 3dTiels.
[0028] S08, Render the white model according to the configuration file; in this embodiment, WebGL technology is used to visualize 3D Tiles slices. The web client loads the corresponding 3D Tiles slice file b3dm according to the visualization range, parses the b3dm file, and dynamically loads the configuration file. According to the current style of the configuration file, the corresponding style and texture image path are obtained. The vertex index, vertex coordinates, and other information stored in the b3dm are matched with the texture image, and the white model texture image mapping and specular reflection are implemented in the shader, thereby realizing the white model texture rendering. First, in the vertex shader, the model normal vector is passed to the fragment shader, and then the texture, texture coordinates, and specular reflection are specifically processed in the fragment shader. It is determined whether the x-coordinate of the texture coordinate texCoord_1 corresponding to the texture unit TEXTURE1 is 0 to distinguish whether the top surface slice or the extruded body is being rendered. If the x-coordinate of texCoord_1 is not 0, it means that the top surface slice is being rendered and the top surface needs to be rendered; otherwise, it means that the extruded body is being rendered and the side surface needs to be rendered. For the bottom surface, since it is close to the ground, no processing is required.
[0029] For top-side rendering, diffuse reflection processing is performed. The diffuse color of the given model's top surface is the sampling result of the top surface texture image. The top surface texture is relatively simple; a whole texture image can be tiled onto the top surface.
[0030] For side rendering, the top surface rendering is discarded, and only the side textures are rendered. The sides include faces in multiple directions, and the model coordinates on each face must match the texture coordinates to ensure that each side texture is not distorted. Specifically, given the correspondence between the horizontal and vertical directions of the model's side and the texture coordinates, if the normal vector of a point inside the model is perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, normalized to the [0,1] interval; if the normal vector of a point inside the model is not perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, normalized to the [0,1] interval, and rotated by the angle between the two vectors. Simultaneously, the scaling ratio of the texture image is set according to the texture image size and the range of the model's horizontal and vertical coordinates. After matching, the sampled texture color is assigned to the diffuse color. Specular reflection is given to make the white model more realistic.
[0031] Define style variables and map them to style fields in the configuration file to determine the current rendering style type. 0 is the default style, i.e., white texture. Other styles start from 1 and correspond to the style fields in the configuration file in turn.
[0032] In a specific application, this embodiment uses the CesiumJS engine on the web to implement the basic loading of 3dtiles. CesiumJS is a WebGL-based map engine written in JavaScript. Cesium supports 3D, 2D, and 2.5D map displays. A method for obtaining texture images is added. Specifically, the b3dm is parsed to obtain basic texture image information. When the texture image has the KHR_texture_basisu extension and the browser supports basis images (i.e., the ktx2 format images mentioned earlier), the basis image ID and the corresponding model height are obtained. Based on the image ID, the height is compared with the current style image group (images) in the configuration file. Based on the maximum model height corresponding to the image, the corresponding texture image is loaded.
[0033] Simultaneously, shaders are set for 3dtiels to determine how to render the graphics and achieve effects such as texture mapping and specular reflection. Specifically, in this embodiment, firstly, v_normalMC is passed into the fragment shader in the variable varyings; v_normalMC is the normal vector in the model's internal coordinate system. Then, in the fragment shader, it distinguishes whether the material to be rendered is a top-side thin sheet or an extruded body by determining whether the texCoord_1.x corresponding to the texture unit TEXTURE1 is 0.
[0034] If texCoord_1.x is not 0, it means the top surface needs to be rendered. This can be achieved by: material.diffuse=texture2D(u_baseColorTexture,vec2(mod(positionMC.x,1024.0) / 1024.0,mod(positionMC.y,1024.0) / 1024.0)).rgb The color from the texture image is captured and set to the material. Here, `material.diffuse` is the base material type, defining the diffuse color of the model surface; `u_baseColorTexture` is the passed-in texture; `mod` is the modulo function; and `positionMC` represents the model's internal coordinates. This example uses a 1024*1024 resolution texture image, meaning both `width` and `height` are 1024, representing a single top-side texture image. `mod(positionMC.x, width) / width` normalizes the texture coordinates. If the sampling point coordinates on the texture image are changed, for example, by multiplying the denominator of `mod(positionMC.x, width) / width` by a factor of 10 (e.g., `widthScale` by 10), the sampling point coordinates are reduced by a factor of 10 on the texture image's x-axis. Here, `widthScale` is the width multiplier in the configuration file, used to change the scaling factor of the sampling point coordinates on the texture image's x-axis.
[0035] If texCoord_1.x equals 0, it indicates an extruded body, and its sides need to be rendered. First, the top face needs to be discarded from rendering. If it is rendered, it will overwrite the rendering result of the previous top face slice. This can be done by comparing the top face direction vector with the vertex normal vector. If dot(vec3(0.,0.,1.),v_normalMC)>0.0, it indicates the top of the extruded body, and its rendering should be discarded using discard. If it is greater than 0.0, it indicates a side face.
[0036] To ensure that the texture fits perfectly against the side of the building's white model without deformation, inversion, or tilting, the following processing is required.
[0037] The texture image is the same as before, using a resolution of 1024*1024. The dot product of the Y-axis direction and the normal vector of the model's interior points is set to `dotYAxis=dot(vec3(0.,1.,0.),v_normalMC)`. The magnitude of the normal vector of the model's interior points is calculated as `absNNomal`. The cosine of the normal vector of the model's interior points relative to the Y-axis direction can be calculated by dividing `dotYAxis / absNNomal`. If the cosine value is 0.0, it means that the normal vector of the model's interior points is perpendicular to the Y-axis direction, so the texture X coordinate is: textureX=mod(positionMC.y,width) / width / widthScale Here, `widthScale` is the width multiplier in the configuration file, used to change the scaling factor of the sampling point coordinates on the x-axis of the texture image; if the `cos` value is not 0.0, then... The formula textureX=mod(positionMC.x,width) / width / cosA determines the horizontal position of the texture's x-axis coordinate on the side of the building's white model. The formula `textureY = mod(positionMC.z, width) / width / heightScale)` determines the position of the texture image's y-axis coordinates vertically along the side of the building's white membrane. Here, `height` is the height specified in the configuration file, used to change the scaling factor of the sampling point coordinates on the texture image's y-axis. Finally, the texture color is sampled using `vec4 color = texture2D(u_baseColorTexture, vec2(textureX, -textureY))`, and the color is assigned to the material using `material.diffuse = color .rgb`. The `material.specular` property is set to establish an overall specular reflection effect.
[0038] Additionally, define the uniforms field `u_texture_type`. This field will map to the style field in the configuration file, determining the current rendering style type. In the fragment shader, check the value of `u_texture_type`; if it equals 0, render a white texture image, such as... Figure 2 The image shown is the default texture image; if it equals 1, a set of texture images corresponding to the daytime style will be rendered, such as... Figure 3 As shown; if it equals 2, then render a set of texture images corresponding to the night scene style, such as... Figure 4 As shown.
[0039] S09: Switch styles, clear the white model and its occupied memory, and load the new style white model; when switching between different style textures on the web, clear the existing white model and its occupied memory. After clearing, load the white model of the currently selected style. Iterate through each tile node in 3dtiles, setting its associated objects such as _content, _ancestorWithContent, and _priorityHolder to null, and also setting the derivedCommands and _uniformMap associated objects in view.frustumCommandsList to null. This truly releases the memory occupied by the original 3dtiles, making the loading of 3dtiles tiles with different style textures faster and preventing freezing.
[0040] For example, using the same set of 3dtiles tiles, monitor the actual memory usage of JavaScript using Google Chrome's incognito mode Task Manager. If only the Cesium-provided method `viewer.scene.primitives.remove(tileset)` is used to remove 3dtiles, the actual memory usage of JavaScript decreases from 309209kb to 235770kb, a reduction of only 73439kb, or approximately 23%. However, if the method described above for clearing 3dtiles memory is used, the actual memory usage of JavaScript decreases from 307861kb to 99612kb, a reduction of 208249kb, or approximately 68%. Therefore, the method described above for clearing 3dtiles memory significantly reduces the memory usage of 3dtiles.
[0041] Example 2 This embodiment discloses a system for batch dynamic switching of architectural white model textures on a web-based platform, such as... Figure 5 The following are included: The Shapefile acquisition module is used to obtain building shapefiles that include the height field (Height). The surface file processing module reads each surface feature from the Shapefile building surface file and calculates the bounding rectangle of each surface feature; it uses a quadtree algorithm to process the bounding rectangle of each surface feature, generating a box-type bounding box; it extrudes the surface features along the Z-axis with the height field to construct a geometric triangulation; after extruded, it generates an extruded body with one top surface and multiple side surfaces, and simultaneously generates a thin sheet containing only the top surface; it stores all vertex coordinates, vertex indices, normal vectors, and the height field (Height) of the extruded body, as well as all vertex coordinates, vertex indices, and normal vectors of the top surface thin sheet; The texture setting slicing module is used for texture settings. The `images` field of the white model texture image array retains only one image information, including the image name and path. The image is a white image in ktx2 format. Simultaneously, the `KHR_texture_basisu` extension setting is performed, establishing a connection with the `images` field through an index. The coordinates of the aforementioned extruded body and top sheet are bound to texture units `TEXTURE0` and `TEXTURE1`, respectively. Based on the vertex coordinates, initial values for the texture coordinates of the extruded body and top sheet are given, and the texture coordinates are bound to texture units `TEXTURE0` and `TEXTURE1`, respectively. Following the 3dtiles standard, other data is organized and generated to create 3dtiles slices. All vertex coordinates, vertex indices, normal vectors, texture coordinates, texture units, and the height field are organized into a `b3dm` file, and the bounding box and `b3dm` file path are organized into a `tileset.json` file.
[0042] The file configuration module is used to create configuration files and set texture image information for different styles. The white model rendering module is used to render white models according to the configuration file. When switching between different styles of white model textures, it clears the existing white models and the memory they occupy, and then loads the white model of the currently selected style.
[0043] Based on the system operation described in this embodiment for batch dynamic switching of architectural white model textures on the Web client, the specific method and steps are the same as those in the aforementioned Embodiment 1, and will not be repeated here.
[0044] Example 3 This embodiment discloses a device for batch dynamic switching of architectural white model textures on a web-based platform, comprising a processor and a memory electrically connected to each other; the memory is used to store a computer program; when the processor executes the aforementioned computer program, it can implement the method for batch dynamic switching of architectural white model textures on a web-based platform as described in Embodiment 1 above. The specific method steps are the same as those in Embodiment 1 above, and will not be repeated here.
[0045] Example 4 This embodiment discloses a computer-readable storage medium storing a computer program. When the computer program is executed, it can implement the method for batch dynamic switching of building white model textures for Web-based applications as described in Embodiment 1 above. The specific method steps are the same as in Embodiment 1 above and will not be repeated here.
[0046] The computer described in this application embodiment can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. The computer-readable storage medium can be any usable medium that a computer can read, or a data storage device such as a server or data center that integrates one or more usable media. The usable medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital versatile optical disc (DVD)), or a semiconductor medium (e.g., solid-state drive (SSD)). The software formed by the computer's stored code can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other storage media that are mature in the art.
[0047] In the various embodiments of this application, the functional modules can be integrated into one processing unit or module, or each module can exist physically separately, or two or more modules can be integrated into one unit or module. In the above embodiments, they can be implemented entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, they can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated.
[0048] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for batch dynamic switching of architectural white model textures on a web-based platform, characterized in that... include: Retrieve the Shapefile building surface file containing the Height field; Read each face feature from the Shapefile building face file and calculate the bounding rectangle of each face feature; The quadtree algorithm is used to process the bounding rectangle of each face feature to generate a box-type bounding box. The opposite features are stretched along the Z-axis using the height field to construct a geometric triangulation. After stretching, an extruded body with one top face and multiple side faces is generated, along with a thin sheet containing only the top face. All vertex coordinates, vertex indices, normals, and the height field of the extruded body, as well as all vertex coordinates, vertex indices, and normals of the top face thin sheet, are stored. Perform texture settings; the images field of the white model texture image array for the building retains only one image information, including the image name and path, and the image is a white image in ktx2 format; at the same time, perform KHR_texture_basisu extended settings, and establish a relationship with the images field through index; the coordinates of the aforementioned extruded body and the top surface sheet are respectively bound to the texture units TEXTURE0 and TEXTURE1; according to the vertex coordinates, the initial values of the texture coordinates of the extruded body and the top surface sheet are given respectively, and the texture coordinates are bound to the texture units TEXTURE0 and TEXTURE1 respectively; According to the 3dtiles standard, organize and generate other data to generate 3dtiles tiles; organize all vertex coordinates, vertex indices, normal vectors, texture coordinates, texture units and height field Height to generate a b3dm file, and organize the bounding box and b3dm file path to generate a tilesset.json file; Create a configuration file to set texture image information for different styles; Based on the configuration file, render the white model; when switching between different styles of white model textures, clear the existing white model and the memory it occupies, and then load the white model of the currently selected style. The white model rendering based on the configuration file includes: the web client loads and parses the b3dm file in the corresponding 3dtiels slice file according to the visualization range, and dynamically loads the configuration file. According to the current style of the configuration file, the corresponding style and texture image path are obtained. The stored vertex index, vertex coordinates, normal vector and height fields are matched with the texture image, and the white model texture rendering is realized through the shader. The specific steps for rendering white model textures using shaders include: first, in the vertex shader, the model normal vector is passed to the fragment shader; then, in the fragment shader, the texture, texture coordinates, and specular reflection are processed; the x-coordinate of the texture coordinate texCoord_1 corresponding to the texture unit TEXTURE1 is determined to distinguish whether the top surface sheet or the extruded body is being rendered; if the x-coordinate of texCoord_1 is not 0, it means that the top surface sheet is being rendered and the top surface needs to be rendered; otherwise, it means that the side surface needs to be rendered; the bottom surface is not processed. For top-side rendering, diffuse reflection processing is performed. Given the diffuse reflection color of the top surface of the model, the sampling result of the top surface texture image is used, and the corresponding texture image is tiled onto the top surface. For side rendering, the top surface rendering is discarded first, and only the side texture is rendered. Given the correspondence between the horizontal and vertical directions of the model's side and the texture coordinates, if the normal vector of the model's internal point is perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1]. If the normal vector of the model's internal point is not perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1], and the angle between the two vectors is rotated. At the same time, the scaling ratio of the texture image is set according to the size of the texture image and the range of the model's horizontal and vertical coordinates. After matching, the sampled texture result color is assigned to the diffuse color. Specular reflection is given. Style variables are defined and mapped to the style fields in the configuration file to determine the current rendering style type. 0 is the default white texture style, and other styles start from 1 and correspond to the style fields in the configuration file in sequence.
2. The method for batch dynamic switching of architectural white model textures for Web clients according to claim 1, characterized in that: When calculating the bounding rectangle range of each face feature, first find the point with the minimum x value, find the point with the maximum x value, find the point with the minimum y value, find the point with the maximum y value, and then combine the x and y values of the points with the minimum x and y values into a corner point.
3. The method for batch dynamic switching of architectural white model textures for Web clients according to claim 2, characterized in that: The texture image information includes white model texture style information, current style, whether specular reflection is used, specular reflection value, scaling factor of texture image upsampling point coordinates on texture image x-axis, and texture image paths for the top and sides of the building under each style.
4. A system for batch dynamic switching of architectural white model textures on a web-based platform, characterized in that... include: The Shapefile acquisition module is used to obtain building shapefiles that include the height field (Height). The Shapefile processing module is used to read each face feature of the Shapefile building face file and calculate the bounding rectangle of each face feature; The quadtree algorithm is used to process the bounding rectangle of each face feature to generate a box-type bounding box. The opposite features are stretched along the Z-axis using the height field to construct a geometric triangulation. After stretching, an extruded body with one top face and multiple side faces is generated, along with a thin sheet containing only the top face. All vertex coordinates, vertex indices, normals, and the height field of the extruded body, as well as all vertex coordinates, vertex indices, and normals of the top face thin sheet, are stored. The texture setting slice module is used for texture settings; the images field of the building white model texture image array retains only one image information, including the image name and path, and the image is a white image in ktx2 format; at the same time, KHR_texture_basisu extended settings are performed, and the association is established with the images field through index; the coordinates of the aforementioned extruded body and the top surface sheet are respectively bound to the texture units TEXTURE0 and TEXTURE1; according to the vertex coordinates, the initial values of the texture coordinates of the extruded body and the top surface sheet are given respectively, and the texture coordinates are bound to the texture units TEXTURE0 and TEXTURE1 respectively; According to the 3dtiles standard, organize and generate other data to generate 3dtiles tiles; organize all vertex coordinates, vertex indices, normal vectors, texture coordinates, texture units and height field Height to generate a b3dm file, and organize the bounding box and b3dm file path to generate a tilesset.json file; The file configuration module is used to create configuration files and set texture image information for different styles. The white model rendering module is used to render white models according to the configuration file; when switching between different styles of white model textures, it clears the existing white models and the memory they occupy, and then loads the white model of the currently selected style. The process of rendering the white model according to the configuration file includes: the web client loads and parses the b3dm file in the corresponding 3dtiels slice file according to the visualization range, and dynamically loads the configuration file. According to the current style of the configuration file, the corresponding style and texture image path are obtained. The stored vertex index, vertex coordinates, normal vector and height fields are matched with the texture image, and the white model texture is rendered through the shader. The specific steps for rendering white model textures using shaders include: first, in the vertex shader, the model normal vector is passed to the fragment shader; then, in the fragment shader, the texture, texture coordinates, and specular reflection are processed; the x-coordinate of the texture coordinate texCoord_1 corresponding to the texture unit TEXTURE1 is determined to distinguish whether the top surface sheet or the extruded body is being rendered; if the x-coordinate of texCoord_1 is not 0, it means that the top surface sheet is being rendered and the top surface needs to be rendered; otherwise, it means that the side surface needs to be rendered; the bottom surface is not processed. For top-side rendering, diffuse reflection processing is performed. Given the diffuse reflection color of the top surface of the model, the sampling result of the top surface texture image is used, and the corresponding texture image is tiled onto the top surface. For side rendering, the top surface rendering is discarded first, and only the side texture is rendered. Given the correspondence between the horizontal and vertical directions of the model's side and the texture coordinates, if the normal vector of the model's internal point is perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1]. If the normal vector of the model's internal point is not perpendicular to the unit vector vec3(0.,1.,0.), the sampled texture x-coordinate is equal to the remainder of the model's internal x-coordinate and the width of the texture image, and normalized to the interval [0,1], and the angle between the two vectors is rotated. At the same time, the scaling ratio of the texture image is set according to the size of the texture image and the range of the model's horizontal and vertical coordinates. After matching, the sampled texture result color is assigned to the diffuse color. Specular reflection is given. Style variables are defined and mapped to the style fields in the configuration file to determine the current rendering style type. 0 is the default white texture style, and other styles start from 1 and correspond to the style fields in the configuration file in sequence.
5. A device for batch dynamic switching of architectural white model textures for web-based applications, comprising a processor and a memory electrically connected to each other; the memory is used to store computer programs; characterized in that: When the processor executes the aforementioned computer program, it can implement the method for batch dynamic switching of architectural white model textures for Web-based applications as described in any one of claims 1-3.
6. A computer-readable storage medium, characterized in that: The storage medium stores a computer program; when the computer program is executed, it can implement the method for batch dynamic switching of architectural white model textures for Web-based applications as described in any one of claims 1-3.
Citation Information
Patent Citations
Automatic texture construction method for white mold based on live-action three dimensions
CN114998503A
Vector-based road three-dimensional live-action structured modeling method
CN115187647A