forked from BabylonJS/Babylon.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelemetryLoaderPlugin.ts
More file actions
46 lines (37 loc) · 1.72 KB
/
Copy pathtelemetryLoaderPlugin.ts
File metadata and controls
46 lines (37 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { ILoaderPlugin } from "./loaderPlugin";
import { telemetryManager } from "../../managers/telemetryManager";
import { ViewerModel } from "../../model/viewerModel";
import { ISceneLoaderPlugin, ISceneLoaderPluginAsync } from "babylonjs/Loading/sceneLoader";
import { PrecisionDate } from "babylonjs/Misc/precisionDate";
export class TelemetryLoaderPlugin implements ILoaderPlugin {
private _model: ViewerModel;
private _loadStart: number;
private _loadEnd: number;
public onInit(loader: ISceneLoaderPlugin | ISceneLoaderPluginAsync, model: ViewerModel) {
this._model = model;
this._loadStart = PrecisionDate.Now;
}
public onLoaded(model: ViewerModel) {
telemetryManager.broadcast("Model Loaded", model.getViewerId(), {
model: model,
loadTime: PrecisionDate.Now - this._loadStart
});
telemetryManager.flushWebGLErrors(model.rootMesh.getEngine(), model.getViewerId());
}
public onError(message: string, exception: any) {
this._loadEnd = PrecisionDate.Now;
telemetryManager.broadcast("Load Error", this._model.getViewerId(), {
model: this._model,
loadTime: this._loadEnd - this._loadStart
});
telemetryManager.flushWebGLErrors(this._model.rootMesh.getEngine(), this._model.getViewerId());
}
public onComplete() {
this._loadEnd = PrecisionDate.Now;
telemetryManager.broadcast("Load Complete", this._model.getViewerId(), {
model: this._model,
loadTime: this._loadEnd - this._loadStart
});
telemetryManager.flushWebGLErrors(this._model.rootMesh.getEngine(), this._model.getViewerId());
}
}