From 7a9457075067afa1a7aa2dc3cb72999033105ff6 Mon Sep 17 00:00:00 2001 From: gchoqueux Date: Tue, 13 Jul 2021 14:47:53 +0200 Subject: [PATCH] chore: expose 3dtiles process methods. --- docs/config.json | 1 + src/Main.js | 1 + src/Process/3dTilesProcessing.js | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/docs/config.json b/docs/config.json index fa1e7c55b0..d746b35373 100644 --- a/docs/config.json +++ b/docs/config.json @@ -108,6 +108,7 @@ ], "3D Tiles": [ + "3dTilesProcessing", "C3DTileset", "C3DTBatchTable", "C3DTBoundingVolume", diff --git a/src/Main.js b/src/Main.js index 2ef3f966b7..5ec973b895 100644 --- a/src/Main.js +++ b/src/Main.js @@ -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'; diff --git a/src/Process/3dTilesProcessing.js b/src/Process/3dTilesProcessing.js index d42920844c..facaf78301 100644 --- a/src/Process/3dTilesProcessing.js +++ b/src/Process/3dTilesProcessing.js @@ -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 */ @@ -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 @@ -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 @@ -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; @@ -348,3 +381,5 @@ export function $3dTilesSubdivisionControl(context, layer, node) { const sse = computeNodeSSE(context.camera, node); return sse > layer.sseThreshold; } + +