Skip to content

Commit

Permalink
2 more
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Dec 18, 2023
1 parent 4f66f8e commit 5599b10
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 32 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

0 comments on commit 5599b10

Please sign in to comment.