@combeenation/3d-viewer 4.0.0-alpha8 → 4.0.0-beta3
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/README.md +1 -0
- package/dist/lib-cjs/api/classes/element.d.ts +9 -14
- package/dist/lib-cjs/api/classes/element.js +96 -143
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/event.d.ts +1 -15
- package/dist/lib-cjs/api/classes/event.js +1 -15
- package/dist/lib-cjs/api/classes/event.js.map +1 -1
- package/dist/lib-cjs/api/classes/parameter.d.ts +7 -101
- package/dist/lib-cjs/api/classes/parameter.js +21 -141
- package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
- package/dist/lib-cjs/api/classes/parameterObservable.js +36 -11
- package/dist/lib-cjs/api/classes/parameterObservable.js.map +1 -1
- package/dist/lib-cjs/api/classes/variant.d.ts +14 -48
- package/dist/lib-cjs/api/classes/variant.js +56 -315
- package/dist/lib-cjs/api/classes/variant.js.map +1 -1
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +1 -5
- package/dist/lib-cjs/api/classes/variantInstance.js +0 -10
- package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewer.d.ts +1 -0
- package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewerLight.js +24 -16
- package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +1 -5
- package/dist/lib-cjs/api/internal/sceneSetup.js +71 -75
- package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +4 -51
- package/dist/lib-cjs/api/util/babylonHelper.js +8 -141
- package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +11 -53
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +26 -4
- package/dist/lib-cjs/api/util/resourceHelper.js +56 -53
- package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
- package/dist/lib-cjs/index.d.ts +22 -24
- package/dist/lib-cjs/index.js +38 -42
- package/dist/lib-cjs/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/classes/element.ts +100 -110
- package/src/api/classes/{parameterizable.ts → elementParameterizable.ts} +1 -12
- package/src/api/classes/event.ts +1 -16
- package/src/api/classes/parameter.ts +22 -153
- package/src/api/classes/parameterObservable.ts +31 -9
- package/src/api/classes/variant.ts +51 -184
- package/src/api/classes/variantInstance.ts +1 -8
- package/src/api/classes/viewer.ts +1 -0
- package/src/api/internal/sceneSetup.ts +109 -99
- package/src/api/util/babylonHelper.ts +9 -153
- package/src/api/util/globalTypes.ts +13 -64
- package/src/api/util/resourceHelper.ts +53 -26
- package/src/dev.ts +7 -5
- package/src/index.ts +23 -27
- package/src/pagesconfig.json +13 -8
- package/dist/lib-cjs/api/emitter.d.ts +0 -35
- package/dist/lib-cjs/api/emitter.js +0 -61
- package/dist/lib-cjs/api/emitter.js.map +0 -1
- package/src/api/classes/variantParameterizable.ts +0 -73
- package/src/api/classes/viewerLight.ts +0 -326
- package/src/api/util/stringHelper.ts +0 -26
|
@@ -1,171 +1,180 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { Engine } from '@babylonjs/core/Engines/engine';
|
|
3
|
-
import '@babylonjs/core/Helpers/sceneHelpers';
|
|
4
3
|
import '@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader';
|
|
5
|
-
import
|
|
4
|
+
import '@babylonjs/core/Helpers/sceneHelpers';
|
|
5
|
+
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
|
|
6
|
+
import { HDRCubeTexture } from '@babylonjs/core/Materials/Textures/hdrCubeTexture';
|
|
7
|
+
import { Texture } from '@babylonjs/core/Materials/Textures/texture';
|
|
8
|
+
import { Color3, Color4 } from '@babylonjs/core/Maths/math.color';
|
|
6
9
|
import { Vector3 } from '@babylonjs/core/Maths/math.vector';
|
|
7
|
-
import { GroundMesh } from '@babylonjs/core/Meshes/groundMesh';
|
|
8
10
|
import { MeshBuilder } from '@babylonjs/core/Meshes/meshBuilder';
|
|
9
11
|
import { DefaultRenderingPipeline } from '@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline';
|
|
10
12
|
import { Scene } from '@babylonjs/core/scene';
|
|
11
|
-
import {
|
|
13
|
+
import type { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight';
|
|
14
|
+
import { Camera } from '@babylonjs/core/Cameras/camera';
|
|
15
|
+
import { Light } from '@babylonjs/core/Lights/light';
|
|
12
16
|
import { Parameter } from '../classes/parameter';
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_resolve( _ground );
|
|
47
|
-
};
|
|
48
|
-
MeshBuilder.CreateGroundFromHeightMap(
|
|
49
|
-
name,
|
|
50
|
-
definition.url,
|
|
51
|
-
definition,
|
|
52
|
-
scene,
|
|
53
|
-
);
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
throw new Error( `Ground of type "${definition.type}" not implemented (yet).` );
|
|
57
|
-
}
|
|
58
|
-
} );
|
|
18
|
+
|
|
19
|
+
const defaultLightning = async function(scene: Scene) {
|
|
20
|
+
const defaultSetup: LightDefinition = {
|
|
21
|
+
type: 'hemispheric',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const defaultLight = await processLight(scene, 'default_light', defaultSetup) as HemisphericLight;
|
|
25
|
+
defaultLight.groundColor = Color3.Black();
|
|
26
|
+
defaultLight.diffuse = Color3.White();
|
|
27
|
+
|
|
28
|
+
return defaultLight;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const processLight = async function(scene: Scene, name: string, lightSetup: LightDefinition) {
|
|
33
|
+
|
|
34
|
+
let light: Light;
|
|
35
|
+
|
|
36
|
+
switch(lightSetup.type ) {
|
|
37
|
+
case 'hemispheric':
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
const hemisphericLightModule = await import(/* webpackChunkName: "hemispheric-light" */ '@babylonjs/core/Lights/hemisphericLight');
|
|
40
|
+
light = new hemisphericLightModule.HemisphericLight( name, Vector3.Up(), scene);
|
|
41
|
+
break;
|
|
42
|
+
case 'point':
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
const pointLightModule = await import(/* webpackChunkName: "point-light" */ '@babylonjs/core/Lights/pointLight');
|
|
45
|
+
light = new pointLightModule.PointLight( name, Vector3.Up(), scene);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return light;
|
|
59
50
|
};
|
|
60
51
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
return await processCamera( scene, 'default_camera', {
|
|
52
|
+
|
|
53
|
+
const defaultCamera = async function(scene: Scene) {
|
|
54
|
+
|
|
55
|
+
const cameraSetup: CameraDefinition = {
|
|
66
56
|
type: 'arc',
|
|
67
57
|
active: true,
|
|
68
|
-
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const defaultCamera = await processCamera(scene, 'default_camera', cameraSetup);
|
|
61
|
+
|
|
62
|
+
return defaultCamera;
|
|
69
63
|
};
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* @param name
|
|
74
|
-
* @param cameraSetup
|
|
75
|
-
*/
|
|
76
|
-
const processCamera = async function( scene: Scene, name: string, cameraSetup: CameraDefinition ): Promise<Camera> {
|
|
65
|
+
const processCamera = async function(scene: Scene, name: string, cameraSetup: CameraDefinition) {
|
|
66
|
+
|
|
77
67
|
let camera: Camera;
|
|
68
|
+
|
|
78
69
|
let target = Vector3.Zero();
|
|
79
|
-
if(
|
|
80
|
-
target = Parameter.parseVector(
|
|
70
|
+
if(cameraSetup.target) {
|
|
71
|
+
target = Parameter.parseVector(cameraSetup.target);
|
|
81
72
|
}
|
|
82
|
-
|
|
73
|
+
|
|
74
|
+
switch(cameraSetup.type ) {
|
|
83
75
|
case 'arc':
|
|
84
76
|
// @ts-ignore
|
|
85
77
|
const arcCameraModule = await import(/* webpackChunkName: "arc-rotate-camera" */ '@babylonjs/core/Cameras/arcRotateCamera');
|
|
86
|
-
camera = new arcCameraModule.ArcRotateCamera(
|
|
78
|
+
camera = new arcCameraModule.ArcRotateCamera(name, Math.PI / 4, Math.PI / 4, 2, target, scene );
|
|
87
79
|
camera.metadata = {
|
|
88
80
|
alpha: Math.PI / 4,
|
|
89
81
|
beta: Math.PI / 4,
|
|
90
82
|
radius: 2
|
|
91
83
|
};
|
|
92
84
|
break;
|
|
85
|
+
|
|
93
86
|
}
|
|
94
|
-
|
|
87
|
+
|
|
88
|
+
if(cameraSetup.active) {
|
|
95
89
|
camera.attachControl( scene.getEngine().getRenderingCanvas()!, true );
|
|
96
90
|
}
|
|
91
|
+
|
|
97
92
|
if( cameraSetup.fov ) {
|
|
98
93
|
camera.fov = cameraSetup.fov;
|
|
99
94
|
}
|
|
95
|
+
|
|
100
96
|
camera.storeState();
|
|
101
97
|
return camera;
|
|
102
98
|
};
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
* @param engine
|
|
106
|
-
* @param sceneJson
|
|
107
|
-
*/
|
|
108
|
-
const sceneSetup = async function(engine: Engine, sceneJson: SceneJson): Promise<Scene> {
|
|
100
|
+
const sceneSetup = async function(engine: Engine, sceneJson: SceneJson) {
|
|
109
101
|
const scene = new Scene( engine );
|
|
110
102
|
scene.clearColor = new Color4(0, 0, 0, 0);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if( !
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
|
|
104
|
+
let cameras: Camera[] = [];
|
|
105
|
+
//there is either no "cameras" or "cameras" is empty
|
|
106
|
+
if( ! sceneJson.scene.hasOwnProperty('cameras') || (sceneJson.scene.cameras && ! Object.keys(sceneJson.scene.cameras).length ) ) {
|
|
107
|
+
const camera = await defaultCamera(scene);
|
|
108
|
+
|
|
109
|
+
cameras.push(camera);
|
|
118
110
|
} else {
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
for(let camera in sceneJson.scene.cameras) {
|
|
112
|
+
cameras.push(await processCamera(scene, camera, sceneJson.scene.cameras[camera]));
|
|
113
|
+
}
|
|
121
114
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
//there is either no "lights" or "lights" is empty
|
|
118
|
+
if( ! sceneJson.scene.hasOwnProperty('lights') || (sceneJson.scene.lights && ! Object.keys(sceneJson.scene.lights).length ) ) {
|
|
119
|
+
// await defaultLightning(scene);
|
|
120
|
+
} else {
|
|
121
|
+
for(let light in sceneJson.scene.lights) {
|
|
122
|
+
await processLight(scene, light, sceneJson.scene.lights[light]);
|
|
127
123
|
}
|
|
128
124
|
}
|
|
125
|
+
|
|
126
|
+
|
|
129
127
|
// TODO: try to split this away from the default rendering pipeline to save module imports
|
|
130
128
|
// The "hdr" setting had negative effect on rendering in Safari. Everything looked a little "edgy". I'm not completely
|
|
131
129
|
// sure if disabling it comes with other negative side effects I don't see right now, so we should probably
|
|
132
130
|
// investigate this a little more in detail at some point.
|
|
133
131
|
const defaultPipeline = new DefaultRenderingPipeline( 'default-rendering-pipeline', false, scene );
|
|
132
|
+
|
|
134
133
|
/* DISABLED: causes problems with Internet Explorer
|
|
135
134
|
defaultPipeline.imageProcessingEnabled = true;
|
|
136
135
|
*/
|
|
136
|
+
|
|
137
137
|
if( sceneJson.scene.globals.aa ) {
|
|
138
138
|
defaultPipeline.fxaaEnabled = true; //implicitly does FxaaPostProcess()
|
|
139
139
|
}
|
|
140
|
+
|
|
140
141
|
// Set samples regardless of fxaa setting since we don't want to use fxaa but still increase the sample count
|
|
141
142
|
defaultPipeline.samples = 8;
|
|
143
|
+
|
|
142
144
|
if( sceneJson.scene.globals['camera-settings'] ) {
|
|
143
|
-
if( sceneJson.scene.globals['camera-settings']
|
|
145
|
+
if( sceneJson.scene.globals['camera-settings'].sharpen && sceneJson.scene.globals['camera-settings'].sharpen.enabled ) {
|
|
144
146
|
defaultPipeline.sharpenEnabled = true; //implicitly does SharpenPostProcess()
|
|
145
147
|
//defaultPipeline.sharpen.colorAmount = 1;
|
|
146
148
|
//defaultPipeline.sharpen.edgeAmount = 0;
|
|
147
149
|
}
|
|
148
|
-
|
|
150
|
+
|
|
151
|
+
if( sceneJson.scene.globals['camera-settings'].bloom && sceneJson.scene.globals['camera-settings'].bloom.enabled ) {
|
|
149
152
|
defaultPipeline.bloomEnabled = true;
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
|
|
154
|
+
if( sceneJson.scene.globals['camera-settings'].bloom.size ) {
|
|
155
|
+
defaultPipeline.bloomScale = sceneJson.scene.globals['camera-settings'].bloom.size;
|
|
152
156
|
}
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
|
|
158
|
+
if( sceneJson.scene.globals['camera-settings'].bloom.threshold ) {
|
|
159
|
+
defaultPipeline.bloomThreshold = sceneJson.scene.globals['camera-settings'].bloom.threshold;
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
|
|
163
|
+
if( sceneJson.scene.globals['camera-settings'].contrast ) {
|
|
164
|
+
scene.imageProcessingConfiguration.contrast = sceneJson.scene.globals['camera-settings'].contrast;
|
|
159
165
|
}
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
|
|
167
|
+
if( sceneJson.scene.globals['camera-settings'].exposure ) {
|
|
168
|
+
scene.imageProcessingConfiguration.exposure = sceneJson.scene.globals['camera-settings'].exposure;
|
|
162
169
|
}
|
|
163
|
-
|
|
170
|
+
|
|
171
|
+
if( sceneJson.scene.globals['camera-settings'].dof && sceneJson.scene.globals['camera-settings'].dof.enabled ) {
|
|
164
172
|
//@ts-ignore
|
|
165
173
|
const module = await import(/* webpackChunkName: "lens-rendering" */ './lensRendering');
|
|
166
|
-
new module.LensRenderingPipeline( 'lens-rendering', sceneJson.scene.globals['camera-settings']!.
|
|
174
|
+
new module.LensRenderingPipeline( 'lens-rendering', sceneJson.scene.globals['camera-settings'].dof!.settings, scene, 1.0, cameras );
|
|
167
175
|
}
|
|
168
176
|
}
|
|
177
|
+
|
|
169
178
|
// TODO: make this dynamic
|
|
170
179
|
/*
|
|
171
180
|
const texture = new HDRCubeTexture("/assets/small_cave_1k.hdr", scene, 256);
|
|
@@ -186,9 +195,10 @@ const sceneSetup = async function(engine: Engine, sceneJson: SceneJson): Promise
|
|
|
186
195
|
*/
|
|
187
196
|
|
|
188
197
|
// TODO: shadows don't work with HemishpericLight
|
|
198
|
+
|
|
189
199
|
return scene;
|
|
190
200
|
};
|
|
191
201
|
|
|
192
202
|
export {
|
|
193
203
|
sceneSetup
|
|
194
|
-
}
|
|
204
|
+
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { HighlightLayer } from '@babylonjs/core/Layers/highlightLayer';
|
|
2
|
-
import { Light } from '@babylonjs/core/Lights/light';
|
|
3
|
-
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
|
|
4
2
|
import { Material } from '@babylonjs/core/Materials/material';
|
|
5
3
|
import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
|
|
6
4
|
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
|
|
7
|
-
import { Axis, Space } from '@babylonjs/core/Maths/math.axis';
|
|
8
5
|
import { Color3 } from '@babylonjs/core/Maths/math.color';
|
|
9
6
|
import { Vector3 } from '@babylonjs/core/Maths/math.vector';
|
|
10
7
|
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
|
|
@@ -13,22 +10,9 @@ import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
|
13
10
|
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
14
11
|
import { Node } from '@babylonjs/core/node';
|
|
15
12
|
import { Scene } from '@babylonjs/core/scene';
|
|
16
|
-
import {
|
|
17
|
-
import { cloneDeep, get, merge } from 'lodash-es';
|
|
13
|
+
import { cloneDeep, merge } from 'lodash-es';
|
|
18
14
|
import { DottedPath } from '../classes/dottedPath';
|
|
19
15
|
|
|
20
|
-
/**
|
|
21
|
-
* @param node
|
|
22
|
-
* @return Node
|
|
23
|
-
*/
|
|
24
|
-
const getRootNode = function( node: Node ): Node {
|
|
25
|
-
let _node = node;
|
|
26
|
-
while( _node.parent ) {
|
|
27
|
-
_node = _node.parent;
|
|
28
|
-
}
|
|
29
|
-
return _node;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
16
|
/**
|
|
33
17
|
* @param nodes
|
|
34
18
|
* @param predicate
|
|
@@ -55,17 +39,18 @@ const mapToDottedNodes = function <T>( nodes: Node[],
|
|
|
55
39
|
* @param node
|
|
56
40
|
* @return DottedPath
|
|
57
41
|
*/
|
|
58
|
-
const
|
|
42
|
+
const getDottedPathForTransformNode = function( node: TransformNode ): DottedPath {
|
|
59
43
|
const dottedPath = DottedPath.create( node.name );
|
|
60
44
|
let _parent = node;
|
|
61
45
|
while( _parent.parent ) {
|
|
62
|
-
_parent = _parent.parent;
|
|
46
|
+
_parent = _parent.parent as TransformNode;
|
|
63
47
|
dottedPath.unshiftPart( _parent.name );
|
|
64
48
|
}
|
|
65
49
|
return dottedPath;
|
|
66
50
|
};
|
|
67
51
|
|
|
68
52
|
/**
|
|
53
|
+
*
|
|
69
54
|
* @param node
|
|
70
55
|
* @param predicate
|
|
71
56
|
* @param deep
|
|
@@ -93,21 +78,6 @@ const cloneTransformNode = function( node: TransformNode,
|
|
|
93
78
|
return clone;
|
|
94
79
|
};
|
|
95
80
|
|
|
96
|
-
/**
|
|
97
|
-
* @param node
|
|
98
|
-
*/
|
|
99
|
-
const cloneNodeWithParents = function( node: Node | null ): Node | null {
|
|
100
|
-
let clone = null;
|
|
101
|
-
if( node instanceof TransformNode ) {
|
|
102
|
-
clone = node.clone( node.name, cloneNodeWithParents( node.parent ), true );
|
|
103
|
-
} else if( node instanceof Light ) {
|
|
104
|
-
clone = node.clone( node.name, cloneNodeWithParents( node.parent ) );
|
|
105
|
-
} else if( node ) {
|
|
106
|
-
throw new Error( `Cloning of "${node?.constructor.name}" is not implemented (yet).` );
|
|
107
|
-
}
|
|
108
|
-
return clone;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
81
|
/**
|
|
112
82
|
* @param node
|
|
113
83
|
* @param deep
|
|
@@ -136,11 +106,11 @@ const cloneTransformNodeMaterial = function( node: TransformNode,
|
|
|
136
106
|
* @param deep
|
|
137
107
|
* @param metadata
|
|
138
108
|
*/
|
|
139
|
-
const
|
|
109
|
+
const injectTransformNodeMetadata = function( node: TransformNode, metadata: {}, deep: boolean = true ) {
|
|
140
110
|
node.metadata = merge( {}, node.metadata, metadata );
|
|
141
|
-
if( deep
|
|
111
|
+
if( deep ) {
|
|
142
112
|
const children = node.getChildTransformNodes( true );
|
|
143
|
-
children.forEach( child =>
|
|
113
|
+
children.forEach( child => injectTransformNodeMetadata( child, metadata, deep ) );
|
|
144
114
|
}
|
|
145
115
|
};
|
|
146
116
|
|
|
@@ -195,61 +165,6 @@ const deactivateTransformNode = function( node: TransformNode, deep: boolean = t
|
|
|
195
165
|
}
|
|
196
166
|
};
|
|
197
167
|
|
|
198
|
-
/**
|
|
199
|
-
* @param node
|
|
200
|
-
*/
|
|
201
|
-
const enableNodeWithParents = function( node: Node ) {
|
|
202
|
-
node.setEnabled( true );
|
|
203
|
-
if ( node.parent ) {
|
|
204
|
-
enableNodeWithParents( node.parent );
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* @param node
|
|
210
|
-
*/
|
|
211
|
-
const disableNodeWithParents = function( node: Node ) {
|
|
212
|
-
node.setEnabled( false );
|
|
213
|
-
if ( node.parent ) {
|
|
214
|
-
disableNodeWithParents( node.parent );
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* @param node
|
|
220
|
-
* @param rotation
|
|
221
|
-
* @param space
|
|
222
|
-
*/
|
|
223
|
-
const rotateTransformNode = function( node: TransformNode, rotation: Vector3 ): TransformNode {
|
|
224
|
-
// remember absolute rotation and reset it before translating
|
|
225
|
-
if( !get( node.metadata, 'rotation' ) ) {
|
|
226
|
-
injectNodeMetadata( node, { rotation: node.rotation.clone() }, false);
|
|
227
|
-
}
|
|
228
|
-
node.rotation = node.metadata.rotation;
|
|
229
|
-
// rotate
|
|
230
|
-
node.rotate( Axis.X, rotation.x, Space.WORLD );
|
|
231
|
-
node.rotate( Axis.Y, rotation.y, Space.WORLD );
|
|
232
|
-
node.rotate( Axis.Z, rotation.z, Space.WORLD );
|
|
233
|
-
return node;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @param node
|
|
238
|
-
* @param distance
|
|
239
|
-
*/
|
|
240
|
-
const moveTransformNode = function( node: TransformNode, distance: Vector3 ): TransformNode {
|
|
241
|
-
// remember absolute position and reset it before translating
|
|
242
|
-
if( !get( node.metadata, 'position' ) ) {
|
|
243
|
-
injectNodeMetadata( node, { position: node.absolutePosition.clone() }, false);
|
|
244
|
-
}
|
|
245
|
-
node.setAbsolutePosition( node.metadata.position );
|
|
246
|
-
// move
|
|
247
|
-
node.translate( Axis.X, distance.x, Space.WORLD );
|
|
248
|
-
node.translate( Axis.Y, distance.y, Space.WORLD );
|
|
249
|
-
node.translate( Axis.Z, distance.z, Space.WORLD );
|
|
250
|
-
return node;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
168
|
/**
|
|
254
169
|
* @param node
|
|
255
170
|
* @param material
|
|
@@ -420,56 +335,6 @@ const removeFromHighlightLayer = function( layer: HighlightLayer, node: Transfor
|
|
|
420
335
|
}
|
|
421
336
|
};
|
|
422
337
|
|
|
423
|
-
/**
|
|
424
|
-
* @param node
|
|
425
|
-
* @param receiveShadows
|
|
426
|
-
* @param deep
|
|
427
|
-
*/
|
|
428
|
-
const setReceiveShadows = function( node: TransformNode, receiveShadows: boolean, deep: boolean = true ) {
|
|
429
|
-
if( node instanceof AbstractMesh ) {
|
|
430
|
-
node.receiveShadows = receiveShadows;
|
|
431
|
-
}
|
|
432
|
-
if( deep ) {
|
|
433
|
-
node.getChildTransformNodes( true ).forEach(
|
|
434
|
-
child => setReceiveShadows( child, receiveShadows, deep )
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* @param node
|
|
441
|
-
* @param generator
|
|
442
|
-
* @param deep
|
|
443
|
-
*/
|
|
444
|
-
const addToShadowGenerator = function( generator: ShadowGenerator, node: TransformNode, deep: boolean = true ) {
|
|
445
|
-
if( node instanceof AbstractMesh ) {
|
|
446
|
-
// We have to remove the node because there's no duplicate check in babylon
|
|
447
|
-
generator.removeShadowCaster( node, false );
|
|
448
|
-
generator.addShadowCaster( node, false );
|
|
449
|
-
}
|
|
450
|
-
if( deep ) {
|
|
451
|
-
node.getChildTransformNodes( true ).forEach(
|
|
452
|
-
child => addToShadowGenerator( generator, child, deep )
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* @param node
|
|
459
|
-
* @param generator
|
|
460
|
-
* @param deep
|
|
461
|
-
*/
|
|
462
|
-
const removeFromShadowGenerator = function( generator: ShadowGenerator, node: TransformNode, deep: boolean = true ) {
|
|
463
|
-
if( node instanceof AbstractMesh ) {
|
|
464
|
-
generator.removeShadowCaster( node, false );
|
|
465
|
-
}
|
|
466
|
-
if( deep ) {
|
|
467
|
-
node.getChildTransformNodes( true ).forEach(
|
|
468
|
-
child => removeFromShadowGenerator( generator, child, deep )
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
|
|
473
338
|
/**
|
|
474
339
|
* https://forum.babylonjs.com/t/get-mesh-bounding-box-position-and-size-in-2d-screen-coordinates/1058/3
|
|
475
340
|
* @param mesh
|
|
@@ -507,20 +372,14 @@ const getClientRectFromMesh = function( mesh: AbstractMesh, scene: Scene, canvas
|
|
|
507
372
|
};
|
|
508
373
|
|
|
509
374
|
export {
|
|
510
|
-
getRootNode,
|
|
511
375
|
mapToDottedNodes,
|
|
512
|
-
|
|
376
|
+
getDottedPathForTransformNode,
|
|
513
377
|
cloneTransformNode,
|
|
514
|
-
cloneNodeWithParents,
|
|
515
378
|
cloneTransformNodeMaterial,
|
|
516
|
-
|
|
379
|
+
injectTransformNodeMetadata,
|
|
517
380
|
assertTransformNode,
|
|
518
381
|
activateTransformNode,
|
|
519
382
|
deactivateTransformNode,
|
|
520
|
-
enableNodeWithParents,
|
|
521
|
-
disableNodeWithParents,
|
|
522
|
-
rotateTransformNode,
|
|
523
|
-
moveTransformNode,
|
|
524
383
|
setMaterial,
|
|
525
384
|
setSourceNodeMaterial,
|
|
526
385
|
setMaterialColor,
|
|
@@ -529,8 +388,5 @@ export {
|
|
|
529
388
|
setMaterialRoughness,
|
|
530
389
|
addToHighlightLayer,
|
|
531
390
|
removeFromHighlightLayer,
|
|
532
|
-
setReceiveShadows,
|
|
533
|
-
addToShadowGenerator,
|
|
534
|
-
removeFromShadowGenerator,
|
|
535
391
|
getClientRectFromMesh
|
|
536
392
|
};
|
|
@@ -8,7 +8,6 @@ type VariantInstance = import("../classes/variantInstance").VariantInstance;
|
|
|
8
8
|
*/
|
|
9
9
|
type VariantElement = import("../classes/element").Element;
|
|
10
10
|
type DottedPath = import("../classes/dottedPath").DottedPath;
|
|
11
|
-
type ViewerLight = import("../classes/viewerLight").ViewerLight;
|
|
12
11
|
|
|
13
12
|
// global accessible types imported from BabylonJS
|
|
14
13
|
type Scene = import("@babylonjs/core/scene").Scene;
|
|
@@ -69,10 +68,6 @@ type Asset = {
|
|
|
69
68
|
fileName: string | undefined
|
|
70
69
|
};
|
|
71
70
|
|
|
72
|
-
type ElementDefinitions = {
|
|
73
|
-
[name: string]: ElementDefinition | string[]
|
|
74
|
-
};
|
|
75
|
-
|
|
76
71
|
type ElementDefinition = {
|
|
77
72
|
paths: PathDefinitions,
|
|
78
73
|
traceables?: TraceableDefinitions,
|
|
@@ -97,9 +92,9 @@ type StructureJson = {
|
|
|
97
92
|
glTF?: Asset | string,
|
|
98
93
|
parameterDeclaration?: ParameterDeclarations,
|
|
99
94
|
parameters?: ParameterBag,
|
|
100
|
-
elements?:
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
elements?: {
|
|
96
|
+
[name: string]: ElementDefinition | string[]
|
|
97
|
+
},
|
|
103
98
|
/**
|
|
104
99
|
* `variants` is a declarative description of 3D-model variations in the configurator. Each variant itself is a
|
|
105
100
|
* {@link StructureJson} which must at least define a `name` in the key of the list and the properties `glTF` and
|
|
@@ -128,7 +123,7 @@ type StructureJson = {
|
|
|
128
123
|
*/
|
|
129
124
|
variants?: {
|
|
130
125
|
[id: string]: StructureJson,
|
|
131
|
-
}
|
|
126
|
+
}
|
|
132
127
|
};
|
|
133
128
|
|
|
134
129
|
type SceneJson = {
|
|
@@ -149,7 +144,8 @@ type SceneJson = {
|
|
|
149
144
|
|
|
150
145
|
type SceneDefinition = {
|
|
151
146
|
globals: SceneGlobals,
|
|
152
|
-
|
|
147
|
+
lights?: LightDefinitions,
|
|
148
|
+
cameras?: CameraDefinitions
|
|
153
149
|
};
|
|
154
150
|
|
|
155
151
|
type SceneGlobals = {
|
|
@@ -193,29 +189,12 @@ type SceneGlobals = {
|
|
|
193
189
|
}
|
|
194
190
|
};
|
|
195
191
|
|
|
196
|
-
/**
|
|
197
|
-
* {@link Viewer.screenshot} internally uses Babylons [ScreenshotTools.CreateScreenshotUsingRenderTarget](https://doc.babylonjs.com/typedoc/classes/babylon.screenshottools#createscreenshotusingrendertarget). \
|
|
198
|
-
* See this link for additional info about the properties.
|
|
199
|
-
*/
|
|
200
192
|
type ScreenshotSettings = {
|
|
201
|
-
/** Defaults to canvas width & height */
|
|
202
193
|
size?: IScreenshotSize,
|
|
203
|
-
/**
|
|
204
|
-
* Default `image/png`
|
|
205
|
-
*
|
|
206
|
-
* **Info regarding JPEG:** \
|
|
207
|
-
* Use mimeType `image/jpeg` (**not** `image/jpg`) when creating jpeg's. \
|
|
208
|
-
* Also ensure that {@link Scene.clearColor | viewer.scene.clearColor} has an alpha value of `1` as jpeg's don't support
|
|
209
|
-
* transparency. Otherwise background will always be black for jpeg's.
|
|
210
|
-
*/
|
|
211
194
|
mimeType?: string,
|
|
212
|
-
/** Default `1` */
|
|
213
195
|
samples?: number,
|
|
214
|
-
/** Default `false` */
|
|
215
196
|
antialiasing?: boolean,
|
|
216
|
-
/** Default `screenshot.png` */
|
|
217
197
|
fileName?: string,
|
|
218
|
-
/** Default `false` */
|
|
219
198
|
renderSprites?: boolean
|
|
220
199
|
};
|
|
221
200
|
|
|
@@ -231,40 +210,11 @@ type AutofocusSettings = {
|
|
|
231
210
|
};
|
|
232
211
|
|
|
233
212
|
type LightDefinitions = {
|
|
234
|
-
[
|
|
213
|
+
[light: string]: LightDefinition
|
|
235
214
|
};
|
|
236
215
|
|
|
237
216
|
type LightDefinition = {
|
|
238
|
-
type: '
|
|
239
|
-
path?: string,
|
|
240
|
-
shadowGenerator?: ShadowGeneratorDefinition
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
type ShadowGeneratorDefinition = {
|
|
244
|
-
mapSize: number
|
|
245
|
-
[others: string]: any,
|
|
246
|
-
/**
|
|
247
|
-
* Further properties like `usePoissonSampling` are set directly on the ShadowGenerator object.
|
|
248
|
-
* [Shadows](https://doc.babylonjs.com/divingDeeper/lights/shadows)
|
|
249
|
-
*/
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
type GroundDefinitions = {
|
|
253
|
-
[ground: string]: GroundDefinition
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
type GroundDefinition = {
|
|
257
|
-
type: 'baked' | 'ground' | 'heightmap',
|
|
258
|
-
meshId?: string,
|
|
259
|
-
url?: string,
|
|
260
|
-
width?: number,
|
|
261
|
-
height?: number,
|
|
262
|
-
subdivisions?: number,
|
|
263
|
-
receiveShadows?: boolean,
|
|
264
|
-
minHeight?: number,
|
|
265
|
-
maxHeight?: number,
|
|
266
|
-
alphaFilter?: number,
|
|
267
|
-
onReady?: any
|
|
217
|
+
type: 'hemispheric' | 'point'
|
|
268
218
|
};
|
|
269
219
|
|
|
270
220
|
type CameraDefinitions = {
|
|
@@ -280,6 +230,10 @@ type CameraDefinition = {
|
|
|
280
230
|
/**
|
|
281
231
|
* `arc` is a default camera position where the 3D-model is the center and the camera rotates around the 3D-model.
|
|
282
232
|
* More Information about `arc` in [ArcRotateCamera](https://doc.babylonjs.com/typedoc/classes/babylon.arcrotatecamera).
|
|
233
|
+
*
|
|
234
|
+
* NOTE: While "baked" camera definitions from a GLB or babylon file can currently not be instatiated within the `Specification`, it's still possible to use them in the viewer.\
|
|
235
|
+
* For the moment all camera definitions inside these files are automatically added to the scene and can be actived using the {@link switchCamera} function.\
|
|
236
|
+
* The `newCamera` input has to match the name of the camera node inside the GLB/babylon file.
|
|
283
237
|
*/
|
|
284
238
|
type: 'arc'
|
|
285
239
|
/**
|
|
@@ -304,8 +258,7 @@ type ParameterDeclarations = {
|
|
|
304
258
|
};
|
|
305
259
|
|
|
306
260
|
type ParameterDeclaration = {
|
|
307
|
-
type: 'string' | 'boolean' | 'number' | 'color' | 'select' | 'vector'
|
|
308
|
-
parser?: any,
|
|
261
|
+
type: 'string' | 'boolean' | 'number' | 'color' | 'select' | 'vector',
|
|
309
262
|
options?: ParameterValue[]
|
|
310
263
|
};
|
|
311
264
|
|
|
@@ -315,10 +268,6 @@ type ParameterBag = {
|
|
|
315
268
|
[name: string]: ParameterValue
|
|
316
269
|
};
|
|
317
270
|
|
|
318
|
-
type ParsedParameterBag = {
|
|
319
|
-
[name: string]: any
|
|
320
|
-
};
|
|
321
|
-
|
|
322
271
|
type DottedPathArgument = string | string[] | DottedPath;
|
|
323
272
|
|
|
324
273
|
type ParameterObserver = (
|