Skip to content

Commit

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

* Fix demos

* TilesCompressionPlugin -> TileCompressionPlugin
  • Loading branch information
gkjohnson authored Dec 1, 2024
1 parent b0891f9 commit 5eea577
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 23 deletions.
2 changes: 1 addition & 1 deletion example/fadingTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
OrthographicCamera,
Group,
} from 'three';
import { TilesFadePlugin } from './src/plugins/fade/TilesFadePlugin.js';
import { TilesFadePlugin } from '3d-tiles-renderer/plugins';
import { EnvironmentControls, TilesRenderer, CameraTransitionManager } from '3d-tiles-renderer';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';

Expand Down
4 changes: 1 addition & 3 deletions example/googleMapsAerial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GeoUtils, WGS84_ELLIPSOID, TilesRenderer } from '3d-tiles-renderer';
import { GoogleCloudAuthPlugin } from '3d-tiles-renderer/plugins';
import { GoogleCloudAuthPlugin, TilesFadePlugin, TileCompressionPlugin } from '3d-tiles-renderer/plugins';
import {
Scene,
WebGLRenderer,
Expand All @@ -11,8 +11,6 @@ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { TileCompressionPlugin } from './src/plugins/TileCompressionPlugin.js';
import { TilesFadePlugin } from './src/plugins/fade/TilesFadePlugin.js';

let camera, controls, scene, renderer, tiles;

Expand Down
10 changes: 6 additions & 4 deletions example/googleMapsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
CameraTransitionManager,
TilesRenderer,
} from '3d-tiles-renderer';
import { GoogleCloudAuthPlugin } from '3d-tiles-renderer/plugins';
import {
GoogleCloudAuthPlugin,
TilesFadePlugin,
UpdateOnChangePlugin,
TileCompressionPlugin,
} from '3d-tiles-renderer/plugins';
import {
Scene,
WebGLRenderer,
Expand All @@ -18,9 +23,6 @@ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import Stats from 'three/examples/jsm/libs/stats.module.js';
import { TileCompressionPlugin } from './src/plugins/TileCompressionPlugin.js';
import { UpdateOnChangePlugin } from './src/plugins/UpdateOnChangePlugin.js';
import { TilesFadePlugin } from './src/plugins/fade/TilesFadePlugin.js';
import { BatchedTilesPlugin } from './src/plugins/batched/BatchedTilesPlugin.js';

let controls, scene, renderer, tiles, transition;
Expand Down
10 changes: 6 additions & 4 deletions example/ionLunar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import {
TilesRenderer,
LUNAR_ELLIPSOID,
} from '3d-tiles-renderer';
import { CesiumIonAuthPlugin } from '3d-tiles-renderer/plugins';
import {
CesiumIonAuthPlugin,
UpdateOnChangePlugin,
TileCompressionPlugin,
TilesFadePlugin,
} from '3d-tiles-renderer/plugins';
import {
Scene,
WebGLRenderer,
PerspectiveCamera,
} from 'three';
import { TilesFadePlugin } from './src/plugins/fade/TilesFadePlugin.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { TileCompressionPlugin } from './src/plugins/TileCompressionPlugin.js';
import { UpdateOnChangePlugin } from './src/plugins/UpdateOnChangePlugin.js';

let controls, scene, camera, renderer, tiles;

Expand Down
2 changes: 1 addition & 1 deletion example/r3f/basic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createRoot } from 'react-dom/client';
import { Canvas, useFrame } from '@react-three/fiber';
import { Environment, GizmoHelper, GizmoViewport, MeshTransmissionMaterial } from '@react-three/drei';
import { TilesPlugin, TilesRenderer, EnvironmentControls } from '3d-tiles-renderer/r3f';
import { TilesFadePlugin } from '../src/plugins/fade/TilesFadePlugin.js';
import { TilesFadePlugin } from '3d-tiles-renderer/plugins';

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';

Expand Down
10 changes: 6 additions & 4 deletions example/r3f/globe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import {
} from '3d-tiles-renderer/r3f';

// Plugins
import { GoogleCloudAuthPlugin } from '3d-tiles-renderer/plugins';
import {
GoogleCloudAuthPlugin,
UpdateOnChangePlugin,
TileCompressionPlugin,
TilesFadePlugin,
} 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';
import { UpdateOnChangePlugin } from '../src/plugins/UpdateOnChangePlugin.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';

// R3F, DREI and LEVA imports
Expand Down
3 changes: 1 addition & 2 deletions example/r3f/ion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ 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/plugins';
import { CesiumIonAuthPlugin, UpdateOnChangePlugin } from '3d-tiles-renderer/plugins';

// Plugins
import { GLTFExtensionsPlugin } from '../src/plugins/GLTFExtensionsPlugin.js';
import { ReorientationPlugin } from '../src/plugins/ReorientationPlugin.js';
import { UpdateOnChangePlugin } from '../src/plugins/UpdateOnChangePlugin.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';

// R3F, DREI and LEVA imports
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Plugins to register to the TilesRenderer instance to modify behavior.

```js
const tiles = new TilesRenderer( url );
tiles.registerPlugin( new TilesCompressionPlugin() );
tiles.registerPlugin( new TileCompressionPlugin() );
tiles.registerPlugin( new TilesFadePlugin() );
```

Expand Down Expand Up @@ -404,7 +404,7 @@ unregisterLayer( name : string ) : void
hasLayer( name : string ) : boolean
```

## TilesCompressionPlugin
## TileCompressionPlugin

_available in the examples directory_

Expand Down
3 changes: 3 additions & 0 deletions src/plugins/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// three.js plugins
export { CesiumIonAuthPlugin } from './three/CesiumIonAuthPlugin';
export { GoogleCloudAuthPlugin } from './three/GoogleCloudAuthPlugin';
export { UpdateOnChangePlugin } from './three/UpdateOnChangePlugin';
export { TileCompressionPlugin } from './three/TileCompressionPlugin';
export { TilesFadePlugin } from './three/fade/TilesFadePlugin';
export * from './three/DebugTilesPlugin';

// common plugins
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// three.js plugins
export { CesiumIonAuthPlugin } from './three/CesiumIonAuthPlugin.js';
export { GoogleCloudAuthPlugin } from './three/GoogleCloudAuthPlugin.js';
export { UpdateOnChangePlugin } from './three/UpdateOnChangePlugin.js';
export { TileCompressionPlugin } from './three/TileCompressionPlugin.js';
export { TilesFadePlugin } from './three/fade/TilesFadePlugin.js';
export * from './three/DebugTilesPlugin.js';

// common plugins
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/three/TileCompressionPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TypedArray } from 'three';

export class TileCompressionPlugin {

constructor( options: {
generateNormals: Boolean,
disableMipmaps: Boolean,
compressIndex: Boolean,
compressNormals: Boolean,
compressUvs: Boolean,
compressPosition: Boolean,

uvType: TypedArray,
normalType: TypedArray,
positionType: TypedArray,
} );

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { MeshNormalMaterial } from 'three';
import { Vector3, LinearFilter, BufferAttribute, MathUtils } from 'three';
import { toCreasedNormals } from 'three/examples/jsm/utils/BufferGeometryUtils.js';

const _vec = new Vector3();
function compressAttribute( attribute, arrayType ) {
Expand Down Expand Up @@ -167,7 +169,7 @@ export class TileCompressionPlugin {
// handle geometry attribute compression
if ( c.geometry ) {

const geometry = c.geometry;
let geometry = c.geometry;
const attributes = geometry.attributes;
if ( compressUvs ) {

Expand All @@ -181,7 +183,10 @@ export class TileCompressionPlugin {

if ( generateNormals && ! attributes.normals ) {

geometry.computeVertexNormals();
geometry = toCreasedNormals( geometry, 30 * MathUtils.DEG2RAD );
c.geometry = geometry;

c.material = new MeshNormalMaterial();

}

Expand Down
5 changes: 5 additions & 0 deletions src/plugins/three/UpdateOnChange.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class UpdateOnChangePlugin {

constructor();

}
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions src/plugins/three/fade/TilesFadePlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class TilesFadePlugin {

constructor( options: {
maximumFadeOutTiles: Number,
fadeRootTiles: Boolean,
fadeDuration: Number,
} );

}
File renamed without changes.

0 comments on commit 5eea577

Please sign in to comment.