@combeenation/3d-viewer 13.0.1 → 14.0.0
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/dist/lib-cjs/buildinfo.json +1 -1
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/dist/lib-cjs/index.d.ts +0 -1
- package/dist/lib-cjs/index.js +0 -1
- package/dist/lib-cjs/index.js.map +1 -1
- package/dist/lib-cjs/manager/camera-manager.d.ts +60 -1
- package/dist/lib-cjs/manager/camera-manager.js +62 -9
- package/dist/lib-cjs/manager/camera-manager.js.map +1 -1
- package/dist/lib-cjs/viewer.d.ts +1 -3
- package/dist/lib-cjs/viewer.js +0 -4
- package/dist/lib-cjs/viewer.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/manager/camera-manager.ts +140 -11
- package/src/viewer.ts +0 -6
- package/dist/lib-cjs/manager/screenshot-manager.d.ts +0 -36
- package/dist/lib-cjs/manager/screenshot-manager.js +0 -40
- package/dist/lib-cjs/manager/screenshot-manager.js.map +0 -1
- package/src/manager/screenshot-manager.ts +0 -59
package/dist/lib-cjs/index.d.ts
CHANGED
|
@@ -59,5 +59,4 @@ export * from './manager/material-manager';
|
|
|
59
59
|
export * from './manager/model-manager';
|
|
60
60
|
export * from './manager/parameter-manager';
|
|
61
61
|
export * from './manager/scene-manager';
|
|
62
|
-
export * from './manager/screenshot-manager';
|
|
63
62
|
export * from './manager/texture-manager';
|
package/dist/lib-cjs/index.js
CHANGED
|
@@ -91,6 +91,5 @@ __exportStar(require("./manager/material-manager"), exports);
|
|
|
91
91
|
__exportStar(require("./manager/model-manager"), exports);
|
|
92
92
|
__exportStar(require("./manager/parameter-manager"), exports);
|
|
93
93
|
__exportStar(require("./manager/scene-manager"), exports);
|
|
94
|
-
__exportStar(require("./manager/screenshot-manager"), exports);
|
|
95
94
|
__exportStar(require("./manager/texture-manager"), exports);
|
|
96
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,wBAAwB;AACxB,6EAA2E;AAC3E,0EAAwE;AACxE,oEAAkE;AAClE,sFAAoF;AACpF,sEAAoE;AACpE,yEAAuE;AACvE,6EAA2E;AAC3E,6EAA2E;AAC3E,sEAAoE;AACpE,yEAAuE;AACvE,qEAAmE;AACnE,wEAAsE;AACtE,4EAA0E;AAE1E,qBAAqB;AACrB,2DAA2D;AAC3D,wHAAwH;AACxH,+CAA+C;AAC/C,yGAAyG;AACzG,iEAAiE;AACjE,gEAA8C;AAC9C,6DAA2C;AAC3C,iEAA+C;AAC/C,0DAAwC;AACxC,0EAAwD;AACxD,iEAA+C;AAC/C,0DAAwC;AACxC,mEAAiD;AACjD,mEAAiD;AACjD,iEAA+C;AAC/C,qEAAmD;AACnD,yDAAuC;AACvC,0DAAwC;AACxC,qEAAmD;AACnD,gEAA8C;AAC9C,6EAA2D;AAC3D,qEAAmD;AACnD,wDAAsC;AACtC,sEAAoD;AACpD,kEAAgD;AAChD,uEAAqD;AACrD,8DAA4C;AAC5C,qEAAmD;AACnD,uEAAqD;AACrD,iFAA+D;AAC/D,uEAAqD;AACrD,wDAAsC;AACtC,uDAAqC;AACrC,iFAA+D;AAC/D,wDAAsC;AACtC,wDAAsC;AACtC,yEAAuD;AACvD,iFAA+D;AAE/D,gCAAgC;AAChC,sHAAsH;AACtH,UAAU;AACV,2DAA2D;AAC3D,6DAA2C;AAC3C,qCAAqC;AACrC,uEAAqD;AACrD,sDAAsD;AACtD,uEAAqD;AACrD,gDAAgD;AAChD,iEAA+C;AAE/C,iBAAiB;AACjB,qFAAqF;AACrF,2CAAyB;AACzB,iDAA+B;AAC/B,2DAAyC;AACzC,0DAAwC;AACxC,0DAAwC;AACxC,gEAA8C;AAC9C,6DAA2C;AAC3C,0DAAwC;AACxC,8DAA4C;AAC5C,0DAAwC;AACxC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,wBAAwB;AACxB,6EAA2E;AAC3E,0EAAwE;AACxE,oEAAkE;AAClE,sFAAoF;AACpF,sEAAoE;AACpE,yEAAuE;AACvE,6EAA2E;AAC3E,6EAA2E;AAC3E,sEAAoE;AACpE,yEAAuE;AACvE,qEAAmE;AACnE,wEAAsE;AACtE,4EAA0E;AAE1E,qBAAqB;AACrB,2DAA2D;AAC3D,wHAAwH;AACxH,+CAA+C;AAC/C,yGAAyG;AACzG,iEAAiE;AACjE,gEAA8C;AAC9C,6DAA2C;AAC3C,iEAA+C;AAC/C,0DAAwC;AACxC,0EAAwD;AACxD,iEAA+C;AAC/C,0DAAwC;AACxC,mEAAiD;AACjD,mEAAiD;AACjD,iEAA+C;AAC/C,qEAAmD;AACnD,yDAAuC;AACvC,0DAAwC;AACxC,qEAAmD;AACnD,gEAA8C;AAC9C,6EAA2D;AAC3D,qEAAmD;AACnD,wDAAsC;AACtC,sEAAoD;AACpD,kEAAgD;AAChD,uEAAqD;AACrD,8DAA4C;AAC5C,qEAAmD;AACnD,uEAAqD;AACrD,iFAA+D;AAC/D,uEAAqD;AACrD,wDAAsC;AACtC,uDAAqC;AACrC,iFAA+D;AAC/D,wDAAsC;AACtC,wDAAsC;AACtC,yEAAuD;AACvD,iFAA+D;AAE/D,gCAAgC;AAChC,sHAAsH;AACtH,UAAU;AACV,2DAA2D;AAC3D,6DAA2C;AAC3C,qCAAqC;AACrC,uEAAqD;AACrD,sDAAsD;AACtD,uEAAqD;AACrD,gDAAgD;AAChD,iEAA+C;AAE/C,iBAAiB;AACjB,qFAAqF;AACrF,2CAAyB;AACzB,iDAA+B;AAC/B,2DAAyC;AACzC,0DAAwC;AACxC,0DAAwC;AACxC,gEAA8C;AAC9C,6DAA2C;AAC3C,0DAAwC;AACxC,8DAA4C;AAC5C,0DAAwC;AACxC,4DAA0C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimationGroup, ArcRotateCamera, ExcludedGeometryList, Vector3, Viewer } from '../index';
|
|
1
|
+
import { AnimationGroup, ArcRotateCamera, BoundingSphere, ExcludedGeometryList, Vector3, Viewer } from '../index';
|
|
2
2
|
export declare type CameraPosition = {
|
|
3
3
|
alpha: number;
|
|
4
4
|
beta: number;
|
|
@@ -19,6 +19,58 @@ export declare type AutofocusSettings = {
|
|
|
19
19
|
exclude?: ExcludedGeometryList;
|
|
20
20
|
durationMs?: number;
|
|
21
21
|
};
|
|
22
|
+
export declare type ScreenshotSettings = {
|
|
23
|
+
/** Width of the final screenshot image, defaults to canvas width */
|
|
24
|
+
width?: number;
|
|
25
|
+
/** Height of the final screenshot image, defaults to canvas height */
|
|
26
|
+
height?: number;
|
|
27
|
+
/** Camera alpha angle used for the screenshot, defaults to alpha angle of currently active camera */
|
|
28
|
+
alpha?: number;
|
|
29
|
+
/** Camera beta angle used for the screenshot, defaults to beta angle of currently active camera */
|
|
30
|
+
beta?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Camera radius used for the screenshot, default value depends on `autofocusScene` flag:
|
|
33
|
+
* - `true`: radius is calculated automatically so that the whole current scene content is visible
|
|
34
|
+
* - `false`: radius of currently active camera is used
|
|
35
|
+
*/
|
|
36
|
+
radius?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Camera target used for the screenshot, default value depends on `autofocusScene` flag:
|
|
39
|
+
* - `true`: center of the current scene content is set as camera target
|
|
40
|
+
* - `false`: target of currently active camera is used
|
|
41
|
+
*/
|
|
42
|
+
target?: Vector3;
|
|
43
|
+
/** Used to scale the calculated radius if `radius` property is not set and `autofocusScene` mode is active */
|
|
44
|
+
radiusFactor?: number;
|
|
45
|
+
/** Can be used to automatically calculate camera `radius` and `target`, if these 2 settings are not defined
|
|
46
|
+
* explicitely */
|
|
47
|
+
autofocusScene?: boolean;
|
|
48
|
+
/** Optional list of geometry to be excluded from consideration */
|
|
49
|
+
exclude?: ExcludedGeometryList;
|
|
50
|
+
/**
|
|
51
|
+
* "MIME type" of the returned screenshot image, defaults to `image/png`
|
|
52
|
+
*
|
|
53
|
+
* **Info regarding JPEG:** \
|
|
54
|
+
* Use mimeType `image/jpeg` (**not** `image/jpg`) when creating jpeg's. \
|
|
55
|
+
* Also ensure that the viewer scenes `clearColor` has an alpha value of `1` as jpeg's don't
|
|
56
|
+
* support transparency. Otherwise background will always be black for jpeg's.
|
|
57
|
+
*/
|
|
58
|
+
mimeType?: string;
|
|
59
|
+
/** If file name is given, the screenshot image will be downloaded and the base64 string will NOT be returned! */
|
|
60
|
+
fileName?: string;
|
|
61
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
62
|
+
samples?: number;
|
|
63
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
64
|
+
antialiasing?: boolean;
|
|
65
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
66
|
+
renderSprites?: boolean;
|
|
67
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
68
|
+
enableStencilBuffer?: boolean;
|
|
69
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
70
|
+
useLayerMask?: boolean;
|
|
71
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
72
|
+
quality?: number;
|
|
73
|
+
};
|
|
22
74
|
/**
|
|
23
75
|
* Manager for camera related tasks
|
|
24
76
|
*/
|
|
@@ -35,6 +87,7 @@ export declare class CameraManager {
|
|
|
35
87
|
};
|
|
36
88
|
protected static readonly _DEFAULT_AUTOFOCUS_RADIUS_FACTOR = 1;
|
|
37
89
|
protected static readonly _DEFAULT_CAM_SPEED_MS = 250;
|
|
90
|
+
protected static readonly _SCREENSHOT_CAMERA_NAME = "__screenshotCamera__";
|
|
38
91
|
/** @internal */
|
|
39
92
|
constructor(viewer: Viewer);
|
|
40
93
|
/**
|
|
@@ -47,5 +100,11 @@ export declare class CameraManager {
|
|
|
47
100
|
* @param durationMs defaults to 250ms if unset, use 0 for instant movement
|
|
48
101
|
*/
|
|
49
102
|
moveActiveCameraTo(position: CameraPosition, durationMs?: number): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Takes a sceenshot the the current scene.\
|
|
105
|
+
* The result is a string containing a base64 encoded image.
|
|
106
|
+
*/
|
|
107
|
+
createScreenshot(settings?: ScreenshotSettings): Promise<string>;
|
|
50
108
|
protected static _addCameraAnimationToGroup(targetProperty: string, from: number | Vector3, to: number | Vector3, framesPerSec: number, dataType: number, animationGroup: AnimationGroup, activeCamera: ArcRotateCamera): void;
|
|
109
|
+
protected _getAutofocusZoomingDistance(boundingSphere: BoundingSphere, camera: ArcRotateCamera): number;
|
|
51
110
|
}
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CameraManager = void 0;
|
|
13
13
|
const index_1 = require("../index");
|
|
14
|
+
const geometry_helper_1 = require("../internal/geometry-helper");
|
|
14
15
|
/**
|
|
15
16
|
* Manager for camera related tasks
|
|
16
17
|
*/
|
|
@@ -33,6 +34,7 @@ class CameraManager {
|
|
|
33
34
|
const boundingInfo = this.viewer.calculateBoundingInfo(settings === null || settings === void 0 ? void 0 : settings.exclude);
|
|
34
35
|
// optionally show bounding sphere for debugging purpose
|
|
35
36
|
this.viewer.eventManager.fireEvent(index_1.ViewerEvent.AutofocusStart, boundingInfo.boundingSphere);
|
|
37
|
+
const distance = this._getAutofocusZoomingDistance(boundingInfo.boundingSphere, activeCamera);
|
|
36
38
|
const radius = boundingInfo.boundingSphere.radius;
|
|
37
39
|
const center = boundingInfo.boundingSphere.center;
|
|
38
40
|
// set lower radius limit on edge of bounding sphere to make sure that we can't dive into the meshes
|
|
@@ -52,15 +54,6 @@ class CameraManager {
|
|
|
52
54
|
const radiusFactor = (_a = settings === null || settings === void 0 ? void 0 : settings.radiusFactor) !== null && _a !== void 0 ? _a : CameraManager._DEFAULT_AUTOFOCUS_RADIUS_FACTOR;
|
|
53
55
|
const alpha = (_b = settings === null || settings === void 0 ? void 0 : settings.alpha) !== null && _b !== void 0 ? _b : CameraManager.DEFAULT_CAMERA_POSITION.alpha;
|
|
54
56
|
const beta = (_c = settings === null || settings === void 0 ? void 0 : settings.beta) !== null && _c !== void 0 ? _c : CameraManager.DEFAULT_CAMERA_POSITION.beta;
|
|
55
|
-
// calculation is taken from Babylon.js repository, which on their side took it from this SO post:
|
|
56
|
-
// http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene
|
|
57
|
-
// there's a good sketch which explains the calculation quite a bit
|
|
58
|
-
const aspectRatio = this.viewer.engine.getAspectRatio(activeCamera);
|
|
59
|
-
const frustumSlopeY = Math.tan(activeCamera.fov / 2);
|
|
60
|
-
const frustumSlopeX = frustumSlopeY * aspectRatio;
|
|
61
|
-
const distanceForHorizontalFrustum = radius * Math.sqrt(1 + 1 / (frustumSlopeX * frustumSlopeX));
|
|
62
|
-
const distanceForVerticalFrustum = radius * Math.sqrt(1 + 1 / (frustumSlopeY * frustumSlopeY));
|
|
63
|
-
const distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
|
|
64
57
|
const newCameraPosition = {
|
|
65
58
|
alpha: alpha,
|
|
66
59
|
beta: beta,
|
|
@@ -119,6 +112,53 @@ class CameraManager {
|
|
|
119
112
|
});
|
|
120
113
|
});
|
|
121
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Takes a sceenshot the the current scene.\
|
|
117
|
+
* The result is a string containing a base64 encoded image.
|
|
118
|
+
*/
|
|
119
|
+
createScreenshot(settings) {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const screenshotCam = (_a = this.viewer.scene.activeCamera) === null || _a === void 0 ? void 0 : _a.clone(CameraManager._SCREENSHOT_CAMERA_NAME);
|
|
123
|
+
const boundingInfo = (settings === null || settings === void 0 ? void 0 : settings.autofocusScene) ? this.viewer.calculateBoundingInfo(settings.exclude) : undefined;
|
|
124
|
+
if ((settings === null || settings === void 0 ? void 0 : settings.alpha) !== undefined) {
|
|
125
|
+
screenshotCam.alpha = settings.alpha;
|
|
126
|
+
}
|
|
127
|
+
if ((settings === null || settings === void 0 ? void 0 : settings.beta) !== undefined) {
|
|
128
|
+
screenshotCam.beta = settings.beta;
|
|
129
|
+
}
|
|
130
|
+
if ((settings === null || settings === void 0 ? void 0 : settings.radius) !== undefined) {
|
|
131
|
+
screenshotCam.radius = settings.radius;
|
|
132
|
+
}
|
|
133
|
+
else if (boundingInfo) {
|
|
134
|
+
// zoom out to have full scene in view if requested by `autofocusScene` flag
|
|
135
|
+
const distance = this._getAutofocusZoomingDistance(boundingInfo.boundingSphere, screenshotCam);
|
|
136
|
+
const radiusFactor = (_b = settings === null || settings === void 0 ? void 0 : settings.radiusFactor) !== null && _b !== void 0 ? _b : 1;
|
|
137
|
+
screenshotCam.radius = distance * radiusFactor;
|
|
138
|
+
}
|
|
139
|
+
// `cloneAlphaBetaRadius` has to be set to true, otherwise these values get adapted by setting the new target
|
|
140
|
+
// this would also be the case when setting `screenshotCam.target` directly
|
|
141
|
+
if ((settings === null || settings === void 0 ? void 0 : settings.target) !== undefined) {
|
|
142
|
+
screenshotCam.setTarget(settings.target, undefined, undefined, true);
|
|
143
|
+
}
|
|
144
|
+
else if (boundingInfo) {
|
|
145
|
+
screenshotCam.setTarget(boundingInfo.boundingSphere.center, undefined, undefined, true);
|
|
146
|
+
}
|
|
147
|
+
// don't expose internal props of `IScreenshotSize` in the API (yet), as it gets rather confusing and it shouldn't
|
|
148
|
+
// be necessary in the first place
|
|
149
|
+
// also let Babylon.js do all the fallback handling for missing properties
|
|
150
|
+
const size = { width: settings === null || settings === void 0 ? void 0 : settings.width, height: settings === null || settings === void 0 ? void 0 : settings.height };
|
|
151
|
+
// for some reason the `customizeTexture` property is not exposed in the async version of this function, therefore
|
|
152
|
+
// we create the promise here manually
|
|
153
|
+
const imageStr = yield new Promise(resolve => {
|
|
154
|
+
index_1.ScreenshotTools.CreateScreenshotUsingRenderTarget(this.viewer.engine, screenshotCam, size, (data) => resolve(data), settings === null || settings === void 0 ? void 0 : settings.mimeType, settings === null || settings === void 0 ? void 0 : settings.samples, settings === null || settings === void 0 ? void 0 : settings.antialiasing, settings === null || settings === void 0 ? void 0 : settings.fileName, settings === null || settings === void 0 ? void 0 : settings.renderSprites, settings === null || settings === void 0 ? void 0 : settings.enableStencilBuffer, settings === null || settings === void 0 ? void 0 : settings.useLayerMask, settings === null || settings === void 0 ? void 0 : settings.quality, texture => {
|
|
155
|
+
texture.renderList = this.viewer.scene.meshes.filter(mesh => !(settings === null || settings === void 0 ? void 0 : settings.exclude) || !(0, geometry_helper_1.isNodeExcluded)(mesh, settings.exclude));
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
screenshotCam.dispose();
|
|
159
|
+
return imageStr;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
122
162
|
static _addCameraAnimationToGroup(targetProperty, from, to, framesPerSec, dataType, animationGroup, activeCamera) {
|
|
123
163
|
const alphaAnimation = new index_1.Animation(targetProperty, targetProperty, framesPerSec, dataType, index_1.Animation.ANIMATIONLOOPMODE_CONSTANT);
|
|
124
164
|
alphaAnimation.setKeys([
|
|
@@ -133,6 +173,18 @@ class CameraManager {
|
|
|
133
173
|
]);
|
|
134
174
|
animationGroup.addTargetedAnimation(alphaAnimation, activeCamera);
|
|
135
175
|
}
|
|
176
|
+
_getAutofocusZoomingDistance(boundingSphere, camera) {
|
|
177
|
+
// calculation is taken from Babylon.js repository, which on their side took it from this SO post:
|
|
178
|
+
// http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene
|
|
179
|
+
// there's a good sketch which explains the calculation quite a bit
|
|
180
|
+
const aspectRatio = this.viewer.engine.getAspectRatio(camera);
|
|
181
|
+
const frustumSlopeY = Math.tan(camera.fov / 2);
|
|
182
|
+
const frustumSlopeX = frustumSlopeY * aspectRatio;
|
|
183
|
+
const distanceForHorizontalFrustum = boundingSphere.radius * Math.sqrt(1 + 1 / (frustumSlopeX * frustumSlopeX));
|
|
184
|
+
const distanceForVerticalFrustum = boundingSphere.radius * Math.sqrt(1 + 1 / (frustumSlopeY * frustumSlopeY));
|
|
185
|
+
const distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
|
|
186
|
+
return distance;
|
|
187
|
+
}
|
|
136
188
|
}
|
|
137
189
|
exports.CameraManager = CameraManager;
|
|
138
190
|
CameraManager.CAMERA_ANIMATION_NAME = '__cameraAnimation__';
|
|
@@ -151,4 +203,5 @@ CameraManager._AUTOFOCUS_CONSTANTS = {
|
|
|
151
203
|
};
|
|
152
204
|
CameraManager._DEFAULT_AUTOFOCUS_RADIUS_FACTOR = 1;
|
|
153
205
|
CameraManager._DEFAULT_CAM_SPEED_MS = 250;
|
|
206
|
+
CameraManager._SCREENSHOT_CAMERA_NAME = '__screenshotCamera__';
|
|
154
207
|
//# sourceMappingURL=camera-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera-manager.js","sourceRoot":"","sources":["../../../src/manager/camera-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"camera-manager.js","sour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AC,GAAG,CAAC,4BAA4B,EAAE,0BAA0B,CAAC,CAAC;QAEpF,OAAO,QAAQ,CAAC;IAClB,CAAC;;AA/QH,sCAgRC;AA/QwB,mCAAqB,GAAG,qBAAqB,CAAC;AAErE,gBAAgB;AACO,qCAAuB,GAAmB;IAC/D,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG;IAC3B,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG;IAC1B,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEwB,kCAAoB,GAAG;IAC/C,IAAI,EAAE,GAAG;IACT,cAAc,EAAE,GAAG;IACnB,kBAAkB,EAAE,IAAI;IACxB,cAAc,EAAE,GAAG;CACpB,CAAC;AAEwB,8CAAgC,GAAG,CAAC,CAAC;AACrC,mCAAqB,GAAG,GAAG,CAAC;AAC5B,qCAAuB,GAAG,sBAAsB,CAAC"}
|
package/dist/lib-cjs/viewer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Index from './index';
|
|
2
|
-
import { BoundingInfo, CameraManager, DebugManager, DefaultSceneSettings, Engine, EngineOptions, EventManager, GltfExportManager, MaterialManager, ModelManager, ParameterManager, ParameterSubject, Scene, SceneManager,
|
|
2
|
+
import { BoundingInfo, CameraManager, DebugManager, DefaultSceneSettings, Engine, EngineOptions, EventManager, GltfExportManager, MaterialManager, ModelManager, ParameterManager, ParameterSubject, Scene, SceneManager, TextureManager, TransformNode } from './index';
|
|
3
3
|
/**
|
|
4
4
|
* Use this to define geometry to be excluded from autofocus, GLB export, etc.
|
|
5
5
|
*/
|
|
@@ -57,7 +57,6 @@ export declare class Viewer {
|
|
|
57
57
|
protected _modelManager: ModelManager;
|
|
58
58
|
protected _parameterManager: ParameterManager;
|
|
59
59
|
protected _sceneManager: SceneManager;
|
|
60
|
-
protected _screenshotManager: ScreenshotManager;
|
|
61
60
|
protected _textureManager: TextureManager;
|
|
62
61
|
protected _viewerSettings: ViewerSettings;
|
|
63
62
|
protected _isRenderLoopPaused: boolean;
|
|
@@ -72,7 +71,6 @@ export declare class Viewer {
|
|
|
72
71
|
get parameterManager(): ParameterManager;
|
|
73
72
|
/** @internal */
|
|
74
73
|
get sceneManager(): SceneManager;
|
|
75
|
-
get screenshotManager(): ScreenshotManager;
|
|
76
74
|
/** @internal */
|
|
77
75
|
get textureManager(): TextureManager;
|
|
78
76
|
get viewerSettings(): ViewerSettings;
|
package/dist/lib-cjs/viewer.js
CHANGED
|
@@ -104,9 +104,6 @@ class Viewer {
|
|
|
104
104
|
get sceneManager() {
|
|
105
105
|
return this._sceneManager;
|
|
106
106
|
}
|
|
107
|
-
get screenshotManager() {
|
|
108
|
-
return this._screenshotManager;
|
|
109
|
-
}
|
|
110
107
|
/** @internal */
|
|
111
108
|
get textureManager() {
|
|
112
109
|
return this._textureManager;
|
|
@@ -201,7 +198,6 @@ class Viewer {
|
|
|
201
198
|
this._modelManager = new index_1.ModelManager(this);
|
|
202
199
|
this._parameterManager = new index_1.ParameterManager(this);
|
|
203
200
|
this._sceneManager = new index_1.SceneManager(this, defaultSceneSettings);
|
|
204
|
-
this._screenshotManager = new index_1.ScreenshotManager(this);
|
|
205
201
|
this._textureManager = new index_1.TextureManager(this);
|
|
206
202
|
// creates black cube
|
|
207
203
|
// this model is not based on an URL and can be targeted by the Combeenation backend as fallback model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/viewer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAyC;AACzC,+CAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/viewer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEA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G,IAAI,CAAC,aAAa,CAAC,mBAAmB,EAAE,CAAC;QAEzC,gHAAgH;QAChH,2BAA2B;QAC3B,IAAI,CAAC,aAAa,CAAC,2BAA2B,EAAE,CAAC;QAEjD,IAAI,CAAC,aAAa,CAAC,8BAA8B,EAAE,CAAC;QAEpD,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;gBAC7B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;aACrB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;AAtNH,wBAuNC;AAtNiB,cAAO,GAAG,wBAAS,CAAC,OAAO,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -78,5 +78,4 @@ export * from './manager/material-manager';
|
|
|
78
78
|
export * from './manager/model-manager';
|
|
79
79
|
export * from './manager/parameter-manager';
|
|
80
80
|
export * from './manager/scene-manager';
|
|
81
|
-
export * from './manager/screenshot-manager';
|
|
82
81
|
export * from './manager/texture-manager';
|
|
@@ -2,11 +2,15 @@ import {
|
|
|
2
2
|
Animation,
|
|
3
3
|
AnimationGroup,
|
|
4
4
|
ArcRotateCamera,
|
|
5
|
+
BoundingSphere,
|
|
5
6
|
ExcludedGeometryList,
|
|
7
|
+
IScreenshotSize,
|
|
8
|
+
ScreenshotTools,
|
|
6
9
|
Vector3,
|
|
7
10
|
Viewer,
|
|
8
11
|
ViewerEvent,
|
|
9
12
|
} from '../index';
|
|
13
|
+
import { isNodeExcluded } from '../internal/geometry-helper';
|
|
10
14
|
|
|
11
15
|
export type CameraPosition = {
|
|
12
16
|
alpha: number;
|
|
@@ -30,6 +34,59 @@ export type AutofocusSettings = {
|
|
|
30
34
|
durationMs?: number;
|
|
31
35
|
};
|
|
32
36
|
|
|
37
|
+
export type ScreenshotSettings = {
|
|
38
|
+
/** Width of the final screenshot image, defaults to canvas width */
|
|
39
|
+
width?: number;
|
|
40
|
+
/** Height of the final screenshot image, defaults to canvas height */
|
|
41
|
+
height?: number;
|
|
42
|
+
/** Camera alpha angle used for the screenshot, defaults to alpha angle of currently active camera */
|
|
43
|
+
alpha?: number;
|
|
44
|
+
/** Camera beta angle used for the screenshot, defaults to beta angle of currently active camera */
|
|
45
|
+
beta?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Camera radius used for the screenshot, default value depends on `autofocusScene` flag:
|
|
48
|
+
* - `true`: radius is calculated automatically so that the whole current scene content is visible
|
|
49
|
+
* - `false`: radius of currently active camera is used
|
|
50
|
+
*/
|
|
51
|
+
radius?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Camera target used for the screenshot, default value depends on `autofocusScene` flag:
|
|
54
|
+
* - `true`: center of the current scene content is set as camera target
|
|
55
|
+
* - `false`: target of currently active camera is used
|
|
56
|
+
*/
|
|
57
|
+
target?: Vector3;
|
|
58
|
+
/** Used to scale the calculated radius if `radius` property is not set and `autofocusScene` mode is active */
|
|
59
|
+
radiusFactor?: number;
|
|
60
|
+
/** Can be used to automatically calculate camera `radius` and `target`, if these 2 settings are not defined
|
|
61
|
+
* explicitely */
|
|
62
|
+
autofocusScene?: boolean;
|
|
63
|
+
/** Optional list of geometry to be excluded from consideration */
|
|
64
|
+
exclude?: ExcludedGeometryList;
|
|
65
|
+
/**
|
|
66
|
+
* "MIME type" of the returned screenshot image, defaults to `image/png`
|
|
67
|
+
*
|
|
68
|
+
* **Info regarding JPEG:** \
|
|
69
|
+
* Use mimeType `image/jpeg` (**not** `image/jpg`) when creating jpeg's. \
|
|
70
|
+
* Also ensure that the viewer scenes `clearColor` has an alpha value of `1` as jpeg's don't
|
|
71
|
+
* support transparency. Otherwise background will always be black for jpeg's.
|
|
72
|
+
*/
|
|
73
|
+
mimeType?: string;
|
|
74
|
+
/** If file name is given, the screenshot image will be downloaded and the base64 string will NOT be returned! */
|
|
75
|
+
fileName?: string;
|
|
76
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
77
|
+
samples?: number;
|
|
78
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
79
|
+
antialiasing?: boolean;
|
|
80
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
81
|
+
renderSprites?: boolean;
|
|
82
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
83
|
+
enableStencilBuffer?: boolean;
|
|
84
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
85
|
+
useLayerMask?: boolean;
|
|
86
|
+
/** Expert settings to tweak the screenshot image, see [Babylon.js](https://doc.babylonjs.com/typedoc/functions/BABYLON.CreateScreenshotUsingRenderTarget) docs for further information */
|
|
87
|
+
quality?: number;
|
|
88
|
+
};
|
|
89
|
+
|
|
33
90
|
/**
|
|
34
91
|
* Manager for camera related tasks
|
|
35
92
|
*/
|
|
@@ -53,6 +110,7 @@ export class CameraManager {
|
|
|
53
110
|
|
|
54
111
|
protected static readonly _DEFAULT_AUTOFOCUS_RADIUS_FACTOR = 1;
|
|
55
112
|
protected static readonly _DEFAULT_CAM_SPEED_MS = 250;
|
|
113
|
+
protected static readonly _SCREENSHOT_CAMERA_NAME = '__screenshotCamera__';
|
|
56
114
|
|
|
57
115
|
/** @internal */
|
|
58
116
|
public constructor(protected viewer: Viewer) {}
|
|
@@ -72,6 +130,7 @@ export class CameraManager {
|
|
|
72
130
|
// optionally show bounding sphere for debugging purpose
|
|
73
131
|
this.viewer.eventManager.fireEvent(ViewerEvent.AutofocusStart, boundingInfo.boundingSphere);
|
|
74
132
|
|
|
133
|
+
const distance = this._getAutofocusZoomingDistance(boundingInfo.boundingSphere, activeCamera);
|
|
75
134
|
const radius = boundingInfo.boundingSphere.radius;
|
|
76
135
|
const center = boundingInfo.boundingSphere.center;
|
|
77
136
|
|
|
@@ -95,17 +154,6 @@ export class CameraManager {
|
|
|
95
154
|
const alpha = settings?.alpha ?? CameraManager.DEFAULT_CAMERA_POSITION.alpha;
|
|
96
155
|
const beta = settings?.beta ?? CameraManager.DEFAULT_CAMERA_POSITION.beta;
|
|
97
156
|
|
|
98
|
-
// calculation is taken from Babylon.js repository, which on their side took it from this SO post:
|
|
99
|
-
// http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene
|
|
100
|
-
// there's a good sketch which explains the calculation quite a bit
|
|
101
|
-
const aspectRatio = this.viewer.engine.getAspectRatio(activeCamera);
|
|
102
|
-
const frustumSlopeY = Math.tan(activeCamera.fov / 2);
|
|
103
|
-
const frustumSlopeX = frustumSlopeY * aspectRatio;
|
|
104
|
-
|
|
105
|
-
const distanceForHorizontalFrustum = radius * Math.sqrt(1 + 1 / (frustumSlopeX * frustumSlopeX));
|
|
106
|
-
const distanceForVerticalFrustum = radius * Math.sqrt(1 + 1 / (frustumSlopeY * frustumSlopeY));
|
|
107
|
-
const distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
|
|
108
|
-
|
|
109
157
|
const newCameraPosition: CameraPosition = {
|
|
110
158
|
alpha: alpha,
|
|
111
159
|
beta: beta,
|
|
@@ -205,6 +253,72 @@ export class CameraManager {
|
|
|
205
253
|
});
|
|
206
254
|
}
|
|
207
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Takes a sceenshot the the current scene.\
|
|
258
|
+
* The result is a string containing a base64 encoded image.
|
|
259
|
+
*/
|
|
260
|
+
public async createScreenshot(settings?: ScreenshotSettings): Promise<string> {
|
|
261
|
+
const screenshotCam = this.viewer.scene.activeCamera?.clone(
|
|
262
|
+
CameraManager._SCREENSHOT_CAMERA_NAME
|
|
263
|
+
) as ArcRotateCamera;
|
|
264
|
+
const boundingInfo = settings?.autofocusScene ? this.viewer.calculateBoundingInfo(settings.exclude) : undefined;
|
|
265
|
+
|
|
266
|
+
if (settings?.alpha !== undefined) {
|
|
267
|
+
screenshotCam.alpha = settings.alpha;
|
|
268
|
+
}
|
|
269
|
+
if (settings?.beta !== undefined) {
|
|
270
|
+
screenshotCam.beta = settings.beta;
|
|
271
|
+
}
|
|
272
|
+
if (settings?.radius !== undefined) {
|
|
273
|
+
screenshotCam.radius = settings.radius;
|
|
274
|
+
} else if (boundingInfo) {
|
|
275
|
+
// zoom out to have full scene in view if requested by `autofocusScene` flag
|
|
276
|
+
const distance = this._getAutofocusZoomingDistance(boundingInfo.boundingSphere, screenshotCam);
|
|
277
|
+
const radiusFactor = settings?.radiusFactor ?? 1;
|
|
278
|
+
screenshotCam.radius = distance * radiusFactor;
|
|
279
|
+
}
|
|
280
|
+
// `cloneAlphaBetaRadius` has to be set to true, otherwise these values get adapted by setting the new target
|
|
281
|
+
// this would also be the case when setting `screenshotCam.target` directly
|
|
282
|
+
if (settings?.target !== undefined) {
|
|
283
|
+
screenshotCam.setTarget(settings.target, undefined, undefined, true);
|
|
284
|
+
} else if (boundingInfo) {
|
|
285
|
+
screenshotCam.setTarget(boundingInfo.boundingSphere.center, undefined, undefined, true);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// don't expose internal props of `IScreenshotSize` in the API (yet), as it gets rather confusing and it shouldn't
|
|
289
|
+
// be necessary in the first place
|
|
290
|
+
// also let Babylon.js do all the fallback handling for missing properties
|
|
291
|
+
const size: IScreenshotSize = { width: settings?.width, height: settings?.height };
|
|
292
|
+
|
|
293
|
+
// for some reason the `customizeTexture` property is not exposed in the async version of this function, therefore
|
|
294
|
+
// we create the promise here manually
|
|
295
|
+
const imageStr = await new Promise<string>(resolve => {
|
|
296
|
+
ScreenshotTools.CreateScreenshotUsingRenderTarget(
|
|
297
|
+
this.viewer.engine,
|
|
298
|
+
screenshotCam,
|
|
299
|
+
size,
|
|
300
|
+
(data: string) => resolve(data),
|
|
301
|
+
settings?.mimeType,
|
|
302
|
+
settings?.samples,
|
|
303
|
+
settings?.antialiasing,
|
|
304
|
+
settings?.fileName,
|
|
305
|
+
settings?.renderSprites,
|
|
306
|
+
settings?.enableStencilBuffer,
|
|
307
|
+
settings?.useLayerMask,
|
|
308
|
+
settings?.quality,
|
|
309
|
+
texture => {
|
|
310
|
+
texture.renderList = this.viewer.scene.meshes.filter(
|
|
311
|
+
mesh => !settings?.exclude || !isNodeExcluded(mesh, settings.exclude)
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
screenshotCam.dispose();
|
|
318
|
+
|
|
319
|
+
return imageStr;
|
|
320
|
+
}
|
|
321
|
+
|
|
208
322
|
protected static _addCameraAnimationToGroup(
|
|
209
323
|
targetProperty: string,
|
|
210
324
|
from: number | Vector3,
|
|
@@ -233,4 +347,19 @@ export class CameraManager {
|
|
|
233
347
|
]);
|
|
234
348
|
animationGroup.addTargetedAnimation(alphaAnimation, activeCamera);
|
|
235
349
|
}
|
|
350
|
+
|
|
351
|
+
protected _getAutofocusZoomingDistance(boundingSphere: BoundingSphere, camera: ArcRotateCamera): number {
|
|
352
|
+
// calculation is taken from Babylon.js repository, which on their side took it from this SO post:
|
|
353
|
+
// http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene
|
|
354
|
+
// there's a good sketch which explains the calculation quite a bit
|
|
355
|
+
const aspectRatio = this.viewer.engine.getAspectRatio(camera);
|
|
356
|
+
const frustumSlopeY = Math.tan(camera.fov / 2);
|
|
357
|
+
const frustumSlopeX = frustumSlopeY * aspectRatio;
|
|
358
|
+
|
|
359
|
+
const distanceForHorizontalFrustum = boundingSphere.radius * Math.sqrt(1 + 1 / (frustumSlopeX * frustumSlopeX));
|
|
360
|
+
const distanceForVerticalFrustum = boundingSphere.radius * Math.sqrt(1 + 1 / (frustumSlopeY * frustumSlopeY));
|
|
361
|
+
const distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
|
|
362
|
+
|
|
363
|
+
return distance;
|
|
364
|
+
}
|
|
236
365
|
}
|
package/src/viewer.ts
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
ParameterSubject,
|
|
16
16
|
Scene,
|
|
17
17
|
SceneManager,
|
|
18
|
-
ScreenshotManager,
|
|
19
18
|
TextureManager,
|
|
20
19
|
TransformNode,
|
|
21
20
|
Vector3,
|
|
@@ -88,7 +87,6 @@ export class Viewer {
|
|
|
88
87
|
protected _modelManager!: ModelManager;
|
|
89
88
|
protected _parameterManager!: ParameterManager;
|
|
90
89
|
protected _sceneManager!: SceneManager;
|
|
91
|
-
protected _screenshotManager!: ScreenshotManager;
|
|
92
90
|
protected _textureManager!: TextureManager;
|
|
93
91
|
|
|
94
92
|
// default viewer settings
|
|
@@ -141,9 +139,6 @@ export class Viewer {
|
|
|
141
139
|
get sceneManager(): SceneManager {
|
|
142
140
|
return this._sceneManager;
|
|
143
141
|
}
|
|
144
|
-
get screenshotManager(): ScreenshotManager {
|
|
145
|
-
return this._screenshotManager;
|
|
146
|
-
}
|
|
147
142
|
/** @internal */
|
|
148
143
|
get textureManager(): TextureManager {
|
|
149
144
|
return this._textureManager;
|
|
@@ -274,7 +269,6 @@ export class Viewer {
|
|
|
274
269
|
this._modelManager = new ModelManager(this);
|
|
275
270
|
this._parameterManager = new ParameterManager(this);
|
|
276
271
|
this._sceneManager = new SceneManager(this, defaultSceneSettings);
|
|
277
|
-
this._screenshotManager = new ScreenshotManager(this);
|
|
278
272
|
this._textureManager = new TextureManager(this);
|
|
279
273
|
|
|
280
274
|
// creates black cube
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { IScreenshotSize, Viewer } from '../index';
|
|
2
|
-
export declare type ScreenshotSettings = {
|
|
3
|
-
/** Defaults to canvas width & height */
|
|
4
|
-
size?: IScreenshotSize;
|
|
5
|
-
/**
|
|
6
|
-
* Default `image/png`
|
|
7
|
-
*
|
|
8
|
-
* **Info regarding JPEG:** \
|
|
9
|
-
* Use mimeType `image/jpeg` (**not** `image/jpg`) when creating jpeg's. \
|
|
10
|
-
* Also ensure that the viewer scenes `clearColor` has an alpha value of `1` as jpeg's don't
|
|
11
|
-
* support transparency. Otherwise background will always be black for jpeg's.
|
|
12
|
-
*/
|
|
13
|
-
mimeType?: string;
|
|
14
|
-
/** Default `1` */
|
|
15
|
-
samples?: number;
|
|
16
|
-
/** Default `false` */
|
|
17
|
-
antialiasing?: boolean;
|
|
18
|
-
/** NOTE: after update to Babylon.js V6: if file name is given, the screenshot image will be downloaded and the base64
|
|
19
|
-
* string will NOT be returned! */
|
|
20
|
-
fileName?: string;
|
|
21
|
-
/** Default `false` */
|
|
22
|
-
renderSprites?: boolean;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Manager for tasks related to screenshots
|
|
26
|
-
*/
|
|
27
|
-
export declare class ScreenshotManager {
|
|
28
|
-
protected viewer: Viewer;
|
|
29
|
-
/** @internal */
|
|
30
|
-
constructor(viewer: Viewer);
|
|
31
|
-
/**
|
|
32
|
-
* Takes a sceenshot the the current scene.\
|
|
33
|
-
* The result is a string containing a base64 encoded image.
|
|
34
|
-
*/
|
|
35
|
-
takeScreenshot(settings?: ScreenshotSettings): Promise<string>;
|
|
36
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ScreenshotManager = void 0;
|
|
13
|
-
const index_1 = require("../index");
|
|
14
|
-
/**
|
|
15
|
-
* Manager for tasks related to screenshots
|
|
16
|
-
*/
|
|
17
|
-
class ScreenshotManager {
|
|
18
|
-
/** @internal */
|
|
19
|
-
constructor(viewer) {
|
|
20
|
-
this.viewer = viewer;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Takes a sceenshot the the current scene.\
|
|
24
|
-
* The result is a string containing a base64 encoded image.
|
|
25
|
-
*/
|
|
26
|
-
takeScreenshot(settings) {
|
|
27
|
-
var _a;
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
// in combination with a render target, we need to refresh the scene manually to get the latest view
|
|
30
|
-
this.viewer.scene.render();
|
|
31
|
-
const size = (_a = settings === null || settings === void 0 ? void 0 : settings.size) !== null && _a !== void 0 ? _a : { width: this.viewer.canvas.clientWidth, height: this.viewer.canvas.clientHeight };
|
|
32
|
-
const imageStr = yield index_1.ScreenshotTools.CreateScreenshotUsingRenderTargetAsync(this.viewer.engine,
|
|
33
|
-
// mark as non-nullable as we wouldn't come this far if no camera is active anyway
|
|
34
|
-
this.viewer.scene.activeCamera, size, settings === null || settings === void 0 ? void 0 : settings.mimeType, settings === null || settings === void 0 ? void 0 : settings.samples, settings === null || settings === void 0 ? void 0 : settings.antialiasing, settings === null || settings === void 0 ? void 0 : settings.fileName, settings === null || settings === void 0 ? void 0 : settings.renderSprites);
|
|
35
|
-
return imageStr;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.ScreenshotManager = ScreenshotManager;
|
|
40
|
-
//# sourceMappingURL=screenshot-manager.js.map
|