Skip to content

Commit

Permalink
chore: expose 3dtiles process methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Jul 30, 2021
1 parent b560005 commit 7a94570
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
],

"3D Tiles": [
"3dTilesProcessing",
"C3DTileset",
"C3DTBatchTable",
"C3DTBoundingVolume",
Expand Down
1 change: 1 addition & 0 deletions src/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ export { default as C3DTBatchTable } from './Core/3DTiles/C3DTBatchTable';
export { default as C3DTExtensions } from './Core/3DTiles/C3DTExtensions';
export { default as C3DTilesTypes } from './Core/3DTiles/C3DTilesTypes';
export { default as C3DTBatchTableHierarchyExtension } from './Core/3DTiles/C3DTBatchTableHierarchyExtension';
export { process3dTilesNode, $3dTilesCulling, $3dTilesSubdivisionControl } from 'Process/3dTilesProcessing';
35 changes: 35 additions & 0 deletions src/Process/3dTilesProcessing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as THREE from 'three';
import Extent from 'Core/Geographic/Extent';

/** @module 3dTilesProcessing
*/

function requestNewTile(view, scheduler, geometryLayer, metadata, parent, redraw) {
const command = {
/* mandatory */
Expand Down Expand Up @@ -120,6 +123,15 @@ function _subdivideNodeSubstractive(context, layer, node) {
}
}

/**
* Check if the node is visible in the camera.
*
* @param {C3DTilesLayer} layer node 3D tiles layer
* @param {Camera} camera camera
* @param {THREE.Object3D} node The 3d tile node to check.
* @param {THREE.Matrix4} tileMatrixWorld The node matrix world
* @return {boolean} return true if the node is visible
*/
export function $3dTilesCulling(layer, camera, node, tileMatrixWorld) {
// For viewer Request Volume
// https://github.com/AnalyticalGraphicsInc/3d-tiles-samples/tree/master/tilesets/TilesetWithRequestVolume
Expand Down Expand Up @@ -299,6 +311,16 @@ function markForDeletion(layer, elt) {
}
}

/**
* This funcion builds the method to update 3d tiles node.
*
* The returned method checks the 3d tile visibility with `cullingTest` function.
* It subdivises visible node if `subdivisionTest` return `true`.
*
* @param {Function} [cullingTest=$3dTilesCulling] The culling test method.
* @param {Function} [subdivisionTest=$3dTilesSubdivisionControl] The subdivision test method.
* @return {Function} { description_of_the_return_value }
*/
export function process3dTilesNode(cullingTest = $3dTilesCulling, subdivisionTest = $3dTilesSubdivisionControl) {
return function _process3dTilesNodes(context, layer, node) {
// early exit if parent's subdivision is in progress
Expand Down Expand Up @@ -338,6 +360,17 @@ export function process3dTilesNode(cullingTest = $3dTilesCulling, subdivisionTes
};
}

/**
*
*
* the method returns true if the `node` should be subivised.
*
* @param {object} context The current context
* @param {Camera} context.camera The current camera
* @param {C3DTilesLayer} layer The 3d tile layer
* @param {THREE.Object3D} node The 3d tile node
* @return {boolean}
*/
export function $3dTilesSubdivisionControl(context, layer, node) {
if (layer.tileset.tiles[node.tileId].children === undefined) {
return false;
Expand All @@ -348,3 +381,5 @@ export function $3dTilesSubdivisionControl(context, layer, node) {
const sse = computeNodeSSE(context.camera, node);
return sse > layer.sseThreshold;
}


0 comments on commit 7a94570

Please sign in to comment.