@shapediver/viewer.viewport 3.16.7 → 3.16.9
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/implementation/PostProcessingApi.d.ts +37 -37
- package/dist/implementation/PostProcessingApi.js +149 -149
- package/dist/implementation/PostProcessingApi.js.map +1 -1
- package/dist/implementation/ViewportApi.d.ts +217 -217
- package/dist/implementation/ViewportApi.js +1003 -993
- package/dist/implementation/ViewportApi.js.map +1 -1
- package/dist/implementation/camera/AbstractCameraApi.d.ts +140 -140
- package/dist/implementation/camera/AbstractCameraApi.js +478 -478
- package/dist/implementation/camera/AbstractCameraApi.js.map +1 -1
- package/dist/implementation/camera/OrthographicCameraApi.d.ts +10 -10
- package/dist/implementation/camera/OrthographicCameraApi.js +47 -47
- package/dist/implementation/camera/OrthographicCameraApi.js.map +1 -1
- package/dist/implementation/camera/PerspectiveCameraApi.d.ts +10 -10
- package/dist/implementation/camera/PerspectiveCameraApi.js +46 -46
- package/dist/implementation/camera/PerspectiveCameraApi.js.map +1 -1
- package/dist/implementation/lights/AbstractLightApi.d.ts +19 -19
- package/dist/implementation/lights/AbstractLightApi.js +80 -80
- package/dist/implementation/lights/AbstractLightApi.js.map +1 -1
- package/dist/implementation/lights/LightSceneApi.d.ts +68 -68
- package/dist/implementation/lights/LightSceneApi.js +171 -171
- package/dist/implementation/lights/LightSceneApi.js.map +1 -1
- package/dist/implementation/lights/types/AmbientLightApi.d.ts +8 -8
- package/dist/implementation/lights/types/AmbientLightApi.js +26 -26
- package/dist/implementation/lights/types/AmbientLightApi.js.map +1 -1
- package/dist/implementation/lights/types/DirectionalLightApi.d.ts +17 -17
- package/dist/implementation/lights/types/DirectionalLightApi.js +76 -76
- package/dist/implementation/lights/types/DirectionalLightApi.js.map +1 -1
- package/dist/implementation/lights/types/HemisphereLightApi.d.ts +11 -11
- package/dist/implementation/lights/types/HemisphereLightApi.js +46 -46
- package/dist/implementation/lights/types/HemisphereLightApi.js.map +1 -1
- package/dist/implementation/lights/types/PointLightApi.d.ts +15 -15
- package/dist/implementation/lights/types/PointLightApi.js +66 -66
- package/dist/implementation/lights/types/PointLightApi.js.map +1 -1
- package/dist/implementation/lights/types/SpotLightApi.d.ts +21 -21
- package/dist/implementation/lights/types/SpotLightApi.js +96 -96
- package/dist/implementation/lights/types/SpotLightApi.js.map +1 -1
- package/dist/index.d.ts +52 -52
- package/dist/index.js +189 -189
- package/dist/interfaces/IPostProcessingApi.d.ts +183 -183
- package/dist/interfaces/IPostProcessingApi.js +2 -2
- package/dist/interfaces/IViewportApi.d.ts +699 -699
- package/dist/interfaces/IViewportApi.js +2 -2
- package/dist/interfaces/camera/ICameraApi.d.ts +256 -256
- package/dist/interfaces/camera/ICameraApi.js +2 -2
- package/dist/interfaces/camera/IOrthographicCameraApi.d.ts +13 -13
- package/dist/interfaces/camera/IOrthographicCameraApi.js +2 -2
- package/dist/interfaces/camera/IPerspectiveCameraApi.d.ts +12 -12
- package/dist/interfaces/camera/IPerspectiveCameraApi.js +2 -2
- package/dist/interfaces/lights/ILightApi.d.ts +35 -35
- package/dist/interfaces/lights/ILightApi.js +2 -2
- package/dist/interfaces/lights/ILightSceneApi.d.ts +138 -138
- package/dist/interfaces/lights/ILightSceneApi.js +2 -2
- package/dist/interfaces/lights/types/IAmbientLightApi.d.ts +6 -6
- package/dist/interfaces/lights/types/IAmbientLightApi.d.ts.map +1 -1
- package/dist/interfaces/lights/types/IAmbientLightApi.js +2 -2
- package/dist/interfaces/lights/types/IDirectionalLightApi.d.ts +24 -24
- package/dist/interfaces/lights/types/IDirectionalLightApi.js +2 -2
- package/dist/interfaces/lights/types/IHemisphereLightApi.d.ts +12 -12
- package/dist/interfaces/lights/types/IHemisphereLightApi.js +2 -2
- package/dist/interfaces/lights/types/IPointLightApi.d.ts +20 -20
- package/dist/interfaces/lights/types/IPointLightApi.js +2 -2
- package/dist/interfaces/lights/types/ISpotLightApi.d.ts +32 -32
- package/dist/interfaces/lights/types/ISpotLightApi.js +2 -2
- package/dist/main.d.ts +30 -30
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +91 -91
- package/dist/main.js.map +1 -1
- package/package.json +20 -20
|
@@ -1,700 +1,700 @@
|
|
|
1
|
-
import { OrthographicCameraProperties, PerspectiveCameraProperties } from "@shapediver/viewer.rendering-engine.camera-engine";
|
|
2
|
-
import { IConvert3Dto2DResult } from "@shapediver/viewer.rendering-engine.rendering-engine";
|
|
3
|
-
import { ISettings } from "@shapediver/viewer.settings";
|
|
4
|
-
import { ITreeNode, MaterialBasicLineData, MaterialPointData, MaterialStandardData } from "@shapediver/viewer.shared.node-tree";
|
|
5
|
-
import { IDomEventListener, SESSION_SETTINGS_MODE } from "@shapediver/viewer.shared.services";
|
|
6
|
-
import { Color, FLAG_TYPE, IAnimationData, IGeometryData, IIntersectionFilter, ISDTFAttributeVisualizationData, ISDTFItemData, ISDTFOverview, MATERIAL_TYPE, RENDERER_TYPE, TEXTURE_ENCODING, TONE_MAPPING } from "@shapediver/viewer.shared.types";
|
|
7
|
-
import { quat, vec3 } from "gl-matrix";
|
|
8
|
-
import * as THREE from "three";
|
|
9
|
-
import { ICameraApi } from "./camera/ICameraApi";
|
|
10
|
-
import { IOrthographicCameraApi } from "./camera/IOrthographicCameraApi";
|
|
11
|
-
import { IPerspectiveCameraApi } from "./camera/IPerspectiveCameraApi";
|
|
12
|
-
import { IPostProcessingApi } from "./IPostProcessingApi";
|
|
13
|
-
import { ILightSceneApi } from "./lights/ILightSceneApi";
|
|
14
|
-
/**
|
|
15
|
-
* The api for viewports.
|
|
16
|
-
*
|
|
17
|
-
* Viewports are created by calling the {@link createViewport} method.
|
|
18
|
-
*
|
|
19
|
-
* Each viewport has corresponding [cameras]{@link ICameraApi} and [lights]{@link ILightApi}.
|
|
20
|
-
*
|
|
21
|
-
* Additionally, there are various other settings to adjust the behavior and rendering of the viewport.
|
|
22
|
-
*
|
|
23
|
-
* By default a new viewport displays the complete scene tree. Viewports can be excluded from
|
|
24
|
-
* displaying geometry for specific sessions by using the {@link excludeViewports} property of
|
|
25
|
-
* {@link ISessionApi}.
|
|
26
|
-
*/
|
|
27
|
-
export interface IViewportApi {
|
|
28
|
-
/**
|
|
29
|
-
* A dictionary of all animations that are currently present in the parts of
|
|
30
|
-
* the scene tree relevant to this viewport.
|
|
31
|
-
*/
|
|
32
|
-
readonly animations: {
|
|
33
|
-
[key: string]: IAnimationData;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The current [camera]{@link ICameraApi}.
|
|
37
|
-
*/
|
|
38
|
-
readonly camera: ICameraApi | null;
|
|
39
|
-
/**
|
|
40
|
-
* The [cameras]{@link ICameraApi} of the viewport.
|
|
41
|
-
*/
|
|
42
|
-
readonly cameras: {
|
|
43
|
-
[key: string]: ICameraApi;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The canvas that is used to render the viewport.
|
|
47
|
-
*/
|
|
48
|
-
readonly canvas: HTMLCanvasElement;
|
|
49
|
-
/**
|
|
50
|
-
* The default line material that is used for line geometry without a specified material.
|
|
51
|
-
* Please use {@link updateDefaultLineMaterial} to update the material.
|
|
52
|
-
*/
|
|
53
|
-
readonly defaultLineMaterial: MaterialBasicLineData;
|
|
54
|
-
/**
|
|
55
|
-
* The default material that is used for geometry without a specified material.
|
|
56
|
-
* Please use {@link updateDefaultMaterial} to update the material.
|
|
57
|
-
*/
|
|
58
|
-
readonly defaultMaterial: MaterialStandardData;
|
|
59
|
-
/**
|
|
60
|
-
* The default point material that is used for point geometry without a specified material.
|
|
61
|
-
* Please use {@link updateDefaultPointMaterial} to update the material.
|
|
62
|
-
*/
|
|
63
|
-
readonly defaultPointMaterial: MaterialPointData;
|
|
64
|
-
/**
|
|
65
|
-
* The id of the viewport.
|
|
66
|
-
*/
|
|
67
|
-
readonly id: string;
|
|
68
|
-
/**
|
|
69
|
-
* If the viewer is currently busy.
|
|
70
|
-
* This is set by the viewer [addFlag]{@link addFlag} and [removeFlag]{@link removeFlag} methods.
|
|
71
|
-
*/
|
|
72
|
-
readonly isBusy: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* The current [light scene]{@link ILightSceneApi}.
|
|
75
|
-
*/
|
|
76
|
-
readonly lightScene: ILightSceneApi | null;
|
|
77
|
-
/**
|
|
78
|
-
* The [light scenes]{@link ILightSceneApi} of the viewport.
|
|
79
|
-
*/
|
|
80
|
-
readonly lightScenes: {
|
|
81
|
-
[key: string]: ILightSceneApi;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* The [post processing api]{@link IPostProcessingApi} of the viewport.
|
|
85
|
-
*
|
|
86
|
-
* Note: The post-processing API is still WIP. Breaking changes are to be expected.
|
|
87
|
-
*/
|
|
88
|
-
readonly postProcessing: IPostProcessingApi;
|
|
89
|
-
/**
|
|
90
|
-
* Optional identifier of the session to be used for loading / persisting settings of the viewport.
|
|
91
|
-
* This is ignored in case {@link sessionSettingsMode} is not {@link SESSION_SETTINGS_MODE.MANUAL}.
|
|
92
|
-
*/
|
|
93
|
-
readonly sessionSettingsId?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Allows to control which session to use for loading / persisting settings of the viewport.
|
|
96
|
-
* (default: {@link SESSION_SETTINGS_MODE.FIRST}).
|
|
97
|
-
* @see {@link sessionSettingsId}
|
|
98
|
-
*/
|
|
99
|
-
readonly sessionSettingsMode?: SESSION_SETTINGS_MODE;
|
|
100
|
-
/**
|
|
101
|
-
* The rotation factor that is used when exporting the scene for AR (Augmented Reality). The unit system used by AR is meter.
|
|
102
|
-
*
|
|
103
|
-
* @see {@link arScale}
|
|
104
|
-
* @see {@link arTranslation}
|
|
105
|
-
* @see {@link arRotation}
|
|
106
|
-
*/
|
|
107
|
-
arRotation: vec3;
|
|
108
|
-
/**
|
|
109
|
-
* The scaling factor that is used when exporting the scene for AR (Augmented Reality).
|
|
110
|
-
*
|
|
111
|
-
* The unit system used by AR is meter, therefore this scaling factor needs to be chosen
|
|
112
|
-
* such that scene coordinates are transformed to meters.
|
|
113
|
-
*
|
|
114
|
-
* @see {@link arScale}
|
|
115
|
-
* @see {@link arTranslation}
|
|
116
|
-
* @see {@link arRotation}
|
|
117
|
-
*/
|
|
118
|
-
arScale: vec3;
|
|
119
|
-
/**
|
|
120
|
-
* The translation factor that is used when exporting the scene for AR (Augmented Reality). The unit system used by AR is meter.
|
|
121
|
-
*
|
|
122
|
-
* @see {@link arScale}
|
|
123
|
-
* @see {@link arTranslation}
|
|
124
|
-
* @see {@link arRotation}
|
|
125
|
-
*/
|
|
126
|
-
arTranslation: vec3;
|
|
127
|
-
/**
|
|
128
|
-
* Option to enable / disable the automatic color space adaption. This converts all color inputs to the chosen {@link outputEncoding}. (default: true)
|
|
129
|
-
*/
|
|
130
|
-
automaticColorAdjustment: boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Option to enable / disable the automatic resizing of the viewport to changes of the {@link canvas}. (default: true)
|
|
133
|
-
*/
|
|
134
|
-
automaticResizing: boolean;
|
|
135
|
-
/**
|
|
136
|
-
* The duration used by the beauty rendering to blend in (milliseconds).
|
|
137
|
-
*/
|
|
138
|
-
beautyRenderBlendingDuration: number;
|
|
139
|
-
/**
|
|
140
|
-
* The delay after which the beauty rendering starts (milliseconds).
|
|
141
|
-
*/
|
|
142
|
-
beautyRenderDelay: number;
|
|
143
|
-
/**
|
|
144
|
-
* The clear alpha value of the viewport.
|
|
145
|
-
* Use this to influence the background appearance of the viewport.
|
|
146
|
-
*/
|
|
147
|
-
clearAlpha: number;
|
|
148
|
-
/**
|
|
149
|
-
* The clear color value of the viewport.
|
|
150
|
-
* Use this to influence the background appearance of the viewport.
|
|
151
|
-
*/
|
|
152
|
-
clearColor: Color;
|
|
153
|
-
/**
|
|
154
|
-
* The maximum percentage of height that is still considered for the creation of the contact shadow. (default: 0.25)
|
|
155
|
-
* The maximum height is equal to the width and height of the ground plane.
|
|
156
|
-
*/
|
|
157
|
-
contactShadowHeight: number;
|
|
158
|
-
/**
|
|
159
|
-
* Option to enable / disable the contact shadow. (default: false)
|
|
160
|
-
*/
|
|
161
|
-
contactShadowVisibility: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* The blur amount of the contact shadow. (default: 1.5)
|
|
164
|
-
*/
|
|
165
|
-
contactShadowBlur: number;
|
|
166
|
-
/**
|
|
167
|
-
* The darkness of the contact shadow. (default: 2.5)
|
|
168
|
-
*/
|
|
169
|
-
contactShadowDarkness: number;
|
|
170
|
-
/**
|
|
171
|
-
* The opacity of the contact shadow. (default: 1)
|
|
172
|
-
*/
|
|
173
|
-
contactShadowOpacity: number;
|
|
174
|
-
/**
|
|
175
|
-
* The color that is used when no material is specified. (default: #199b9b)
|
|
176
|
-
*/
|
|
177
|
-
defaultMaterialColor: Color;
|
|
178
|
-
/**
|
|
179
|
-
* Option to enable / disable the AR (Augmented Reality) functionality for this viewport. (default: true)
|
|
180
|
-
* This setting is used purely for UI purposes, it does not have any influence on the viewport itself.
|
|
181
|
-
*/
|
|
182
|
-
enableAR: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* The environment map used by the viewport.
|
|
185
|
-
* You can either use the HDR maps at {@link ENVIRONMENT_MAP} or the LDR legacy maps at {@link ENVIRONMENT_MAP_CUBE}.
|
|
186
|
-
* Additionally, you can specify your own maps. For HDR maps, provide a link to a .hdr file, for LDR provide the folder where the six cube map images are located.
|
|
187
|
-
*/
|
|
188
|
-
environmentMap: string | string[];
|
|
189
|
-
/**
|
|
190
|
-
* Option to set the environment map as the background of the viewport. (default: false)
|
|
191
|
-
*/
|
|
192
|
-
environmentMapAsBackground: boolean;
|
|
193
|
-
/**
|
|
194
|
-
* The amount of which the environment map is blurred. (default: 0)
|
|
195
|
-
*/
|
|
196
|
-
environmentMapBlurriness: number;
|
|
197
|
-
/**
|
|
198
|
-
* Option to set the environment map for unlit materials. (default: false)
|
|
199
|
-
* For unlit materials, which use the three.js MeshBasicMaterial, per default we don't set the environment map to keep the colors as realistic as possible.
|
|
200
|
-
*/
|
|
201
|
-
environmentMapForUnlitMaterials: boolean;
|
|
202
|
-
/**
|
|
203
|
-
* Scales how much the environment map effects the materials. (default: 1)
|
|
204
|
-
*/
|
|
205
|
-
environmentMapIntensity: number;
|
|
206
|
-
/**
|
|
207
|
-
* The environment map resolution that is used for preset cube maps.
|
|
208
|
-
* @see {@link environmentMap}
|
|
209
|
-
*/
|
|
210
|
-
environmentMapResolution: string;
|
|
211
|
-
/**
|
|
212
|
-
* The rotation quaternion that is used on the environment map. (default: [0,0,0,1])
|
|
213
|
-
*/
|
|
214
|
-
environmentMapRotation: quat;
|
|
215
|
-
/**
|
|
216
|
-
* The color of the grid.
|
|
217
|
-
*/
|
|
218
|
-
gridColor: Color;
|
|
219
|
-
/**
|
|
220
|
-
* Option to enable / disable the grid. (default: true)
|
|
221
|
-
*/
|
|
222
|
-
gridVisibility: boolean;
|
|
223
|
-
/**
|
|
224
|
-
* The color of the ground plane.
|
|
225
|
-
*/
|
|
226
|
-
groundPlaneColor: Color;
|
|
227
|
-
/**
|
|
228
|
-
* The color of the ground plane shadow.
|
|
229
|
-
*/
|
|
230
|
-
groundPlaneShadowColor: Color;
|
|
231
|
-
/**
|
|
232
|
-
* Option to enable / disable the ground plane shadow. (default: false)
|
|
233
|
-
*/
|
|
234
|
-
groundPlaneShadowVisibility: boolean;
|
|
235
|
-
/**
|
|
236
|
-
* Option to enable / disable the ground plane. (default: true)
|
|
237
|
-
*/
|
|
238
|
-
groundPlaneVisibility: boolean;
|
|
239
|
-
/**
|
|
240
|
-
* Option to enable / disable lights. (default: true)
|
|
241
|
-
*/
|
|
242
|
-
lights: boolean;
|
|
243
|
-
/**
|
|
244
|
-
* Option to load the default cameras when the viewport is created. (default: true)
|
|
245
|
-
* This will create 6 orthographic cameras (top, bottom, left, right, front, back).
|
|
246
|
-
*/
|
|
247
|
-
loadDefaultCameras: boolean;
|
|
248
|
-
/**
|
|
249
|
-
* The type of material that is used as an override for all materials in the scene.
|
|
250
|
-
* This can be used to enforce a specific material type for all materials in the scene.
|
|
251
|
-
*
|
|
252
|
-
* As point and line materials are not supported by all three.js materials, the override will be ignored for these materials.
|
|
253
|
-
*
|
|
254
|
-
* If no override is set, the materials will be used as they are.
|
|
255
|
-
*/
|
|
256
|
-
materialOverrideType: MATERIAL_TYPE | undefined;
|
|
257
|
-
/**
|
|
258
|
-
* The maximum size of the renderings. The renderings will be upscaled to the actual resolution if these values are lower than the resolution of the canvas.
|
|
259
|
-
* This setting exists, as for higher resolutions the performance can drop due to the rendering effort. (default: { width: 1920, height: 1080 })
|
|
260
|
-
*/
|
|
261
|
-
maximumRenderingSize: {
|
|
262
|
-
width: number;
|
|
263
|
-
height: number;
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* The encoding that is used for the output texture. (default: TEXTURE_ENCODING.SRGB)
|
|
267
|
-
* This is the texture that is rendered to the screen.
|
|
268
|
-
*
|
|
269
|
-
* @see {@link textureEncoding}
|
|
270
|
-
*/
|
|
271
|
-
outputEncoding: TEXTURE_ENCODING;
|
|
272
|
-
/**
|
|
273
|
-
* Option to enable / disable the physically correct lights. (default: true)
|
|
274
|
-
*/
|
|
275
|
-
physicallyCorrectLights: boolean;
|
|
276
|
-
/**
|
|
277
|
-
* The point size that is used for rendering point data.
|
|
278
|
-
*/
|
|
279
|
-
pointSize: number;
|
|
280
|
-
/**
|
|
281
|
-
* Optional callback that is called after the rendering of the scene.
|
|
282
|
-
*/
|
|
283
|
-
postRenderingCallback?: (renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => void;
|
|
284
|
-
/**
|
|
285
|
-
* Optional callback that is called before the rendering of the scene.
|
|
286
|
-
*/
|
|
287
|
-
preRenderingCallback?: (renderer: THREE.WebGLRenderer) => void;
|
|
288
|
-
/**
|
|
289
|
-
* Option to enable / disable rendering of shadows. (default: true)
|
|
290
|
-
*/
|
|
291
|
-
shadows: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* Option to show / hide the viewport.
|
|
294
|
-
* This will disable rendering, and hide the canvas behind the logo.
|
|
295
|
-
* Using this setting especially makes sense with {@link VISIBILITY_MODE.MANUAL} where you can decide at what point you first want to show the scene.
|
|
296
|
-
*/
|
|
297
|
-
show: boolean;
|
|
298
|
-
/**
|
|
299
|
-
* Option to show / hide rendering statistics overlayed to the viewport. (default: false)
|
|
300
|
-
*/
|
|
301
|
-
showStatistics: boolean;
|
|
302
|
-
/**
|
|
303
|
-
* Option if the soft shadows should be rendered when the camera is not moving. (default: true)
|
|
304
|
-
*/
|
|
305
|
-
softShadows: boolean;
|
|
306
|
-
/**
|
|
307
|
-
* The encoding that is used for textures. (default: TEXTURE_ENCODING.SRGB)
|
|
308
|
-
*
|
|
309
|
-
* @see {@link outputEncoding}
|
|
310
|
-
*/
|
|
311
|
-
textureEncoding: TEXTURE_ENCODING;
|
|
312
|
-
/**
|
|
313
|
-
* Some of the three.js core objects so that you are free to use and adjust them yourself.
|
|
314
|
-
*
|
|
315
|
-
* Please note that the camera will be replaced when you change it via the API.
|
|
316
|
-
* The same goes for the children in the scene tree that are auto-generated and properties of the renderer that are adjusted internally.
|
|
317
|
-
*/
|
|
318
|
-
threeJsCoreObjects: {
|
|
319
|
-
scene: THREE.Scene;
|
|
320
|
-
renderer: THREE.WebGLRenderer;
|
|
321
|
-
camera: THREE.Camera;
|
|
322
|
-
};
|
|
323
|
-
/**
|
|
324
|
-
* The tone mapping that is used. (default: TONE_MAPPING.NONE)
|
|
325
|
-
*/
|
|
326
|
-
toneMapping: TONE_MAPPING;
|
|
327
|
-
/**
|
|
328
|
-
* The intensity of the tone mapping.
|
|
329
|
-
*/
|
|
330
|
-
toneMappingExposure: number;
|
|
331
|
-
/**
|
|
332
|
-
* The type of rendering of this viewport.
|
|
333
|
-
*/
|
|
334
|
-
type: RENDERER_TYPE;
|
|
335
|
-
/**
|
|
336
|
-
* A possibility to visualize the attributes of the scene in any way you want.
|
|
337
|
-
* Please have a look at the {@link https://help.shapediver.com/doc/Attribute-Visualization.1856733198.html|help desk} documentation for more information.
|
|
338
|
-
*
|
|
339
|
-
* Provide a callback that transforms a {@link ISDTFItemData} to a {@link ISDTFAttributeVisualizationData}.
|
|
340
|
-
* The {@link ISDTFOverview} provides general information like min and max values for numbers or the available options for strings.
|
|
341
|
-
*/
|
|
342
|
-
visualizeAttributes: ((overview: ISDTFOverview, itemData?: ISDTFItemData) => ISDTFAttributeVisualizationData) | undefined;
|
|
343
|
-
/**
|
|
344
|
-
* Add an event listener that receives all canvas events.
|
|
345
|
-
*
|
|
346
|
-
* @param listener The listener that is called when the events occur.
|
|
347
|
-
*/
|
|
348
|
-
addCanvasEventListener(listener: IDomEventListener): string;
|
|
349
|
-
/**
|
|
350
|
-
* Add a flag for this viewport. Adding/removing flags allows to influence the render loop.
|
|
351
|
-
* If you want to stop this again call {@link removeFlag} with the returned token.
|
|
352
|
-
*/
|
|
353
|
-
addFlag(flag: FLAG_TYPE): string;
|
|
354
|
-
/**
|
|
355
|
-
* Add a token to the list of restricted canvas listener tokens.
|
|
356
|
-
* This can be used to restrict events for a viewport.
|
|
357
|
-
* Only listeners with a token in this list will receive events (if there is at least one item in the list).
|
|
358
|
-
*
|
|
359
|
-
* @param token
|
|
360
|
-
*/
|
|
361
|
-
addRestrictedCanvasListenerToken(token: string): void;
|
|
362
|
-
/**
|
|
363
|
-
* Apply the settings of a viewport manually. You can get the settings via {@link getViewportSettings}.
|
|
364
|
-
* You can choose which sections will be applied, by default they are all set to false.
|
|
365
|
-
*
|
|
366
|
-
* @param settings
|
|
367
|
-
* @param sections
|
|
368
|
-
*
|
|
369
|
-
* @throws {@type ShapeDiverViewerError}
|
|
370
|
-
*/
|
|
371
|
-
applyViewportSettings(settings: ISettings, sections?: {
|
|
372
|
-
ar?: boolean | undefined;
|
|
373
|
-
scene?: boolean | undefined;
|
|
374
|
-
camera?: boolean | undefined;
|
|
375
|
-
light?: boolean | undefined;
|
|
376
|
-
environment?: boolean | undefined;
|
|
377
|
-
general?: boolean | undefined;
|
|
378
|
-
postprocessing?: boolean | undefined;
|
|
379
|
-
}): Promise<void>;
|
|
380
|
-
/**
|
|
381
|
-
* Assign the camera with the specified id to the viewport.
|
|
382
|
-
* This will make the given camera the current one.
|
|
383
|
-
*
|
|
384
|
-
* @see {@link camera}
|
|
385
|
-
*
|
|
386
|
-
* @param id The id of the camera.
|
|
387
|
-
*/
|
|
388
|
-
assignCamera(id: string): boolean;
|
|
389
|
-
/**
|
|
390
|
-
* Assign the light scene with the current id to the viewport.
|
|
391
|
-
* This will make the given light scene the current one.
|
|
392
|
-
*
|
|
393
|
-
* @see {@link lightScene}
|
|
394
|
-
*
|
|
395
|
-
* @param id The id of the light scene.
|
|
396
|
-
*/
|
|
397
|
-
assignLightScene(id: string): boolean;
|
|
398
|
-
/**
|
|
399
|
-
* Closes the viewport and will remove all traces of the canvas element.
|
|
400
|
-
*/
|
|
401
|
-
close(): Promise<void>;
|
|
402
|
-
/**
|
|
403
|
-
* Continue the rendering of the scene.
|
|
404
|
-
* Can be used with {@link pauseRendering} to continue/pause the rendering at will.
|
|
405
|
-
*
|
|
406
|
-
* @see {@link pauseRendering}
|
|
407
|
-
*/
|
|
408
|
-
continueRendering(): void;
|
|
409
|
-
/**
|
|
410
|
-
* Convert the given 3D position to different 2D coordinates of HTML Elements.
|
|
411
|
-
* If the point is hidden by geometry, the hidden property will be set to true.
|
|
412
|
-
*
|
|
413
|
-
* The returned coordinates all have their origin in the top left corner of the element.
|
|
414
|
-
* For container, the position is relative to the canvas element.
|
|
415
|
-
* For client, the position is relative to the canvas element, including the results of {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect|getBoundingClientRect}.
|
|
416
|
-
* For page, the position is relative to the whole page.
|
|
417
|
-
*
|
|
418
|
-
* @param p
|
|
419
|
-
*/
|
|
420
|
-
convert3Dto2D(p: vec3): IConvert3Dto2DResult;
|
|
421
|
-
/**
|
|
422
|
-
* Convert the current visible elements (or just from the node specified) in the viewport into a glTF file.
|
|
423
|
-
*
|
|
424
|
-
* The ground plane and grid will not be included, as well as additionally added data that was added to the scene other than through a {@link GeometryData} property.
|
|
425
|
-
*
|
|
426
|
-
* @param node Optional node to provide to transform into a glTF. (default: scene tree)
|
|
427
|
-
* @param convertForAR Option to convert the scene for AR. In this case some specific use cases are target to ensure the best AR performance. (default: false)
|
|
428
|
-
*
|
|
429
|
-
* @throws {@type ShapeDiverViewerError}
|
|
430
|
-
*/
|
|
431
|
-
convertToGlTF(node?: ITreeNode, convertForAR?: boolean): Promise<Blob>;
|
|
432
|
-
/**
|
|
433
|
-
* Create a link / QRCode that can be opened by mobile devices to display in AR.
|
|
434
|
-
*
|
|
435
|
-
* As some models might have a different scale then the AR apps (meters), the scaling can be chosen freely {@link arScale}.
|
|
436
|
-
*
|
|
437
|
-
* Internally, the scene will first be converted into a glTF. This glTF will be uploaded to our backend and converted into a USDZ to be able to start AR on iOS and Android.
|
|
438
|
-
*
|
|
439
|
-
* @param node Optional node to display in AR. (default: scene tree)
|
|
440
|
-
* @param qrCode Option to receive a QR Code instead of a link (default: true)
|
|
441
|
-
* @param fallbackUrl Optional fallback url if the link was opened by an unsupported device or an error occurred. If none was provided, the user will be redirected to shapediver.com/app
|
|
442
|
-
*
|
|
443
|
-
* @throws {@type ShapeDiverViewerError}
|
|
444
|
-
*/
|
|
445
|
-
createArSessionLink(node?: ITreeNode, qrCode?: boolean, fallbackUrl?: string): Promise<string>;
|
|
446
|
-
/**
|
|
447
|
-
* Create a new light scene.
|
|
448
|
-
* An id can be provided. If not, a unique id will be created.
|
|
449
|
-
* If the standard option is chosen, the default lights will be added from the start.
|
|
450
|
-
*
|
|
451
|
-
* @param properties.id The id of the light scene.
|
|
452
|
-
* @param properties.standard The option to add the standard lights.
|
|
453
|
-
*/
|
|
454
|
-
createLightScene(properties?: {
|
|
455
|
-
name?: string;
|
|
456
|
-
standard?: boolean;
|
|
457
|
-
}): ILightSceneApi;
|
|
458
|
-
/**
|
|
459
|
-
* Create an orthographic camera.
|
|
460
|
-
* An id can be provided. If not, a unique id will be created.
|
|
461
|
-
*
|
|
462
|
-
* @param id The id of the camera.
|
|
463
|
-
*/
|
|
464
|
-
createOrthographicCamera(id?: string): IOrthographicCameraApi;
|
|
465
|
-
/**
|
|
466
|
-
* Create a perspective camera.
|
|
467
|
-
* An id can be provided. If not, a unique id will be created.
|
|
468
|
-
*
|
|
469
|
-
* @param id The id of the camera.
|
|
470
|
-
*/
|
|
471
|
-
createPerspectiveCamera(id?: string): IPerspectiveCameraApi;
|
|
472
|
-
/**
|
|
473
|
-
* Create the {@link ISDTFOverview} for the provided node.
|
|
474
|
-
* If no node was provided, the scene root is used instead.
|
|
475
|
-
*
|
|
476
|
-
* @param node The node for which the overview is created.
|
|
477
|
-
*/
|
|
478
|
-
createSDTFOverview(node: ITreeNode): ISDTFOverview;
|
|
479
|
-
/**
|
|
480
|
-
* Display an error message on the canvas.
|
|
481
|
-
*
|
|
482
|
-
* @param message The message to display.
|
|
483
|
-
*/
|
|
484
|
-
displayErrorMessage(message: string): void;
|
|
485
|
-
/**
|
|
486
|
-
* Get the complete URL of the current environment map, if it is a single file.
|
|
487
|
-
* This can be used in case {@link environmentMap} is set to a preset environment map.
|
|
488
|
-
*/
|
|
489
|
-
getEnvironmentMapImageUrl(): string;
|
|
490
|
-
/**
|
|
491
|
-
* Create a screenshot for the requested type and options.
|
|
492
|
-
*
|
|
493
|
-
* @param type The type as string, default is 'image/png'.
|
|
494
|
-
* @param quality The quality of the screenshot, default is 1.
|
|
495
|
-
*/
|
|
496
|
-
getScreenshot(type?: string, quality?: number): string;
|
|
497
|
-
/**
|
|
498
|
-
* Create a screenshot for the requested type and options.
|
|
499
|
-
*
|
|
500
|
-
* @param type The type as string, default is 'image/png'.
|
|
501
|
-
* @param quality The quality of the screenshot, default is 1.
|
|
502
|
-
* @param resolution The resolution of the screenshot, default is the current canvas size.
|
|
503
|
-
* @param camera The camera that should be used for the screenshot, default is the current camera.
|
|
504
|
-
*/
|
|
505
|
-
getScreenshotAdvanced(type?: string, quality?: number, resolution?: {
|
|
506
|
-
width: number;
|
|
507
|
-
height: number;
|
|
508
|
-
}, camera?: OrthographicCameraProperties | PerspectiveCameraProperties): Promise<string>;
|
|
509
|
-
/**
|
|
510
|
-
* Get the current settings object of this viewport.
|
|
511
|
-
* Can be re-applied at a later point with {@link applyViewportSettings}.
|
|
512
|
-
*/
|
|
513
|
-
getViewportSettings(): ISettings;
|
|
514
|
-
/**
|
|
515
|
-
* Determines if the current device is a mobile device (or tablet) but still doesn't support to view the content in AR.
|
|
516
|
-
*
|
|
517
|
-
* Can be used in combination with {@link viewableInAR} to display a warning to use a different browser
|
|
518
|
-
* if {@link viewableInAR} is false and {@link isMobileDeviceWithoutBrowserARSupport} is true.
|
|
519
|
-
*
|
|
520
|
-
* Reasons for that can be:
|
|
521
|
-
* - Firefox on Android
|
|
522
|
-
* - Instagram in App browser
|
|
523
|
-
*/
|
|
524
|
-
isMobileDeviceWithoutBrowserARSupport(): boolean;
|
|
525
|
-
/**
|
|
526
|
-
* Pause the rendering of the scene.
|
|
527
|
-
* Can be used with {@link continueRendering} to continue/pause the rendering at will.
|
|
528
|
-
*
|
|
529
|
-
* @see {@link continueRendering}
|
|
530
|
-
*/
|
|
531
|
-
pauseRendering(): void;
|
|
532
|
-
/**
|
|
533
|
-
* Calculate the ray that is created by the pointer event and the camera.
|
|
534
|
-
*
|
|
535
|
-
* @param event
|
|
536
|
-
* @returns
|
|
537
|
-
*/
|
|
538
|
-
pointerEventToRay(event: PointerEvent): {
|
|
539
|
-
origin: vec3;
|
|
540
|
-
direction: vec3;
|
|
541
|
-
};
|
|
542
|
-
/**
|
|
543
|
-
* From the provided origin and direction, trace the ray through the scene.
|
|
544
|
-
* The intersections with GeometryData will be returned including the corresponding nodes, sorted by their smallest distance.
|
|
545
|
-
*
|
|
546
|
-
* If you want to raytrace the scene from an interaction with the the canvas,
|
|
547
|
-
* please use {@link pointerEventToRay} to create a ray first.
|
|
548
|
-
*
|
|
549
|
-
* @param origin The origin of the ray.
|
|
550
|
-
* @param direction The direction of the ray.
|
|
551
|
-
* @param filterCriteria Optional filter criteria to filter the intersections.
|
|
552
|
-
*/
|
|
553
|
-
raytraceScene(origin: vec3, direction: vec3, filterCriteria?: IIntersectionFilter[]): {
|
|
554
|
-
distance: number;
|
|
555
|
-
node: ITreeNode;
|
|
556
|
-
data?: IGeometryData;
|
|
557
|
-
}[];
|
|
558
|
-
/**
|
|
559
|
-
* Remove the camera with the specified id and destroys it.
|
|
560
|
-
* If you remove the current active camera, the rendering will be stopped until a new camera is assigned.
|
|
561
|
-
*
|
|
562
|
-
* @param id The id of the camera.
|
|
563
|
-
*/
|
|
564
|
-
removeCamera(id: string): boolean;
|
|
565
|
-
/**
|
|
566
|
-
* Remove an event listener that received all canvas events.
|
|
567
|
-
*
|
|
568
|
-
* @param token The token that was returned by {@link addCanvasEventListener}.
|
|
569
|
-
*/
|
|
570
|
-
removeCanvasEventListener(token: string): boolean;
|
|
571
|
-
/**
|
|
572
|
-
* Removes the registered flag. Adding/removing flags allows to influence the render loop.
|
|
573
|
-
*
|
|
574
|
-
* @param token The token that was returned by {@link addFlag}.
|
|
575
|
-
*/
|
|
576
|
-
removeFlag(token: string): boolean;
|
|
577
|
-
/**
|
|
578
|
-
* Remove the light scene with the specified id.
|
|
579
|
-
* If you remove the current active light scene, no lights will be shown.
|
|
580
|
-
*
|
|
581
|
-
* @param id The id of the light scene.
|
|
582
|
-
*/
|
|
583
|
-
removeLightScene(id: string): boolean;
|
|
584
|
-
/**
|
|
585
|
-
* Remove the token from the list of restricted canvas listener tokens.
|
|
586
|
-
* Only listeners with a token in this list will receive events (if there is at least one item in the list).
|
|
587
|
-
*/
|
|
588
|
-
removeRestrictedCanvasListenerToken(token: string): void;
|
|
589
|
-
/**
|
|
590
|
-
* Manual call to render the scene.
|
|
591
|
-
*/
|
|
592
|
-
render(): void;
|
|
593
|
-
/**
|
|
594
|
-
* Delete all current cameras and create our 7 default cameras.
|
|
595
|
-
*
|
|
596
|
-
* A perspective one (default) and 6 orthographic ones (top, bottom, left, right, front, back).
|
|
597
|
-
*/
|
|
598
|
-
resetToDefaultCameras(): void;
|
|
599
|
-
/**
|
|
600
|
-
* If the {@link automaticResizing} is option is set to `false`, this function resizes the Viewport.
|
|
601
|
-
* @param width The new width of the Viewport.
|
|
602
|
-
* @param height The new height of the Viewport.
|
|
603
|
-
*/
|
|
604
|
-
resize(width: number, height: number): void;
|
|
605
|
-
/**
|
|
606
|
-
* Restrict events.
|
|
607
|
-
* This can be used to disable events for a viewport.
|
|
608
|
-
*
|
|
609
|
-
* Example use case: If you don't want to allow mouse wheel events for a specific viewport so that users can scroll past the viewport.
|
|
610
|
-
*
|
|
611
|
-
* Be aware that this might cause some issues with the the camera controls if the pointer events are disabled only partially.
|
|
612
|
-
*
|
|
613
|
-
* @param allowedListeners
|
|
614
|
-
*/
|
|
615
|
-
restrictEventListeners(allowedListeners: {
|
|
616
|
-
mousewheel?: boolean;
|
|
617
|
-
pointerdown?: boolean;
|
|
618
|
-
pointermove?: boolean;
|
|
619
|
-
pointerup?: boolean;
|
|
620
|
-
pointerout?: boolean;
|
|
621
|
-
keydown?: boolean;
|
|
622
|
-
keyup?: boolean;
|
|
623
|
-
contextmenu?: boolean;
|
|
624
|
-
}): void;
|
|
625
|
-
/**
|
|
626
|
-
* Update the viewport with the current changes of the complete scene tree.
|
|
627
|
-
* This carries out preparations for rendering. Call it after doing
|
|
628
|
-
* direct changes to the scene tree.
|
|
629
|
-
*/
|
|
630
|
-
update(): void;
|
|
631
|
-
/**
|
|
632
|
-
* Update the default line material of the viewport.
|
|
633
|
-
*
|
|
634
|
-
* @param value The new default line material.
|
|
635
|
-
*/
|
|
636
|
-
updateDefaultLineMaterial(value: MaterialBasicLineData): void;
|
|
637
|
-
/**
|
|
638
|
-
* Update the default materials of the viewport.
|
|
639
|
-
*
|
|
640
|
-
* @param value The new default material.
|
|
641
|
-
*/
|
|
642
|
-
updateDefaultMaterial(value: MaterialStandardData): void;
|
|
643
|
-
/**
|
|
644
|
-
* Update the default point material of the viewport.
|
|
645
|
-
*
|
|
646
|
-
* @param value The new default point material.
|
|
647
|
-
*/
|
|
648
|
-
updateDefaultPointMaterial(value: MaterialPointData): void;
|
|
649
|
-
/**
|
|
650
|
-
* Update the position of the environment geometry (grid, groundplane, etc) to the current viewport bounding box.
|
|
651
|
-
* Internally, this functions is called whenever a session is customized,
|
|
652
|
-
* but if you manually change parts of the scene, it might get necessary to call this function.
|
|
653
|
-
* Make sure to call {@link update} before, to apply the last changes.
|
|
654
|
-
*/
|
|
655
|
-
updateEnvironmentGeometry(): void;
|
|
656
|
-
/**
|
|
657
|
-
* Update the material of the given geometry data on the GPU without triggering a full scene tree reconversion.
|
|
658
|
-
* Use this instead of calling {@link IGeometryData.updateVersion} when only the effect material has changed,
|
|
659
|
-
* e.g. during hover interactions, to avoid the overhead of reconstructing Three.js objects.
|
|
660
|
-
*
|
|
661
|
-
* @param geometryData The geometry data whose material should be updated.
|
|
662
|
-
*/
|
|
663
|
-
updateGeometryData(geometryData: IGeometryData): void;
|
|
664
|
-
/**
|
|
665
|
-
* Update the viewport with the current changes of given scene tree node and its descendants.
|
|
666
|
-
* This carries out preparations for rendering. Call it after doing direct changes to the scene tree.
|
|
667
|
-
*
|
|
668
|
-
* @param node The node to update.
|
|
669
|
-
*/
|
|
670
|
-
updateNode(node: ITreeNode): void;
|
|
671
|
-
/**
|
|
672
|
-
* Update the viewport with the current changes in transformation of given scene tree node and its descendants.
|
|
673
|
-
* This carries out preparations for rendering. Call it after doing direct changes to the scene tree transformations.
|
|
674
|
-
*
|
|
675
|
-
* @param node The node to update.
|
|
676
|
-
*/
|
|
677
|
-
updateNodeTransformation(node: ITreeNode): void;
|
|
678
|
-
/**
|
|
679
|
-
* View the current scene in AR.
|
|
680
|
-
*
|
|
681
|
-
* Please check first if the device supports the viewing of models in AR, see {@link viewableInAR}.
|
|
682
|
-
* As some models might have a different scale then the AR apps (meters), the scaling can be chosen freely {@link arScale}.
|
|
683
|
-
*
|
|
684
|
-
* Internally, the scene will first be converted into a glTF. This glTF will be uploaded to our backend to be able to start AR.
|
|
685
|
-
*
|
|
686
|
-
* @param node Optional node to display in AR. (default: scene tree)
|
|
687
|
-
* @param androidOptions
|
|
688
|
-
*
|
|
689
|
-
* @throws {@type ShapeDiverViewerError}
|
|
690
|
-
*/
|
|
691
|
-
viewInAR(node?: ITreeNode): Promise<void>;
|
|
692
|
-
/**
|
|
693
|
-
* Determines if the current device supports viewing in AR.
|
|
694
|
-
*
|
|
695
|
-
* Can be used in combination with {@link isMobileDeviceWithoutBrowserARSupport} to display a warning to use a different browser
|
|
696
|
-
* if {@link viewableInAR} is false and {@link isMobileDeviceWithoutBrowserARSupport} is true.
|
|
697
|
-
*/
|
|
698
|
-
viewableInAR(): boolean;
|
|
699
|
-
}
|
|
1
|
+
import { OrthographicCameraProperties, PerspectiveCameraProperties } from "@shapediver/viewer.rendering-engine.camera-engine";
|
|
2
|
+
import { IConvert3Dto2DResult } from "@shapediver/viewer.rendering-engine.rendering-engine";
|
|
3
|
+
import { ISettings } from "@shapediver/viewer.settings";
|
|
4
|
+
import { ITreeNode, MaterialBasicLineData, MaterialPointData, MaterialStandardData } from "@shapediver/viewer.shared.node-tree";
|
|
5
|
+
import { IDomEventListener, SESSION_SETTINGS_MODE } from "@shapediver/viewer.shared.services";
|
|
6
|
+
import { Color, FLAG_TYPE, IAnimationData, IGeometryData, IIntersectionFilter, ISDTFAttributeVisualizationData, ISDTFItemData, ISDTFOverview, MATERIAL_TYPE, RENDERER_TYPE, TEXTURE_ENCODING, TONE_MAPPING } from "@shapediver/viewer.shared.types";
|
|
7
|
+
import { quat, vec3 } from "gl-matrix";
|
|
8
|
+
import * as THREE from "three";
|
|
9
|
+
import { ICameraApi } from "./camera/ICameraApi";
|
|
10
|
+
import { IOrthographicCameraApi } from "./camera/IOrthographicCameraApi";
|
|
11
|
+
import { IPerspectiveCameraApi } from "./camera/IPerspectiveCameraApi";
|
|
12
|
+
import { IPostProcessingApi } from "./IPostProcessingApi";
|
|
13
|
+
import { ILightSceneApi } from "./lights/ILightSceneApi";
|
|
14
|
+
/**
|
|
15
|
+
* The api for viewports.
|
|
16
|
+
*
|
|
17
|
+
* Viewports are created by calling the {@link createViewport} method.
|
|
18
|
+
*
|
|
19
|
+
* Each viewport has corresponding [cameras]{@link ICameraApi} and [lights]{@link ILightApi}.
|
|
20
|
+
*
|
|
21
|
+
* Additionally, there are various other settings to adjust the behavior and rendering of the viewport.
|
|
22
|
+
*
|
|
23
|
+
* By default a new viewport displays the complete scene tree. Viewports can be excluded from
|
|
24
|
+
* displaying geometry for specific sessions by using the {@link excludeViewports} property of
|
|
25
|
+
* {@link ISessionApi}.
|
|
26
|
+
*/
|
|
27
|
+
export interface IViewportApi {
|
|
28
|
+
/**
|
|
29
|
+
* A dictionary of all animations that are currently present in the parts of
|
|
30
|
+
* the scene tree relevant to this viewport.
|
|
31
|
+
*/
|
|
32
|
+
readonly animations: {
|
|
33
|
+
[key: string]: IAnimationData;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The current [camera]{@link ICameraApi}.
|
|
37
|
+
*/
|
|
38
|
+
readonly camera: ICameraApi | null;
|
|
39
|
+
/**
|
|
40
|
+
* The [cameras]{@link ICameraApi} of the viewport.
|
|
41
|
+
*/
|
|
42
|
+
readonly cameras: {
|
|
43
|
+
[key: string]: ICameraApi;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The canvas that is used to render the viewport.
|
|
47
|
+
*/
|
|
48
|
+
readonly canvas: HTMLCanvasElement;
|
|
49
|
+
/**
|
|
50
|
+
* The default line material that is used for line geometry without a specified material.
|
|
51
|
+
* Please use {@link updateDefaultLineMaterial} to update the material.
|
|
52
|
+
*/
|
|
53
|
+
readonly defaultLineMaterial: MaterialBasicLineData;
|
|
54
|
+
/**
|
|
55
|
+
* The default material that is used for geometry without a specified material.
|
|
56
|
+
* Please use {@link updateDefaultMaterial} to update the material.
|
|
57
|
+
*/
|
|
58
|
+
readonly defaultMaterial: MaterialStandardData;
|
|
59
|
+
/**
|
|
60
|
+
* The default point material that is used for point geometry without a specified material.
|
|
61
|
+
* Please use {@link updateDefaultPointMaterial} to update the material.
|
|
62
|
+
*/
|
|
63
|
+
readonly defaultPointMaterial: MaterialPointData;
|
|
64
|
+
/**
|
|
65
|
+
* The id of the viewport.
|
|
66
|
+
*/
|
|
67
|
+
readonly id: string;
|
|
68
|
+
/**
|
|
69
|
+
* If the viewer is currently busy.
|
|
70
|
+
* This is set by the viewer [addFlag]{@link addFlag} and [removeFlag]{@link removeFlag} methods.
|
|
71
|
+
*/
|
|
72
|
+
readonly isBusy: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The current [light scene]{@link ILightSceneApi}.
|
|
75
|
+
*/
|
|
76
|
+
readonly lightScene: ILightSceneApi | null;
|
|
77
|
+
/**
|
|
78
|
+
* The [light scenes]{@link ILightSceneApi} of the viewport.
|
|
79
|
+
*/
|
|
80
|
+
readonly lightScenes: {
|
|
81
|
+
[key: string]: ILightSceneApi;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The [post processing api]{@link IPostProcessingApi} of the viewport.
|
|
85
|
+
*
|
|
86
|
+
* Note: The post-processing API is still WIP. Breaking changes are to be expected.
|
|
87
|
+
*/
|
|
88
|
+
readonly postProcessing: IPostProcessingApi;
|
|
89
|
+
/**
|
|
90
|
+
* Optional identifier of the session to be used for loading / persisting settings of the viewport.
|
|
91
|
+
* This is ignored in case {@link sessionSettingsMode} is not {@link SESSION_SETTINGS_MODE.MANUAL}.
|
|
92
|
+
*/
|
|
93
|
+
readonly sessionSettingsId?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Allows to control which session to use for loading / persisting settings of the viewport.
|
|
96
|
+
* (default: {@link SESSION_SETTINGS_MODE.FIRST}).
|
|
97
|
+
* @see {@link sessionSettingsId}
|
|
98
|
+
*/
|
|
99
|
+
readonly sessionSettingsMode?: SESSION_SETTINGS_MODE;
|
|
100
|
+
/**
|
|
101
|
+
* The rotation factor that is used when exporting the scene for AR (Augmented Reality). The unit system used by AR is meter.
|
|
102
|
+
*
|
|
103
|
+
* @see {@link arScale}
|
|
104
|
+
* @see {@link arTranslation}
|
|
105
|
+
* @see {@link arRotation}
|
|
106
|
+
*/
|
|
107
|
+
arRotation: vec3;
|
|
108
|
+
/**
|
|
109
|
+
* The scaling factor that is used when exporting the scene for AR (Augmented Reality).
|
|
110
|
+
*
|
|
111
|
+
* The unit system used by AR is meter, therefore this scaling factor needs to be chosen
|
|
112
|
+
* such that scene coordinates are transformed to meters.
|
|
113
|
+
*
|
|
114
|
+
* @see {@link arScale}
|
|
115
|
+
* @see {@link arTranslation}
|
|
116
|
+
* @see {@link arRotation}
|
|
117
|
+
*/
|
|
118
|
+
arScale: vec3;
|
|
119
|
+
/**
|
|
120
|
+
* The translation factor that is used when exporting the scene for AR (Augmented Reality). The unit system used by AR is meter.
|
|
121
|
+
*
|
|
122
|
+
* @see {@link arScale}
|
|
123
|
+
* @see {@link arTranslation}
|
|
124
|
+
* @see {@link arRotation}
|
|
125
|
+
*/
|
|
126
|
+
arTranslation: vec3;
|
|
127
|
+
/**
|
|
128
|
+
* Option to enable / disable the automatic color space adaption. This converts all color inputs to the chosen {@link outputEncoding}. (default: true)
|
|
129
|
+
*/
|
|
130
|
+
automaticColorAdjustment: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Option to enable / disable the automatic resizing of the viewport to changes of the {@link canvas}. (default: true)
|
|
133
|
+
*/
|
|
134
|
+
automaticResizing: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* The duration used by the beauty rendering to blend in (milliseconds).
|
|
137
|
+
*/
|
|
138
|
+
beautyRenderBlendingDuration: number;
|
|
139
|
+
/**
|
|
140
|
+
* The delay after which the beauty rendering starts (milliseconds).
|
|
141
|
+
*/
|
|
142
|
+
beautyRenderDelay: number;
|
|
143
|
+
/**
|
|
144
|
+
* The clear alpha value of the viewport.
|
|
145
|
+
* Use this to influence the background appearance of the viewport.
|
|
146
|
+
*/
|
|
147
|
+
clearAlpha: number;
|
|
148
|
+
/**
|
|
149
|
+
* The clear color value of the viewport.
|
|
150
|
+
* Use this to influence the background appearance of the viewport.
|
|
151
|
+
*/
|
|
152
|
+
clearColor: Color;
|
|
153
|
+
/**
|
|
154
|
+
* The maximum percentage of height that is still considered for the creation of the contact shadow. (default: 0.25)
|
|
155
|
+
* The maximum height is equal to the width and height of the ground plane.
|
|
156
|
+
*/
|
|
157
|
+
contactShadowHeight: number;
|
|
158
|
+
/**
|
|
159
|
+
* Option to enable / disable the contact shadow. (default: false)
|
|
160
|
+
*/
|
|
161
|
+
contactShadowVisibility: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* The blur amount of the contact shadow. (default: 1.5)
|
|
164
|
+
*/
|
|
165
|
+
contactShadowBlur: number;
|
|
166
|
+
/**
|
|
167
|
+
* The darkness of the contact shadow. (default: 2.5)
|
|
168
|
+
*/
|
|
169
|
+
contactShadowDarkness: number;
|
|
170
|
+
/**
|
|
171
|
+
* The opacity of the contact shadow. (default: 1)
|
|
172
|
+
*/
|
|
173
|
+
contactShadowOpacity: number;
|
|
174
|
+
/**
|
|
175
|
+
* The color that is used when no material is specified. (default: #199b9b)
|
|
176
|
+
*/
|
|
177
|
+
defaultMaterialColor: Color;
|
|
178
|
+
/**
|
|
179
|
+
* Option to enable / disable the AR (Augmented Reality) functionality for this viewport. (default: true)
|
|
180
|
+
* This setting is used purely for UI purposes, it does not have any influence on the viewport itself.
|
|
181
|
+
*/
|
|
182
|
+
enableAR: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* The environment map used by the viewport.
|
|
185
|
+
* You can either use the HDR maps at {@link ENVIRONMENT_MAP} or the LDR legacy maps at {@link ENVIRONMENT_MAP_CUBE}.
|
|
186
|
+
* Additionally, you can specify your own maps. For HDR maps, provide a link to a .hdr file, for LDR provide the folder where the six cube map images are located.
|
|
187
|
+
*/
|
|
188
|
+
environmentMap: string | string[];
|
|
189
|
+
/**
|
|
190
|
+
* Option to set the environment map as the background of the viewport. (default: false)
|
|
191
|
+
*/
|
|
192
|
+
environmentMapAsBackground: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* The amount of which the environment map is blurred. (default: 0)
|
|
195
|
+
*/
|
|
196
|
+
environmentMapBlurriness: number;
|
|
197
|
+
/**
|
|
198
|
+
* Option to set the environment map for unlit materials. (default: false)
|
|
199
|
+
* For unlit materials, which use the three.js MeshBasicMaterial, per default we don't set the environment map to keep the colors as realistic as possible.
|
|
200
|
+
*/
|
|
201
|
+
environmentMapForUnlitMaterials: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Scales how much the environment map effects the materials. (default: 1)
|
|
204
|
+
*/
|
|
205
|
+
environmentMapIntensity: number;
|
|
206
|
+
/**
|
|
207
|
+
* The environment map resolution that is used for preset cube maps.
|
|
208
|
+
* @see {@link environmentMap}
|
|
209
|
+
*/
|
|
210
|
+
environmentMapResolution: string;
|
|
211
|
+
/**
|
|
212
|
+
* The rotation quaternion that is used on the environment map. (default: [0,0,0,1])
|
|
213
|
+
*/
|
|
214
|
+
environmentMapRotation: quat;
|
|
215
|
+
/**
|
|
216
|
+
* The color of the grid.
|
|
217
|
+
*/
|
|
218
|
+
gridColor: Color;
|
|
219
|
+
/**
|
|
220
|
+
* Option to enable / disable the grid. (default: true)
|
|
221
|
+
*/
|
|
222
|
+
gridVisibility: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* The color of the ground plane.
|
|
225
|
+
*/
|
|
226
|
+
groundPlaneColor: Color;
|
|
227
|
+
/**
|
|
228
|
+
* The color of the ground plane shadow.
|
|
229
|
+
*/
|
|
230
|
+
groundPlaneShadowColor: Color;
|
|
231
|
+
/**
|
|
232
|
+
* Option to enable / disable the ground plane shadow. (default: false)
|
|
233
|
+
*/
|
|
234
|
+
groundPlaneShadowVisibility: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Option to enable / disable the ground plane. (default: true)
|
|
237
|
+
*/
|
|
238
|
+
groundPlaneVisibility: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Option to enable / disable lights. (default: true)
|
|
241
|
+
*/
|
|
242
|
+
lights: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Option to load the default cameras when the viewport is created. (default: true)
|
|
245
|
+
* This will create 6 orthographic cameras (top, bottom, left, right, front, back).
|
|
246
|
+
*/
|
|
247
|
+
loadDefaultCameras: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* The type of material that is used as an override for all materials in the scene.
|
|
250
|
+
* This can be used to enforce a specific material type for all materials in the scene.
|
|
251
|
+
*
|
|
252
|
+
* As point and line materials are not supported by all three.js materials, the override will be ignored for these materials.
|
|
253
|
+
*
|
|
254
|
+
* If no override is set, the materials will be used as they are.
|
|
255
|
+
*/
|
|
256
|
+
materialOverrideType: MATERIAL_TYPE | undefined;
|
|
257
|
+
/**
|
|
258
|
+
* The maximum size of the renderings. The renderings will be upscaled to the actual resolution if these values are lower than the resolution of the canvas.
|
|
259
|
+
* This setting exists, as for higher resolutions the performance can drop due to the rendering effort. (default: { width: 1920, height: 1080 })
|
|
260
|
+
*/
|
|
261
|
+
maximumRenderingSize: {
|
|
262
|
+
width: number;
|
|
263
|
+
height: number;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* The encoding that is used for the output texture. (default: TEXTURE_ENCODING.SRGB)
|
|
267
|
+
* This is the texture that is rendered to the screen.
|
|
268
|
+
*
|
|
269
|
+
* @see {@link textureEncoding}
|
|
270
|
+
*/
|
|
271
|
+
outputEncoding: TEXTURE_ENCODING;
|
|
272
|
+
/**
|
|
273
|
+
* Option to enable / disable the physically correct lights. (default: true)
|
|
274
|
+
*/
|
|
275
|
+
physicallyCorrectLights: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* The point size that is used for rendering point data.
|
|
278
|
+
*/
|
|
279
|
+
pointSize: number;
|
|
280
|
+
/**
|
|
281
|
+
* Optional callback that is called after the rendering of the scene.
|
|
282
|
+
*/
|
|
283
|
+
postRenderingCallback?: (renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => void;
|
|
284
|
+
/**
|
|
285
|
+
* Optional callback that is called before the rendering of the scene.
|
|
286
|
+
*/
|
|
287
|
+
preRenderingCallback?: (renderer: THREE.WebGLRenderer) => void;
|
|
288
|
+
/**
|
|
289
|
+
* Option to enable / disable rendering of shadows. (default: true)
|
|
290
|
+
*/
|
|
291
|
+
shadows: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Option to show / hide the viewport.
|
|
294
|
+
* This will disable rendering, and hide the canvas behind the logo.
|
|
295
|
+
* Using this setting especially makes sense with {@link VISIBILITY_MODE.MANUAL} where you can decide at what point you first want to show the scene.
|
|
296
|
+
*/
|
|
297
|
+
show: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Option to show / hide rendering statistics overlayed to the viewport. (default: false)
|
|
300
|
+
*/
|
|
301
|
+
showStatistics: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Option if the soft shadows should be rendered when the camera is not moving. (default: true)
|
|
304
|
+
*/
|
|
305
|
+
softShadows: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* The encoding that is used for textures. (default: TEXTURE_ENCODING.SRGB)
|
|
308
|
+
*
|
|
309
|
+
* @see {@link outputEncoding}
|
|
310
|
+
*/
|
|
311
|
+
textureEncoding: TEXTURE_ENCODING;
|
|
312
|
+
/**
|
|
313
|
+
* Some of the three.js core objects so that you are free to use and adjust them yourself.
|
|
314
|
+
*
|
|
315
|
+
* Please note that the camera will be replaced when you change it via the API.
|
|
316
|
+
* The same goes for the children in the scene tree that are auto-generated and properties of the renderer that are adjusted internally.
|
|
317
|
+
*/
|
|
318
|
+
threeJsCoreObjects: {
|
|
319
|
+
scene: THREE.Scene;
|
|
320
|
+
renderer: THREE.WebGLRenderer;
|
|
321
|
+
camera: THREE.Camera;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* The tone mapping that is used. (default: TONE_MAPPING.NONE)
|
|
325
|
+
*/
|
|
326
|
+
toneMapping: TONE_MAPPING;
|
|
327
|
+
/**
|
|
328
|
+
* The intensity of the tone mapping.
|
|
329
|
+
*/
|
|
330
|
+
toneMappingExposure: number;
|
|
331
|
+
/**
|
|
332
|
+
* The type of rendering of this viewport.
|
|
333
|
+
*/
|
|
334
|
+
type: RENDERER_TYPE;
|
|
335
|
+
/**
|
|
336
|
+
* A possibility to visualize the attributes of the scene in any way you want.
|
|
337
|
+
* Please have a look at the {@link https://help.shapediver.com/doc/Attribute-Visualization.1856733198.html|help desk} documentation for more information.
|
|
338
|
+
*
|
|
339
|
+
* Provide a callback that transforms a {@link ISDTFItemData} to a {@link ISDTFAttributeVisualizationData}.
|
|
340
|
+
* The {@link ISDTFOverview} provides general information like min and max values for numbers or the available options for strings.
|
|
341
|
+
*/
|
|
342
|
+
visualizeAttributes: ((overview: ISDTFOverview, itemData?: ISDTFItemData) => ISDTFAttributeVisualizationData) | undefined;
|
|
343
|
+
/**
|
|
344
|
+
* Add an event listener that receives all canvas events.
|
|
345
|
+
*
|
|
346
|
+
* @param listener The listener that is called when the events occur.
|
|
347
|
+
*/
|
|
348
|
+
addCanvasEventListener(listener: IDomEventListener): string;
|
|
349
|
+
/**
|
|
350
|
+
* Add a flag for this viewport. Adding/removing flags allows to influence the render loop.
|
|
351
|
+
* If you want to stop this again call {@link removeFlag} with the returned token.
|
|
352
|
+
*/
|
|
353
|
+
addFlag(flag: FLAG_TYPE): string;
|
|
354
|
+
/**
|
|
355
|
+
* Add a token to the list of restricted canvas listener tokens.
|
|
356
|
+
* This can be used to restrict events for a viewport.
|
|
357
|
+
* Only listeners with a token in this list will receive events (if there is at least one item in the list).
|
|
358
|
+
*
|
|
359
|
+
* @param token
|
|
360
|
+
*/
|
|
361
|
+
addRestrictedCanvasListenerToken(token: string): void;
|
|
362
|
+
/**
|
|
363
|
+
* Apply the settings of a viewport manually. You can get the settings via {@link getViewportSettings}.
|
|
364
|
+
* You can choose which sections will be applied, by default they are all set to false.
|
|
365
|
+
*
|
|
366
|
+
* @param settings
|
|
367
|
+
* @param sections
|
|
368
|
+
*
|
|
369
|
+
* @throws {@type ShapeDiverViewerError}
|
|
370
|
+
*/
|
|
371
|
+
applyViewportSettings(settings: ISettings, sections?: {
|
|
372
|
+
ar?: boolean | undefined;
|
|
373
|
+
scene?: boolean | undefined;
|
|
374
|
+
camera?: boolean | undefined;
|
|
375
|
+
light?: boolean | undefined;
|
|
376
|
+
environment?: boolean | undefined;
|
|
377
|
+
general?: boolean | undefined;
|
|
378
|
+
postprocessing?: boolean | undefined;
|
|
379
|
+
}): Promise<void>;
|
|
380
|
+
/**
|
|
381
|
+
* Assign the camera with the specified id to the viewport.
|
|
382
|
+
* This will make the given camera the current one.
|
|
383
|
+
*
|
|
384
|
+
* @see {@link camera}
|
|
385
|
+
*
|
|
386
|
+
* @param id The id of the camera.
|
|
387
|
+
*/
|
|
388
|
+
assignCamera(id: string): boolean;
|
|
389
|
+
/**
|
|
390
|
+
* Assign the light scene with the current id to the viewport.
|
|
391
|
+
* This will make the given light scene the current one.
|
|
392
|
+
*
|
|
393
|
+
* @see {@link lightScene}
|
|
394
|
+
*
|
|
395
|
+
* @param id The id of the light scene.
|
|
396
|
+
*/
|
|
397
|
+
assignLightScene(id: string): boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Closes the viewport and will remove all traces of the canvas element.
|
|
400
|
+
*/
|
|
401
|
+
close(): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Continue the rendering of the scene.
|
|
404
|
+
* Can be used with {@link pauseRendering} to continue/pause the rendering at will.
|
|
405
|
+
*
|
|
406
|
+
* @see {@link pauseRendering}
|
|
407
|
+
*/
|
|
408
|
+
continueRendering(): void;
|
|
409
|
+
/**
|
|
410
|
+
* Convert the given 3D position to different 2D coordinates of HTML Elements.
|
|
411
|
+
* If the point is hidden by geometry, the hidden property will be set to true.
|
|
412
|
+
*
|
|
413
|
+
* The returned coordinates all have their origin in the top left corner of the element.
|
|
414
|
+
* For container, the position is relative to the canvas element.
|
|
415
|
+
* For client, the position is relative to the canvas element, including the results of {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect|getBoundingClientRect}.
|
|
416
|
+
* For page, the position is relative to the whole page.
|
|
417
|
+
*
|
|
418
|
+
* @param p
|
|
419
|
+
*/
|
|
420
|
+
convert3Dto2D(p: vec3): IConvert3Dto2DResult;
|
|
421
|
+
/**
|
|
422
|
+
* Convert the current visible elements (or just from the node specified) in the viewport into a glTF file.
|
|
423
|
+
*
|
|
424
|
+
* The ground plane and grid will not be included, as well as additionally added data that was added to the scene other than through a {@link GeometryData} property.
|
|
425
|
+
*
|
|
426
|
+
* @param node Optional node to provide to transform into a glTF. (default: scene tree)
|
|
427
|
+
* @param convertForAR Option to convert the scene for AR. In this case some specific use cases are target to ensure the best AR performance. (default: false)
|
|
428
|
+
*
|
|
429
|
+
* @throws {@type ShapeDiverViewerError}
|
|
430
|
+
*/
|
|
431
|
+
convertToGlTF(node?: ITreeNode, convertForAR?: boolean): Promise<Blob>;
|
|
432
|
+
/**
|
|
433
|
+
* Create a link / QRCode that can be opened by mobile devices to display in AR.
|
|
434
|
+
*
|
|
435
|
+
* As some models might have a different scale then the AR apps (meters), the scaling can be chosen freely {@link arScale}.
|
|
436
|
+
*
|
|
437
|
+
* Internally, the scene will first be converted into a glTF. This glTF will be uploaded to our backend and converted into a USDZ to be able to start AR on iOS and Android.
|
|
438
|
+
*
|
|
439
|
+
* @param node Optional node to display in AR. (default: scene tree)
|
|
440
|
+
* @param qrCode Option to receive a QR Code instead of a link (default: true)
|
|
441
|
+
* @param fallbackUrl Optional fallback url if the link was opened by an unsupported device or an error occurred. If none was provided, the user will be redirected to shapediver.com/app
|
|
442
|
+
*
|
|
443
|
+
* @throws {@type ShapeDiverViewerError}
|
|
444
|
+
*/
|
|
445
|
+
createArSessionLink(node?: ITreeNode, qrCode?: boolean, fallbackUrl?: string): Promise<string>;
|
|
446
|
+
/**
|
|
447
|
+
* Create a new light scene.
|
|
448
|
+
* An id can be provided. If not, a unique id will be created.
|
|
449
|
+
* If the standard option is chosen, the default lights will be added from the start.
|
|
450
|
+
*
|
|
451
|
+
* @param properties.id The id of the light scene.
|
|
452
|
+
* @param properties.standard The option to add the standard lights.
|
|
453
|
+
*/
|
|
454
|
+
createLightScene(properties?: {
|
|
455
|
+
name?: string;
|
|
456
|
+
standard?: boolean;
|
|
457
|
+
}): ILightSceneApi;
|
|
458
|
+
/**
|
|
459
|
+
* Create an orthographic camera.
|
|
460
|
+
* An id can be provided. If not, a unique id will be created.
|
|
461
|
+
*
|
|
462
|
+
* @param id The id of the camera.
|
|
463
|
+
*/
|
|
464
|
+
createOrthographicCamera(id?: string): IOrthographicCameraApi;
|
|
465
|
+
/**
|
|
466
|
+
* Create a perspective camera.
|
|
467
|
+
* An id can be provided. If not, a unique id will be created.
|
|
468
|
+
*
|
|
469
|
+
* @param id The id of the camera.
|
|
470
|
+
*/
|
|
471
|
+
createPerspectiveCamera(id?: string): IPerspectiveCameraApi;
|
|
472
|
+
/**
|
|
473
|
+
* Create the {@link ISDTFOverview} for the provided node.
|
|
474
|
+
* If no node was provided, the scene root is used instead.
|
|
475
|
+
*
|
|
476
|
+
* @param node The node for which the overview is created.
|
|
477
|
+
*/
|
|
478
|
+
createSDTFOverview(node: ITreeNode): ISDTFOverview;
|
|
479
|
+
/**
|
|
480
|
+
* Display an error message on the canvas.
|
|
481
|
+
*
|
|
482
|
+
* @param message The message to display.
|
|
483
|
+
*/
|
|
484
|
+
displayErrorMessage(message: string): void;
|
|
485
|
+
/**
|
|
486
|
+
* Get the complete URL of the current environment map, if it is a single file.
|
|
487
|
+
* This can be used in case {@link environmentMap} is set to a preset environment map.
|
|
488
|
+
*/
|
|
489
|
+
getEnvironmentMapImageUrl(): string;
|
|
490
|
+
/**
|
|
491
|
+
* Create a screenshot for the requested type and options.
|
|
492
|
+
*
|
|
493
|
+
* @param type The type as string, default is 'image/png'.
|
|
494
|
+
* @param quality The quality of the screenshot, default is 1.
|
|
495
|
+
*/
|
|
496
|
+
getScreenshot(type?: string, quality?: number): string;
|
|
497
|
+
/**
|
|
498
|
+
* Create a screenshot for the requested type and options.
|
|
499
|
+
*
|
|
500
|
+
* @param type The type as string, default is 'image/png'.
|
|
501
|
+
* @param quality The quality of the screenshot, default is 1.
|
|
502
|
+
* @param resolution The resolution of the screenshot, default is the current canvas size.
|
|
503
|
+
* @param camera The camera that should be used for the screenshot, default is the current camera.
|
|
504
|
+
*/
|
|
505
|
+
getScreenshotAdvanced(type?: string, quality?: number, resolution?: {
|
|
506
|
+
width: number;
|
|
507
|
+
height: number;
|
|
508
|
+
}, camera?: OrthographicCameraProperties | PerspectiveCameraProperties): Promise<string>;
|
|
509
|
+
/**
|
|
510
|
+
* Get the current settings object of this viewport.
|
|
511
|
+
* Can be re-applied at a later point with {@link applyViewportSettings}.
|
|
512
|
+
*/
|
|
513
|
+
getViewportSettings(): ISettings;
|
|
514
|
+
/**
|
|
515
|
+
* Determines if the current device is a mobile device (or tablet) but still doesn't support to view the content in AR.
|
|
516
|
+
*
|
|
517
|
+
* Can be used in combination with {@link viewableInAR} to display a warning to use a different browser
|
|
518
|
+
* if {@link viewableInAR} is false and {@link isMobileDeviceWithoutBrowserARSupport} is true.
|
|
519
|
+
*
|
|
520
|
+
* Reasons for that can be:
|
|
521
|
+
* - Firefox on Android
|
|
522
|
+
* - Instagram in App browser
|
|
523
|
+
*/
|
|
524
|
+
isMobileDeviceWithoutBrowserARSupport(): boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Pause the rendering of the scene.
|
|
527
|
+
* Can be used with {@link continueRendering} to continue/pause the rendering at will.
|
|
528
|
+
*
|
|
529
|
+
* @see {@link continueRendering}
|
|
530
|
+
*/
|
|
531
|
+
pauseRendering(): void;
|
|
532
|
+
/**
|
|
533
|
+
* Calculate the ray that is created by the pointer event and the camera.
|
|
534
|
+
*
|
|
535
|
+
* @param event
|
|
536
|
+
* @returns
|
|
537
|
+
*/
|
|
538
|
+
pointerEventToRay(event: PointerEvent): {
|
|
539
|
+
origin: vec3;
|
|
540
|
+
direction: vec3;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* From the provided origin and direction, trace the ray through the scene.
|
|
544
|
+
* The intersections with GeometryData will be returned including the corresponding nodes, sorted by their smallest distance.
|
|
545
|
+
*
|
|
546
|
+
* If you want to raytrace the scene from an interaction with the the canvas,
|
|
547
|
+
* please use {@link pointerEventToRay} to create a ray first.
|
|
548
|
+
*
|
|
549
|
+
* @param origin The origin of the ray.
|
|
550
|
+
* @param direction The direction of the ray.
|
|
551
|
+
* @param filterCriteria Optional filter criteria to filter the intersections.
|
|
552
|
+
*/
|
|
553
|
+
raytraceScene(origin: vec3, direction: vec3, filterCriteria?: IIntersectionFilter[]): {
|
|
554
|
+
distance: number;
|
|
555
|
+
node: ITreeNode;
|
|
556
|
+
data?: IGeometryData;
|
|
557
|
+
}[];
|
|
558
|
+
/**
|
|
559
|
+
* Remove the camera with the specified id and destroys it.
|
|
560
|
+
* If you remove the current active camera, the rendering will be stopped until a new camera is assigned.
|
|
561
|
+
*
|
|
562
|
+
* @param id The id of the camera.
|
|
563
|
+
*/
|
|
564
|
+
removeCamera(id: string): boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Remove an event listener that received all canvas events.
|
|
567
|
+
*
|
|
568
|
+
* @param token The token that was returned by {@link addCanvasEventListener}.
|
|
569
|
+
*/
|
|
570
|
+
removeCanvasEventListener(token: string): boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Removes the registered flag. Adding/removing flags allows to influence the render loop.
|
|
573
|
+
*
|
|
574
|
+
* @param token The token that was returned by {@link addFlag}.
|
|
575
|
+
*/
|
|
576
|
+
removeFlag(token: string): boolean;
|
|
577
|
+
/**
|
|
578
|
+
* Remove the light scene with the specified id.
|
|
579
|
+
* If you remove the current active light scene, no lights will be shown.
|
|
580
|
+
*
|
|
581
|
+
* @param id The id of the light scene.
|
|
582
|
+
*/
|
|
583
|
+
removeLightScene(id: string): boolean;
|
|
584
|
+
/**
|
|
585
|
+
* Remove the token from the list of restricted canvas listener tokens.
|
|
586
|
+
* Only listeners with a token in this list will receive events (if there is at least one item in the list).
|
|
587
|
+
*/
|
|
588
|
+
removeRestrictedCanvasListenerToken(token: string): void;
|
|
589
|
+
/**
|
|
590
|
+
* Manual call to render the scene.
|
|
591
|
+
*/
|
|
592
|
+
render(): void;
|
|
593
|
+
/**
|
|
594
|
+
* Delete all current cameras and create our 7 default cameras.
|
|
595
|
+
*
|
|
596
|
+
* A perspective one (default) and 6 orthographic ones (top, bottom, left, right, front, back).
|
|
597
|
+
*/
|
|
598
|
+
resetToDefaultCameras(): void;
|
|
599
|
+
/**
|
|
600
|
+
* If the {@link automaticResizing} is option is set to `false`, this function resizes the Viewport.
|
|
601
|
+
* @param width The new width of the Viewport.
|
|
602
|
+
* @param height The new height of the Viewport.
|
|
603
|
+
*/
|
|
604
|
+
resize(width: number, height: number): void;
|
|
605
|
+
/**
|
|
606
|
+
* Restrict events.
|
|
607
|
+
* This can be used to disable events for a viewport.
|
|
608
|
+
*
|
|
609
|
+
* Example use case: If you don't want to allow mouse wheel events for a specific viewport so that users can scroll past the viewport.
|
|
610
|
+
*
|
|
611
|
+
* Be aware that this might cause some issues with the the camera controls if the pointer events are disabled only partially.
|
|
612
|
+
*
|
|
613
|
+
* @param allowedListeners
|
|
614
|
+
*/
|
|
615
|
+
restrictEventListeners(allowedListeners: {
|
|
616
|
+
mousewheel?: boolean;
|
|
617
|
+
pointerdown?: boolean;
|
|
618
|
+
pointermove?: boolean;
|
|
619
|
+
pointerup?: boolean;
|
|
620
|
+
pointerout?: boolean;
|
|
621
|
+
keydown?: boolean;
|
|
622
|
+
keyup?: boolean;
|
|
623
|
+
contextmenu?: boolean;
|
|
624
|
+
}): void;
|
|
625
|
+
/**
|
|
626
|
+
* Update the viewport with the current changes of the complete scene tree.
|
|
627
|
+
* This carries out preparations for rendering. Call it after doing
|
|
628
|
+
* direct changes to the scene tree.
|
|
629
|
+
*/
|
|
630
|
+
update(): void;
|
|
631
|
+
/**
|
|
632
|
+
* Update the default line material of the viewport.
|
|
633
|
+
*
|
|
634
|
+
* @param value The new default line material.
|
|
635
|
+
*/
|
|
636
|
+
updateDefaultLineMaterial(value: MaterialBasicLineData): void;
|
|
637
|
+
/**
|
|
638
|
+
* Update the default materials of the viewport.
|
|
639
|
+
*
|
|
640
|
+
* @param value The new default material.
|
|
641
|
+
*/
|
|
642
|
+
updateDefaultMaterial(value: MaterialStandardData): void;
|
|
643
|
+
/**
|
|
644
|
+
* Update the default point material of the viewport.
|
|
645
|
+
*
|
|
646
|
+
* @param value The new default point material.
|
|
647
|
+
*/
|
|
648
|
+
updateDefaultPointMaterial(value: MaterialPointData): void;
|
|
649
|
+
/**
|
|
650
|
+
* Update the position of the environment geometry (grid, groundplane, etc) to the current viewport bounding box.
|
|
651
|
+
* Internally, this functions is called whenever a session is customized,
|
|
652
|
+
* but if you manually change parts of the scene, it might get necessary to call this function.
|
|
653
|
+
* Make sure to call {@link update} before, to apply the last changes.
|
|
654
|
+
*/
|
|
655
|
+
updateEnvironmentGeometry(): void;
|
|
656
|
+
/**
|
|
657
|
+
* Update the material of the given geometry data on the GPU without triggering a full scene tree reconversion.
|
|
658
|
+
* Use this instead of calling {@link IGeometryData.updateVersion} when only the effect material has changed,
|
|
659
|
+
* e.g. during hover interactions, to avoid the overhead of reconstructing Three.js objects.
|
|
660
|
+
*
|
|
661
|
+
* @param geometryData The geometry data whose material should be updated.
|
|
662
|
+
*/
|
|
663
|
+
updateGeometryData(geometryData: IGeometryData): void;
|
|
664
|
+
/**
|
|
665
|
+
* Update the viewport with the current changes of given scene tree node and its descendants.
|
|
666
|
+
* This carries out preparations for rendering. Call it after doing direct changes to the scene tree.
|
|
667
|
+
*
|
|
668
|
+
* @param node The node to update.
|
|
669
|
+
*/
|
|
670
|
+
updateNode(node: ITreeNode): void;
|
|
671
|
+
/**
|
|
672
|
+
* Update the viewport with the current changes in transformation of given scene tree node and its descendants.
|
|
673
|
+
* This carries out preparations for rendering. Call it after doing direct changes to the scene tree transformations.
|
|
674
|
+
*
|
|
675
|
+
* @param node The node to update.
|
|
676
|
+
*/
|
|
677
|
+
updateNodeTransformation(node: ITreeNode): void;
|
|
678
|
+
/**
|
|
679
|
+
* View the current scene in AR.
|
|
680
|
+
*
|
|
681
|
+
* Please check first if the device supports the viewing of models in AR, see {@link viewableInAR}.
|
|
682
|
+
* As some models might have a different scale then the AR apps (meters), the scaling can be chosen freely {@link arScale}.
|
|
683
|
+
*
|
|
684
|
+
* Internally, the scene will first be converted into a glTF. This glTF will be uploaded to our backend to be able to start AR.
|
|
685
|
+
*
|
|
686
|
+
* @param node Optional node to display in AR. (default: scene tree)
|
|
687
|
+
* @param androidOptions
|
|
688
|
+
*
|
|
689
|
+
* @throws {@type ShapeDiverViewerError}
|
|
690
|
+
*/
|
|
691
|
+
viewInAR(node?: ITreeNode): Promise<void>;
|
|
692
|
+
/**
|
|
693
|
+
* Determines if the current device supports viewing in AR.
|
|
694
|
+
*
|
|
695
|
+
* Can be used in combination with {@link isMobileDeviceWithoutBrowserARSupport} to display a warning to use a different browser
|
|
696
|
+
* if {@link viewableInAR} is false and {@link isMobileDeviceWithoutBrowserARSupport} is true.
|
|
697
|
+
*/
|
|
698
|
+
viewableInAR(): boolean;
|
|
699
|
+
}
|
|
700
700
|
//# sourceMappingURL=IViewportApi.d.ts.map
|