-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/* global describe, it */ | ||
import proj4 from 'proj4'; | ||
import assert from 'assert'; | ||
import Camera from '../src/Renderer/Camera'; | ||
import { Matrix4, Object3D } from 'three'; | ||
import Coordinates from '../src/Core/Geographic/Coordinates'; | ||
import Extent from '../src/Core/Geographic/Extent'; | ||
import OBB from '../src/Renderer/ThreeExtended/OBB'; | ||
import { computeNodeSSE } from '../src/Process/3dTilesProcessing'; | ||
import { $3dTilesIndex, configureTile } from '../src/Provider/3dTilesProvider'; | ||
|
||
function tilesetWithRegion(transformMatrix) { | ||
const tileset = { | ||
root: { | ||
boundingVolume: { | ||
region: [ | ||
-0.1, -0.1, | ||
0.1, 0.1, | ||
0, 0], | ||
} | ||
} | ||
}; | ||
if (transformMatrix) { | ||
tileset.root.transform = transformMatrix.elements; | ||
} | ||
return tileset; | ||
} | ||
|
||
function tilesetWithBox(transformMatrix) { | ||
const tileset = { | ||
root: { | ||
boundingVolume: { | ||
box: [ | ||
0, 0, 0, | ||
1, 0, 0, | ||
0, 1, 0, | ||
0, 0, 1], | ||
} | ||
} | ||
}; | ||
if (transformMatrix) { | ||
tileset.root.transform = transformMatrix.elements; | ||
} | ||
return tileset; | ||
} | ||
|
||
function tilesetWithSphere(transformMatrix) { | ||
const tileset = { | ||
root: { | ||
boundingVolume: { | ||
sphere: [0, 0, 0, 1], | ||
} | ||
} | ||
}; | ||
if (transformMatrix) { | ||
tileset.root.transform = transformMatrix.elements; | ||
} | ||
return tileset; | ||
} | ||
|
||
describe('Distance computation using boundingVolume.region', function() { | ||
const camera = new Camera('EPSG:4978', 100, 100); | ||
camera.camera3D.position.copy(new Coordinates('EPSG:4326', 0, 0, 10000).as('EPSG:4978').xyz()); | ||
camera.camera3D.updateMatrixWorld(true); | ||
|
||
xit('should compute distance correctly', function() { | ||
const tileset = tilesetWithRegion(); | ||
const tileIndex = new $3dTilesIndex(tileset, ''); | ||
const tile = new Object3D(); | ||
configureTile(tile, { }, tileIndex.index['0']) | ||
|
||
computeNodeSSE(camera, tile); | ||
|
||
assert.equal(tile.distance, camera.position().as('EPSG:4326').altitude()); | ||
}); | ||
|
||
xit('should not be affected by transform', function() { | ||
const m = new Matrix4().makeTranslation(0, 0, 10).multiply( | ||
new Matrix4().makeScale(0.01, 0.01, 0.01)); | ||
const tileset = tilesetWithRegion(m); | ||
const tileIndex = new $3dTilesIndex(tileset, ''); | ||
const tile = new Object3D(); | ||
configureTile(tile, { }, tileIndex.index['0']) | ||
|
||
computeNodeSSE(camera, tile); | ||
|
||
assert.equal(tile.distance, camera.position().as('EPSG:4326').altitude()); | ||
}); | ||
}); | ||
|
||
describe('Distance computation using boundingVolume.box', function() { | ||
proj4.defs('EPSG:3946', | ||
'+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); | ||
|
||
const camera = new Camera('EPSG:3946', 100, 100); | ||
camera.camera3D.position.copy(new Coordinates('EPSG:3946', 0, 0, 100).xyz()); | ||
camera.camera3D.updateMatrixWorld(true); | ||
|
||
it('should compute distance correctly', function() { | ||
const tileset = tilesetWithBox(); | ||
const tileIndex = new $3dTilesIndex(tileset, ''); | ||
|
||
const tile = new Object3D(); | ||
configureTile(tile, { }, tileIndex.index['0']) | ||
|
||
computeNodeSSE(camera, tile); | ||
|
||
assert.equal(tile.distance, 100 - 1); | ||
}); | ||
|
||
it('should affected by transform', function() { | ||
const m = new Matrix4().makeTranslation(0, 0, 10).multiply( | ||
new Matrix4().makeScale(0.01, 0.01, 0.01)); | ||
const tileset = tilesetWithBox(m); | ||
|
||
const tileIndex = new $3dTilesIndex(tileset, ''); | ||
|
||
const tile = new Object3D(); | ||
configureTile(tile, { }, tileIndex.index['0']) | ||
|
||
tile.updateMatrixWorld(true); | ||
|
||
computeNodeSSE(camera, tile); | ||
|
||
assert.equal(tile.distance, 100 - 1 * 0.01 - 10); | ||
}); | ||
}); | ||
|
||
describe('Distance computation using boundingVolume.sphere', function() { | ||
proj4.defs('EPSG:3946', | ||
'+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); | ||
|
||
const camera = new Camera('EPSG:3946', 100, 100); | ||
camera.camera3D.position.copy(new Coordinates('EPSG:3946', 0, 0, 100).xyz()); | ||
camera.camera3D.updateMatrixWorld(true); | ||
|
||
it('should compute distance correctly', function() { | ||
const tileset = tilesetWithSphere(); | ||
const tileIndex = new $3dTilesIndex(tileset, ''); | ||
|
||
const tile = new Object3D(); | ||
configureTile(tile, { }, tileIndex.index['0']) | ||
|
||
computeNodeSSE(camera, tile); | ||
|
||
assert.equal(tile.distance, 100 - 1); | ||
}); | ||
|
||
it('should affected by transform', function() { | ||
const m = new Matrix4().makeTranslation(0, 0, 10).multiply( | ||
new Matrix4().makeScale(0.01, 0.01, 0.01)); | ||
const tileset = tilesetWithSphere(m); | ||
|
||
const tileIndex = new $3dTilesIndex(tileset, ''); | ||
|
||
const tile = new Object3D(); | ||
configureTile(tile, { }, tileIndex.index['0']) | ||
|
||
tile.updateMatrixWorld(true); | ||
|
||
computeNodeSSE(camera, tile); | ||
|
||
assert.equal(tile.distance, 100 - 1 * 0.01 - 10); | ||
}); | ||
}); |