mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
Merge pull request #863 from openglobus/memclear
frequently clear memory and pass parameters for that
This commit is contained in:
commit
a529debb5e
@ -55,6 +55,8 @@ export interface IGlobeParams {
|
|||||||
fontsSrc?: string;
|
fontsSrc?: string;
|
||||||
resourcesSrc?: string;
|
resourcesSrc?: string;
|
||||||
atmosphereParameters?: IAtmosphereParams;
|
atmosphereParameters?: IAtmosphereParams;
|
||||||
|
minDistanceBeforeMemClear?: number;
|
||||||
|
vectorTileSize?: number;
|
||||||
gamma?: number;
|
gamma?: number;
|
||||||
exposure?: number;
|
exposure?: number;
|
||||||
}
|
}
|
||||||
@ -252,6 +254,8 @@ class Globe {
|
|||||||
atmosphereEnabled: options.atmosphereEnabled,
|
atmosphereEnabled: options.atmosphereEnabled,
|
||||||
transitionOpacityEnabled: options.transitionOpacityEnabled,
|
transitionOpacityEnabled: options.transitionOpacityEnabled,
|
||||||
atmosphereParameters: options.atmosphereParameters,
|
atmosphereParameters: options.atmosphereParameters,
|
||||||
|
minDistanceBeforeMemClear: options.minDistanceBeforeMemClear,
|
||||||
|
vectorTileSize: options.vectorTileSize,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attach terrain provider (can be one object or array)
|
// Attach terrain provider (can be one object or array)
|
||||||
|
|||||||
@ -64,6 +64,8 @@ export interface IPlanetParams {
|
|||||||
atmosphereEnabled?: boolean;
|
atmosphereEnabled?: boolean;
|
||||||
transitionOpacityEnabled?: boolean;
|
transitionOpacityEnabled?: boolean;
|
||||||
atmosphereParameters?: IAtmosphereParams;
|
atmosphereParameters?: IAtmosphereParams;
|
||||||
|
minDistanceBeforeMemClear?: number;
|
||||||
|
vectorTileSize?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PlanetEventsList = [
|
export type PlanetEventsList = [
|
||||||
@ -399,6 +401,7 @@ export class Planet extends RenderNode {
|
|||||||
protected _transitionOpacityEnabled: boolean;
|
protected _transitionOpacityEnabled: boolean;
|
||||||
|
|
||||||
protected _atmosphere: Atmosphere;
|
protected _atmosphere: Atmosphere;
|
||||||
|
private _minDistanceBeforeMemClear: number = 0;
|
||||||
|
|
||||||
constructor(options: IPlanetParams = {}) {
|
constructor(options: IPlanetParams = {}) {
|
||||||
super(options.name);
|
super(options.name);
|
||||||
@ -515,7 +518,7 @@ export class Planet extends RenderNode {
|
|||||||
|
|
||||||
this._geoImageCreator = new GeoImageCreator(this);
|
this._geoImageCreator = new GeoImageCreator(this);
|
||||||
|
|
||||||
this._vectorTileCreator = new VectorTileCreator(this);
|
this._vectorTileCreator = new VectorTileCreator(this, options.vectorTileSize, options.vectorTileSize);
|
||||||
|
|
||||||
this._normalMapCreator = new NormalMapCreator(this);
|
this._normalMapCreator = new NormalMapCreator(this);
|
||||||
|
|
||||||
@ -1382,7 +1385,7 @@ export class Planet extends RenderNode {
|
|||||||
cam.checkFly();
|
cam.checkFly();
|
||||||
|
|
||||||
// free memory
|
// free memory
|
||||||
if (this._createdNodesCount > MAX_NODES && this._distBeforeMemClear > 1000.0) {
|
if (this._createdNodesCount > MAX_NODES && this._distBeforeMemClear > this._minDistanceBeforeMemClear) {
|
||||||
this.terrain!.clearCache();
|
this.terrain!.clearCache();
|
||||||
this.memClear();
|
this.memClear();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export class VectorTileCreator {
|
|||||||
protected _queue: Material[];
|
protected _queue: Material[];
|
||||||
protected _handler: Handler | null;
|
protected _handler: Handler | null;
|
||||||
|
|
||||||
constructor(planet: Planet, width: number = 512, height: number = 512) {
|
constructor(planet: Planet, width: number = 256, height: number = 256) {
|
||||||
this._width = width;
|
this._width = width;
|
||||||
this._height = height;
|
this._height = height;
|
||||||
this._planet = planet;
|
this._planet = planet;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user