Skip to content

Commit

Permalink
Move plugins (#838)
Browse files Browse the repository at this point in the history
* Move plugins

* Add subclasses

* Move gltf plugins

* Update package.json imports

* README update

* docs update

* Fixes

* Update examples

* Fix examples
  • Loading branch information
gkjohnson authored Nov 1, 2024
1 parent f5e6874 commit 2abf083
Show file tree
Hide file tree
Showing 54 changed files with 2,071 additions and 1,943 deletions.
587 changes: 2 additions & 585 deletions PLUGINS.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion example/ellipsoid.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SphereHelper, EllipsoidRegionLineHelper, EllipsoidRegionHelper } from '3d-tiles-renderer';
import { SphereHelper } from '../src/plugins/three/objects/SphereHelper.js';
import { EllipsoidRegionHelper, EllipsoidRegionLineHelper } from '../src/plugins/three/objects/EllipsoidRegionHelper.js';
import {
Scene,
Group,
Expand Down
3 changes: 2 additions & 1 deletion example/googleMapsAerial.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GeoUtils, WGS84_ELLIPSOID, TilesRenderer, GoogleCloudAuthPlugin } from '3d-tiles-renderer';
import { GeoUtils, WGS84_ELLIPSOID, TilesRenderer } from '3d-tiles-renderer';
import { GoogleCloudAuthPlugin } from '3d-tiles-renderer/plugins';
import {
Scene,
WebGLRenderer,
Expand Down
2 changes: 1 addition & 1 deletion example/googleMapsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
GeoUtils,
GlobeControls,
TilesRenderer,
GoogleCloudAuthPlugin,
} from '3d-tiles-renderer';
import { GoogleCloudAuthPlugin } from '3d-tiles-renderer/plugins';
import {
Scene,
WebGLRenderer,
Expand Down
6 changes: 4 additions & 2 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
TilesRenderer,
DebugTilesPlugin,
ImplicitTilingPlugin,
GLTFCesiumRTCExtension,
NONE,
SCREEN_ERROR,
Expand All @@ -15,6 +13,10 @@ import {
CUSTOM_COLOR,
LOAD_ORDER,
} from '3d-tiles-renderer';
import {
DebugTilesPlugin,
ImplicitTilingPlugin,
} from '3d-tiles-renderer/plugins';
import {
Scene,
DirectionalLight,
Expand Down
3 changes: 2 additions & 1 deletion example/ionExample.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CesiumIonAuthPlugin, EnvironmentControls, TilesRenderer } from '3d-tiles-renderer';
import { EnvironmentControls, TilesRenderer } from '3d-tiles-renderer';
import { CesiumIonAuthPlugin } from '3d-tiles-renderer/plugins';
import {
Scene,
WebGLRenderer,
Expand Down
2 changes: 1 addition & 1 deletion example/ionLunar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
GlobeControls,
TilesRenderer,
LUNAR_ELLIPSOID,
CesiumIonAuthPlugin,
} from '3d-tiles-renderer';
import { CesiumIonAuthPlugin } from '3d-tiles-renderer/plugins';
import {
Scene,
WebGLRenderer,
Expand Down
6 changes: 2 additions & 4 deletions example/mars.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
TilesRenderer,
DebugTilesPlugin,
} from '3d-tiles-renderer';
import { TilesRenderer } from '3d-tiles-renderer';
import { DebugTilesPlugin } from '3d-tiles-renderer/plugins';
import {
Scene,
DirectionalLight,
Expand Down
6 changes: 4 additions & 2 deletions example/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import {
} from 'three';
import {
EnvironmentControls,
TilesRenderer,
} from '3d-tiles-renderer';
import {
GLTFMeshFeaturesExtension,
GLTFStructuralMetadataExtension,
TilesRenderer,
CesiumIonAuthPlugin,
} from '..';
} from '3d-tiles-renderer/plugins';
import { MeshFeaturesMaterialMixin } from './src/MeshFeaturesMaterial';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import GUI from 'three/examples/jsm/libs/lil-gui.module.min.js';
Expand Down
2 changes: 1 addition & 1 deletion example/r3f/globe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { CameraTransition } from './components/CameraTransition.jsx';

// Plugins
import { GoogleCloudAuthPlugin } from '3d-tiles-renderer';
import { GoogleCloudAuthPlugin } from '3d-tiles-renderer/plugins';
import { GLTFExtensionsPlugin } from '../src/plugins/GLTFExtensionsPlugin.js';
import { TilesFadePlugin } from '../src/plugins/fade/TilesFadePlugin.js';
import { TileCompressionPlugin } from '../src/plugins/TileCompressionPlugin.js';
Expand Down
2 changes: 1 addition & 1 deletion example/r3f/ion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createRoot } from 'react-dom/client';

// TilesRenderer, controls and attribution imports
import { TilesPlugin, TilesRenderer, TilesAttributionOverlay, EnvironmentControls } from '3d-tiles-renderer/r3f';
import { CesiumIonAuthPlugin } from '3d-tiles-renderer';
import { CesiumIonAuthPlugin } from '3d-tiles-renderer/plugins';

// Plugins
import { GLTFExtensionsPlugin } from '../src/plugins/GLTFExtensionsPlugin.js';
Expand Down
2 changes: 1 addition & 1 deletion example/src/plugins/GLTFExtensionsPlugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { GLTFStructuralMetadataExtension, GLTFMeshFeaturesExtension, GLTFCesiumRTCExtension } from '3d-tiles-renderer';
import { GLTFStructuralMetadataExtension, GLTFMeshFeaturesExtension, GLTFCesiumRTCExtension } from '3d-tiles-renderer/plugins';

export class GLTFExtensionsPlugin {

Expand Down
3 changes: 1 addition & 2 deletions example/src/plugins/TileCompressionPlugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Vector3, LinearFilter } from 'three';
import { BufferAttribute, MathUtils } from 'three';
import { Vector3, LinearFilter, BufferAttribute, MathUtils } from 'three';

const _vec = new Vector3();
function compressAttribute( attribute, arrayType ) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
],
"exports": {
".": "./src/index.js",
"./r3f": "./src/r3f/index.jsx"
"./r3f": "./src/r3f/index.jsx",
"./plugins": "./src/plugins/index.js"
},
"scripts": {
"start": "vite --config ./vite.config.js",
Expand Down
80 changes: 4 additions & 76 deletions src/base/plugins/ImplicitTilingPlugin.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,11 @@
import { SUBTREELoader } from './SUBTREELoader.js';
import { ImplicitTilingPlugin as ImplicitTilingPluginImpl } from '../../plugins/index.js';

export class ImplicitTilingPlugin {
export class ImplicitTilingPlugin extends ImplicitTilingPluginImpl {

constructor() {

this.name = 'IMPLICIT_TILING_PLUGIN';

}

init( tiles ) {

this.tiles = tiles;

}

preprocessNode( tile, tileSetDir, parentTile ) {

if ( tile.implicitTiling ) {

tile.__hasUnrenderableContent = true;
tile.__hasRenderableContent = false;

// Declare some properties
tile.__subtreeIdx = 0; // Idx of the tile in its subtree
tile.__implicitRoot = tile; // Keep this tile as an Implicit Root Tile

// Coords of the tile
tile.__x = 0;
tile.__y = 0;
tile.__z = 0;
tile.__level = 0;

} else if ( /.subtree$/i.test( tile.content?.uri ) ) {

// Handling content uri pointing to a subtree file
tile.__hasUnrenderableContent = true;
tile.__hasRenderableContent = false;

}

}

parseTile( buffer, parseTile, extension ) {

if ( /^subtree$/i.test( extension ) ) {

const loader = new SUBTREELoader( parseTile );
loader.parse( buffer );
return Promise.resolve();

}

}

preprocessURL( url, tile ) {

if ( tile && tile.implicitTiling ) {

const implicitUri = tile.implicitTiling.subtrees.uri
.replace( '{level}', tile.__level )
.replace( '{x}', tile.__x )
.replace( '{y}', tile.__y )
.replace( '{z}', tile.__z );

return new URL( implicitUri, tile.__basePath + '/' ).toString();

}

return url;

}

disposeTile( tile ) {

if ( /.subtree$/i.test( tile.content?.uri ) ) {

tile.children.length = 0;

}
super();
console.warn( 'ImplicitTilingPlugin: Plugins should now be imported from "3d-tiles-renderer/plugins" path.' );

}

Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export { GLTFCesiumRTCExtension } from './three/loaders/gltf/GLTFCesiumRTCExtens
export { GLTFStructuralMetadataExtension } from './three/loaders/gltf/GLTFStructuralMetadataExtension.js';
export { GLTFMeshFeaturesExtension } from './three/loaders/gltf/GLTFMeshFeaturesExtension.js';
export { GLTFExtensionLoader } from './three/loaders/GLTFExtensionLoader.js';
export { EllipsoidRegionHelper, EllipsoidRegionLineHelper } from './three/objects/EllipsoidRegionHelper.js';
export { SphereHelper } from './three/objects/SphereHelper.js';

export * from './three/math/Ellipsoid.js';
export * from './three/math/EllipsoidRegion.js';
export * as GeoUtils from './three/math/GeoUtils.js';
Expand Down
Loading

0 comments on commit 2abf083

Please sign in to comment.