Skip to content

Commit 721f27f

Browse files
authored
ImageOverlayPlugins: Move tile composition to a separate class (#1413)
* Add region image source * Enable use of region source * Updates * Update all overlays * Small updates * Simplify ranges so they are always normalized * Cleanup * Fixes * Simplify * Remove renderer * Cleanup * Use resolution * Add "TiledImageOverlay" * Updates * Clean up overlay initialization * Remove need for "countTilesInRnge" * Add support for "none" projection scheme * Fix lint * Steps towards removing use of "tiling * More simplification * Updates * Rearrange some dependencies * Remove unused dispose call * Simplify use of aspect ratio * Use "processedTiles" where possible * Fix memory leak * Remove parent tile drawing * Defer to "Overlay" implementation for texture fetch * memory leak fixes * Update geojson example * Add prepare logic to allow for loading data without creating and composing a texture * rearrange * Fix lint issue * GeoJSONOverlay: Convert to use "region" directly * Add a separate "lock" and "get" function * Remove need for "meshRange" * Remove "rangeMarked" field * Remove prepare functions * Remove comments * Fix geojson overlay * simplification * Remove passing level to the overlay * Lint fix * lint fix * Geojson split update * Add pass through for geojson overlay fields * Add ability to redraw the geojson * Fix up url * Add an animation to projection demo
1 parent b0db7fe commit 721f27f

7 files changed

Lines changed: 659 additions & 455 deletions

File tree

example/r3f/projection.jsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,38 @@ import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeome
1111

1212
const tilesetUrl = 'https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json';
1313

14-
// construct a shape via geojson
15-
const shape = [];
16-
for ( let i = 0; i < 100; i ++ ) {
14+
// Function to generate animated shape
15+
function generateShape( rotation, amplitudeScale, target = null ) {
1716

18-
const x = Math.sin( Math.PI * 2 * i / 100 );
19-
const y = Math.cos( Math.PI * 2 * i / 100 );
20-
const len = Math.sin( 10 * 2 * Math.PI * i / 100 ) * 10 + 75;
17+
if ( target === null ) {
2118

22-
shape.push( [ x * len, y * len ] );
19+
target = new Array( 100 )
20+
.fill()
21+
.map( () => new Array( 2 ) );
22+
23+
}
24+
25+
for ( let i = 0; i < 100; i ++ ) {
26+
27+
const angle = Math.PI * 2 * i / 100;
28+
const x = Math.sin( angle + rotation );
29+
const y = Math.cos( angle + rotation );
30+
const len = Math.sin( 10 * angle ) * 10 * amplitudeScale + 75;
31+
32+
target[ i ][ 0 ] = x * len;
33+
target[ i ][ 1 ] = y * len;
34+
35+
}
36+
37+
return target;
2338

2439
}
2540

2641
const geojson = {
2742
type: 'Feature',
2843
geometry: {
2944
type: 'Polygon',
30-
coordinates: [ shape ],
45+
coordinates: [ generateShape( 0, 1 ) ],
3146
},
3247
};
3348

@@ -77,7 +92,7 @@ function Scene() {
7792

7893
}, [ boxMesh ] );
7994

80-
useFrame( () => {
95+
useFrame( state => {
8196

8297
if ( overlay && boxMesh ) {
8398

@@ -86,6 +101,18 @@ function Scene() {
86101

87102
}
88103

104+
if ( overlay ) {
105+
106+
// animate the geojson shape
107+
const time = state.clock.getElapsedTime();
108+
const rotation = time * Math.PI * 2.0 * 0.1;
109+
const amplitudeScale = Math.sin( time * 5 );
110+
111+
generateShape( rotation, amplitudeScale, geojson.geometry.coordinates[ 0 ] );
112+
overlay.imageSource.redraw();
113+
114+
}
115+
89116
} );
90117

91118
return (
@@ -127,7 +154,6 @@ function App() {
127154

128155
return (
129156
<Canvas
130-
frameloop='demand'
131157
camera={ {
132158
position: [ 0, 40, 35 ],
133159
} }

example/three/geojson.js

Lines changed: 43 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)