Skip to content

Commit 8ecd0bd

Browse files
committed
Update projection demo, remove unneeded geojson plugin
1 parent c0f889b commit 8ecd0bd

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

example/geojson.js

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

example/r3f/projection.jsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { StrictMode, useEffect, useMemo, useState } from 'react';
22
import { createRoot } from 'react-dom/client';
33
import { Canvas, useFrame } from '@react-three/fiber';
44
import { TilesPlugin, TilesRenderer, EnvironmentControls } from '3d-tiles-renderer/r3f';
5-
import { TilesFadePlugin, CesiumIonOverlay, EnforceNonZeroErrorPlugin } from '3d-tiles-renderer/plugins';
5+
import { TilesFadePlugin, EnforceNonZeroErrorPlugin, GeoJSONOverlay } from '3d-tiles-renderer/plugins';
66
import { BoxGeometry, EdgesGeometry, Euler, Matrix4, Quaternion, Vector3 } from 'three';
77
import { PivotControls } from '@react-three/drei';
88
import { ImageOverlay, ImageOverlayPlugin } from './plugins/ImageOverlayPlugin.jsx';
@@ -11,6 +11,26 @@ 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 ++ ) {
17+
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;
21+
22+
shape.push( [ x * len, y * len ] );
23+
24+
}
25+
26+
const geojson = {
27+
type: 'Feature',
28+
geometry: {
29+
type: 'Polygon',
30+
coordinates: [ shape ],
31+
},
32+
};
33+
1434
function Scene() {
1535

1636
const [ transformRoot, setTransformRoot ] = useState( null );
@@ -74,13 +94,15 @@ function Scene() {
7494

7595
{/* 3D Tiles renderer tileset */}
7696
<group rotation-x={ Math.PI / 2 }>
77-
<TilesRenderer url={ tilesetUrl }>
97+
<TilesRenderer url={ tilesetUrl } errorTarget={ 6 }>
7898
<TilesPlugin plugin={ TilesFadePlugin } fadeDuration={ 500 } />
7999
<ImageOverlayPlugin>
80100
<ImageOverlay
81-
type={ CesiumIonOverlay }
82-
assetId='3954'
83-
apiToken={ import.meta.env.VITE_ION_KEY }
101+
type={ GeoJSONOverlay }
102+
geojson={ geojson }
103+
color={ 'red' }
104+
strokeWidth={ 10 }
105+
fillStyle={ 'rgba( 255, 255, 255, 0.25 )' }
84106
worldToProjection={ worldToProjectionMatrix }
85107
ref={ setOverlay }
86108
/>

src/three/plugins/images/EPSGTilesPlugin.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { XYZImageSource } from './sources/XYZImageSource.js';
66
import { TMSImageSource } from './sources/TMSImageSource.js';
77
import { WMTSImageSource } from './sources/WMTSImageSource.js';
88
import { WMSImageSource } from './sources/WMSImageSource.js';
9-
import { GeoJSONImageSource } from './sources/GeoJSONImageSource.js';
109

1110
// https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
1211
export class XYZTilesPlugin extends EllipsoidProjectionTilesPlugin {
@@ -77,19 +76,6 @@ export class WMTSTilesPlugin extends EllipsoidProjectionTilesPlugin {
7776

7877
}
7978

80-
export class GeoJSONTilesPlugin extends EllipsoidProjectionTilesPlugin {
81-
82-
constructor( options = {} ) {
83-
84-
super( options );
85-
86-
this.name = 'GEOJSON_TILES_PLUGIN';
87-
this.imageSource = new GeoJSONImageSource( options );
88-
89-
}
90-
91-
}
92-
9379
export class WMSTilesPlugin extends EllipsoidProjectionTilesPlugin {
9480

9581
constructor( options = {} ) {

src/three/plugins/images/ImageOverlayPlugin.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class XYZTilesOverlay extends ImageOverlay {
3838

3939
}
4040

41-
export class GeoJSONTilesOverlay extends ImageOverlay {
41+
export class GeoJSONOverlay extends ImageOverlay {
4242

4343
constructor( options: {
4444
// rasterize GeoJSON per tile (forwarded to GeoJSONImageSource)

src/three/plugins/images/ImageOverlayPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ export class XYZTilesOverlay extends ImageOverlay {
14761476

14771477
}
14781478

1479-
export class GeoJSONTilesOverlay extends ImageOverlay {
1479+
export class GeoJSONOverlay extends ImageOverlay {
14801480

14811481
constructor( options = {} ) {
14821482

src/three/plugins/images/sources/GeoJSONImageSource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class GeoJSONImageSource extends TiledImageSource {
1717
pointRadius = 6,
1818
strokeStyle = 'white',
1919
strokeWidth = 2,
20-
fillStyle = 'rgba( 255, 255, 255, 0.65 )',
20+
fillStyle = 'rgba( 255, 255, 255, 0.5 )',
2121
} = {} ) {
2222

2323
super();

0 commit comments

Comments
 (0)