Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Dec 18, 2018
1 parent 3302245 commit 5f89b26
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 111 deletions.
49 changes: 29 additions & 20 deletions Specs/Scene/ClassificationPrimitiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,8 @@ defineSuite([
var primitive;
var globePrimitive;
var tilesetPrimitive;

beforeAll(function() {
scene = createScene();
scene.postProcessStages.fxaa.enabled = false;

ellipsoid = Ellipsoid.WGS84;
});

afterAll(function() {
scene.destroyForSpecs();
});
var reusableGlobePrimitive;
var reusableTilesetPrimitive;

function viewCenter() {
scene.camera.setView({ destination : rectangle });
Expand All @@ -88,7 +79,7 @@ defineSuite([
scene.camera.setView({ destination : tilesetRectangle });
}

function MockPrimitive(rectangle, pass) {
function createPrimitive(rectangle, pass) {
var renderState;
if (pass === Pass.CESIUM_3D_TILE) {
renderState = RenderState.fromCache({
Expand All @@ -101,7 +92,7 @@ defineSuite([
}
var depthColorAttribute = ColorGeometryInstanceAttribute.fromColor(new Color(0.0, 0.0, 1.0, 1.0));
depthColor = depthColorAttribute.value;
this._primitive = new Primitive({
return new Primitive({
geometryInstances : new GeometryInstance({
geometry : new RectangleGeometry({
ellipsoid : Ellipsoid.WGS84,
Expand All @@ -119,7 +110,10 @@ defineSuite([
}),
asynchronous : false
});
}

function MockPrimitive(primitive, pass) {
this._primitive = primitive;
this._pass = pass;
}

Expand All @@ -139,21 +133,36 @@ defineSuite([
};

MockPrimitive.prototype.destroy = function() {
this._primitive.destroy();
return destroyObject(this);
};

beforeEach(function() {
scene.morphTo3D(0);
scene.render(); // clear any afterRender commands
beforeAll(function() {
scene = createScene();
scene.postProcessStages.fxaa.enabled = false;

ellipsoid = Ellipsoid.WGS84;

rectangle = Rectangle.fromDegrees(-75.0, 25.0, -70.0, 30.0);
globeRectangle = Rectangle.fromDegrees(-75.0, 27.5, -70.0, 30.0);
tilesetRectangle = Rectangle.fromDegrees(-75.0, 25.0, -70.0, 27.5);

reusableGlobePrimitive = createPrimitive(globeRectangle, Pass.GLOBE);
reusableTilesetPrimitive = createPrimitive(tilesetRectangle, Pass.CESIUM_3D_TILE);
});

afterAll(function() {
reusableGlobePrimitive.destroy();
reusableTilesetPrimitive.destroy();
scene.destroyForSpecs();
});

beforeEach(function() {
scene.morphTo3D(0);
scene.render(); // clear any afterRender commands

// wrap rectangle primitive so it gets executed during the globe pass or 3D Tiles pass to lay down depth
globePrimitive = new MockPrimitive(globeRectangle, Pass.GLOBE);
tilesetPrimitive = new MockPrimitive(tilesetRectangle, Pass.CESIUM_3D_TILE);
globePrimitive = new MockPrimitive(reusableGlobePrimitive, Pass.GLOBE);
tilesetPrimitive = new MockPrimitive(reusableTilesetPrimitive, Pass.CESIUM_3D_TILE);

var center = Rectangle.center(rectangle);
var origin = ellipsoid.cartographicToCartesian(center);
Expand Down Expand Up @@ -1046,7 +1055,7 @@ defineSuite([
primitive.appearance = new MaterialAppearance();

expect(function() {
expectRender(boxColor);
expect(scene).toRender(boxColor);
}).toThrowDeveloperError();
});

Expand Down
Loading

0 comments on commit 5f89b26

Please sign in to comment.