@babylonjs/viewer 5.0.0-rc.4 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configuration/configuration.d.ts +107 -107
- package/configuration/configuration.js +15 -15
- package/configuration/configuration.js.map +1 -1
- package/configuration/configurationCompatibility.d.ts +8 -8
- package/configuration/configurationCompatibility.js +65 -65
- package/configuration/configurationCompatibility.js.map +1 -1
- package/configuration/configurationContainer.d.ts +10 -10
- package/configuration/configurationContainer.js +9 -9
- package/configuration/configurationContainer.js.map +1 -1
- package/configuration/globals.d.ts +6 -6
- package/configuration/globals.js +17 -17
- package/configuration/globals.js.map +1 -1
- package/configuration/index.d.ts +2 -2
- package/configuration/index.js +3 -2
- package/configuration/index.js.map +1 -1
- package/configuration/interfaces/cameraConfiguration.d.ts +31 -31
- package/configuration/interfaces/cameraConfiguration.js +1 -1
- package/configuration/interfaces/cameraConfiguration.js.map +1 -1
- package/configuration/interfaces/colorGradingConfiguration.d.ts +81 -81
- package/configuration/interfaces/colorGradingConfiguration.js +1 -1
- package/configuration/interfaces/colorGradingConfiguration.js.map +1 -1
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +20 -20
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js +1 -1
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js.map +1 -1
- package/configuration/interfaces/environmentMapConfiguration.d.ts +22 -22
- package/configuration/interfaces/environmentMapConfiguration.js +1 -1
- package/configuration/interfaces/environmentMapConfiguration.js.map +1 -1
- package/configuration/interfaces/groundConfiguration.d.ts +24 -24
- package/configuration/interfaces/groundConfiguration.js +1 -1
- package/configuration/interfaces/groundConfiguration.js.map +1 -1
- package/configuration/interfaces/imageProcessingConfiguration.d.ts +43 -43
- package/configuration/interfaces/imageProcessingConfiguration.js +1 -1
- package/configuration/interfaces/imageProcessingConfiguration.js.map +1 -1
- package/configuration/interfaces/index.d.ts +15 -15
- package/configuration/interfaces/index.js +15 -15
- package/configuration/interfaces/index.js.map +1 -1
- package/configuration/interfaces/lightConfiguration.d.ts +60 -60
- package/configuration/interfaces/lightConfiguration.js +1 -1
- package/configuration/interfaces/lightConfiguration.js.map +1 -1
- package/configuration/interfaces/modelAnimationConfiguration.d.ts +26 -26
- package/configuration/interfaces/modelAnimationConfiguration.js +1 -1
- package/configuration/interfaces/modelAnimationConfiguration.js.map +1 -1
- package/configuration/interfaces/modelConfiguration.d.ts +65 -65
- package/configuration/interfaces/modelConfiguration.js +1 -1
- package/configuration/interfaces/modelConfiguration.js.map +1 -1
- package/configuration/interfaces/observersConfiguration.d.ts +5 -5
- package/configuration/interfaces/observersConfiguration.js +1 -1
- package/configuration/interfaces/observersConfiguration.js.map +1 -1
- package/configuration/interfaces/sceneConfiguration.d.ts +48 -48
- package/configuration/interfaces/sceneConfiguration.js +1 -1
- package/configuration/interfaces/sceneConfiguration.js.map +1 -1
- package/configuration/interfaces/sceneOptimizerConfiguration.d.ts +23 -23
- package/configuration/interfaces/sceneOptimizerConfiguration.js +1 -1
- package/configuration/interfaces/sceneOptimizerConfiguration.js.map +1 -1
- package/configuration/interfaces/skyboxConfiguration.d.ts +21 -21
- package/configuration/interfaces/skyboxConfiguration.js +1 -1
- package/configuration/interfaces/skyboxConfiguration.js.map +1 -1
- package/configuration/interfaces/templateConfiguration.d.ts +67 -67
- package/configuration/interfaces/templateConfiguration.js +1 -1
- package/configuration/interfaces/templateConfiguration.js.map +1 -1
- package/configuration/interfaces/vrConfiguration.d.ts +16 -16
- package/configuration/interfaces/vrConfiguration.js +1 -1
- package/configuration/interfaces/vrConfiguration.js.map +1 -1
- package/configuration/loader.d.ts +4 -4
- package/configuration/loader.js +16 -28
- package/configuration/loader.js.map +1 -1
- package/configuration/mappers.d.ts +42 -42
- package/configuration/mappers.js +190 -189
- package/configuration/mappers.js.map +1 -1
- package/configuration/renderOnlyLoader.d.ts +33 -33
- package/configuration/renderOnlyLoader.js +161 -158
- package/configuration/renderOnlyLoader.js.map +1 -1
- package/configuration/types/default.d.ts +6 -6
- package/configuration/types/default.js +120 -119
- package/configuration/types/default.js.map +1 -1
- package/configuration/types/environmentMap.d.ts +5 -5
- package/configuration/types/environmentMap.js +13 -13
- package/configuration/types/environmentMap.js.map +1 -1
- package/configuration/types/extended.d.ts +6 -6
- package/configuration/types/extended.js +316 -316
- package/configuration/types/extended.js.map +1 -1
- package/configuration/types/index.d.ts +13 -13
- package/configuration/types/index.js +49 -48
- package/configuration/types/index.js.map +1 -1
- package/configuration/types/minimal.d.ts +6 -6
- package/configuration/types/minimal.js +42 -42
- package/configuration/types/minimal.js.map +1 -1
- package/configuration/types/renderOnlyDefault.d.ts +30 -30
- package/configuration/types/renderOnlyDefault.js +30 -30
- package/configuration/types/renderOnlyDefault.js.map +1 -1
- package/configuration/types/shadowLight.d.ts +9 -9
- package/configuration/types/shadowLight.js +63 -63
- package/configuration/types/shadowLight.js.map +1 -1
- package/helper/index.d.ts +26 -26
- package/helper/index.js +62 -56
- package/helper/index.js.map +1 -1
- package/index.d.ts +30 -30
- package/index.js +45 -41
- package/index.js.map +1 -1
- package/initializer.d.ts +11 -11
- package/initializer.js +34 -33
- package/initializer.js.map +1 -1
- package/interfaces.d.ts +5 -5
- package/interfaces.js +1 -1
- package/interfaces.js.map +1 -1
- package/labs/environmentSerializer.d.ts +126 -126
- package/labs/environmentSerializer.js +190 -186
- package/labs/environmentSerializer.js.map +1 -1
- package/labs/texture.d.ts +183 -184
- package/labs/texture.js +300 -297
- package/labs/texture.js.map +1 -1
- package/labs/viewerLabs.d.ts +51 -51
- package/labs/viewerLabs.js +133 -131
- package/labs/viewerLabs.js.map +1 -1
- package/license.md +71 -0
- package/loader/modelLoader.d.ts +47 -44
- package/loader/modelLoader.js +189 -182
- package/loader/modelLoader.js.map +1 -1
- package/loader/plugins/applyMaterialConfig.d.ts +12 -12
- package/loader/plugins/applyMaterialConfig.js +15 -15
- package/loader/plugins/applyMaterialConfig.js.map +1 -1
- package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +9 -9
- package/loader/plugins/extendedMaterialLoaderPlugin.js +15 -15
- package/loader/plugins/extendedMaterialLoaderPlugin.js.map +1 -1
- package/loader/plugins/index.d.ts +18 -17
- package/loader/plugins/index.js +42 -41
- package/loader/plugins/index.js.map +1 -1
- package/loader/plugins/loaderPlugin.d.ts +24 -24
- package/loader/plugins/loaderPlugin.js +1 -1
- package/loader/plugins/loaderPlugin.js.map +1 -1
- package/loader/plugins/msftLodLoaderPlugin.d.ts +12 -12
- package/loader/plugins/msftLodLoaderPlugin.js +20 -19
- package/loader/plugins/msftLodLoaderPlugin.js.map +1 -1
- package/loader/plugins/telemetryLoaderPlugin.d.ts +12 -12
- package/loader/plugins/telemetryLoaderPlugin.js +35 -35
- package/loader/plugins/telemetryLoaderPlugin.js.map +1 -1
- package/managers/observablesManager.d.ts +66 -66
- package/managers/observablesManager.js +34 -34
- package/managers/observablesManager.js.map +1 -1
- package/managers/sceneManager.d.ts +243 -245
- package/managers/sceneManager.js +1388 -1387
- package/managers/sceneManager.js.map +1 -1
- package/managers/telemetryManager.d.ts +57 -57
- package/managers/telemetryManager.js +113 -113
- package/managers/telemetryManager.js.map +1 -1
- package/model/modelAnimation.d.ts +215 -215
- package/model/modelAnimation.js +232 -232
- package/model/modelAnimation.js.map +1 -1
- package/model/viewerModel.d.ts +228 -236
- package/model/viewerModel.js +669 -664
- package/model/viewerModel.js.map +1 -1
- package/optimizer/custom/extended.d.ts +11 -13
- package/optimizer/custom/extended.js +98 -100
- package/optimizer/custom/extended.js.map +1 -1
- package/optimizer/custom/index.d.ts +8 -8
- package/optimizer/custom/index.js +24 -24
- package/optimizer/custom/index.js.map +1 -1
- package/package.json +41 -215
- package/readme.md +12 -8
- package/renderOnlyIndex.d.ts +11 -11
- package/renderOnlyIndex.js +17 -15
- package/renderOnlyIndex.js.map +1 -1
- package/templating/eventManager.d.ts +35 -35
- package/templating/eventManager.js +65 -63
- package/templating/eventManager.js.map +1 -1
- package/templating/plugins/hdButtonPlugin.d.ts +9 -9
- package/templating/plugins/hdButtonPlugin.js +21 -34
- package/templating/plugins/hdButtonPlugin.js.map +1 -1
- package/templating/plugins/printButton.d.ts +9 -10
- package/templating/plugins/printButton.js +40 -53
- package/templating/plugins/printButton.js.map +1 -1
- package/templating/templateManager.d.ts +190 -189
- package/templating/templateManager.js +553 -543
- package/templating/templateManager.js.map +1 -1
- package/templating/viewerTemplatePlugin.d.ts +21 -21
- package/templating/viewerTemplatePlugin.js +68 -68
- package/templating/viewerTemplatePlugin.js.map +1 -1
- package/viewer/defaultViewer.d.ts +122 -116
- package/viewer/defaultViewer.js +665 -670
- package/viewer/defaultViewer.js.map +1 -1
- package/viewer/renderOnlyViewer.d.ts +8 -8
- package/viewer/renderOnlyViewer.js +43 -50
- package/viewer/renderOnlyViewer.js.map +1 -1
- package/viewer/viewer.d.ts +254 -253
- package/viewer/viewer.js +777 -763
- package/viewer/viewer.js.map +1 -1
- package/viewer/viewerManager.d.ts +55 -55
- package/viewer/viewerManager.js +87 -86
- package/viewer/viewerManager.js.map +1 -1
- package/viewer/viewerWithTemplate.d.ts +9 -9
- package/viewer/viewerWithTemplate.js +19 -32
- package/viewer/viewerWithTemplate.js.map +1 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { Observable } from "@babylonjs/core/Misc/observable";
|
|
2
|
-
import { Engine } from "@babylonjs/core/Engines/engine";
|
|
3
|
-
/**
|
|
4
|
-
* The data structure of a telemetry event.
|
|
5
|
-
*/
|
|
6
|
-
export interface TelemetryData {
|
|
7
|
-
event: string;
|
|
8
|
-
session: string;
|
|
9
|
-
date: Date;
|
|
10
|
-
now: number;
|
|
11
|
-
viewerId?: string;
|
|
12
|
-
detail: any;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Receives Telemetry events and raises events to the API
|
|
16
|
-
*/
|
|
17
|
-
export declare class TelemetryManager {
|
|
18
|
-
onEventBroadcastedObservable: Observable<TelemetryData>;
|
|
19
|
-
private _currentSessionId;
|
|
20
|
-
private _event;
|
|
21
|
-
/**
|
|
22
|
-
* Receives a telemetry event
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param details An additional value, or an object containing a list of property/value pairs
|
|
45
|
-
*/
|
|
46
|
-
private _eventEnabled;
|
|
47
|
-
/**
|
|
48
|
-
* Returns the current session ID or creates one if it doesn't
|
|
49
|
-
* @return The current session ID
|
|
50
|
-
*/
|
|
51
|
-
get session(): string;
|
|
52
|
-
/**
|
|
53
|
-
* Disposes the telemetry manager
|
|
54
|
-
*/
|
|
55
|
-
dispose(): void;
|
|
56
|
-
}
|
|
57
|
-
export declare const telemetryManager: TelemetryManager;
|
|
1
|
+
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
2
|
+
import type { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
3
|
+
/**
|
|
4
|
+
* The data structure of a telemetry event.
|
|
5
|
+
*/
|
|
6
|
+
export interface TelemetryData {
|
|
7
|
+
event: string;
|
|
8
|
+
session: string;
|
|
9
|
+
date: Date;
|
|
10
|
+
now: number;
|
|
11
|
+
viewerId?: string;
|
|
12
|
+
detail: any;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Receives Telemetry events and raises events to the API
|
|
16
|
+
*/
|
|
17
|
+
export declare class TelemetryManager {
|
|
18
|
+
onEventBroadcastedObservable: Observable<TelemetryData>;
|
|
19
|
+
private _currentSessionId;
|
|
20
|
+
private _event;
|
|
21
|
+
/**
|
|
22
|
+
* Receives a telemetry event
|
|
23
|
+
*/
|
|
24
|
+
get broadcast(): (event: string, viewerId?: string | undefined, details?: any) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Log a Telemetry event for errors raised on the WebGL context.
|
|
27
|
+
* @param engine The Babylon engine with the WebGL context.
|
|
28
|
+
* @param viewerId
|
|
29
|
+
*/
|
|
30
|
+
flushWebGLErrors(engine: Engine, viewerId?: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Enable or disable telemetry events
|
|
33
|
+
* @param enabled Boolean, true if events are enabled
|
|
34
|
+
*/
|
|
35
|
+
set enable(enabled: boolean);
|
|
36
|
+
/**
|
|
37
|
+
* Called on event when disabled, typically do nothing here
|
|
38
|
+
*/
|
|
39
|
+
private _eventDisabled;
|
|
40
|
+
/**
|
|
41
|
+
* Called on event when enabled
|
|
42
|
+
* @param event - The name of the Telemetry event
|
|
43
|
+
* @param viewerId
|
|
44
|
+
* @param details An additional value, or an object containing a list of property/value pairs
|
|
45
|
+
*/
|
|
46
|
+
private _eventEnabled;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the current session ID or creates one if it doesn't exist
|
|
49
|
+
* @return The current session ID
|
|
50
|
+
*/
|
|
51
|
+
get session(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Disposes the telemetry manager
|
|
54
|
+
*/
|
|
55
|
+
dispose(): void;
|
|
56
|
+
}
|
|
57
|
+
export declare const telemetryManager: TelemetryManager;
|
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
2
|
-
/**
|
|
3
|
-
* Receives Telemetry events and raises events to the API
|
|
4
|
-
*/
|
|
5
|
-
var TelemetryManager = /** @class */ (function () {
|
|
6
|
-
function TelemetryManager() {
|
|
7
|
-
this.onEventBroadcastedObservable = new Observable();
|
|
8
|
-
this._event = this._eventEnabled;
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(TelemetryManager.prototype, "broadcast", {
|
|
11
|
-
/**
|
|
12
|
-
* Receives a telemetry event
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
* @param
|
|
66
|
-
* @param details An additional value, or an object containing a list of property/value pairs
|
|
67
|
-
*/
|
|
68
|
-
TelemetryManager.prototype._eventEnabled = function (event, viewerId, details) {
|
|
69
|
-
var telemetryData = {
|
|
70
|
-
viewerId: viewerId,
|
|
71
|
-
event: event,
|
|
72
|
-
session: this.session,
|
|
73
|
-
date: new Date(),
|
|
74
|
-
now: window.performance ? window.performance.now() : Date.now(),
|
|
75
|
-
detail: null
|
|
76
|
-
};
|
|
77
|
-
if (typeof details === "object") {
|
|
78
|
-
for (var attr in details) {
|
|
79
|
-
if (
|
|
80
|
-
telemetryData[attr] = details[attr];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else if (details) {
|
|
85
|
-
telemetryData.detail = details;
|
|
86
|
-
}
|
|
87
|
-
this.onEventBroadcastedObservable.notifyObservers(telemetryData);
|
|
88
|
-
};
|
|
89
|
-
Object.defineProperty(TelemetryManager.prototype, "session", {
|
|
90
|
-
/**
|
|
91
|
-
* Returns the current session ID or creates one if it doesn't
|
|
92
|
-
* @return The current session ID
|
|
93
|
-
*/
|
|
94
|
-
get: function () {
|
|
95
|
-
if (!this._currentSessionId) {
|
|
96
|
-
//String + Timestamp + Random Integer
|
|
97
|
-
this._currentSessionId = "SESSION_" + Date.now() + Math.floor(Math.random() * 0x10000);
|
|
98
|
-
}
|
|
99
|
-
return this._currentSessionId;
|
|
100
|
-
},
|
|
101
|
-
enumerable: false,
|
|
102
|
-
configurable: true
|
|
103
|
-
});
|
|
104
|
-
/**
|
|
105
|
-
* Disposes the telemetry manager
|
|
106
|
-
*/
|
|
107
|
-
TelemetryManager.prototype.dispose = function () {
|
|
108
|
-
this.onEventBroadcastedObservable.clear();
|
|
109
|
-
};
|
|
110
|
-
return TelemetryManager;
|
|
111
|
-
}());
|
|
112
|
-
export { TelemetryManager };
|
|
113
|
-
export var telemetryManager = new TelemetryManager();
|
|
1
|
+
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
2
|
+
/**
|
|
3
|
+
* Receives Telemetry events and raises events to the API
|
|
4
|
+
*/
|
|
5
|
+
var TelemetryManager = /** @class */ (function () {
|
|
6
|
+
function TelemetryManager() {
|
|
7
|
+
this.onEventBroadcastedObservable = new Observable();
|
|
8
|
+
this._event = this._eventEnabled;
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(TelemetryManager.prototype, "broadcast", {
|
|
11
|
+
/**
|
|
12
|
+
* Receives a telemetry event
|
|
13
|
+
*/
|
|
14
|
+
get: function () {
|
|
15
|
+
return this._event;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Log a Telemetry event for errors raised on the WebGL context.
|
|
22
|
+
* @param engine The Babylon engine with the WebGL context.
|
|
23
|
+
* @param viewerId
|
|
24
|
+
*/
|
|
25
|
+
TelemetryManager.prototype.flushWebGLErrors = function (engine, viewerId) {
|
|
26
|
+
if (!engine) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var logErrors = true;
|
|
30
|
+
while (logErrors) {
|
|
31
|
+
var error = engine.getError();
|
|
32
|
+
if (error === 0) {
|
|
33
|
+
logErrors = false;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.broadcast("WebGL Error", viewerId, { error: error });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(TelemetryManager.prototype, "enable", {
|
|
41
|
+
/**
|
|
42
|
+
* Enable or disable telemetry events
|
|
43
|
+
* @param enabled Boolean, true if events are enabled
|
|
44
|
+
*/
|
|
45
|
+
set: function (enabled) {
|
|
46
|
+
if (enabled) {
|
|
47
|
+
this._event = this._eventEnabled;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this._event = this._eventDisabled;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
enumerable: false,
|
|
54
|
+
configurable: true
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Called on event when disabled, typically do nothing here
|
|
58
|
+
*/
|
|
59
|
+
TelemetryManager.prototype._eventDisabled = function () {
|
|
60
|
+
// nothing to do
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Called on event when enabled
|
|
64
|
+
* @param event - The name of the Telemetry event
|
|
65
|
+
* @param viewerId
|
|
66
|
+
* @param details An additional value, or an object containing a list of property/value pairs
|
|
67
|
+
*/
|
|
68
|
+
TelemetryManager.prototype._eventEnabled = function (event, viewerId, details) {
|
|
69
|
+
var telemetryData = {
|
|
70
|
+
viewerId: viewerId,
|
|
71
|
+
event: event,
|
|
72
|
+
session: this.session,
|
|
73
|
+
date: new Date(),
|
|
74
|
+
now: window.performance ? window.performance.now() : Date.now(),
|
|
75
|
+
detail: null,
|
|
76
|
+
};
|
|
77
|
+
if (typeof details === "object") {
|
|
78
|
+
for (var attr in details) {
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(details, attr)) {
|
|
80
|
+
telemetryData[attr] = details[attr];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (details) {
|
|
85
|
+
telemetryData.detail = details;
|
|
86
|
+
}
|
|
87
|
+
this.onEventBroadcastedObservable.notifyObservers(telemetryData);
|
|
88
|
+
};
|
|
89
|
+
Object.defineProperty(TelemetryManager.prototype, "session", {
|
|
90
|
+
/**
|
|
91
|
+
* Returns the current session ID or creates one if it doesn't exist
|
|
92
|
+
* @return The current session ID
|
|
93
|
+
*/
|
|
94
|
+
get: function () {
|
|
95
|
+
if (!this._currentSessionId) {
|
|
96
|
+
//String + Timestamp + Random Integer
|
|
97
|
+
this._currentSessionId = "SESSION_" + Date.now() + Math.floor(Math.random() * 0x10000);
|
|
98
|
+
}
|
|
99
|
+
return this._currentSessionId;
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Disposes the telemetry manager
|
|
106
|
+
*/
|
|
107
|
+
TelemetryManager.prototype.dispose = function () {
|
|
108
|
+
this.onEventBroadcastedObservable.clear();
|
|
109
|
+
};
|
|
110
|
+
return TelemetryManager;
|
|
111
|
+
}());
|
|
112
|
+
export { TelemetryManager };
|
|
113
|
+
export var telemetryManager = new TelemetryManager();
|
|
114
114
|
//# sourceMappingURL=telemetryManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetryManager.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"telemetryManager.js","sourceRoot":"","sources":["../../../../../tools/viewer/src/managers/telemetryManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAelD;;GAEG;AACH;IAAA;QACW,iCAA4B,GAA8B,IAAI,UAAU,EAAE,CAAC;QAI1E,WAAM,GAA8D,IAAI,CAAC,aAAa,CAAC;IAgGnG,CAAC;IA3FG,sBAAW,uCAAS;QAHpB;;WAEG;aACH;YACI,OAAO,IAAI,CAAC,MAAM,CAAC;QACvB,CAAC;;;OAAA;IAED;;;;OAIG;IACI,2CAAgB,GAAvB,UAAwB,MAAc,EAAE,QAAiB;QACrD,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QACD,IAAI,SAAS,GAAG,IAAI,CAAC;QAErB,OAAO,SAAS,EAAE;YACd,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;YAChC,IAAI,KAAK,KAAK,CAAC,EAAE;gBACb,SAAS,GAAG,KAAK,CAAC;aACrB;iBAAM;gBACH,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;aAC7D;SACJ;IACL,CAAC;IAMD,sBAAW,oCAAM;QAJjB;;;WAGG;aACH,UAAkB,OAAgB;YAC9B,IAAI,OAAO,EAAE;gBACT,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;aACpC;iBAAM;gBACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC;aACrC;QACL,CAAC;;;OAAA;IAED;;OAEG;IACK,yCAAc,GAAtB;QACI,gBAAgB;IACpB,CAAC;IAED;;;;;OAKG;IACK,wCAAa,GAArB,UAAsB,KAAa,EAAE,QAAiB,EAAE,OAAa;QACjE,IAAM,aAAa,GAAkB;YACjC,QAAQ,UAAA;YACR,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,IAAI,EAAE;YAChB,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC/D,MAAM,EAAE,IAAI;SACf,CAAC;QAEF,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC7B,KAAK,IAAM,IAAI,IAAI,OAAO,EAAE;gBACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;oBACpD,aAAqB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;iBAChD;aACJ;SACJ;aAAM,IAAI,OAAO,EAAE;YAChB,aAAa,CAAC,MAAM,GAAG,OAAO,CAAC;SAClC;QAED,IAAI,CAAC,4BAA4B,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IACrE,CAAC;IAMD,sBAAW,qCAAO;QAJlB;;;WAGG;aACH;YACI,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;gBACzB,qCAAqC;gBACrC,IAAI,CAAC,iBAAiB,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;aAC1F;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAClC,CAAC;;;OAAA;IAED;;OAEG;IACI,kCAAO,GAAd;QACI,IAAI,CAAC,4BAA4B,CAAC,KAAK,EAAE,CAAC;IAC9C,CAAC;IACL,uBAAC;AAAD,CAAC,AArGD,IAqGC;;AAED,MAAM,CAAC,IAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\n\r\n/**\r\n * The data structure of a telemetry event.\r\n */\r\nexport interface TelemetryData {\r\n event: string;\r\n session: string;\r\n date: Date;\r\n now: number;\r\n viewerId?: string;\r\n detail: any;\r\n}\r\n\r\n/**\r\n * Receives Telemetry events and raises events to the API\r\n */\r\nexport class TelemetryManager {\r\n public onEventBroadcastedObservable: Observable<TelemetryData> = new Observable();\r\n\r\n private _currentSessionId: string;\r\n\r\n private _event: (event: string, viewerId?: string, details?: any) => void = this._eventEnabled;\r\n\r\n /**\r\n * Receives a telemetry event\r\n */\r\n public get broadcast() {\r\n return this._event;\r\n }\r\n\r\n /**\r\n * Log a Telemetry event for errors raised on the WebGL context.\r\n * @param engine The Babylon engine with the WebGL context.\r\n * @param viewerId\r\n */\r\n public flushWebGLErrors(engine: Engine, viewerId?: string) {\r\n if (!engine) {\r\n return;\r\n }\r\n let logErrors = true;\r\n\r\n while (logErrors) {\r\n const error = engine.getError();\r\n if (error === 0) {\r\n logErrors = false;\r\n } else {\r\n this.broadcast(\"WebGL Error\", viewerId, { error: error });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Enable or disable telemetry events\r\n * @param enabled Boolean, true if events are enabled\r\n */\r\n public set enable(enabled: boolean) {\r\n if (enabled) {\r\n this._event = this._eventEnabled;\r\n } else {\r\n this._event = this._eventDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Called on event when disabled, typically do nothing here\r\n */\r\n private _eventDisabled(): void {\r\n // nothing to do\r\n }\r\n\r\n /**\r\n * Called on event when enabled\r\n * @param event - The name of the Telemetry event\r\n * @param viewerId\r\n * @param details An additional value, or an object containing a list of property/value pairs\r\n */\r\n private _eventEnabled(event: string, viewerId?: string, details?: any): void {\r\n const telemetryData: TelemetryData = {\r\n viewerId,\r\n event: event,\r\n session: this.session,\r\n date: new Date(),\r\n now: window.performance ? window.performance.now() : Date.now(),\r\n detail: null,\r\n };\r\n\r\n if (typeof details === \"object\") {\r\n for (const attr in details) {\r\n if (Object.prototype.hasOwnProperty.call(details, attr)) {\r\n (telemetryData as any)[attr] = details[attr];\r\n }\r\n }\r\n } else if (details) {\r\n telemetryData.detail = details;\r\n }\r\n\r\n this.onEventBroadcastedObservable.notifyObservers(telemetryData);\r\n }\r\n\r\n /**\r\n * Returns the current session ID or creates one if it doesn't exist\r\n * @return The current session ID\r\n */\r\n public get session(): string {\r\n if (!this._currentSessionId) {\r\n //String + Timestamp + Random Integer\r\n this._currentSessionId = \"SESSION_\" + Date.now() + Math.floor(Math.random() * 0x10000);\r\n }\r\n return this._currentSessionId;\r\n }\r\n\r\n /**\r\n * Disposes the telemetry manager\r\n */\r\n public dispose() {\r\n this.onEventBroadcastedObservable.clear();\r\n }\r\n}\r\n\r\nexport const telemetryManager = new TelemetryManager();\r\n"]}
|