-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(unit): add GlobeView, feature process, point clould, 3dtiles tes…
…t unit. GlobeControls, TileMesh subdivision.
- Loading branch information
Showing
17 changed files
with
477 additions
and
69 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,56 @@ | ||
/* global process */ | ||
import assert from 'assert'; | ||
import { Group } from 'three'; | ||
import GeometryLayer from 'Layer/GeometryLayer'; | ||
import View from 'Core/View'; | ||
import GlobeView from 'Core/Prefab/GlobeView'; | ||
import HttpsProxyAgent from 'https-proxy-agent'; | ||
import CameraUtils from 'Utils/CameraUtils'; | ||
import Coordinates from 'Core/Geographic/Coordinates'; | ||
import Renderer from './mock'; | ||
|
||
const renderer = new Renderer(); | ||
|
||
const coordinatesOnGlobe = new Coordinates('EPSG:4326', -75.6134910, 40.0442592, 0); | ||
const threedTilesLayer = new GeometryLayer('3d-tiles-discrete-lod', new Group()); | ||
|
||
threedTilesLayer.name = 'DiscreteLOD'; | ||
threedTilesLayer.url = 'https://raw.githubusercontent.com/AnalyticalGraphicsInc/3d-tiles-samples/master/tilesets/TilesetWithDiscreteLOD/tileset.json'; | ||
threedTilesLayer.protocol = '3d-tiles'; | ||
threedTilesLayer.overrideMaterials = true; // custom cesium shaders are not functional | ||
|
||
if (process.env.HTTPS_PROXY) { | ||
threedTilesLayer.networkOptions = { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) }; | ||
} | ||
|
||
const viewer = new GlobeView('EPSG:4326', coordinatesOnGlobe, { renderer, noControls: true }); | ||
|
||
const p = { coord: coordinatesOnGlobe, heading: -145, range: 200, tilt: 10 }; | ||
CameraUtils.transformCameraToLookAtTarget(viewer, viewer.camera.camera3D, p); | ||
|
||
// viewer.controls.lookAtCoordinate({ range: 200, tilt: 10, heading: -145 }, false); | ||
const context = { | ||
camera: viewer.camera, | ||
engine: viewer.mainLoop.gfxEngine, | ||
scheduler: viewer.mainLoop.scheduler, | ||
geometryLayer: threedTilesLayer, | ||
view: viewer, | ||
}; | ||
|
||
describe('3Dtiles layer', function () { | ||
it('Add 3dtiles layer', function (done) { | ||
View.prototype.addLayer.call(viewer, threedTilesLayer).then((layer) => { | ||
assert.equal(layer.root.children.length, 1); | ||
done(); | ||
}); | ||
}); | ||
it('preUpdate 3dtiles layer', function () { | ||
const elements = threedTilesLayer.preUpdate(context, new Set([threedTilesLayer])); | ||
assert.equal(elements.length, 1); | ||
}); | ||
it('update 3dtiles layer', function () { | ||
const node = threedTilesLayer.root; | ||
threedTilesLayer.update(context, threedTilesLayer, node); | ||
assert.ok(node.pendingSubdivision); | ||
}); | ||
}); |
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,88 @@ | ||
import * as THREE from 'three'; | ||
import assert from 'assert'; | ||
import GlobeView from 'Core/Prefab/GlobeView'; | ||
import FeatureProcessing from 'Process/FeatureProcessing'; | ||
import Feature2Mesh from 'Converter/Feature2Mesh'; | ||
import GeometryLayer from 'Layer/GeometryLayer'; | ||
import FileSource from 'Source/FileSource'; | ||
import HttpsProxyAgent from 'https-proxy-agent'; | ||
import Extent from 'Core/Geographic/Extent'; | ||
import OBB from 'Renderer/OBB'; | ||
import TileMesh from 'Core/TileMesh'; | ||
import Renderer from './mock'; | ||
|
||
const renderer = new Renderer(); | ||
|
||
const positionOnGlobe = { longitude: 1.5, latitude: 43, altitude: 300000 }; | ||
const div = {}; | ||
const viewer = new GlobeView(div, positionOnGlobe, { renderer }); | ||
|
||
function extrude() { | ||
return 5000; | ||
} | ||
|
||
function color() { | ||
return new THREE.Color(0xffcc00); | ||
} | ||
|
||
|
||
const ariege = new GeometryLayer('ariege', new THREE.Group()); | ||
ariege.update = FeatureProcessing.update; | ||
ariege.convert = Feature2Mesh.convert({ | ||
color, | ||
extrude, | ||
}); | ||
|
||
ariege.source = new FileSource({ | ||
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson', | ||
projection: 'EPSG:4326', | ||
format: 'application/json', | ||
zoom: { min: 0, max: 0 }, | ||
// extent: new Extent('EPSG:4326', -90, -10, -900, 900), | ||
}); | ||
|
||
ariege.source.zoom = 0; | ||
|
||
if (process.env.HTTPS_PROXY) { | ||
ariege.source.networkOptions = { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) }; | ||
} | ||
|
||
const context = { | ||
camera: viewer.camera, | ||
engine: viewer.mainLoop.gfxEngine, | ||
scheduler: viewer.mainLoop.scheduler, | ||
geometryLayer: ariege, | ||
view: viewer, | ||
}; | ||
|
||
const extent = new Extent('EPSG:4326', 1.40625, 2.8125, 42.1875, 42.1875); | ||
const geom = new THREE.Geometry(); | ||
geom.OBB = new OBB(new THREE.Vector3(), new THREE.Vector3(1, 1, 1)); | ||
const tile = new TileMesh(geom, new THREE.Material(), viewer.tileLayer, extent, 7); | ||
tile.parent = {}; | ||
|
||
describe('Layer with Feature process', function () { | ||
it('add layer', function (done) { | ||
viewer.addLayer(ariege).then((layer) => { | ||
assert.ok(layer); | ||
done(); | ||
}); | ||
}); | ||
it('update', function (done) { | ||
viewer.tileLayer.whenReady.then(() => { | ||
tile.visible = true; | ||
ariege.update(context, ariege, tile).then(() => { | ||
// Hack to force add Mesh to tile | ||
// Feature Processing needs refactoring to simplify it. | ||
tile.layerUpdateState[ariege.id] = undefined; | ||
ariege.source.parsedData.extent.crs = 'EPSG:4326'; | ||
ariege.source.parsedData.extent.set(0, 10, 40, 50); | ||
ariege.update(context, ariege, tile).then(() => { | ||
assert.equal(tile.children.length, 1); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
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,78 @@ | ||
import * as THREE from 'three'; | ||
import assert from 'assert'; | ||
import GlobeView from 'Core/Prefab/GlobeView'; | ||
import Renderer from './mock'; | ||
|
||
const renderer = new Renderer(); | ||
|
||
const positionOnGlobe = { longitude: 2.351323, latitude: 48.856712, altitude: 250000 }; | ||
const viewer = new GlobeView('EPSG:4326', positionOnGlobe, { renderer }); | ||
|
||
const event = { | ||
stopPropagation: () => {}, | ||
preventDefault: () => {}, | ||
button: THREE.MOUSE.LEFT, | ||
}; | ||
|
||
describe('GlobeControls', function () { | ||
it('instance GlobeControls', function () { | ||
assert.ok(viewer.controls); | ||
}); | ||
it('Set Tilt', function (done) { | ||
viewer.controls.setTilt(10, false).then((e) => { | ||
assert.equal(e.tilt, 10); | ||
done(); | ||
}); | ||
}); | ||
it('update', function () { | ||
viewer.controls._mouseToPan(10, 10); | ||
viewer.controls.update(); | ||
}); | ||
it('mouse down', function (done) { | ||
renderer.domElement.emitEvent('mousedown', event).then(() => { | ||
renderer.domElement.emitEvent('mousemove', event); | ||
renderer.domElement.emitEvent('mouseup', event); | ||
done(); | ||
}); | ||
}); | ||
it('dolly', function () { | ||
viewer.controls.dollyIn(); | ||
viewer.controls.dollyOut(); | ||
}); | ||
it('mouse down + crtl', function (done) { | ||
event.keyCode = 17; | ||
renderer.domElement.emitEvent('keydown', event).then(() => { | ||
renderer.domElement.emitEvent('mousedown', event).then(() => { | ||
renderer.domElement.emitEvent('mousemove', event); | ||
renderer.domElement.emitEvent('mouseup', event); | ||
renderer.domElement.emitEvent('keyup', event); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('mouse wheel', function (done) { | ||
renderer.domElement.emitEvent('mousewheel', event).then(() => { | ||
done(); | ||
}); | ||
}); | ||
it('mouse dblclick', function (done) { | ||
renderer.domElement.emitEvent('dblclick', event).then(() => { | ||
done(); | ||
}); | ||
}); | ||
|
||
event.touches = [1, 1]; | ||
it('touch start', function (done) { | ||
renderer.domElement.emitEvent('touchstart', event).then(() => { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('touch move', function () { | ||
renderer.domElement.emitEvent('touchmove', event); | ||
}); | ||
|
||
it('touch end', function () { | ||
renderer.domElement.emitEvent('touchend', event); | ||
}); | ||
}); |
Oops, something went wrong.