@shapediver/viewer.viewport 3.3.3 → 3.3.6
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/package.json +21 -22
- package/src/implementation/PostProcessingApi.ts +0 -184
- package/src/implementation/ViewportApi.ts +0 -1071
- package/src/implementation/camera/AbstractCameraApi.ts +0 -560
- package/src/implementation/camera/OrthographicCameraApi.ts +0 -43
- package/src/implementation/camera/PerspectiveCameraApi.ts +0 -43
- package/src/implementation/lights/AbstractLightApi.ts +0 -87
- package/src/implementation/lights/LightSceneApi.ts +0 -198
- package/src/implementation/lights/types/AmbientLightApi.ts +0 -24
- package/src/implementation/lights/types/DirectionalLightApi.ts +0 -80
- package/src/implementation/lights/types/HemisphereLightApi.ts +0 -44
- package/src/implementation/lights/types/PointLightApi.ts +0 -68
- package/src/implementation/lights/types/SpotLightApi.ts +0 -104
- package/src/index.ts +0 -312
- package/src/interfaces/IPostProcessingApi.ts +0 -269
- package/src/interfaces/IViewportApi.ts +0 -640
- package/src/interfaces/camera/ICameraApi.ts +0 -237
- package/src/interfaces/camera/IOrthographicCameraApi.ts +0 -18
- package/src/interfaces/camera/IPerspectiveCameraApi.ts +0 -17
- package/src/interfaces/lights/ILightApi.ts +0 -41
- package/src/interfaces/lights/ILightSceneApi.ts +0 -147
- package/src/interfaces/lights/types/IAmbientLightApi.ts +0 -7
- package/src/interfaces/lights/types/IDirectionalLightApi.ts +0 -29
- package/src/interfaces/lights/types/IHemisphereLightApi.ts +0 -17
- package/src/interfaces/lights/types/IPointLightApi.ts +0 -25
- package/src/interfaces/lights/types/ISpotLightApi.ts +0 -37
- package/src/main.ts +0 -89
- package/tsconfig.json +0 -17
|
@@ -1,1071 +0,0 @@
|
|
|
1
|
-
import * as QRCode from 'qrcode';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { AnimationEngine } from '@shapediver/viewer.rendering-engine.animation-engine';
|
|
4
|
-
import { build_data } from '@shapediver/viewer.shared.build-data';
|
|
5
|
-
import { CAMERA_TYPE, IOrthographicCamera, IPerspectiveCamera } from '@shapediver/viewer.rendering-engine.camera-engine';
|
|
6
|
-
import {
|
|
7
|
-
Color,
|
|
8
|
-
IAnimationData,
|
|
9
|
-
IGeometryData,
|
|
10
|
-
ISDTFAttributeVisualizationData,
|
|
11
|
-
ISDTFItemData,
|
|
12
|
-
ISDTFOverview,
|
|
13
|
-
MaterialBasicLineData,
|
|
14
|
-
MaterialPointData,
|
|
15
|
-
MaterialStandardData
|
|
16
|
-
} from '@shapediver/viewer.shared.types';
|
|
17
|
-
import {
|
|
18
|
-
Converter,
|
|
19
|
-
IDomEventListener,
|
|
20
|
-
InputValidator,
|
|
21
|
-
Logger,
|
|
22
|
-
SESSION_SETTINGS_MODE,
|
|
23
|
-
ShapeDiverViewerArError,
|
|
24
|
-
ShapeDiverViewerValidationError,
|
|
25
|
-
StateEngine,
|
|
26
|
-
SystemInfo
|
|
27
|
-
} from '@shapediver/viewer.shared.services';
|
|
28
|
-
import { CreationControlCenterViewport, ICreationControlCenterViewport } from '@shapediver/viewer.creation-control-center.viewport';
|
|
29
|
-
import {
|
|
30
|
-
FLAG_TYPE,
|
|
31
|
-
RENDERER_TYPE,
|
|
32
|
-
TEXTURE_ENCODING,
|
|
33
|
-
TONE_MAPPING
|
|
34
|
-
} from '@shapediver/viewer.rendering-engine.rendering-engine';
|
|
35
|
-
import { GLTFConverter } from '@shapediver/viewer.data-engine.gltf-converter';
|
|
36
|
-
import { ICameraApi } from '../interfaces/camera/ICameraApi';
|
|
37
|
-
import { ILightSceneApi } from '../interfaces/lights/ILightSceneApi';
|
|
38
|
-
import { IOrthographicCameraApi } from '../interfaces/camera/IOrthographicCameraApi';
|
|
39
|
-
import { IPerspectiveCameraApi } from '../interfaces/camera/IPerspectiveCameraApi';
|
|
40
|
-
import { IPostProcessingApi } from '../interfaces/IPostProcessingApi';
|
|
41
|
-
import { ISettings } from '@shapediver/viewer.settings';
|
|
42
|
-
import { ITreeNode, TreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
43
|
-
import { IViewportApi } from '../interfaces/IViewportApi';
|
|
44
|
-
import { LightSceneApi } from './lights/LightSceneApi';
|
|
45
|
-
import {
|
|
46
|
-
mat4,
|
|
47
|
-
quat,
|
|
48
|
-
vec2,
|
|
49
|
-
vec3
|
|
50
|
-
} from 'gl-matrix';
|
|
51
|
-
import { OrthographicCameraApi } from './camera/OrthographicCameraApi';
|
|
52
|
-
import { PerspectiveCameraApi } from './camera/PerspectiveCameraApi';
|
|
53
|
-
import { PostProcessingApi } from './PostProcessingApi';
|
|
54
|
-
import { RenderingEngine as RenderingEngineThreeJs } from '@shapediver/viewer.rendering-engine.rendering-engine-threejs';
|
|
55
|
-
import { sceneTree } from '@shapediver/viewer.api.general';
|
|
56
|
-
import { ShapeDiverRequestGltfUploadQueryConversion } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
57
|
-
|
|
58
|
-
export class ViewportApi implements IViewportApi {
|
|
59
|
-
// #region Properties (11)
|
|
60
|
-
|
|
61
|
-
readonly #animationEngine: AnimationEngine = AnimationEngine.instance;
|
|
62
|
-
readonly #cameras: { [key: string]: ICameraApi } = {};
|
|
63
|
-
readonly #creationControlCenterViewport: ICreationControlCenterViewport = CreationControlCenterViewport.instance;
|
|
64
|
-
readonly #gltfConverter: GLTFConverter = GLTFConverter.instance;
|
|
65
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
66
|
-
readonly #lightScenes: { [key: string]: ILightSceneApi } = {};
|
|
67
|
-
readonly #logger: Logger = Logger.instance;
|
|
68
|
-
readonly #postProcessing: IPostProcessingApi;
|
|
69
|
-
readonly #renderingEngine: RenderingEngineThreeJs;
|
|
70
|
-
readonly #stateEngine: StateEngine = StateEngine.instance;
|
|
71
|
-
readonly #systemInfo: SystemInfo = SystemInfo.instance;
|
|
72
|
-
|
|
73
|
-
// #endregion Properties (11)
|
|
74
|
-
|
|
75
|
-
// #region Constructors (1)
|
|
76
|
-
|
|
77
|
-
constructor(renderingEngine: RenderingEngineThreeJs) {
|
|
78
|
-
this.#renderingEngine = renderingEngine;
|
|
79
|
-
|
|
80
|
-
// Whenever a camera is added or removed from the camera engine, this update is called.
|
|
81
|
-
this.#renderingEngine.cameraEngine.update = () => {
|
|
82
|
-
for (const c in this.#renderingEngine.cameraEngine.cameras) {
|
|
83
|
-
if (!this.#cameras[c]) {
|
|
84
|
-
if (this.#renderingEngine.cameraEngine.cameras[c].type === CAMERA_TYPE.PERSPECTIVE) {
|
|
85
|
-
this.#cameras[c] = new PerspectiveCameraApi(this, <IPerspectiveCamera>this.#renderingEngine.cameraEngine.cameras[c]);
|
|
86
|
-
} else {
|
|
87
|
-
this.#cameras[c] = new OrthographicCameraApi(this, <IOrthographicCamera>this.#renderingEngine.cameraEngine.cameras[c]);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
for (const c in this.#cameras) {
|
|
93
|
-
if (!this.#renderingEngine.cameraEngine.cameras[c]) {
|
|
94
|
-
delete this.#cameras[c];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// We call it once in the beginning to get the current state.
|
|
100
|
-
this.#renderingEngine.cameraEngine.update();
|
|
101
|
-
|
|
102
|
-
// Whenever a camera is added or removed from the camera engine, this update is called.
|
|
103
|
-
this.#renderingEngine.lightEngine.update = () => {
|
|
104
|
-
for (const l in this.#renderingEngine.lightEngine.lightScenes) {
|
|
105
|
-
if (!this.#lightScenes[l]) {
|
|
106
|
-
this.#lightScenes[l] = new LightSceneApi(this, this.#renderingEngine.lightEngine.lightScenes[l]);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
for (const l in this.#lightScenes) {
|
|
111
|
-
if (!this.#renderingEngine.lightEngine.lightScenes[l]) {
|
|
112
|
-
delete this.#lightScenes[l];
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// We call it once in the beginning to get the current state.
|
|
118
|
-
this.#renderingEngine.lightEngine.update();
|
|
119
|
-
|
|
120
|
-
// We create the post processing api
|
|
121
|
-
this.#postProcessing = new PostProcessingApi(this, this.#renderingEngine);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// #endregion Constructors (1)
|
|
125
|
-
|
|
126
|
-
// #region Public Getters And Setters (94)
|
|
127
|
-
|
|
128
|
-
public get animations(): {
|
|
129
|
-
[key: string]: IAnimationData
|
|
130
|
-
} {
|
|
131
|
-
return this.#animationEngine.animations;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
public get arRotation(): vec3 {
|
|
135
|
-
return this.#renderingEngine.arRotation;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public set arRotation(value: vec3) {
|
|
139
|
-
const scope = 'arRotation';
|
|
140
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'vec3');
|
|
141
|
-
this.#renderingEngine.arRotation = value;
|
|
142
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
143
|
-
this.update('arRotation');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public get arScale(): vec3 {
|
|
147
|
-
return this.#renderingEngine.arScale;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public set arScale(value: vec3) {
|
|
151
|
-
const scope = 'arScale';
|
|
152
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'vec3');
|
|
153
|
-
this.#renderingEngine.arScale = vec3.max(vec3.create(), value, vec3.fromValues(0.001, 0.001, 0.001));
|
|
154
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
155
|
-
this.update('arScale');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public get arTranslation(): vec3 {
|
|
159
|
-
return this.#renderingEngine.arTranslation;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public set arTranslation(value: vec3) {
|
|
163
|
-
const scope = 'arTranslation';
|
|
164
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'vec3');
|
|
165
|
-
this.#renderingEngine.arTranslation = value;
|
|
166
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
167
|
-
this.update('arTranslation');
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public get automaticColorAdjustment(): boolean {
|
|
171
|
-
return this.#renderingEngine.automaticColorAdjustment;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
public set automaticColorAdjustment(value: boolean) {
|
|
175
|
-
const scope = 'automaticColorAdjustment';
|
|
176
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
177
|
-
this.#renderingEngine.automaticColorAdjustment = value;
|
|
178
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
179
|
-
this.update('automaticColorAdjustment');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
public get automaticResizing(): boolean {
|
|
183
|
-
return this.#renderingEngine.automaticResizing;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
public set automaticResizing(value: boolean) {
|
|
187
|
-
const scope = 'automaticResizing';
|
|
188
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
189
|
-
this.#renderingEngine.automaticResizing = value;
|
|
190
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
191
|
-
this.update('automaticResizing');
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
public get beautyRenderBlendingDuration(): number {
|
|
195
|
-
return this.#renderingEngine.beautyRenderBlendingDuration;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public set beautyRenderBlendingDuration(value: number) {
|
|
199
|
-
const scope = 'beautyRenderBlendingDuration';
|
|
200
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'number');
|
|
201
|
-
this.#renderingEngine.beautyRenderBlendingDuration = value;
|
|
202
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
203
|
-
this.update('beautyRenderBlendingDuration');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
public get beautyRenderDelay(): number {
|
|
207
|
-
return this.#renderingEngine.beautyRenderDelay;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
public set beautyRenderDelay(value: number) {
|
|
211
|
-
const scope = 'beautyRenderDelay';
|
|
212
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'number');
|
|
213
|
-
this.#renderingEngine.beautyRenderDelay = value;
|
|
214
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
215
|
-
this.update('beautyRenderDelay');
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
public get camera(): ICameraApi | null {
|
|
219
|
-
if (!this.#renderingEngine.cameraEngine.camera) return null;
|
|
220
|
-
return this.#cameras[this.#renderingEngine.cameraEngine.camera.id];
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public get cameras(): { [key: string]: ICameraApi; } {
|
|
224
|
-
return this.#cameras;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
public get canvas(): HTMLCanvasElement {
|
|
228
|
-
return this.#renderingEngine.canvas;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
public get clearAlpha(): number {
|
|
232
|
-
return this.#renderingEngine.clearAlpha;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
public set clearAlpha(value: number) {
|
|
236
|
-
const scope = 'clearAlpha';
|
|
237
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'number');
|
|
238
|
-
this.#renderingEngine.clearAlpha = value;
|
|
239
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
240
|
-
this.update('clearAlpha');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
public get clearColor(): Color {
|
|
244
|
-
return this.#renderingEngine.clearColor;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
public set clearColor(value: Color) {
|
|
248
|
-
const scope = 'clearColor';
|
|
249
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'color');
|
|
250
|
-
this.#renderingEngine.clearColor = value;
|
|
251
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
252
|
-
this.update('clearColor');
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
public get defaultLineMaterial(): MaterialBasicLineData {
|
|
256
|
-
return this.#renderingEngine.defaultLineMaterial;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
public get defaultMaterial(): MaterialStandardData {
|
|
260
|
-
return this.#renderingEngine.defaultMaterial;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
public get defaultMaterialColor(): Color {
|
|
264
|
-
return this.#renderingEngine.defaultMaterialColor;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
public set defaultMaterialColor(value: Color) {
|
|
268
|
-
const scope = 'defaultMaterialColor';
|
|
269
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'color');
|
|
270
|
-
this.#renderingEngine.defaultMaterialColor = value;
|
|
271
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
272
|
-
this.update('defaultMaterialColor');
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
public get defaultPointMaterial(): MaterialPointData {
|
|
276
|
-
return this.#renderingEngine.defaultPointMaterial;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
public get enableAR(): boolean {
|
|
280
|
-
return this.#renderingEngine.enableAR;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
public set enableAR(value: boolean) {
|
|
284
|
-
const scope = 'enableAR';
|
|
285
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
286
|
-
this.#renderingEngine.enableAR = value;
|
|
287
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
288
|
-
this.update('enableAR');
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
public get environmentMap(): string | string[] {
|
|
292
|
-
return this.#renderingEngine.environmentMap;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
public set environmentMap(value: string | string[]) {
|
|
296
|
-
const scope = 'environmentMap';
|
|
297
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'cubeMap');
|
|
298
|
-
this.#renderingEngine.environmentMap = value;
|
|
299
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
300
|
-
this.update('environmentMap');
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
public get environmentMapAsBackground(): boolean {
|
|
304
|
-
return this.#renderingEngine.environmentMapAsBackground;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
public set environmentMapAsBackground(value: boolean) {
|
|
308
|
-
const scope = 'environmentMapAsBackground';
|
|
309
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
310
|
-
this.#renderingEngine.environmentMapAsBackground = value;
|
|
311
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
312
|
-
this.update('environmentMapAsBackground');
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
public get environmentMapBlurriness(): number {
|
|
316
|
-
return this.#renderingEngine.environmentMapBlurriness;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
public set environmentMapBlurriness(value: number) {
|
|
320
|
-
const scope = 'environmentMapBlurriness';
|
|
321
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'number');
|
|
322
|
-
this.#renderingEngine.environmentMapBlurriness = value;
|
|
323
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
324
|
-
this.update('environmentMapBlurriness');
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
public get environmentMapForUnlitMaterials(): boolean {
|
|
328
|
-
return this.#renderingEngine.environmentMapForUnlitMaterials;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
public set environmentMapForUnlitMaterials(value: boolean) {
|
|
332
|
-
const scope = 'environmentMapForUnlitMaterials';
|
|
333
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
334
|
-
this.#renderingEngine.environmentMapForUnlitMaterials = value;
|
|
335
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
336
|
-
this.update('environmentMapForUnlitMaterials');
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
public get environmentMapIntensity(): number {
|
|
340
|
-
return this.#renderingEngine.environmentMapIntensity;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
public set environmentMapIntensity(value: number) {
|
|
344
|
-
const scope = 'environmentMapIntensity';
|
|
345
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'number');
|
|
346
|
-
this.#renderingEngine.environmentMapIntensity = value;
|
|
347
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
348
|
-
this.update('environmentMapIntensity');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
public get environmentMapResolution(): string {
|
|
352
|
-
return this.#renderingEngine.environmentMapResolution;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
public set environmentMapResolution(value: string) {
|
|
356
|
-
const scope = 'environmentMapResolution';
|
|
357
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'string');
|
|
358
|
-
this.#renderingEngine.environmentMapResolution = value;
|
|
359
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
360
|
-
this.update('environmentMapResolution');
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
public get environmentMapRotation(): quat {
|
|
364
|
-
return this.#renderingEngine.environmentMapRotation;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
public set environmentMapRotation(value: quat) {
|
|
368
|
-
const scope = 'environmentMapRotation';
|
|
369
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'quat');
|
|
370
|
-
this.#renderingEngine.environmentMapRotation = value;
|
|
371
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
372
|
-
this.update('environmentMapRotation');
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
public get gridColor(): Color {
|
|
376
|
-
return this.#renderingEngine.gridColor;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
public set gridColor(value: Color) {
|
|
380
|
-
const scope = 'gridColor';
|
|
381
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'color');
|
|
382
|
-
this.#renderingEngine.gridColor = value;
|
|
383
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
384
|
-
this.update('gridColor');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
public get gridVisibility(): boolean {
|
|
388
|
-
return this.#renderingEngine.gridVisibility;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
public set gridVisibility(value: boolean) {
|
|
392
|
-
const scope = 'gridVisibility';
|
|
393
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
394
|
-
this.#renderingEngine.gridVisibility = value;
|
|
395
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
396
|
-
this.update('gridVisibility');
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
public get groundPlaneColor(): Color {
|
|
400
|
-
return this.#renderingEngine.groundPlaneColor;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
public set groundPlaneColor(value: Color) {
|
|
404
|
-
const scope = 'groundPlaneColor';
|
|
405
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'color');
|
|
406
|
-
this.#renderingEngine.groundPlaneColor = value;
|
|
407
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
408
|
-
this.update('groundPlaneColor');
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
public get groundPlaneShadowColor(): Color {
|
|
412
|
-
return this.#renderingEngine.groundPlaneShadowColor;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
public set groundPlaneShadowColor(value: Color) {
|
|
416
|
-
const scope = 'groundPlaneShadowColor';
|
|
417
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'color');
|
|
418
|
-
this.#renderingEngine.groundPlaneShadowColor = value;
|
|
419
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
420
|
-
this.update('groundPlaneShadowColor');
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
public get groundPlaneShadowVisibility(): boolean {
|
|
424
|
-
return this.#renderingEngine.groundPlaneShadowVisibility;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
public set groundPlaneShadowVisibility(value: boolean) {
|
|
428
|
-
const scope = 'groundPlaneShadowVisibility';
|
|
429
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
430
|
-
this.#renderingEngine.groundPlaneShadowVisibility = value;
|
|
431
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
432
|
-
this.update('groundPlaneShadowVisibility');
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
public get groundPlaneVisibility(): boolean {
|
|
436
|
-
return this.#renderingEngine.groundPlaneVisibility;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
public set groundPlaneVisibility(value: boolean) {
|
|
440
|
-
const scope = 'groundPlaneVisibility';
|
|
441
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
442
|
-
this.#renderingEngine.groundPlaneVisibility = value;
|
|
443
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
444
|
-
this.update('groundPlaneVisibility');
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
public get id(): string {
|
|
448
|
-
return this.#renderingEngine.id;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
public get lightScene(): ILightSceneApi | null {
|
|
452
|
-
if (!this.#renderingEngine.lightEngine.lightScene) return null;
|
|
453
|
-
return this.#lightScenes[this.#renderingEngine.lightEngine.lightScene.id];
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
public get lightScenes(): { [key: string]: ILightSceneApi; } {
|
|
457
|
-
return this.#lightScenes;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
public get lights(): boolean {
|
|
461
|
-
return this.#renderingEngine.lights;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
public set lights(value: boolean) {
|
|
465
|
-
const scope = 'lights';
|
|
466
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
467
|
-
this.#renderingEngine.lights = value;
|
|
468
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
469
|
-
this.update('lights');
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
public get maximumRenderingSize(): {
|
|
473
|
-
width: number,
|
|
474
|
-
height: number
|
|
475
|
-
} {
|
|
476
|
-
return this.#renderingEngine.maximumRenderingSize;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
public set maximumRenderingSize(value: {
|
|
480
|
-
width: number,
|
|
481
|
-
height: number
|
|
482
|
-
}) {
|
|
483
|
-
const scope = 'maximumRenderingSize';
|
|
484
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'object');
|
|
485
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value.width, 'number');
|
|
486
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value.height, 'number');
|
|
487
|
-
this.#renderingEngine.maximumRenderingSize = value;
|
|
488
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
489
|
-
this.update('maximumRenderingSize');
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
public get outputEncoding(): TEXTURE_ENCODING {
|
|
493
|
-
return this.#renderingEngine.outputEncoding;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
public set outputEncoding(value: TEXTURE_ENCODING) {
|
|
497
|
-
const scope = 'outputEncoding';
|
|
498
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'enum', true, Object.values(TEXTURE_ENCODING));
|
|
499
|
-
this.#renderingEngine.outputEncoding = value;
|
|
500
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
501
|
-
this.update('outputEncoding');
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
public get physicallyCorrectLights(): boolean {
|
|
505
|
-
return this.#renderingEngine.physicallyCorrectLights;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
public set physicallyCorrectLights(value: boolean) {
|
|
509
|
-
const scope = 'physicallyCorrectLights';
|
|
510
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
511
|
-
this.#renderingEngine.physicallyCorrectLights = value;
|
|
512
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
513
|
-
this.update('physicallyCorrectLights');
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
public get pointSize(): number {
|
|
517
|
-
return this.#renderingEngine.pointSize;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
public set pointSize(value: number) {
|
|
521
|
-
const scope = 'pointSize';
|
|
522
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'number');
|
|
523
|
-
this.#renderingEngine.pointSize = value;
|
|
524
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
525
|
-
this.update('pointSize');
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
public get postProcessing(): IPostProcessingApi {
|
|
529
|
-
return this.#postProcessing;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
public get postRenderingCallback(): ((renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => void) | undefined {
|
|
533
|
-
return this.#renderingEngine.postRenderingCallback;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
public set postRenderingCallback(value: ((renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => void) | undefined) {
|
|
537
|
-
const scope = 'postRenderingCallback';
|
|
538
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'function', false);
|
|
539
|
-
this.#renderingEngine.postRenderingCallback = value;
|
|
540
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
541
|
-
this.update('postRenderingCallback');
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
public get preRenderingCallback(): ((renderer: THREE.WebGLRenderer) => void) | undefined {
|
|
545
|
-
return this.#renderingEngine.preRenderingCallback;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
public set preRenderingCallback(value: ((renderer: THREE.WebGLRenderer) => void) | undefined) {
|
|
549
|
-
const scope = 'preRenderingCallback';
|
|
550
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'function', false);
|
|
551
|
-
this.#renderingEngine.preRenderingCallback = value;
|
|
552
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
553
|
-
this.update('preRenderingCallback');
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
public get sessionSettingsId(): string | undefined {
|
|
557
|
-
return this.#renderingEngine.sessionSettingsId;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
public get sessionSettingsMode(): SESSION_SETTINGS_MODE {
|
|
561
|
-
return this.#renderingEngine.sessionSettingsMode;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
public get shadows(): boolean {
|
|
565
|
-
return this.#renderingEngine.shadows;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
public set shadows(value: boolean) {
|
|
569
|
-
const scope = 'shadows';
|
|
570
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
571
|
-
this.#renderingEngine.shadows = value;
|
|
572
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
573
|
-
this.update('shadows');
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
public get show(): boolean {
|
|
577
|
-
return this.#renderingEngine.show;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
public set show(value: boolean) {
|
|
581
|
-
const scope = 'show';
|
|
582
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
583
|
-
this.#renderingEngine.show = value;
|
|
584
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
585
|
-
this.update('show');
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
public get showStatistics(): boolean {
|
|
589
|
-
return this.#renderingEngine.showStatistics;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
public set showStatistics(value: boolean) {
|
|
593
|
-
const scope = 'showStatistics';
|
|
594
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
595
|
-
this.#renderingEngine.showStatistics = value;
|
|
596
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
597
|
-
this.update('showStatistics');
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
public get softShadows(): boolean {
|
|
601
|
-
return this.#renderingEngine.softShadows;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
public set softShadows(value: boolean) {
|
|
605
|
-
const scope = 'softShadows';
|
|
606
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'boolean');
|
|
607
|
-
this.#renderingEngine.softShadows = value;
|
|
608
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
609
|
-
this.update('softShadows');
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
public get textureEncoding(): TEXTURE_ENCODING {
|
|
613
|
-
return this.#renderingEngine.textureEncoding;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
public set textureEncoding(value: TEXTURE_ENCODING) {
|
|
617
|
-
const scope = 'textureEncoding';
|
|
618
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'enum', true, Object.values(TEXTURE_ENCODING));
|
|
619
|
-
this.#renderingEngine.textureEncoding = value;
|
|
620
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
621
|
-
this.update('textureEncoding');
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
public get threeJsCoreObjects(): {
|
|
625
|
-
scene: THREE.Scene,
|
|
626
|
-
renderer: THREE.WebGLRenderer,
|
|
627
|
-
camera: THREE.Camera
|
|
628
|
-
} {
|
|
629
|
-
return {
|
|
630
|
-
scene: this.#renderingEngine.sceneTreeManager.scene,
|
|
631
|
-
renderer: this.#renderingEngine.renderer,
|
|
632
|
-
camera: this.#renderingEngine.cameraManager.camera
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
public get toneMapping(): TONE_MAPPING {
|
|
637
|
-
return this.#renderingEngine.toneMapping;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
public set toneMapping(value: TONE_MAPPING) {
|
|
641
|
-
const scope = 'toneMapping';
|
|
642
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'enum', true, Object.values(TONE_MAPPING));
|
|
643
|
-
this.#renderingEngine.toneMapping = value;
|
|
644
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
645
|
-
this.update('toneMapping');
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
public get toneMappingExposure(): number {
|
|
649
|
-
return this.#renderingEngine.toneMappingExposure;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
public set toneMappingExposure(value: number) {
|
|
653
|
-
const scope = 'toneMappingExposure';
|
|
654
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'number');
|
|
655
|
-
this.#renderingEngine.toneMappingExposure = value;
|
|
656
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
657
|
-
this.update('toneMappingExposure');
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
public get type(): RENDERER_TYPE {
|
|
661
|
-
return this.#renderingEngine.type;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
public set type(value: RENDERER_TYPE) {
|
|
665
|
-
const scope = 'type';
|
|
666
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'enum', true, Object.values(RENDERER_TYPE));
|
|
667
|
-
this.#renderingEngine.type = value;
|
|
668
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
669
|
-
this.update('type');
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
public get visualizeAttributes(): ((overview: ISDTFOverview, itemData?: ISDTFItemData) => ISDTFAttributeVisualizationData) | undefined {
|
|
673
|
-
return this.#renderingEngine.visualizeAttributes;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
public set visualizeAttributes(value: ((overview: ISDTFOverview, itemData?: ISDTFItemData) => ISDTFAttributeVisualizationData) | undefined) {
|
|
677
|
-
const scope = 'visualizeAttributes';
|
|
678
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'function', false);
|
|
679
|
-
this.#renderingEngine.visualizeAttributes = value;
|
|
680
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
681
|
-
this.render();
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// #endregion Public Getters And Setters (94)
|
|
685
|
-
|
|
686
|
-
// #region Public Methods (41)
|
|
687
|
-
|
|
688
|
-
public addCanvasEventListener(listener: IDomEventListener): string {
|
|
689
|
-
const scope = 'addCanvasEventListener';
|
|
690
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, listener, 'object');
|
|
691
|
-
return this.#renderingEngine.domEventEngine.addDomEventListener(listener);
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
public addFlag(flag: FLAG_TYPE): string {
|
|
695
|
-
const scope = 'addFlag';
|
|
696
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, flag, 'enum', true, Object.values(FLAG_TYPE));
|
|
697
|
-
const token = this.#renderingEngine.addFlag(flag);
|
|
698
|
-
return token;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
public addRestrictedCanvasListenerToken(token: string): void {
|
|
702
|
-
this.#renderingEngine.domEventEngine.addRestrictedListenerToken(token);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
public applyViewportSettings(settings: ISettings, sections?: { ar?: boolean | undefined; scene?: boolean | undefined; camera?: boolean | undefined; light?: boolean | undefined; environment?: boolean | undefined; general?: boolean | undefined; postprocessing?: boolean | undefined }) {
|
|
706
|
-
const scope = 'applyViewportSettings';
|
|
707
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, settings, 'object');
|
|
708
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, sections, 'object', false);
|
|
709
|
-
return this.#creationControlCenterViewport.applyViewportSettings(this.id, settings, sections);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
public assignCamera(id: string): boolean {
|
|
713
|
-
const scope = 'assignCamera';
|
|
714
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, id, 'string');
|
|
715
|
-
const check = this.#renderingEngine.cameraEngine.assignCamera(id);
|
|
716
|
-
this.update('assignCamera');
|
|
717
|
-
return check;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
public assignLightScene(id: string): boolean {
|
|
721
|
-
const scope = 'assignLightScene';
|
|
722
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, id, 'string');
|
|
723
|
-
const check = this.#renderingEngine.lightEngine.assignLightScene(id);
|
|
724
|
-
this.update('assignLightScene');
|
|
725
|
-
return check;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
public async close(): Promise<void> {
|
|
729
|
-
return await this.#creationControlCenterViewport.closeViewportEngine(this.id);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
public continueRendering(): void {
|
|
733
|
-
this.#renderingEngine.continueRendering();
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
public convert3Dto2D(p: vec3): { container: vec2; client: vec2; page: vec2; hidden: boolean; } {
|
|
737
|
-
const scope = 'convert3Dto2D';
|
|
738
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, p, 'vec3');
|
|
739
|
-
return this.#renderingEngine.convert3Dto2D(p);
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
public async convertToGlTF(node: ITreeNode = sceneTree.root, convertForAr: boolean = false): Promise<Blob> {
|
|
743
|
-
const scope = 'convertToGlTF';
|
|
744
|
-
if (!(node instanceof TreeNode))
|
|
745
|
-
throw new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${node} is not of type node.`, node, 'node');
|
|
746
|
-
|
|
747
|
-
this.update('convertToGlTF.start');
|
|
748
|
-
const result = await this.#gltfConverter.convert(node, convertForAr, this.id);
|
|
749
|
-
this.update('convertToGlTF.end');
|
|
750
|
-
return new Blob([result], { type: 'application/octet-stream' });
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
public async createArSessionLink(node?: ITreeNode, qrCode: boolean = true, fallbackUrl?: string): Promise<string> {
|
|
754
|
-
const scope = 'createArSessionLink';
|
|
755
|
-
if (node && !(node instanceof TreeNode))
|
|
756
|
-
throw new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${node} is not of type node.`, node, 'node');
|
|
757
|
-
|
|
758
|
-
let sessionEngineId: string | undefined = undefined;
|
|
759
|
-
for (const s in this.#stateEngine.sessionEngines) {
|
|
760
|
-
const state = this.#stateEngine.sessionEngines[s];
|
|
761
|
-
if (state !== undefined && state.canUploadGLTF) {
|
|
762
|
-
sessionEngineId = s;
|
|
763
|
-
break;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
if (!sessionEngineId)
|
|
768
|
-
throw new ShapeDiverViewerArError('ViewportApi.createArSessionLink: None of the sessions that are registered are capable of using the AR feature.');
|
|
769
|
-
|
|
770
|
-
const targetNode = node || sceneTree.root;
|
|
771
|
-
|
|
772
|
-
const scalingMatrix: mat4 = mat4.fromScaling(mat4.create(), this.arScale);
|
|
773
|
-
|
|
774
|
-
// add scaling matrix to scene tree node
|
|
775
|
-
targetNode.transformations.push({ id: 'ar_scaling', matrix: scalingMatrix });
|
|
776
|
-
|
|
777
|
-
// create the gltf
|
|
778
|
-
this.update('createArSessionLink.start');
|
|
779
|
-
const blob = await this.#gltfConverter.convert(targetNode, true, this.id);
|
|
780
|
-
|
|
781
|
-
// remove scaling the matrix
|
|
782
|
-
for (let i = 0; i < targetNode.transformations.length; i++)
|
|
783
|
-
if (targetNode.transformations[i].id === 'ar_scaling')
|
|
784
|
-
targetNode.transformations.splice(i, 1);
|
|
785
|
-
|
|
786
|
-
this.update('createArSessionLink.end');
|
|
787
|
-
|
|
788
|
-
const response = await this.#stateEngine.sessionEngines[sessionEngineId!]?.uploadGLTF(new Blob([blob], { type: 'application/octet-stream' }), ShapeDiverRequestGltfUploadQueryConversion.SCENE);
|
|
789
|
-
|
|
790
|
-
const backends: {
|
|
791
|
-
[key: string]: string
|
|
792
|
-
} = {
|
|
793
|
-
'sddev3': 'https://sddev3.eu-central-1.shapediver.com',
|
|
794
|
-
'sddev2': 'https://sddev2.eu-central-1.shapediver.com',
|
|
795
|
-
'sddev': 'https://sddev.eu-central-1.shapediver.com',
|
|
796
|
-
'sdtest': 'https://sdtest.us-east-1.shapediver.com',
|
|
797
|
-
'sdeuc1': 'https://sdeuc1.eu-central-1.shapediver.com',
|
|
798
|
-
'sdr7euc1': 'https://sdr7euc1.eu-central-1.shapediver.com',
|
|
799
|
-
'sduse1': 'https://model-view.shapediver.com',
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
let backendIdentifier = Object.keys(backends).find((key: string) => backends[key] === this.#stateEngine.sessionEngines[sessionEngineId!]?.modelViewUrl);
|
|
803
|
-
if (!backendIdentifier) {
|
|
804
|
-
const modelViewUrl = this.#stateEngine.sessionEngines[sessionEngineId!]?.modelViewUrl;
|
|
805
|
-
backendIdentifier = modelViewUrl?.replace('https://', '').replace('.shapediver.com', '');
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
const fallbackQueryParameter = fallbackUrl ? `fb=${encodeURIComponent(fallbackUrl)}&` : '';
|
|
809
|
-
|
|
810
|
-
if (!response || !response.gltf || !response.gltf.sceneId)
|
|
811
|
-
throw new ShapeDiverViewerArError('ViewportApi.createArSessionLink: There was an unexpected error with the ar scene response. Please contact us if this happens again.');
|
|
812
|
-
|
|
813
|
-
const sceneId = response.gltf!.sceneId!;
|
|
814
|
-
|
|
815
|
-
const link = `https://viewer.shapediver.com/v3/${build_data.build_version.replace('3.', '')}/ar.html?${fallbackQueryParameter}b=${encodeURIComponent(backendIdentifier!)}&id=${encodeURIComponent(sceneId)}`;
|
|
816
|
-
if (qrCode === false) {
|
|
817
|
-
return link;
|
|
818
|
-
} else {
|
|
819
|
-
const qrCodeLink = await new Promise<string>((resolve, reject) => {
|
|
820
|
-
QRCode.toDataURL(link,
|
|
821
|
-
(error: Error | null | undefined, url: string) => {
|
|
822
|
-
if (error) {
|
|
823
|
-
reject(error);
|
|
824
|
-
} else {
|
|
825
|
-
resolve(url);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
);
|
|
829
|
-
});
|
|
830
|
-
return qrCodeLink;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
public createLightScene(properties?: { name?: string | undefined; standard?: boolean | undefined; }): ILightSceneApi {
|
|
835
|
-
const scope = 'createLightScene';
|
|
836
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, properties, 'object', false);
|
|
837
|
-
const prop = Object.assign({}, properties);
|
|
838
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, prop.name, 'string', false);
|
|
839
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, prop.standard, 'boolean', false);
|
|
840
|
-
const lightScene = this.#renderingEngine.lightEngine.createLightScene(properties || {});
|
|
841
|
-
this.update('createLightScene');
|
|
842
|
-
return this.#lightScenes[lightScene.id];
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
public createOrthographicCamera(id?: string): IOrthographicCameraApi {
|
|
846
|
-
const scope = 'createOrthographicCamera';
|
|
847
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, id, 'string', false);
|
|
848
|
-
const camera = this.#renderingEngine.cameraEngine.createCamera(CAMERA_TYPE.ORTHOGRAPHIC, id);
|
|
849
|
-
this.update('createOrthographicCamera');
|
|
850
|
-
return <IOrthographicCameraApi>this.#cameras[camera.id];
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
public createPerspectiveCamera(id?: string): IPerspectiveCameraApi {
|
|
854
|
-
const scope = 'createPerspectiveCamera';
|
|
855
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, id, 'string', false);
|
|
856
|
-
const camera = this.#renderingEngine.cameraEngine.createCamera(CAMERA_TYPE.PERSPECTIVE, id);
|
|
857
|
-
this.update('createPerspectiveCamera');
|
|
858
|
-
return <IPerspectiveCameraApi>this.#cameras[camera.id];
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
public createSDTFOverview(node: ITreeNode): ISDTFOverview {
|
|
862
|
-
const scope = 'createSDTFOverview';
|
|
863
|
-
if (!(node instanceof TreeNode))
|
|
864
|
-
throw new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${node} is not of type node.`, node, 'node');
|
|
865
|
-
|
|
866
|
-
this.update('createSDTFOverview');
|
|
867
|
-
return this.#renderingEngine.createSDTFOverview(node);
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
public displayErrorMessage(message: string): void {
|
|
871
|
-
const scope = 'displayErrorMessage';
|
|
872
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, message, 'string');
|
|
873
|
-
this.#renderingEngine.displayErrorMessage(message);
|
|
874
|
-
this.update('displayErrorMessage');
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
public getEnvironmentMapImageUrl(): string {
|
|
878
|
-
return this.#renderingEngine.getEnvironmentMapImageUrl();
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
public getScreenshot(type?: string, quality?: number): string {
|
|
882
|
-
const scope = 'getScreenshot';
|
|
883
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, type, 'string', false);
|
|
884
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, quality, 'number', false);
|
|
885
|
-
this.update('getScreenshot');
|
|
886
|
-
return this.#renderingEngine.getScreenshot(type, quality);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
public getViewportSettings(): ISettings {
|
|
890
|
-
return this.#creationControlCenterViewport.getViewportSettings(this.id);
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
public isMobileDeviceWithoutBrowserARSupport(): boolean {
|
|
894
|
-
return this.#renderingEngine.isMobileDeviceWithoutBrowserARSupport();
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
public pauseRendering(): void {
|
|
898
|
-
this.#renderingEngine.pauseRendering();
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
public pointerEventToRay(event: PointerEvent): { origin: vec3; direction: vec3; } {
|
|
902
|
-
return this.#renderingEngine.pointerEventToRay(event);
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
public raytraceScene(origin: vec3, direction: vec3): { distance: number, node: ITreeNode, data?: IGeometryData; }[] {
|
|
906
|
-
const scope = 'raytraceScene';
|
|
907
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, origin, 'vec3');
|
|
908
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, direction, 'vec3');
|
|
909
|
-
return this.#renderingEngine.raytraceScene(origin, direction);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
public removeCamera(id: string): boolean {
|
|
913
|
-
const scope = 'removeCamera';
|
|
914
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, id, 'string');
|
|
915
|
-
const check = this.#renderingEngine.cameraEngine.removeCamera(id);
|
|
916
|
-
this.update('removeCamera');
|
|
917
|
-
return check;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
public removeCanvasEventListener(token: string): boolean {
|
|
921
|
-
const scope = 'removeCanvasEventListener';
|
|
922
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, token, 'string');
|
|
923
|
-
const check = this.#renderingEngine.domEventEngine.removeDomEventListener(token);
|
|
924
|
-
return check;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
public removeFlag(token: string): boolean {
|
|
928
|
-
const scope = 'removeFlag';
|
|
929
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, token, 'string');
|
|
930
|
-
const check = this.#renderingEngine.removeFlag(token);
|
|
931
|
-
return check;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
public removeLightScene(id: string): boolean {
|
|
935
|
-
const scope = 'removeLightScene';
|
|
936
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, id, 'string');
|
|
937
|
-
const check = this.#renderingEngine.lightEngine.removeLightScene(id);
|
|
938
|
-
this.update('removeLightScene');
|
|
939
|
-
return check;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
public removeRestrictedCanvasListenerToken(token: string): void {
|
|
943
|
-
this.#renderingEngine.domEventEngine.removeRestrictedListenerToken(token);
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
public render(): void {
|
|
947
|
-
this.#renderingEngine.renderingManager.render();
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
public resetToDefaultCameras(): void {
|
|
951
|
-
for (const c in this.cameras)
|
|
952
|
-
this.#renderingEngine.cameraEngine.removeCamera(c);
|
|
953
|
-
this.#renderingEngine.cameraEngine.createDefaultCameras();
|
|
954
|
-
this.update('resetToDefaultCameras');
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
public resize(width: number, height: number): void {
|
|
958
|
-
const scope = 'resize';
|
|
959
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, width, 'number');
|
|
960
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, height, 'number');
|
|
961
|
-
this.#renderingEngine.resize(width, height);
|
|
962
|
-
this.update('resize');
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
public restrictEventListeners(allowedListeners: {
|
|
966
|
-
mousewheel?: boolean,
|
|
967
|
-
pointerdown?: boolean,
|
|
968
|
-
pointermove?: boolean,
|
|
969
|
-
pointerup?: boolean,
|
|
970
|
-
pointerout?: boolean,
|
|
971
|
-
keydown?: boolean,
|
|
972
|
-
keyup?: boolean,
|
|
973
|
-
contextmenu?: boolean,
|
|
974
|
-
}) {
|
|
975
|
-
this.#renderingEngine.domEventEngine.allowEventListeners(allowedListeners);
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
public update(id?: string): void {
|
|
979
|
-
this.#renderingEngine.update(id || 'ViewportApi');
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
public updateDefaultLineMaterial(value: MaterialBasicLineData) {
|
|
983
|
-
const scope = 'updateDefaultLineMaterial';
|
|
984
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'object');
|
|
985
|
-
this.#renderingEngine.defaultLineMaterial = value;
|
|
986
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
987
|
-
this.update('updateDefaultLineMaterial');
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
public updateDefaultMaterial(value: MaterialStandardData) {
|
|
991
|
-
const scope = 'updateDefaultMaterial';
|
|
992
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'object');
|
|
993
|
-
this.#renderingEngine.defaultMaterial = value;
|
|
994
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
995
|
-
this.update('updateDefaultMaterial');
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
public updateDefaultPointMaterial(value: MaterialPointData) {
|
|
999
|
-
const scope = 'updateDefaultPointMaterial';
|
|
1000
|
-
this.#inputValidator.validateAndError(`ViewportApi.${scope}`, value, 'object');
|
|
1001
|
-
this.#renderingEngine.defaultPointMaterial = value;
|
|
1002
|
-
this.#logger.debug(`ViewportApi.${scope}: ${scope} was set to: ${value}`);
|
|
1003
|
-
this.update('updateDefaultPointMaterial');
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
public updateEnvironmentGeometry(): void {
|
|
1007
|
-
this.#renderingEngine.updateEnvironmentGeometry();
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
public updateNode(node: ITreeNode): void {
|
|
1011
|
-
const scope = 'updateNode';
|
|
1012
|
-
if (!(node instanceof TreeNode))
|
|
1013
|
-
throw new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${node} is not of type node.`, node, 'node');
|
|
1014
|
-
|
|
1015
|
-
this.#renderingEngine.sceneTreeManager.updateNode(node, node.convertedObject[this.id] as THREE.Object3D);
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
public updateNodeTransformation(node: ITreeNode): void {
|
|
1019
|
-
const scope = 'updateNodeTransformation';
|
|
1020
|
-
if (!(node instanceof TreeNode))
|
|
1021
|
-
throw new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${node} is not of type node.`, node, 'node');
|
|
1022
|
-
|
|
1023
|
-
this.#renderingEngine.sceneTreeManager.updateNode(node, node.convertedObject[this.id] as THREE.Object3D, { transformationOnly: true });
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
public async viewInAR(node?: ITreeNode): Promise<void> {
|
|
1027
|
-
const scope = 'viewInAR';
|
|
1028
|
-
if (node && !(node instanceof TreeNode))
|
|
1029
|
-
throw new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${node} is not of type node.`, node, 'node');
|
|
1030
|
-
|
|
1031
|
-
let sessionEngineId: string | undefined = undefined;
|
|
1032
|
-
for (const s in this.#stateEngine.sessionEngines) {
|
|
1033
|
-
const state = this.#stateEngine.sessionEngines[s];
|
|
1034
|
-
if (state !== undefined && state.canUploadGLTF) {
|
|
1035
|
-
sessionEngineId = s;
|
|
1036
|
-
break;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
if (!sessionEngineId)
|
|
1041
|
-
throw new ShapeDiverViewerArError('Api.viewInAR: None of the sessions that are registered are capable of using the AR feature.');
|
|
1042
|
-
|
|
1043
|
-
const targetNode = node || sceneTree.root;
|
|
1044
|
-
|
|
1045
|
-
const scalingMatrix: mat4 = mat4.fromScaling(mat4.create(), this.arScale);
|
|
1046
|
-
|
|
1047
|
-
// add scaling matrix to scene tree node
|
|
1048
|
-
targetNode.transformations.push({ id: 'ar_scaling', matrix: scalingMatrix });
|
|
1049
|
-
|
|
1050
|
-
// create the gltf
|
|
1051
|
-
this.update('viewInAR.start');
|
|
1052
|
-
const blob = await this.#gltfConverter.convert(targetNode, true, this.id);
|
|
1053
|
-
|
|
1054
|
-
// remove scaling the matrix
|
|
1055
|
-
for (let i = 0; i < targetNode.transformations.length; i++)
|
|
1056
|
-
if (targetNode.transformations[i].id === 'ar_scaling')
|
|
1057
|
-
targetNode.transformations.splice(i, 1);
|
|
1058
|
-
|
|
1059
|
-
this.update('viewInAR.end');
|
|
1060
|
-
|
|
1061
|
-
const response = await this.#stateEngine.sessionEngines[sessionEngineId!]?.uploadGLTF(new Blob([blob], { type: 'application/octet-stream' }), this.#systemInfo.isIOS ? ShapeDiverRequestGltfUploadQueryConversion.USDZ : ShapeDiverRequestGltfUploadQueryConversion.NONE);
|
|
1062
|
-
const href = response?.gltf?.href;
|
|
1063
|
-
if (href) this.#renderingEngine.viewInAR(href);
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
public viewableInAR(): boolean {
|
|
1067
|
-
return this.#renderingEngine.viewableInAR();
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
// #endregion Public Methods (41)
|
|
1071
|
-
}
|