Methods for roaming along spatial paths and computer-readable storage media

By splitting the spatial path into straight lines and inflection point paths, and adjusting the virtual camera's heading and pitch angle in real time, the problem of the virtual camera's observation direction being out of sync with the device's movement direction was solved, achieving a more immersive 3D GIS path roaming experience.

CN116091618BActive Publication Date: 2025-10-31天津市住房和城乡建设综合行政执法总队
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211677195.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-26
Publication Date
2025-10-31
Estimated Expiration
2042-12-26

AI Technical Summary

Technical Problem

When roaming along a path, the virtual camera's observation direction cannot be synchronized with the device's movement direction, resulting in a lack of immersive experience when roaming along a fixed path. Furthermore, existing methods are inefficient and cannot handle points and inflection points in the air above the ground.

Method used

The spatial path is divided into a straight path and a turning point path. By calculating the heading angle and pitch angle, interpolation is performed to adjust the position and orientation of the virtual camera in real time, forming animations of the straight path and the turning point path. At the turning point, the speed is adjusted to ensure that the virtual camera is synchronized with the path.

Benefits of technology

It enables dynamic real-time adjustment of the virtual camera's observation direction and the device's movement direction, solving the problem of the virtual camera's direction being out of sync with the fixed path, and enhancing the immersiveness and efficiency of roaming along the route.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116091618B_ABST
    Figure CN116091618B_ABST
Patent Text Reader

Abstract

This invention relates to the field of three-dimensional spatial scene technology, specifically to a method for roaming along a spatial path, comprising: drawing a spatial path in a three-dimensional spatial scene and obtaining three-dimensional coordinate data of the spatial path; setting initial values ​​for virtual camera roaming; calculating interpolation of the spatial path between two adjacent points and interpolation at inflection points respectively; and using the heading angle and pitch angle of the interpolated spatial path and inflection points, adjusting the position and orientation of the virtual camera in real time to form a spatial path animation. This invention can dynamically adjust the observation direction of the virtual camera in real time, is compatible with adjusting the movement direction of the device, handles the turning of the virtual camera's viewpoint on the path, and solves the problem of the virtual camera's orientation being out of sync with the fixed path direction during roaming, making it convenient for the virtual camera to roam along a fixed path in space from the device's perspective.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of three-dimensional space technology, specifically to a method for roaming along a spatial path and a computer-readable storage medium. Background Technology

[0002] In 3D GIS development, scenarios involving roaming along fixed paths are frequently encountered, and there are two main roaming methods:

[0003] 1) The device moves along a fixed path, and a fixed viewpoint position is set for the virtual camera. The virtual camera tracks the observed object at the fixed viewpoint position.

[0004] 2) The device moves along a fixed path, sets the viewpoints of multiple virtual cameras, records the posture of the virtual cameras at multiple viewpoints, and adjusts the virtual camera viewpoint based on the recorded posture of the virtual cameras at each viewpoint.

[0005] Currently, 3D GIS platforms are typically built based on Cesium. Cesium provides a device tracking mechanism for 3D GIS platforms, enabling devices to move along fixed paths and adjusting their movement direction in real time. However, it does not adjust the viewing direction of the virtual camera. Therefore, there is no immersive feeling when roaming along a path. In order to better adjust the viewing direction of the virtual camera while roaming along a fixed path, the virtual camera's posture at each viewpoint is usually manually recorded. The virtual camera's viewing angle is then adjusted based on the recorded posture at each position. This roaming method relies on manual operation, which is inefficient. It deviates from the fixed path during roaming and cannot perform fixed-point interpolation at turns.

[0006] For example, CN202111151452.6 describes a web-based 3D scene pose-adaptive path roaming method that takes into account terrain undulations. This method primarily involves acquiring existing ecological space element graphics, which have continuous XY coordinate points; simplifying these graphics using the Douglas node extraction algorithm, retaining the nodes as automatic roaming path nodes; and calculating the roaming pose parameters of each frame of the 3D scene in real time based on these path nodes and terrain data. The 3D scene is then rendered and refreshed in real time in the web browser for each frame, completing the automatic roaming process along the path nodes. However, this method relies solely on terrain data for elevation data, which is too limiting; it cannot handle points and inflection points above the ground during roaming.

[0007] Therefore, current 3D GIS platforms can only observe the movement of devices within a fixed range when roaming along a path, and the observation direction of the virtual camera cannot be well controlled. In reality, it is common to need virtual cameras to roam along spatial paths from the perspective of the device. There is an urgent need to design a method for roaming along spatial paths to overcome the above-mentioned defects of existing roaming methods. Summary of the Invention

[0008] The purpose of this invention is to provide a method for roaming along a spatial path, so as to solve the problem that existing roaming methods cannot control the observation direction of the virtual camera and are not convenient for the virtual camera to roam along the spatial path from the device's perspective.

[0009] To achieve the above objectives, the present invention provides the following technical solution:

[0010] A method for roaming along a spatial path, comprising the following steps:

[0011] Step S1: Draw a spatial path in the 3D spatial scene and obtain the 3D coordinate data of the spatial path;

[0012] Step S2: Set the initial values ​​for virtual camera roaming, including initial roaming speed V0, initial camera pitch angle β0, and distance R0 between the virtual camera and the viewpoint;

[0013] Step S3: Divide the spatial path into intermittently distributed straight-line paths and inflection point paths;

[0014] Step S4: Calculate the distance and direction vector of the straight path and the time required for the virtual camera to move;

[0015] Step S5: Perform linear interpolation on the straight path, calculate the heading angle at the interpolation position, the angle between the straight path and the horizontal plane, and the pitch angle of the virtual camera, and construct a linear animation of the straight path;

[0016] Step S6: Construct the quaternions of the virtual camera before and after rotating around the inflection point using the heading angles of the straight paths on both sides of the inflection point and the initial pitch angle β0 of the virtual camera.

[0017] Step S7: Determine the direction vectors of the straight paths on both sides of the inflection point, perform smooth linear interpolation on the quaternions of the virtual camera before and after rotation around the inflection point, perform linear interpolation on the direction vectors of the straight paths on both sides of the inflection point, and determine the angle between the interpolation direction of the inflection point and the horizontal plane, as well as the pitch angle of the virtual camera at the inflection point, and construct the rotation animation at the inflection point.

[0018] Step S8: Following the methods of Steps S4 to S7 above, draw the linear animation and rotation animation corresponding to each straight path and inflection point path separated in Step S3, and combine them into a full path animation according to the multi-segment sequence to complete the roaming along the spatial route.

[0019] Further specifying, step S1 specifically involves: acquiring the three-dimensional coordinate data of the spatial path in the spatial scene, including x and y coordinate values ​​and elevation H, and marking the set of n spatial coordinate points of the spatial path as {P1, P2…P…} i P i+1 …P n}, i∈[1, n-1], and H Pi For P i Elevation of point H Pi+1 For P i+1 Elevation of the point.

[0020] Further specifying, the straight path in step S3 is... The inflection points are P2, P3, P4...P n-1 .

[0021] Further specifying, in step S4, the straight path Where P i To P i+1 Direction vector N i Calculated using the following formula:

[0022]

[0023] Virtual camera from P i Moving at a constant speed to P i+1 The required time t i for:

[0024]

[0025] Further specifying, step S5 specifically includes:

[0026] Step S5.1: For the straight path P i To P i+1 Using time t i Perform linear interpolation, with interpolation coordinates P. t Determine the heading angle α of the interpolation position. t Calculate line segment P i To P i+1 Angle with the horizontal plane Where Δ represents the interpolation P t With straight path P i To P i+1 Direction vector N iThe angle between them is used to determine the virtual camera's pitch angle as β. s =β0+β t ;

[0027] Step S5.2: Based on interpolation P t and from the heading angle α t and virtual camera pitch angle β s and the offset set {α} consisting of the distance R0 between the virtual camera and the viewpoint. t ,β s R0}, updates the position and orientation of the virtual camera in real time to form P i To P i+1 Straight path animation SA i .

[0028] Further specifying, step S5.2 is followed by step S5.3, which involves changing the roaming speed of the virtual camera. The specific operation is as follows:

[0029] Stop all animations, record the current position of the virtual camera, and repeat steps S3-S8 until the path roaming between the current position and point Pn is completed.

[0030] Further specifying, the heading angle α of the interpolation position t The method for determining it is as follows:

[0031] Obtain interpolation coordinates P t Calculate the inverse matrix of the vertical coordinate system matrix that is perpendicular to the current ground surface;

[0032] Calculate the direction from the geocenter to the interpolation point to determine the unit vector;

[0033] Calculate the product U of the inverse matrix and the unit vector, and the product M of the inverse matrix and the direction vector, respectively.

[0034] Determine if M is parallel to the Z-axis; if so, then α t =Math.atan2(Uy,Ux)-π / 2; if not, then α t =

[0035] Math.atan2(My,Mx)-π / 2;

[0036] Using α t =2π-Cesium.Math.zeroToTwoPi(α t ) α t Convert to 0<=α t Angles less than or equal to 2π.

[0037] Further specifying, step S6 specifically involves: calculating the path P between two adjacent straight lines. i To Pi+1 and P i+1 To P i+2 heading angle α i α i+1 Using the initial pitch angle β0 of the virtual camera in step S1, construct the virtual camera orbiting P. i+1 The initial rotation quaternion Q before point rotation i and the final rotation quaternion Q after rotation i+1 .

[0038] Further specifying, step S7 specifically includes:

[0039] S7.1: Calculate P according to the method in step S4. i+1 To P i+2 Direction vector N i+1

[0040] S7.2: Quaternion Q of the virtual camera before and after rotation around the inflection point. i Q i+1 Perform linear interpolation, with the interpolation value being Q. t ;

[0041] S7.3: The direction vector N of the straight path on both sides of the inflection point i and N i+1 Perform linear interpolation, with an interpolation value of N. t Calculate the inflection point P i+1 The angle β between the interpolation direction and the horizontal plane p And the pitch angle β of the virtual camera at this inflection point. i+1 =β0+β p ;

[0042] S7.4: According to P i+1 and rotation offset set {α i+1 ,β i+1 R0}, the position and orientation of the virtual camera are updated in real time to form the inflection point P. i+1 Rotation animation at CA i The heading angle α i+1 From interpolation Q t Obtain from, Where Δ i+1 Indicates interpolation P i+1 With interpolation N t The angle between them.

[0043] Further specifying, in step S7.4, the heading angle α i+1 From interpolation Q t Obtain from the middle, specifically: interpolate Q tConvert to a Cesium.HeadingPitchRoll object and extract its Heading parameter, which is the heading angle α. i+1 .

[0044] Further specifying, step S7.4 is followed by step S7.5, which is as follows: the change in the virtual camera roaming speed occurs at the turning point, all animations are stopped, the current position is recorded, steps S6-S7 are executed, and then the operations of steps S3-S8 are repeated to complete the path roaming between the current position and point Pn.

[0045] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method for roaming along a spatial path.

[0046] Compared with the prior art, the beneficial effects of the present invention are: it can dynamically adjust the observation direction of the virtual camera in real time, be compatible with adjusting the movement direction of the device, reasonably handle the turning of the virtual camera's perspective on the path, solve the problem of the virtual camera's direction being out of sync with the fixed path direction when roaming along the line, and facilitate the virtual camera to roam along the fixed path in space from the device's perspective.

[0047] (1) This invention divides the spatial path into multiple straight paths and multiple inflection point paths, interpolates the straight paths and inflection point paths respectively, calculates the heading angle and pitch angle of the interpolation point, and adjusts the position and direction of the virtual camera in real time to form straight path animation and inflection point path animation. The animations are seamlessly connected during roaming with an interval of 0 seconds. The straight path animation and inflection point path animation are integrated according to the order of spatial path division to form a complete spatial path animation, realizing dynamic real-time adjustment of the virtual camera's observation posture. The virtual camera's view turns at the inflection point on the inflection point path, solving the problem of the virtual camera's direction being out of sync with the fixed path direction during roaming along the line.

[0048] (2) Based on straight paths and inflection point paths, this invention sets a speed adjustment method in the spatial path to change the roaming speed of the virtual camera and determine whether the change in roaming speed occurs on a straight path or in an inflection point path. When the roaming speed changes in the path, all animations are stopped, the current position of the virtual camera in the spatial path is recorded, the interpolation point of the virtual camera and the heading angle and pitch angle of the virtual camera at the interpolation point are recalculated until the entire spatial path is completed, realizing the variable speed movement of the virtual camera in the device's viewpoint, increasing the movement mode of the virtual camera along the path, and enhancing the different sensory experiences of roaming along a fixed path in the first-person perspective.

[0049] (3) The parameters of the virtual camera of the present invention can be set according to actual needs, such as the roaming speed, the camera observation range (i.e., the distance between the camera and the viewpoint), and the initial pitch angle. Therefore, it can be extended to roaming along a fixed path under different parameter modes, making the movement of the virtual camera more diverse. Attached Figure Description

[0050] Figure 1 This is a flowchart of the spatial path roaming method of the present invention;

[0051] Figure 2 This is a schematic diagram of the spatial path breakdown;

[0052] Figure 3 To construct the linear animation algorithm diagram;

[0053] Figure 4 To construct the corner animation algorithm diagram;

[0054] Figure 5 This is a top view of the spatial path;

[0055] Figure 6 This is a plan view of the spatial path. Detailed Implementation

[0056] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0057] Example 1:

[0058] See Figure 1 This invention provides a method for roaming along a spatial path, specifically implemented through the following steps:

[0059] Step S1: Draw a spatial path in the 3D spatial scene and obtain the 3D coordinate data of the spatial path;

[0060] Obtain the 3D coordinate data of the spatial path in the spatial scene, including x, y coordinate values ​​and elevation H, and mark the set of n spatial coordinate points of the spatial path as {P1, P2…P}. i P i+1 …P n}, i∈[1, n-1], and H Pi For P i Elevation of point H Pi+1 For P i+1 Elevation of the point.

[0061] Step S2: Set the initial values ​​for virtual camera roaming, including initial roaming speed V0, initial camera pitch angle β0, and distance R0 between the virtual camera and the viewpoint;

[0062] Step S3: Divide the spatial path into intermittently distributed straight paths and inflection point paths, such as... Figure 2 As shown, the spatial path is divided into intermittently distributed straight-line paths. and the inflection point path P2, P4...P n-1 .

[0063] Step S4: Calculate the distance along the straight path. And the direction vector and the time required for the virtual camera to move;

[0064] Among them, with Figure 3 For example, P i To P i+1 Direction vector N i Calculated using the following formula:

[0065]

[0066] Virtual camera from P i Moving at a constant speed to P i+1 The required time t i for:

[0067]

[0068] Step S5: Perform linear interpolation on the straight path, calculate the heading angle at the interpolation position, the angle between the straight path and the horizontal plane, and the pitch angle of the virtual camera, and construct a linear animation of the straight path;

[0069] Step S5.1: For the straight path P i To P i+1 Using time t i Perform linear interpolation, with interpolation coordinates P. t Determine the heading angle α of the interpolation position. t Calculate line segment P i To P i+1 Angle with the horizontal plane Where Δ represents the interpolation P t With straight path P i To P i+1 Direction vector N i The angle between them is used to determine the virtual camera's pitch angle as β. s =β0+β t ;

[0070] Where the heading angle α t The method for determining it is as follows:

[0071] Obtain interpolation coordinates P t Calculate the inverse matrix of the vertical coordinate system matrix that is perpendicular to the current ground surface;

[0072] Calculate the direction from the geocenter to the interpolation point to determine the unit vector;

[0073] Calculate the product U of the inverse matrix and the unit vector, and the product M of the inverse matrix and the direction vector, respectively.

[0074] Determine if M is parallel to the Z-axis; if so, then α t =Math.atan2(Uy,Ux)-π / 2; if not, then α t =

[0075] Math.atan2(My,Mx)-π / 2;

[0076] Using α t =2π-Cesium.Math.zeroToTwoPi(α t ) α t Convert to 0<=α t Angles less than or equal to 2π.

[0077] The specific algorithm is as follows:

[0078] lettransform=Cesium.Transforms.eastNorthUpToFixedFrame(P t );

[0079] letinvTransform=newCesium.Matrix4();

[0080] Cesium.Matrix4.inverseTransformation(transform,invTransform);

[0081] let up=new Cesium.Cartesian3();

[0082] Cesium.Cartesian3.normalize(P t ,up);

[0083] Cesium.Matrix4.multiplyByPointAsVector(invTransform,N i N i );

[0084] Cesium.Matrix4.multiplyByPointAsVector(invTransform,up,up);

[0085] letαt1 =Math.atan2(up.y,up.x)-π / 2;

[0086] letα t2 =Math.atan2(N i .y,N i .x)-π / 2;

[0087] letα t =Cesium.Math.equalsEpsilon(Math.abs(N i .z),1.0,0.001)? α t1 :α t2 ;α t =2π-

[0088] Cesium.Math.zeroToTwoPi(α t );

[0089] Step S5.2: Based on interpolation P t and from the heading angle α t and virtual camera pitch angle β s and the offset set {α} consisting of the distance R0 between the virtual camera and the viewpoint. t ,β s R0}, updates the position and orientation of the virtual camera in real time to form P i To P i+1 Straight path animation SA i .

[0090] Methods for updating camera pose:

[0091] camera.lookAt(P t ,new Cesium.HeadingPitchRange(α t ,β s ,R0));

[0092] camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

[0093] Step S6: Construct the quaternions of the virtual camera before and after rotating around the inflection point using the heading angles of the straight paths on both sides of the inflection point and the initial pitch angle β0 of the virtual camera.

[0094] Calculate the path P between two adjacent straight lines i To P i+1 and P i+1 To P i+2 heading angle α i αi+1 Using the initial pitch angle β0 of the virtual camera in step S1, construct the virtual camera orbiting P. i+1 The initial rotation quaternion Q before point rotation i and the final rotation quaternion Q after rotation i+1 .

[0095] Step S7: Determine the direction vectors of the straight paths on both sides of the inflection point. Perform smooth linear interpolation on the quaternions of the virtual camera before and after rotation around the inflection point, and perform linear interpolation on the direction vectors of the straight paths on both sides of the inflection point. Determine the angle between the interpolation direction at the inflection point and the horizontal plane, as well as the pitch angle of the virtual camera at the inflection point, and construct the rotation animation at the inflection point; refer to Figure 4 Specifically:

[0096] S7.1: Calculate P according to the method in step S4. i+1 To P i+2 Direction vector N i+1 ;

[0097] S7.2: Quaternion Q of the virtual camera before and after rotation around the inflection point. i Q i+1 Perform linear interpolation, with the interpolation value being Q. t ;

[0098] S7.3: The direction vector N of the straight path on both sides of the inflection point i and N i+1 Perform linear interpolation, with an interpolation value of N. t Calculate the inflection point P i+1 The angle β between the interpolation direction and the horizontal plane p And the pitch angle β of the virtual camera at this inflection point. i+1 =β0+β p ;

[0099] S7.4: According to P i+1 and rotation offset set {α i+1 ,β i+1 R0}, the position and orientation of the virtual camera are updated in real time to form the inflection point P. i+1 Rotation animation at CA i The heading angle α i+1 From interpolation Q t To obtain the value from the middle, the specific operation is as follows: interpolate Q... t Convert to a Cesium.HeadingPitchRoll object and extract its Heading parameter, which is the heading angle α. i+1 .

[0100] in, Where Δ i+1Indicates interpolation P i+1 With interpolation N t The angle between them.

[0101] Step S8: Following the methods described in steps S4 to S7, draw the linear and rotational animations corresponding to the straight paths and inflection point paths separated in step S3, and combine them into a full path animation according to the multi-segment sequence, such as... Figure 5 , 6 As shown, complete the roaming along the spatial route.

[0102] The above method splits the spatial path into multiple straight paths and multiple inflection point paths, interpolates the straight paths and inflection point paths respectively, calculates the heading angle and pitch angle of the interpolation points, and adjusts the position and orientation of the virtual camera in real time to form straight path animation and inflection point path animation. The animations are seamlessly connected during roaming with an interval of 0 seconds. The straight path animation and inflection point path animation are integrated according to the order of spatial path splitting to form a complete spatial path animation, realizing dynamic real-time adjustment of the virtual camera's observation posture. On the inflection point path, the virtual camera's perspective turns at the inflection point, solving the problem of the virtual camera's orientation being out of sync with the fixed path orientation during roaming along the line.

[0103] The parameters of the virtual camera can be set according to actual needs, such as the initial speed of the roaming, the camera's observation range (i.e., the distance between the camera and the viewpoint), and the initial pitch angle. Therefore, it can be extended to roaming along a fixed path in different parameter modes, making the movement of the virtual camera more diverse.

[0104] Example 2:

[0105] Based on the uniform roaming method with a given initial roaming speed in the straight path and inflection point path described above, this embodiment further sets speed adjustment in the straight path segment of the spatial path to speed up or slow down the roaming. Specifically, after step S5.2 in step S5 of the above embodiment, step S5.3 is added to change the roaming speed of the virtual camera, that is, stop all animations, record the current position of the virtual camera, and repeat the operation of steps S3-S8 until the path roaming between the current position and point Pn is completed.

[0106] Example 3:

[0107] Based on the uniform roaming method with a given initial roaming speed in the straight path and the inflection point path described above, this embodiment further sets speed adjustment in the inflection point path segment of the spatial path to increase or decrease the rotation speed at the inflection point. Specifically, in step S7 of the above embodiment, after S7.4, step S7.5 is added to change the roaming speed of the virtual camera. That is, the change in the roaming speed of the virtual camera occurs in the inflection point segment. All animations are stopped, the current position is recorded, steps S6-S7 are executed, and then the operations of steps S3-S8 are repeated to complete the path roaming between the current position and point Pn.

[0108] Furthermore, the present invention provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the aforementioned method for roaming along a spatial path. This computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform the methods described in various embodiments or certain portions of the embodiments.

[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for roaming along a spatial path, characterized in that, include: Step S1: Draw a spatial path in the 3D spatial scene and obtain the 3D coordinate data of the spatial path; Step S2: Set the initial values ​​for virtual camera roaming, including initial roaming speed V0, initial camera pitch angle β0, and distance R0 between the virtual camera and the viewpoint; Step S3: Divide the spatial path into intermittently distributed straight-line paths and inflection point paths; Step S4: Calculate the distance and direction vector of the straight path and the time required for the virtual camera to move; Step S5: Perform linear interpolation on the straight path, calculate the heading angle at the interpolation position, the angle between the straight path and the horizontal plane, and the pitch angle of the virtual camera, and construct a linear animation of the straight path; Step S6: Construct the quaternions of the virtual camera before and after rotating around the inflection point using the heading angles of the straight paths on both sides of the inflection point and the initial pitch angle β0 of the virtual camera. Step S6 specifically involves: calculating the path P between two adjacent straight lines. i To P i+1 and P i+1 To P i+2 heading angle α i α i+1 Using the initial pitch angle β0 of the virtual camera in step S1, construct the virtual camera orbiting P. i+1 The initial rotation quaternion Q before point rotation i and the final rotation quaternion Q after rotation i+1 ; Step S7: Determine the direction vectors of the straight paths on both sides of the inflection point, perform smooth linear interpolation on the quaternions of the virtual camera before and after rotation around the inflection point, perform linear interpolation on the direction vectors of the straight paths on both sides of the inflection point, and determine the angle between the interpolation direction of the inflection point and the horizontal plane, as well as the pitch angle of the virtual camera at the inflection point, and construct the rotation animation at the inflection point. Step S7 specifically involves: S7.1: Calculate P according to the method in step S4. i+1 To P i+2 Direction vector N i+1 ; S7.2: Quaternion Q of the virtual camera before and after rotation around the inflection point. i Q i+1 Perform linear interpolation, with the interpolation value being Q. t ; S7.3: The direction vector N of the straight path on both sides of the inflection point i and N i+1 Perform linear interpolation, with an interpolation value of N. t Calculate the inflection point P i+1 The angle β between the interpolation direction and the horizontal plane p And the pitch angle β of the virtual camera at this inflection point. i+1 =β0 + βp; S7.4: According to P i+1 and rotation offset set {α i+1 ,β i+1 R0}, the position and orientation of the virtual camera are updated in real time to form the inflection point P. i+1 Rotation animation at CA i The heading angle α i+1 From interpolation Q t Obtain from, Where Δ i+1 Indicates interpolation P i+1 With interpolation N t The angle between them; Step S8: Following the methods of Steps S4 to S7 above, draw the linear animation and rotation animation corresponding to each straight path and inflection point path separated in Step S3, and combine them into a full path animation according to the multi-segment sequence to complete the roaming along the spatial route.

2. The method for roaming along a spatial path according to claim 1, characterized in that, Step S1 specifically involves: acquiring the three-dimensional coordinate data of the spatial path in the spatial scene, including x and y coordinate values ​​and elevation H, and marking the set of n spatial coordinate points of the spatial path as {P1, P2…P…}. i P i+1 …P n }, i∈[1, n-1], and H Pi For P i Elevation of point H Pi+1 For P i+1 Elevation of the point.

3. The method for roaming along a spatial path according to claim 2, characterized in that, The straight path in step S3 is: The inflection points are P2, P3, P4...P n-1 .

4. The method for roaming along a spatial path according to claim 3, characterized in that, In step S4, the straight path Where P i To P i+1 Direction vector N i Calculated using the following formula: Virtual camera from P i Moving at a constant speed to P i+1 The required time t i for:

5. The method for roaming along a spatial path according to claim 3, characterized in that, Step S5 specifically involves: Step S5.1: For the straight path P i To P i+1 Using time t i Perform linear interpolation, with interpolation coordinates P. t Determine the heading angle α of the interpolation position. t Calculate line segment P i To P i+1 Angle with the horizontal plane Where Δ represents the interpolation P t With straight path P i To P i+1 Direction vector N i The angle between them is used to determine the virtual camera's pitch angle as β. s =β0+β t ; Step S5.2: Based on interpolation P t and from the heading angle α t and virtual camera pitch angle β s and the offset set {α} consisting of the distance R0 between the virtual camera and the viewpoint. t ,β s R0}, updates the position and orientation of the virtual camera in real time to form P i To P i+1 Straight path animation SA i .

6. The method for roaming along a spatial path according to claim 5, characterized in that, Following step S5.2, step S5.3 further includes changing the roaming speed of the virtual camera, specifically as follows: Stop all animations, record the current position of the virtual camera, and repeat steps S3-S8 until the path roaming between the current position and point Pn is completed.

7. The method for roaming along a spatial path according to claim 5, characterized in that, The heading angle α at the interpolation position t The method for determining it is as follows: Obtain interpolation coordinates P t Calculate the inverse matrix of the vertical coordinate system matrix that is perpendicular to the current ground surface; Calculate the direction from the geocenter to the interpolation point to determine the unit vector; Calculate the product U of the inverse matrix and the unit vector, and the product M of the inverse matrix and the direction vector, respectively. Determine if M is parallel to the Z-axis; if so, then α t =Math.atan2(Uy,Ux)-π / 2; if not, then α t =Math.atan2(My,Mx)-π / 2; Using α t =2π-Cesium.Math.zeroToTwoPi(α t ) α t Convert to 0<=α t Angles less than or equal to 2π.

8. The method for roaming along a spatial path according to claim 1, characterized in that, In step S7.4, the heading angle α i+1 From interpolation Q t Obtain from the middle, specifically: interpolate Q t Convert to a Cesium.HeadingPitchRoll object and extract its Heading parameter, which is the heading angle α. i+1 .

9. The method for roaming along a spatial path according to claim 1, characterized in that, Step S7.4 is followed by S7.5, which is as follows: the change in the virtual camera roaming speed occurs at the turning point, all animations are stopped, the current position is recorded, steps S6-S7 are executed, and then the operations of steps S3-S8 are repeated to complete the path roaming between the current position and point Pn.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the roaming method along the spatial path as described in claim 1.

Citation Information

Patent Citations

  • A Web-based 3D scene pose adaptation method that takes into account terrain undulations

    CN113870429B

  • Roam mode realizing method in three-dimensional scene simulation system

    CN103049934A

  • Method for achieving panorama multi-point roaming

    CN108257219A