diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-10-21 14:49:28 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-10-23 14:22:57 +0200 |
commit | 3b649e32327fa561c75b5ccb762f12e8fd8c18a9 (patch) | |
tree | 368c77aa7a093e8b43fa39758001cf7c311a24c2 /examples | |
parent | b9057e508c85c5b1b12efea57daf9dd6f98971d3 (diff) |
planets-qml: fix flickerring by using less precise scale unit
Essentially use 10^3 KM instead of KM so that we don't end up
with too much precision in the positions which can then result
in the camera flickering when the viewMatrix is computed for
rendering
Change-Id: Id2f878c2e1ccd22a2e72a3494d2e7f623f2b4eb6
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qt3d/planets-qml/SolarSystem.qml | 14 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/planets.js | 32 |
2 files changed, 24 insertions, 22 deletions
diff --git a/examples/qt3d/planets-qml/SolarSystem.qml b/examples/qt3d/planets-qml/SolarSystem.qml index 8c0cfccd4..2b56237f5 100644 --- a/examples/qt3d/planets-qml/SolarSystem.qml +++ b/examples/qt3d/planets-qml/SolarSystem.qml @@ -133,8 +133,8 @@ Entity { projectionType: CameraLens.PerspectiveProjection fieldOfView: 45 aspectRatio: width / height - nearPlane: 2500000.0 - farPlane: 20000000.0 + nearPlane: 2500.0 + farPlane: 20000.0 position: defaultCameraPosition upVector: defaultUp viewCenter: Qt.vector3d( xLookAtOffset, yLookAtOffset, zLookAtOffset ) @@ -211,9 +211,9 @@ Entity { //saturnRing.makeRing() //uranusRing.makeRing() saturnRingOuterRadius = planetData[Planets.SATURN].radius + Planets.saturnOuterRadius - saturnRingInnerRadius = planetData[Planets.SATURN].radius + 6.630 + saturnRingInnerRadius = planetData[Planets.SATURN].radius + 0.006630 uranusRingOuterRadius = planetData[Planets.URANUS].radius + Planets.uranusOuterRadius - uranusRingInnerRadius = planetData[Planets.URANUS].radius + 2 + uranusRingInnerRadius = planetData[Planets.URANUS].radius + 0.002 ready = true changeScale(1200) changeSpeed(0.2) @@ -286,7 +286,7 @@ Entity { // Limit minimum scaling in focus mode to avoid jitter caused by rounding errors if (actualScale <= focusedMinimumScale) { planetScale = focusedMinimumScale - changeScale(focusedMinimumScale, true) + changeScale(focusedMinimumSfocusedPlanetcale, true) } focusedScaling = true } else if (focusedScaling === true) { @@ -423,7 +423,7 @@ Entity { return var scaling = setScale(scale, focused) - sun.r = planetData[Planets.SUN].radius * scaling / 100 + sun.r = planetData[Planets.SUN].radius * scaling / 10 mercury.r = planetData[Planets.MERCURY].radius * scaling venus.r = planetData[Planets.VENUS].radius * scaling earth.r = planetData[Planets.EARTH].radius * scaling @@ -511,7 +511,7 @@ Entity { } property Transform transformStarfield: Transform { - scale: 8500000 + scale: 8500 translation: Qt.vector3d(0, 0, 0) } diff --git a/examples/qt3d/planets-qml/planets.js b/examples/qt3d/planets-qml/planets.js index f64ec3149..b3517ac5a 100644 --- a/examples/qt3d/planets-qml/planets.js +++ b/examples/qt3d/planets-qml/planets.js @@ -115,11 +115,13 @@ function planetIndex(planetName) { var planets = []; // Planet data info -var solarDistance = 2600000; -var saturnOuterRadius = 120.700; -var uranusOuterRadius = 40; +// Units are in 10^3 KM -var auScale = 149597.870700; // AU in thousands of kilometers +var solarDistance = 2600.000; +var saturnOuterRadius = 0.120700; +var uranusOuterRadius = 0.040; + +var auScale = 149.597870700; // 0.001 AU (in thousands of kilometers) function loadPlanetData() { @@ -136,11 +138,11 @@ function loadPlanetData() { // centerOfOrbit - the planet in the center of the orbit // (orbital elements based on http://www.stjarnhimlen.se/comp/ppcomp.html) - var sun = { radius: 694.439, tilt: 63.87, period: 25.05, x: 0, y: 0, z: 0, + var sun = { radius: 0.694439, tilt: 63.87, period: 25.05, x: 0, y: 0, z: 0, roll: 0 }; planets.push(sun); var mercury = { - radius: 2.433722, tilt: 0.04, N1: 48.3313, N2: 0.0000324587, + radius: 0.002433722, tilt: 0.04, N1: 48.3313, N2: 0.0000324587, i1: 7.0047, i2: 0.0000000500, w1: 29.1241, w2: 0.0000101444, a1: 0.387098, a2: 0, e1: 0.205635, e2: 0.000000000559, M1: 168.6562, M2: 4.0923344368, period: 58.646, x: 0, y: 0, z: 0, @@ -148,7 +150,7 @@ function loadPlanetData() { }; planets.push(mercury); var venus = { - radius: 6.046079, tilt: 177.36, N1: 76.6799, N2: 0.0000246590, + radius: 0.006046079, tilt: 177.36, N1: 76.6799, N2: 0.0000246590, i1: 3.3946, i2: 0.0000000275, w1: 54.8910, w2: 0.0000138374, a1: 0.723330, a2: 0, e1: 0.006773, e2: -0.000000001302, M1: 48.0052, M2: 1.6021302244, period: 243.0185, x: 0, y: 0, z: 0, @@ -156,7 +158,7 @@ function loadPlanetData() { }; planets.push(venus); var earth = { - radius: 6.371, tilt: 25.44, N1: 174.873, N2: 0, + radius: 0.006371, tilt: 25.44, N1: 174.873, N2: 0, i1: 0.00005, i2: 0, w1: 102.94719, w2: 0, a1: 1, a2: 0, e1: 0.01671022, e2: 0, M1: 357.529, M2: 0.985608, period: 0.997, x: 0, y: 0, z: 0, @@ -164,7 +166,7 @@ function loadPlanetData() { }; planets.push(earth); var mars = { - radius: 3.389372, tilt: 25.19, N1: 49.5574, N2: 0.0000211081, + radius: 0.003389372, tilt: 25.19, N1: 49.5574, N2: 0.0000211081, i1: 1.8497, i2: -0.0000000178, w1: 286.5016, w2: 0.0000292961, a1: 1.523688, a2: 0, e1: 0.093405, e2: 0.000000002516, M1: 18.6021, M2: 0.5240207766, period: 1.025957, x: 0, y: 0, z: 0, @@ -172,7 +174,7 @@ function loadPlanetData() { }; planets.push(mars); var jupiter = { - radius: 71.41254, tilt: 3.13, N1: 100.4542, N2: 0.0000276854, + radius: 0.07141254, tilt: 3.13, N1: 100.4542, N2: 0.0000276854, i1: 1.3030, i2: -0.0000001557, w1: 273.8777, w2: 0.0000164505, a1: 5.20256, a2: 0, e1: 0.048498, e2: 0.000000004469, M1: 19.8950, M2: 0.0830853001, period: 0.4135, x: 0, y: 0, z: 0, @@ -180,7 +182,7 @@ function loadPlanetData() { }; planets.push(jupiter); var saturn = { - radius: 60.19958, tilt: 26.73, N1: 113.6634, N2: 0.0000238980, + radius: 0.06019958, tilt: 26.73, N1: 113.6634, N2: 0.0000238980, i1: 2.4886, i2: -0.0000001081, w1: 339.3939, w2: 0.0000297661, a1: 9.55475, a2: 0, e1: 0.055546, e2: -0.000000009499, M1: 316.9670, M2: 0.0334442282, period: 0.4395, x: 0, y: 0, z: 0, @@ -188,7 +190,7 @@ function loadPlanetData() { }; planets.push(saturn); var uranus = { - radius: 25.5286, tilt: 97.77, N1: 74.0005, N2: 0.000013978, + radius: 0.0255286, tilt: 97.77, N1: 74.0005, N2: 0.000013978, i1: 0.7733, i2: 0.000000019, w1: 96.6612, w2: 0.000030565, a1: 19.18171, a2: -0.0000000155, e1: 0.047318, e2: 0.00000000745, M1: 142.5905, M2: 0.011725806, period: 0.71833, x: 0, y: 0, z: 0, @@ -196,7 +198,7 @@ function loadPlanetData() { }; planets.push(uranus); var neptune = { - radius: 24.73859, tilt: 28.32, N1: 131.7806, N2: 0.000030173, + radius: 0.02473859, tilt: 28.32, N1: 131.7806, N2: 0.000030173, i1: 1.7700, i2: -0.000000255, w1: 272.8461, w2: 0.000006027, a1: 30.05826, a2: 0.00000003313, e1: 0.008606, e2: 0.00000000215, M1: 260.2471, M2: 0.005995147, period: 0.6713, x: 0, y: 0, z: 0, @@ -204,7 +206,7 @@ function loadPlanetData() { }; planets.push(neptune); var moon = { - radius: 1.5424, tilt: 28.32, N1: 125.1228, N2: -0.0529538083, + radius: 0.0015424, tilt: 28.32, N1: 125.1228, N2: -0.0529538083, i1: 5.1454, i2: 0, w1: 318.0634, w2: 0.1643573223, a1: 0.273, a2: 0, e1: 0.054900, e2: 0, M1: 115.3654, M2: 13.0649929509, period: 27.321582, x: 0, y: 0, z: 0, @@ -224,7 +226,7 @@ function getOuterRadius(planet) { } else if (planet === URANUS) { outerRadius =+ uranusOuterRadius; } else if (planet === SUN) { - outerRadius = planets[planet]["radius"] / 100; + outerRadius = planets[planet]["radius"] / 10; } } |