Skip to content

Commit

Permalink
feature(core): doesn't clean depth buffer when needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Jun 21, 2019
1 parent 3ac9394 commit 3a8daf0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
10 changes: 0 additions & 10 deletions src/Core/Prefab/GlobeView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as THREE from 'three';

import View, { VIEW_EVENTS } from 'Core/View';
import { MAIN_LOOP_EVENTS } from 'Core/MainLoop';
import GlobeControls from 'Controls/GlobeControls';

import GlobeLayer from 'Core/Prefab/Globe/GlobeLayer';
Expand Down Expand Up @@ -125,15 +124,6 @@ class GlobeView extends View {
this.controls.handleCollision = typeof (options.handleCollision) !== 'undefined' ? options.handleCollision : true;
}

this._fullSizeDepthBuffer = null;

this.addFrameRequester(MAIN_LOOP_EVENTS.BEFORE_RENDER, () => {
if (this._fullSizeDepthBuffer != null) {
// clean depth buffer
this._fullSizeDepthBuffer = null;
}
});

this.tileLayer = tileLayer;

this.addLayer(new Atmosphere());
Expand Down
9 changes: 0 additions & 9 deletions src/Core/Prefab/PlanarView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as THREE from 'three';

import View from 'Core/View';
import { MAIN_LOOP_EVENTS } from 'Core/MainLoop';
import CameraUtils from 'Utils/CameraUtils';

import PlanarLayer from './Planar/PlanarLayer';
Expand All @@ -28,14 +27,6 @@ class PlanarView extends View {
const p = { coord: extent.center(), range: max, tilt: 20, heading: 0 };
CameraUtils.transformCameraToLookAtTarget(this, camera3D, p);

this._fullSizeDepthBuffer = null;
this.addFrameRequester(MAIN_LOOP_EVENTS.BEFORE_RENDER, () => {
if (this._fullSizeDepthBuffer != null) {
// clean depth buffer
this._fullSizeDepthBuffer = null;
}
});

this.tileLayer = tileLayer;
}

Expand Down
12 changes: 12 additions & 0 deletions src/Core/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ class View extends THREE.EventDispatcher {
};

this.addEventListener(VIEW_EVENTS.LAYERS_INITIALIZED, fn);

this._fullSizeDepthBuffer = null;

this.addFrameRequester(MAIN_LOOP_EVENTS.BEFORE_RENDER, () => {
if (this._fullSizeDepthBuffer != null && this._fullSizeDepthBuffer.needsUpdate) {
// clean depth buffer
this._fullSizeDepthBuffer = null;
}
});
}


Expand Down Expand Up @@ -313,6 +322,9 @@ class View extends THREE.EventDispatcher {
notifyChange(changeSource = undefined, needsRedraw = true) {
if (changeSource) {
this._changeSources.add(changeSource);
if ((changeSource.isTileMesh || changeSource.isCamera) && this._fullSizeDepthBuffer) {
this._fullSizeDepthBuffer.needsUpdate = true;
}
}
this.mainLoop.scheduleViewUpdate(this, needsRedraw);
}
Expand Down

0 comments on commit 3a8daf0

Please sign in to comment.