Two-phase seabed terrain scouring dynamic simulation method based on three.js
By processing and dynamically rendering the point cloud data of the seabed topography in two phases, the problem of low rendering efficiency of the Three.js library in seabed topography erosion simulation was solved, achieving efficient dynamic simulation effects and serving the construction of offshore wind power projects.
Patent Information
- Application Number
- CN202310809323.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-04
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-07-04
AI Technical Summary
Existing 3D animation and motion simulation methods suffer from low rendering efficiency and network congestion when handling two-phase scour dynamic simulations of seabed topography. In particular, when using the Three.js library, particle properties need to be optimized manually to achieve complex animation effects.
By processing point cloud data from two phases of seabed topography, calculating the elevation difference and marking negative vertices, dynamic rendering is performed using BufferGeometry and RawShaderMaterial, combined with uniforms properties and the requestAnimationFrame function to achieve elevation and color updates.
It improves rendering efficiency, simplifies texture mapping, enhances the sense of three-dimensionality, and intuitively displays the dynamic change process, meeting the construction needs of offshore wind power projects.
Smart Images

Figure CN116992640B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a two-stage dynamic simulation method for seabed topographic erosion based on Three.js. It is applicable to the fields of animation and motion simulation. Background Technology
[0002] 3D modeling of the seabed topography can visually display the seabed topography and scouring / deposition at the wind turbine pile location. By modeling the seabed topography at the same location at different times, the scouring and deposition at the wind turbine pile location at different points in time can be observed. 3D simulation and dynamic scouring simulation of the topography in two phases can visually demonstrate the change process of the topography in two phases. By simulating the scouring or deposition changes at various points of the topography from one point in time to the next, users can understand the scouring and deposition of the seabed topography, assess the topographic stability issues during wind turbine operation, help improve the design of offshore wind turbine seabed foundations, and predict the impact of the marine environment on offshore wind power projects.
[0003] There are two main types of existing 3D animation and motion simulation methods. One type is the rendering engine represented by Unreal Engine, which supports complex physical simulation and animation effects but has high requirements for hardware and software. The other type is the lightweight JavaScript library represented by Three.js, which provides basic functions. Although it is not as rich in rendering functions as Unity and Unreal Engine, it is suitable for displaying animation effects in web browsers and can be integrated into existing offshore wind power platforms.
[0004] Commonly used 3D animation and simulation techniques include keyframe animation, fluid simulation, and particle systems. Traditional keyframe animation utilizes parallax by setting a large number of keyframes and playing them sequentially. However, considering the massive amount of point clouds in terrain, the large amount of keyframe data can cause network congestion and low rendering efficiency. Fluid simulation can simulate flow and deformation effects, but its high computational complexity makes it unsuitable for platform integration. Particle systems can simulate various visual effects such as smoke and fire, enhancing visual effects by adjusting particle effects attributes and changing particle properties and behavior through conditional constraints. In Three.js, "THREE.Points" is a class representing point clouds, with each particle / point cloud having its own position, color, and size attributes, making it suitable for dynamic simulation of seabed terrain. However, when using Three.js to handle large and complex animation effects, it is necessary to manually refactor and optimize the shaders to control particle properties. Summary of the Invention
[0005] The technical problem to be solved by this invention is to provide a two-phase dynamic simulation method for seabed topographic scour based on Three.js to address the problems mentioned above.
[0006] The technical solution adopted in this invention is: a two-phase dynamic simulation method for seabed topographic scour based on Three.js, characterized in that:
[0007] A. Process the point cloud data of the seabed topography in two phases to obtain the vertex coordinate data of the planar buffer geometry corresponding to the point cloud data in the two phases respectively. Calculate the elevation difference of each vertex based on the vertex coordinate data in the two phases respectively and mark the vertices with negative elevation differences.
[0008] B. Create an empty BufferGeometry, pass the vertex coordinate data of the first phase of terrain to the BufferGeometry using the position property, and pass the elevation difference between the two phases of terrain to the BufferGeometry using the newly created property in the index order of the vertex coordinate data;
[0009] C. Use the uniforms property to pass the elevation increment for each frame, the overall translation of the elevation of the vertex of the planar buffer geometry, and the palette values generated from the first phase of terrain elevation data.
[0010] D. Use the RawShaderMaterial encapsulated in Three.js as the base to design a shader renderer that conforms to the seabed terrain, and customize vertex and fragment renderers to complete dynamic rendering.
[0011] The vertex shader is used to determine the elevation increment of the current frame by comparing the elevation increment and elevation difference of the vertices in the previous frame, thereby updating the elevation / position of all point cloud data. The elevation values of the point cloud data in the current frame in the vertex shader are passed into the fragment shader, and the color of each vertex is recalculated according to the color palette based on the elevation values, thereby updating the color of all point cloud data.
[0012] E. Use the requestAnimationFrame function to execute animation effects. Determine whether the elevation difference limit of each vertex in the current frame is increasing by comparing the elevation difference limit of each vertex in the previous frame with the maximum elevation difference between the two point cloud data.
[0013] The process of processing the point cloud data from the two phases of seabed topography to obtain the vertex coordinate data of the planar buffer geometry corresponding to the two phases of point cloud data includes:
[0014] S1. Obtain point cloud data of the seabed topography, and create a new planar buffer geometry based on the range and data interval of the point cloud data;
[0015] S2. Translate the entire point cloud data to move it to the origin.
[0016] S3. Check the mesh matching degree between the translated point cloud data and the planar buffer geometry. If the translated point cloud data does not coincide with the mesh, translate the entire point cloud data again until the point cloud data coincides with the mesh.
[0017] S4. The point cloud data that coincides with the mesh and the vertex coordinate data of the planar buffer geometry are indexed by the point cloud data and mapped one by one to the vertex coordinate data of the planar buffer geometry.
[0018] The translation of the entire point cloud data to move it to the origin includes:
[0019]
[0020] In the formula, These represent the maximum and minimum values of the point cloud data in the X direction, Y direction, and Z direction, respectively, and T. i (x ti ,y ti ,z ti (i = 1, 2, ..., N) represents point cloud data, M i (x mi ,y mi ,z mi ), i = 1, 2, ..., N are the point cloud data after translation.
[0021] If the translated point cloud data does not coincide with the grid, the entire point cloud data is translated again until it coincides with the grid, including:
[0022] If the translated point cloud data does not coincide with the grid, the overall translation of all point cloud data in the X and Y directions is completed by the following formula;
[0023]
[0024] In the formula, d s The data intervals of the planar buffer geometry in the X and Y directions are... This is the floor symbol.
[0025] The indexing mechanism for point cloud data coinciding with the mesh and vertex coordinate data of the planar buffer geometry maps point cloud data one-to-one to vertex coordinate data of the planar buffer geometry, including:
[0026] Index i =((ry) mi ) / ds)*(2*r / ds+1)+(x mi +r) / ds
[0027] In the formula, r is the radius of the seabed topographic point cloud data, (2 / r / ds+1) is the number of vertices per row, and ((ry mi () / ds) is the mapping of the current point cloud onto the Y-axis of the planar buffer geometry mesh, (x) mi +r) / ds represents the mapping of the current point cloud onto the X-axis of the planar buffer geometry mesh, M i (x mi ,y mi ,z mi The vertex coordinate data of the planar buffer geometry are arranged in order of index. i Each vertex corresponds to one vertex.
[0028] z pIndexi =z mi
[0029] In the formula, z pIndexi This represents the index of the vertex coordinate data in sorted order. i The elevation values of each vertex.
[0030] The step of calculating the elevation difference of each vertex based on the vertex coordinate data of the two periods and marking vertices with negative elevation differences includes:
[0031] A marker value is added to vertices with negative elevation differences. This marker value is greater than the maximum absolute value of the differences among all point cloud data.
[0032] The method of using uniforms attributes to pass the elevation increment for each frame and the overall translation of the elevation of the vertex of the planar buffer geometry includes:
[0033] In the uniforms variable, the parameter defineY is set to the elevation change amount for each rendering, and the parameter ignoreZ is used to find missing parts of the vertex data of the plane buffer geometry.
[0034] The method of passing the palette values generated from the first phase of terrain elevation data using uniforms attributes includes:
[0035] The vertex elevation data of the planar buffer geometry corresponding to the first phase of seabed topography are segmented and statistically analyzed. An initial color palette is set based on the premise that the distribution of elevation data is normal, and the elevation values corresponding to the color values of the color palette are passed into uniforms.
[0036] The initial color palette setting, based on the premise that the elevation data distribution follows a normal distribution, includes:
[0037] The interval mean z of the elevation segment corresponding to the expected elevation value μ mid The corresponding color is yellow, and the lowest elevation value is z. tiThe corresponding color is blue, the color corresponding to sea level is red, and the elevation value z mid / 2 is pink, elevation value (z) mid +z ti ) / 2 is cyan.
[0038] The method utilizes RawShaderMaterial, encapsulated in Three.js, as a base to design a shader renderer that conforms to the underwater terrain. Custom vertex and fragment renderers are used to achieve dynamic rendering, including:
[0039] The renderer increments `defineY` at the same rate during each frame's rendering. Using the first phase of terrain data as the base data, the vertex renderer compares the elevation difference `Δz` between the two phases of vertex data with `defineY`. If the elevation difference is less than `defineY`, the point has not yet reached the second phase's terrain elevation point in the current frame, and the elevation value is incremented by `defineY`. If the elevation difference is greater than or equal to `defineY`, the point has reached the second phase's terrain elevation point in the current frame, and the elevation value is incremented by `Δz`. For marked `Δz` values, the absolute value of the initial value is restored before comparison.
[0040] The fragment renderer receives the elevation values corresponding to each initial color in the first phase terrain data palette as uniforms values, as well as the coordinate values of each vertex in the current frame passed in from the vertex renderer. First, it determines the size of the passed coordinate elevation and ignoreZ. If the elevation value is less than or equal to ignoreZ, the color transparency of the vertex is set to 0. Otherwise, it determines the interval of the vertex elevation value in the palette and its ratio, thereby calculating the RGB value of each vertex.
[0041] Step E includes:
[0042] Use requestAnimationFrame(animate) to create a loop and automatically adjust the frame rate according to the monitor's refresh rate. In the JavaScript code, compare the height difference increment aniDefinY of the previous frame with the absolute value of the maximum height difference disperMax.
[0043] If aniDefinY is less than disperMax, then increment the value of aniDefinY; otherwise, assign aniDefinY to 0.
[0044] The vertex elevation is updated in each frame by assigning the value of aniDefinY to the definitionY in uniforms.
[0045] A two-phase dynamic simulation device for seabed topographic scour based on Three.js, characterized in that it includes:
[0046] Module A is used to process the point cloud data of the seabed topography in two phases to obtain the vertex coordinate data of the planar buffer geometry corresponding to the two phases of point cloud data. Based on the vertex coordinate data of the two phases, the elevation difference of each vertex is calculated and the vertices with negative elevation differences are marked.
[0047] Module B is used to create an empty BufferGeometry. The vertex coordinate data of the first phase of terrain is passed to the BufferGeometry using the position property. The elevation difference between the two phases of terrain is passed to the BufferGeometry using a newly created property in the index order of the vertex coordinate data.
[0048] Module C is used to pass the elevation increment for each frame, the overall translation of the elevation of the planar buffer geometry vertices, and the palette values generated from the first phase of terrain elevation data using the uniforms property;
[0049] Module D is used to design shader renderers that conform to the underwater terrain using the RawShaderMaterial encapsulated in Three.js as the base, and to complete dynamic rendering by customizing vertex and fragment renderers.
[0050] The vertex shader is used to determine the elevation increment of the current frame by comparing the elevation increment and elevation difference of the vertices in the previous frame, thereby updating the elevation / position of all point cloud data. The elevation values of the point cloud data in the current frame in the vertex shader are passed into the fragment shader, and the color of each vertex is recalculated according to the color palette based on the elevation values, thereby updating the color of all point cloud data.
[0051] Module E is used to execute animation effects using the requestAnimationFrame function. It determines whether the elevation difference limit of each vertex in the current frame is increasing by comparing the elevation difference limit of each vertex in the previous frame with the maximum elevation difference between the two point cloud data.
[0052] A storage medium storing a computer program executable by a processor, characterized in that: when the computer program is executed, it implements the steps of the two-phase seabed topographic scour dynamic simulation method based on Three.js.
[0053] A two-phase seafloor topographic scour dynamic simulation device based on Three.js has a memory and a processor. The memory stores a computer program that can be executed by the processor. The characteristic is that when the computer program is executed, it implements the steps of the two-phase seafloor topographic scour dynamic simulation method based on Three.js.
[0054] The beneficial effects of this invention are: it improves rendering efficiency, simplifies and efficiently completes texture mapping, and enhances the sense of three-dimensionality; it intuitively displays the dynamic change process, better serving the construction needs of offshore wind power projects. This invention establishes an effective indexing mechanism between point cloud data and the vertices of Three.js built-in geometry, matching the XY coordinates of the point cloud data with the XY values of the Three.js built-in geometry to create an elevation index; by designing a low-level shader renderer suitable for seabed topography data and setting scene animation effects, the elevation value of the point cloud data in each frame of the animation is changed at the same rate, and the color value is recalculated to achieve dynamic rendering effects. Attached Figure Description
[0055] Figure 1 This is a schematic diagram of the overall process of the method of the present invention;
[0056] Figure 2 This is a schematic diagram of a single-phase terrain 3D simulation process;
[0057] Figure 3 This is a schematic diagram of the dynamic simulation process of two phases of terrain erosion.
[0058] Figure 4 This is a schematic diagram of the vertex renderer elevation update process;
[0059] Figure 5 A schematic diagram of the fragment renderer's color update process;
[0060] Figure 6 This is a 3D simulation rendering of the seabed topography for the first phase.
[0061] Figure 7 This is a 3D simulation rendering of the seabed topography for the second phase.
[0062] Figure 8 This is an intermediate state rendering of the two phases of terrain dynamic simulation;
[0063] Figure 9 (1) to (4) are enlarged views of the dynamic simulation process. Detailed Implementation
[0064] This embodiment presents a dynamic simulation and optimization method for seabed topographic scour based on Three.js, which specifically includes the following steps:
[0065] A. Process the point cloud data of the seabed topography in two phases to obtain the vertex coordinate data of the planar buffer geometry corresponding to the two phases of point cloud data. Calculate the elevation difference of each vertex based on the vertex coordinate data of the two phases and mark the vertices with negative elevation differences.
[0066] Since point cloud data will have varying degrees of missing data during scanning, and in order to obtain the elevation difference between the two data sets at each scanning point, it is necessary to match each point cloud data set of the two sets one by one and then calculate the difference. Therefore, in this embodiment, the point cloud data of the two sets of seabed topography are processed to complete the matching of the two sets of topography data in the scene, and the corresponding planar buffer geometry P1, P2 and their vertex arrays are obtained.
[0067] This embodiment describes a method for processing two phases of point cloud data on seabed topography to obtain the corresponding planar buffer geometry for each phase of point cloud data. The method includes the following steps:
[0068] S1. The obtained point cloud data of the seabed topography is the result of regular scanning at certain intervals. Its data characteristics have the highest similarity to the planar buffer geometry in Three.js. Therefore, the planar buffer geometry is selected as the base for seabed topography simulation. First, a planar buffer geometry is created according to the range and interval of the point cloud data.
[0069] Initialize the scene and add light sources, cameras, renderers, and controllers to it, based on the current seabed topography point cloud data range size r and data interval d. s Create a new planar buffer geometry and set the Z-axis values for its vertices. For the vertex data of the geometry, x pi y pi , z pi These represent the values along the X, Y, and Z axes of the point cloud data, respectively, with N being the total number of point clouds.
[0070] S2. Point cloud data consists of the XYZ values of terrain scan points, where XY values are coordinates in a Cartesian coordinate system, and the planar buffer geometry is generated at the scene origin by default. Before matching the point cloud data with the planar buffer geometry, a coordinate transformation must be performed first, that is, the point cloud data is translated as a whole so that the point cloud data is moved to the coordinate origin.
[0071] Let T i (x ti ,y ti ,z ti (i = 1, 2, ..., N) represents any point in the point cloud data, x ti yti , z ti Here, represents the values along the X, Y, and Z axes of the point cloud data, respectively, and N is the total number of point clouds. The translation formula for each point cloud is:
[0072]
[0073] In Equation 1, These represent the maximum value in the X direction, the minimum value in the X direction, the maximum value in the Y direction, the minimum value in the Y direction, and the minimum value in the Z direction, respectively. i (x mi ,y mi ,z mi ), i = 1, 2, ..., N are the point cloud data after translation.
[0074] S3. The spacing between adjacent cells in the planar buffer geometry is the same as the scanning interval of the point cloud data. The planar buffer geometry is created with the origin as the center, and the cells in the X and Y directions are perfectly symmetrical about the coordinate axes, with each cell number being an integer. However, the point cloud data is not symmetrically distributed. After translation, the point cloud data may not coincide with the grid, meaning that while the number of cells is the same about the coordinate axes, it is not an integer. This mismatch will cause incorrect mapping values of the point cloud data on the X and Y axes when establishing the elevation index, resulting in an overall offset of the point cloud data, which visually appears as left-right splitting and mirroring. Therefore, a grid matching check is performed between the translated point cloud data and the planar buffer geometry. If there is a mismatch, the entire point cloud data is translated again on a small scale until the point cloud data coincides with the grid.
[0075] To prevent the translated point cloud data from failing to coincide with the XY grid of the geometry, a grid matching check needs to be performed on the translated point cloud data. If the translated point cloud data does not coincide with the grid, the overall translation of all point cloud data in the X and Y directions can be completed using Formula 2, with the translation amount being the distance between the origin of the point cloud and the origin of the grid.
[0076]
[0077] In Equation 2, d s The data spacing in the X and Y directions for a planar buffer geometry. This is the floor symbol.
[0078] S4. The point cloud data that coincides with the mesh and the vertex data of the planar buffer geometry are indexed by the point cloud data and mapped one by one to the vertex data of the planar buffer geometry.
[0079] Establish the translated point cloud data M i With vertex data P i The indexing mechanism, namely Mi (x mi ,y mi ,z mi Mapping one-to-one to P i (x pi ,y pi ,z pi In this context, the index formula is:
[0080] Index i =((ry) mi ) / ds)*(2*r / ds+1)+(x mi +r)*ds Equation 3
[0081] In Equation 3, r is the radius of the seabed topographic point cloud data, (2*r / ds+1) is the number of vertices per row, ((ry mi ()*ds) represents the mapping of the current point cloud onto the Y-axis of the geometry mesh, (x mi +r)*ds represents the mapping of the current point cloud onto the X-axis of the geometry mesh.
[0082] Get the index value Index i The point cloud data is then mapped onto the grid using the following formula:
[0083] z pIndexi =z mi Formula 4
[0084] In Equation 4, z pIndexi This represents the index in the vertex data arranged in order. i The z-value (elevation value) of each vertex, z mi This represents the z-value (elevation value) of the i-th point in the translated point cloud data.
[0085] In this embodiment, according to The elevation difference between the two vertices is calculated, with positive and negative values representing topographic deposition or erosion, respectively. To differentiate them during rendering, vertices with negative elevation differences are marked in this embodiment:
[0086]
[0087] In Equation 5, Z ex This is a marker value added to the vertices with negative elevation differences. In this example, the marker value is greater than the maximum absolute value of all point cloud data differences.
[0088] B. Create an empty BufferGeometry, pass the vertex coordinate data of the first phase of terrain to the BufferGeometry using the position property, and pass the elevation difference between the two phases of terrain to the BufferGeometry using a newly created property in the index order of the vertex coordinate data.
[0089] C. Use the uniforms property to pass the elevation increment for each frame, the overall translation of the elevation of the planar buffer geometry vertices, and the palette values generated from the first phase of terrain elevation data.
[0090] In this example, the uniforms property is used to pass the elevation increment for each frame and the overall translation of the elevation of the planar buffer geometry vertices. This includes adding defineY and ignoreZ variables to uniforms, setting defineY to the elevation change for each render and ignoreZ to be used to find missing parts of the planar buffer geometry vertex data.
[0091] In this embodiment, the uniforms property is used to pass the palette values generated from the first phase of terrain elevation data. This includes: segmenting and statistically analyzing the vertex elevation data of the planar buffer geometry corresponding to the first phase of seabed topography; setting an initial palette based on the premise that the elevation data distribution is a normal distribution; and using the interval mean z of the elevation segment corresponding to the expected elevation value μ. mid The corresponding color is yellow, and the lowest elevation value is z. ti The corresponding color is blue, the color corresponding to sea level is red, and the elevation value z mid *2 is pink, representing the elevation value (z). mid +z ti ) / 2 is cyan, and the elevation values corresponding to the five color values in the palette are passed into uniforms.
[0092] D. Use the RawShaderMaterial encapsulated in Three.js as the base to design a shader renderer that conforms to the seabed terrain, and customize vertex and fragment renderers to complete dynamic rendering.
[0093] The vertex shader is used to determine the elevation increment of the current frame by comparing the elevation increment and elevation difference of the vertices in the previous frame, thereby updating the elevation / position of all point cloud data. The elevation values of the point cloud data in the current frame are passed from the vertex shader to the fragment shader, and the colors of each vertex are recalculated according to the color palette based on the elevation values, thereby updating the colors of all point cloud data.
[0094] The renderer controls the renderer to increment the size of defineY at the same rate during each frame rendering. Based on the terrain data of the first phase, the vertex renderer judges the difference in elevation between the two phases of vertex data Δz and the difference in predetermined data one by one. Then, it compares the difference with the value of defineY to determine the elevation value of the current vertex data in the current frame. For Δz with markings, it is restored to the absolute value of the initial value before comparison.
[0095] The fragment renderer receives the elevation values corresponding to each initial color in the first phase terrain data palette as uniforms values, as well as the coordinate values of each vertex in the current frame passed in from the vertex renderer. First, it determines the size of the passed coordinate elevation and ignoreZ. If the elevation value is less than or equal to ignoreZ, the color transparency of the vertex is set to 0. Otherwise, it determines the interval of the vertex elevation value in the palette and its ratio, thereby calculating the RGB value of each vertex.
[0096] The method for calculating the RGB value of each vertex in this embodiment includes:
[0097] Iterate through the geometry's vertex data to calculate the color value of each vertex. The color value is determined by the vertex's elevation value (val) before translation. Then, find the color segment (R) in the palette corresponding to the elevation value. i [color i ,color i+1 The elevation interval corresponding to this section is Z. i [z i ,z i+1 If ), then the proportion of val in that elevation interval is:
[0098] ratio=(val-z i ) / (z i+1 -z i Formula 6
[0099] The color value of the vertex is calculated separately for each of the three RGB channels using the ratio in Equation 6:
[0100]
[0101] Create a material named RawShaderMaterial, passing in uniforms, vertexShader, and fragmentShader, and setting the vertex color to true.
[0102] E. Use the requestAnimationFrame function to execute animation effects. Determine whether the elevation difference limit of each vertex in the current frame is increasing by comparing the elevation difference limit of each vertex in the previous frame with the maximum elevation difference between the two point cloud data.
[0103] Use requestAnimationFrame(animate) to create a loop and automatically adjust the frame rate according to the monitor's refresh rate. In the JavaScript code, compare the height difference increment aniDefinY of the previous frame with the absolute value of the maximum height difference disperMax.
[0104] If aniDefinY is less than disperMax, then increment the value of aniDefinY; otherwise, assign aniDefinY to 0.
[0105] The vertex elevation is updated in each frame by assigning the value of aniDefinY to the definitionY in uniforms.
[0106] This embodiment also provides a two-phase dynamic simulation device for seabed topographic scour based on Three.js, including: modules A to E.
[0107] In this example, module A processes the point cloud data of the seabed terrain in two phases, obtaining the vertex coordinate data of the planar buffer geometry corresponding to the two phases of point cloud data. It calculates the elevation difference of each vertex based on the vertex coordinate data of the two phases and marks vertices with negative elevation differences. Module B creates an empty BufferGeometry, passes the vertex coordinate data of the first phase of terrain to the BufferGeometry via the position property, and passes the elevation difference of the two phases of terrain to the BufferGeometry via a newly created property in the index order of the vertex coordinate data. Module C uses the uniforms property to pass the elevation increment value for each frame, the overall translation amount of the elevation of the planar buffer geometry vertices, and the palette value generated from the elevation data of the first phase of terrain. Module D uses the RawShaderMaterial encapsulated in Three.js as a base to design a shader renderer that conforms to the seabed terrain, and customizes vertex and fragment renderers to complete dynamic rendering. Module E uses the requestAnimationFrame function to execute animation effects, and determines whether the elevation difference limit of each vertex in the current frame is increasing by comparing the elevation difference limit of each vertex in the previous frame with the maximum elevation difference value of the two phases of point cloud data.
[0108] This embodiment also provides a storage medium storing a computer program that can be executed by a processor. When the computer program is executed, it implements the steps of the two-phase seabed topographic scour dynamic simulation method based on Three.js in this example.
[0109] This embodiment also provides a two-phase seafloor topographic scour dynamic simulation device based on Three.js, which has a memory and a processor. The memory stores a computer program that can be executed by the processor. When the computer program is executed, it implements the steps of the two-phase seafloor topographic scour dynamic simulation method based on Three.js in this example.
[0110] The following is an example to illustrate this:
[0111] This embodiment demonstrates how to visually display the seabed topography of offshore wind turbine piles using multibeam scanning point cloud data within the Three.js 3D engine environment. The display of a single phase of topography is achieved by matching the multibeam scanning point cloud data with planar buffer geometry in Three.js. The specific steps are as follows:
[0112] S0. Initialize the scene using THREE.Scene(), add a light source using THREE.AmbientLight(), add a camera using THREE.PerspectiveCamera(), add coordinate axes using THREE.AxesHelper(), add a renderer using THREE.WebGLRender(), and add a controller using OrbitControls.
[0113] S1. In this example, the radius of the point cloud data is 50m and the data interval is 0.2m. The initial planar buffer geometry is THREE.PlaneGeometry(50*2,50*2,(50*2) / 0.2,(50*2) / 0.2), and the elevation value of the geometry vertex ignoreZ is set to -1.
[0114] S2. Calculate the extreme values of the point cloud data in three directions as follows: X{min:658401.2,max:658501}, Y{min:3622663.2,max:3622763}, Z{min:-19.26,max:-13.13}. Translate the point cloud according to Equation 1, with translation amounts of 658451.1, 3622713.1, and -19.26 in the three directions, respectively. Taking the point cloud data X(658448.00,3622663.20,-16.13) as an example, after translation, it becomes X1(-3.1,-49.9,3.13).
[0115] S3. Perform a mesh matching check. The original point cloud starts with xxx.00 and is incremented by 0.2, in the form of xxx.00, xxx.20, xxx.40, xxx.60, xxx.80. According to Equation 2, the translation amounts in the X and Y directions are not divisible by 0.2. Therefore, the translation amounts of the point cloud data need to be increased by 0.1 in both the X and Y directions, i.e., the translation amounts are 658451.2 and 3622713.2 respectively. The coordinates of X1 after the check are X2(-3.0, -49.8, 3.13).
[0116] S4. According to the index formula in Equation 3, (50-(-49.8) / 0.2)*(2*50 / 0.2)+((-3.0)+50) / 0.2, the index value is 249735. Therefore, in the planar buffer geometry, the elevation value of the vertex with index 249735 is 3.13m.
[0117] S5. Divide the elevation into intervals with a step size of 0.2m. Calculate the elevation interval containing the expected value of the point cloud quantity according to Equation 5. Set the mean value of the elevation interval -16.629 as yellow, -16.629 / 2 as pink, the lowest elevation value -19.2608 as blue, and (-16.629-19.2608) / 2 as cyan. The corresponding color-elevation values are: 1: {#ff0000, 0}, 2: {#ff00ff, -8.314}, 3: {#ffff00, -16.629}, 4: {#00ffff, -17.9449}, 5: {#0000ff, -19.2608}. The position of point X in the color palette is color 2-3. According to Equation 6, its color ratio rat is calculated as ((-16.13)-(-16.629)) / ((-8.314)-(-16.629)), which is 0.06.
[0118] The color of this point is calculated according to Equation 7 as: {R:255, G:239.70, B:15.30}, and its opacity is set to 1. In this example, the planar buffer geometry used in Three.js is a cuboid, and the scanned seabed topography is circular. The scan data does not completely cover the area and some scan points will be missing. In this example, the elevation value of each vertex is checked individually to see if it is equal to `ignoreZ`. If they are equal, the opacity is set to 0, thus hiding the vertex.
[0119] Call the geometry's setAttribute() method to assign colors, set the material to THREE.MeshPhongMaterial, and set the vertexColors, transparent, and side attributes to THREE.DoubleSide.
[0120] The methods computeBoundingBox(), computeBoundingSphere(), and computeVertexNormals() are called to extract the geometry, and then the renderer is invoked to perform the rendering.
[0121] This embodiment uses the vertex data of the planar geometry of a single-phase terrain as a basis, and uses the RawShaderMaterial native renderer encapsulated in Three.js to simulate the dynamic evolution process of the two-phase terrain. The specific steps are as follows:
[0122] The point cloud data from the two periods are processed according to steps S1 to S5 to obtain the vertex data of the planar buffer geometry corresponding to the point cloud data of the two periods respectively.
[0123] The elevation difference between the two periods is calculated. In this example, the elevation value of the second period's point cloud data corresponding to the first period's point cloud data X is -17.68. In this example, the maximum allowable elevation difference is set to ±3.0. Vertices with an absolute value greater than 3.0 are considered to be missing points in a certain period's terrain or anomalies near stakes. Therefore, the elevation difference of such vertices is set to 0.0, meaning that such points do not have a dynamic simulation process.
[0124] According to Equation 8, negative values of elevation difference are marked. In this example, let Z be... ex If the value is 150.0, then the height difference corresponding to X is (-((-17.68)-(-16.13)))+150.0, which is 148.45.
[0125] Add variables `defineY` and `ignoreZ` to the `uniforms` property of the renderer, with initial values of 0.0 and -1.0 respectively. The value of `ignoreZ` is auxiliary data and remains constant, while the value of `defineY` gradually increases during each rendering process; in this example, the increment per frame is 0.05.
[0126] Based on the terrain data from the first phase, the elevation values corresponding to the five initial colors in the color palette are passed as variables into the renderer's uniforms.
[0127] The vertex shader receives the elevation and height difference values of vertices. In this example, 100.0 is used as the boundary. If the height difference of point X is greater than 100.0, it is determined that the height difference has passed the mark. For the marked height difference, it is necessary to first restore it to the original value, that is, first subtract 150.0 and then take the opposite number.
[0128] Determine the difference between `defineY` and the elevation difference in the current frame. If the elevation difference is greater than `defineY`, set the Z-coordinate of the vertex in the current frame to the original Z-value minus `defineY`. If the elevation difference is less than or equal to `defineY`, it means that the elevation value of the vertex in the current frame has gradually changed to the second-phase elevation value, and the Z-coordinate is the original Z-value minus the elevation difference.
[0129] In this example, the data point size gl_PointSize is set to 2.0, and the point object is multiplied by the model-view matrix projection-Matrix and the projection matrix modelViewMatrix.
[0130] The fragment shader receives the elevation values corresponding to the color palette of the first phase of terrain. It first checks whether the elevation value passed from the vertex shader is less than or equal to ignoreZ. If it is true, the color opacity of the point is set to 0, i.e., it is hidden. If it is not true, it determines whether the point is located in a segment of the color palette in the current frame.
[0131] If the elevation value of this point has a Z value of z1 (-17.13) in the current frame, then the color segment is 3-4 (3:{#ffff00, -16.629}, 4:{#00ffff, -17.9449}), and its color ratio is ((-17.13)-(-17.9449)) / ((-16.629)-(-17.9449)), which is 0.62. Therefore, the RGB values of this point are 0.62, 1.0, and 0.38.
[0132] Set the fragment renderer's gl_FragColor to the calculated color value for each point. In RawShaderMaterial, pass in the uniform value, vertexShader, and fragmentShader, setting the vertexColors property to true and the transparent property to true. Create the point cloud and start rendering.
Claims
1. A two-phase dynamic simulation method for seabed topographic scour based on Three.js, characterized in that: A. Process the point cloud data of the seabed topography in two phases to obtain the vertex coordinate data of the planar buffer geometry corresponding to the point cloud data in the two phases respectively. Calculate the elevation difference of each vertex based on the vertex coordinate data in the two phases respectively and mark the vertices with negative elevation differences. B. Create an empty BufferGeometry, pass the vertex coordinate data of the first phase of terrain to the BufferGeometry using the position property, and pass the elevation difference between the two phases of terrain to the BufferGeometry using the newly created property in the index order of the vertex coordinate data; C. Use the uniforms property to pass the elevation increment for each frame, the overall translation of the elevation of the vertex of the planar buffer geometry, and the palette values generated from the first phase of terrain elevation data. D. Use the RawShaderMaterial encapsulated in Three.js as the base to design a shader renderer that conforms to the seabed terrain, and customize vertex and fragment renderers to complete dynamic rendering. The vertex shader is used to determine the elevation increment of the current frame by comparing the elevation increment and elevation difference of the vertices in the previous frame, thereby updating the elevation / position of all point cloud data. The elevation values of the point cloud data in the current frame in the vertex shader are passed into the fragment shader, and the color of each vertex is recalculated according to the color palette based on the elevation values, thereby updating the color of all point cloud data. E. Use the requestAnimationFrame function to execute animation effects. Determine whether the elevation difference limit of each vertex in the current frame is increasing by comparing the elevation difference limit of each vertex in the previous frame with the maximum elevation difference between the two point cloud data.
2. The two-phase seabed topographic scour dynamic simulation method based on Three.js according to claim 1, characterized in that, The process of processing the point cloud data from the two phases of seabed topography to obtain the vertex coordinate data of the planar buffer geometry corresponding to the two phases of point cloud data includes: S1. Obtain point cloud data of the seabed topography, and create a new planar buffer geometry based on the range and data interval of the point cloud data; S2. Translate the entire point cloud data to move it to the origin. S3. Check the mesh matching degree between the translated point cloud data and the planar buffer geometry. If the translated point cloud data does not coincide with the mesh, translate the entire point cloud data again until the point cloud data coincides with the mesh. S4. The point cloud data that coincides with the mesh and the vertex coordinate data of the planar buffer geometry are indexed by the point cloud data and mapped one by one to the vertex coordinate data of the planar buffer geometry.
3. The two-phase seafloor topography scour dynamic simulation method based on Three.js according to claim 2, characterized in that, The translation of the entire point cloud data to move it to the origin includes: In the formula, x tmax ,x tmin ,y tmax ,y tmin ,z tmin These represent the maximum and minimum values of the point cloud data in the X direction, Y direction, and Z direction, respectively, and T. i (x ti ,y ti ,z ti (i = 1, 2, ..., N) represents point cloud data, M i (x mi ,y mi ,z mi ), i = 1, 2, ..., N are the point cloud data after translation.
4. The two-phase seafloor topography scour dynamic simulation method based on Three.js according to claim 3, characterized in that, If the translated point cloud data does not coincide with the grid, the entire point cloud data is translated again until it coincides with the grid, including: If the translated point cloud data does not coincide with the grid, the overall translation of all point cloud data in the X and Y directions is completed by the following formula; In the formula, d s The data intervals of the planar buffer geometry in the X and Y directions. This is the floor symbol.
5. The two-phase seabed topographic scour dynamic simulation method based on Three.js according to claim 4, characterized in that, The indexing mechanism for point cloud data coinciding with the mesh and vertex coordinate data of the planar buffer geometry maps point cloud data one-to-one to vertex coordinate data of the planar buffer geometry, including: Index i =((r-y mi ) / ds)*(2*r / ds+1)+(x mi +r) / ds In the formula, r is the radius of the seabed topographic point cloud data, (2*r / ds+1) is the number of vertices per row, ((ry mi () / ds) is the mapping of the current point cloud onto the Y-axis of the planar buffer geometry mesh, (x) mi +r) / ds represents the mapping of the current point cloud onto the X-axis of the planar buffer geometry mesh, M i (x mi ,y mi ,z mi The vertex coordinate data of the planar buffer geometry are arranged in order of index. i Each vertex corresponds to one vertex. With pIndexi =z mi In the formula, z pIndexi This represents the index of the vertex coordinate data in sorted order. i The elevation values of each vertex.
6. The two-phase seabed topographic scour dynamic simulation method based on Three.js according to claim 1, characterized in that, The step of calculating the elevation difference of each vertex based on the vertex coordinate data of the two periods and marking vertices with negative elevation differences includes: A marker value is added to vertices with negative elevation differences. This marker value is greater than the maximum absolute value of the differences among all point cloud data.
7. The two-phase seabed topographic scour dynamic simulation method based on Three.js according to claim 1, characterized in that, The method of using uniforms attributes to pass the elevation increment for each frame and the overall translation of the elevation of the vertex of the planar buffer geometry includes: In the uniforms variable, set the parameter defineY to the elevation change amount for each render and ignoreZ to find missing parts of the vertex data of the plane buffer geometry.
8. The two-phase seabed topographic scour dynamic simulation method based on Three.js according to claim 1, characterized in that, The method of passing the palette values generated from the first phase of terrain elevation data using uniforms attributes includes: The vertex elevation data of the planar buffer geometry corresponding to the first phase of seabed topography are segmented and statistically analyzed. An initial color palette is set based on the premise that the distribution of elevation data is normal, and the elevation values corresponding to the color values of the color palette are passed into uniforms.
9. The two-phase seabed topographic scour dynamic simulation method based on Three.js according to claim 8, characterized in that, The initial color palette setting, based on the premise that the elevation data distribution follows a normal distribution, includes: The interval mean z of the elevation segment corresponding to the expected elevation value μ mid The corresponding color is yellow, and the lowest elevation value is z. ti The corresponding color is blue, the color corresponding to sea level is red, and the elevation value z mid / 2 is pink, elevation value (z) mid +z ti ) / 2 is cyan.
10. The two-phase seafloor topography scour dynamic simulation method based on Three.js according to claim 1, characterized in that, The method utilizes RawShaderMaterial, encapsulated in Three.js, as a base to design a shader renderer that conforms to the underwater terrain. Custom vertex and fragment renderers are used to achieve dynamic rendering, including: The renderer controls the renderer to increment the size of defineY at the same rate during each frame rendering. Based on the first phase of terrain data, the vertex renderer determines the difference between the elevation values Δz of the two phases of vertex data and the predetermined data difference, and then compares them with the value of defineY to determine the elevation value of the current vertex data in the current frame. For marked Δz, the absolute value of the initial value is restored before comparison. The fragment renderer receives the elevation values corresponding to each initial color in the first phase terrain data palette as uniforms values, as well as the coordinate values of each vertex in the current frame passed in from the vertex renderer. First, it determines the size of the passed coordinate elevation and ignoreZ. If the elevation value is less than or equal to ignoreZ, the color transparency of the vertex is set to 0. Otherwise, it determines the interval of the vertex elevation value in the palette and its ratio, thereby calculating the RGB value of each vertex.
11. The two-phase seafloor topographic scour dynamic simulation method based on Three.js according to claim 1, characterized in that, Step E includes: Use requestAnimationFrame(animate) to create a loop and automatically adjust the frame rate according to the monitor's refresh rate. In the JavaScript code, compare the height difference increment aniDefinY of the previous frame with the absolute value of the maximum height difference disperMax. If aniDefinY is less than disperMax, then increment the value of aniDefinY; otherwise, assign aniDefinY to 0. The vertex elevation is updated in each frame by assigning the value of aniDefinY to the definitionY in uniforms.
12. A two-phase seabed topographic scour dynamic simulation device based on Three.js, characterized in that, include: Module A is used to process the point cloud data of the seabed topography in two phases to obtain the vertex coordinate data of the planar buffer geometry corresponding to the two phases of point cloud data. Based on the vertex coordinate data of the two phases, the elevation difference of each vertex is calculated and the vertices with negative elevation differences are marked. Module B is used to create an empty BufferGeometry. The vertex coordinate data of the first phase of terrain is passed to the BufferGeometry using the position property. The elevation difference between the two phases of terrain is passed to the BufferGeometry using a newly created property in the index order of the vertex coordinate data. Module C is used to pass the elevation increment for each frame, the overall translation of the elevation of the planar buffer geometry vertices, and the palette values generated from the first phase of terrain elevation data using the uniforms property; Module D is used to design shader renderers that conform to the underwater terrain using the RawShaderMaterial encapsulated in Three.js as the base, and to complete dynamic rendering by customizing vertex and fragment renderers. The vertex shader is used to determine the elevation increment of the current frame by comparing the elevation increment and elevation difference of the vertices in the previous frame, thereby updating the elevation / position of all point cloud data. The elevation values of the point cloud data in the current frame in the vertex shader are passed into the fragment shader, and the color of each vertex is recalculated according to the color palette based on the elevation values, thereby updating the color of all point cloud data. Module E is used to execute animation effects using the requestAnimationFrame function. It determines whether the elevation difference limit of each vertex in the current frame is increasing by comparing the elevation difference limit of each vertex in the previous frame with the maximum elevation difference between the two point cloud data.
13. A storage medium storing a computer program executable by a processor, characterized in that: When the computer program is executed, it implements the steps of the two-phase submarine topographic scour dynamic simulation method based on Three.js as described in any one of claims 1 to 10.
14. A two-phase seabed topographic scour dynamic simulation device based on Three.js, comprising a memory and a processor, wherein the memory stores a computer program executable by the processor, characterized in that: When the computer program is executed, it implements the steps of the two-phase submarine topographic scour dynamic simulation method based on Three.js as described in any one of claims 1 to 10.
