Skip to content

Commit

Permalink
3 more
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Dec 18, 2023
1 parent 4f66f8e commit 1ddc47f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 36 deletions.
2 changes: 1 addition & 1 deletion test/unit/3dtileslayerprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import View from 'Core/View';
import GlobeView from 'Core/Prefab/GlobeView';
import { HttpsProxyAgent } from 'https-proxy-agent';
import Coordinates from 'Core/Geographic/Coordinates';
import Fetcher from 'Provider/Fetcher';
import sinon from 'sinon';
import Fetcher from 'Provider/Fetcher';
import Renderer from './bootstrap';

import tilesetDiscretLOD from '../data/unitTest/3dTiles/tilesetDiscretLOD.json';
Expand Down
77 changes: 46 additions & 31 deletions test/unit/3dtileslayerstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,70 @@ import PlanarView from 'Core/Prefab/PlanarView';
import C3DTBatchTable from 'Core/3DTiles/C3DTBatchTable';
import C3DTilesSource from 'Source/C3DTilesSource';
import C3DTilesLayer from 'Layer/C3DTilesLayer';
import sinon from 'sinon';
import Fetcher from 'Provider/Fetcher';
import Renderer from './bootstrap';

import tileset from '../data/unitTest/3dTiles/tileset.json';

describe('3DTilesLayer Style', () => {
// Define crs
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');
let view;
let createTileContent;
let stubFetcherJson;

before(function () {
stubFetcherJson = sinon.stub(Fetcher, 'json')
.callsFake(() => Promise.resolve(JSON.parse(tileset)));

// Define crs
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');

// Define geographic extent: CRS, min/max X, min/max Y
const extent = new Extent('EPSG:3946',
1840816.94334, 1843692.32501,
5175036.4587, 5177412.82698);
// Define geographic extent: CRS, min/max X, min/max Y
const extent = new Extent('EPSG:3946',
1840816.94334, 1843692.32501,
5175036.4587, 5177412.82698);

const renderer = new Renderer();
const renderer = new Renderer();

const view = new PlanarView(renderer.domElement, extent, { renderer, noControls: true });
view = new PlanarView(renderer.domElement, extent, { renderer, noControls: true });

// Create a 'fake' tile content for this test purpose
const createTileContent = (tileId) => {
const geometry = new THREE.SphereGeometry(15, 32, 16);
const material = new THREE.MeshBasicMaterial({ color: 0xffff00 });
// Create a 'fake' tile content for this test purpose
createTileContent = (tileId) => {
const geometry = new THREE.SphereGeometry(15, 32, 16);
const material = new THREE.MeshBasicMaterial({ color: 0xffff00 });

// Add _BATCHID geometry attributes
const array = [];
let currentBatchId = Math.round(Math.random() * 50);
for (let index = 0; index < geometry.attributes.position.count; index++) {
array.push(currentBatchId);
// Add _BATCHID geometry attributes
const array = [];
let currentBatchId = Math.round(Math.random() * 50);
for (let index = 0; index < geometry.attributes.position.count; index++) {
array.push(currentBatchId);

// Change randomly batch id
if (Math.random() > 0.5) {
currentBatchId = Math.round(Math.random() * 50);
// Change randomly batch id
if (Math.random() > 0.5) {
currentBatchId = Math.round(Math.random() * 50);
}
}
}
geometry.setAttribute('_BATCHID', new THREE.BufferAttribute(Int32Array.from(array), 1));
geometry.setAttribute('_BATCHID', new THREE.BufferAttribute(Int32Array.from(array), 1));

const result = new THREE.Mesh(geometry, material);
const result = new THREE.Mesh(geometry, material);

result.batchTable = new C3DTBatchTable();
result.tileId = tileId;
result.batchTable = new C3DTBatchTable();
result.tileId = tileId;

return result;
};
return result;
};

after(() => {
stubFetcherJson.restore();
});
});

let $3dTilesLayer;
let source;

const url = 'test/data/unitTest/3dTiles/tileset.json';

it('should instance C3DTilesLayer', function (done) {
source = new C3DTilesSource({
url,
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/' +
'3DTiles/lyon1_with_surface_type_2018/tileset.json',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
});

Expand Down
36 changes: 32 additions & 4 deletions test/unit/entwine.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,41 @@ import Coordinates from 'Core/Geographic/Coordinates';
import EntwinePointTileSource from 'Source/EntwinePointTileSource';
import EntwinePointTileLayer from 'Layer/EntwinePointTileLayer';
import EntwinePointTileNode from 'Core/EntwinePointTileNode';
import sinon from 'sinon';
import Fetcher from 'Provider/Fetcher';
import Renderer from './bootstrap';

import ept from '../data/unitTest/entwine/ept.json';
import eptHierarchy from '../data/unitTest/entwine/ept-hierarchy/0-0-0-0.json';

const urlEpt = 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/entwine/ept.json';
const urlEptHierarchy = 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/entwine/ept-hierarchy/0-0-0-0.json';

const resources = {
[urlEpt]: ept,
[urlEptHierarchy]: eptHierarchy,
};

describe('Entwine Point Tile', function () {
const source = new EntwinePointTileSource({
// url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/entwine',
url: 'test/data/unitTest/entwine',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
let source;
let stubFetcherJson;
let stubFetcherArrayBuf;

before(function () {
stubFetcherJson = sinon.stub(Fetcher, 'json')
.callsFake(url => Promise.resolve(JSON.parse(resources[url])));
stubFetcherArrayBuf = sinon.stub(Fetcher, 'arrayBuffer')
.callsFake(() => Promise.resolve(new ArrayBuffer(8).buffer));

source = new EntwinePointTileSource({
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/entwine',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
});
});

after(function () {
stubFetcherJson.restore();
stubFetcherArrayBuf.restore();
});

it('loads the EPT structure', (done) => {
Expand Down

0 comments on commit 1ddc47f

Please sign in to comment.