@combeenation/3d-viewer 12.4.1 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib-cjs/buildinfo.json +1 -1
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/dist/lib-cjs/index.d.ts +63 -63
- package/dist/lib-cjs/index.js +81 -114
- package/dist/lib-cjs/index.js.map +1 -1
- package/dist/lib-cjs/internal/cbnCustomBabylonLoaderPlugin.d.ts +10 -0
- package/dist/lib-cjs/internal/cbnCustomBabylonLoaderPlugin.js +124 -0
- package/dist/lib-cjs/internal/cbnCustomBabylonLoaderPlugin.js.map +1 -0
- package/dist/lib-cjs/internal/cloningHelper.d.ts +19 -0
- package/dist/lib-cjs/internal/cloningHelper.js +165 -0
- package/dist/lib-cjs/internal/cloningHelper.js.map +1 -0
- package/dist/lib-cjs/internal/deviceHelper.d.ts +9 -0
- package/dist/lib-cjs/{api/util → internal}/deviceHelper.js +6 -10
- package/dist/lib-cjs/internal/deviceHelper.js.map +1 -0
- package/dist/lib-cjs/internal/geometryHelper.d.ts +21 -0
- package/dist/lib-cjs/{api/util → internal}/geometryHelper.js +57 -24
- package/dist/lib-cjs/internal/geometryHelper.js.map +1 -0
- package/dist/lib-cjs/internal/metadataHelper.d.ts +26 -0
- package/dist/lib-cjs/internal/metadataHelper.js +51 -0
- package/dist/lib-cjs/internal/metadataHelper.js.map +1 -0
- package/dist/lib-cjs/internal/paintableHelper.d.ts +40 -0
- package/dist/lib-cjs/internal/paintableHelper.js +287 -0
- package/dist/lib-cjs/internal/paintableHelper.js.map +1 -0
- package/dist/lib-cjs/internal/tagsHelper.d.ts +12 -0
- package/dist/lib-cjs/internal/tagsHelper.js +38 -0
- package/dist/lib-cjs/internal/tagsHelper.js.map +1 -0
- package/dist/lib-cjs/manager/cameraManager.d.ts +51 -0
- package/dist/lib-cjs/manager/cameraManager.js +154 -0
- package/dist/lib-cjs/manager/cameraManager.js.map +1 -0
- package/dist/lib-cjs/manager/debugManager.d.ts +60 -0
- package/dist/lib-cjs/manager/debugManager.js +218 -0
- package/dist/lib-cjs/manager/debugManager.js.map +1 -0
- package/dist/lib-cjs/manager/eventManager.d.ts +52 -0
- package/dist/lib-cjs/manager/eventManager.js +72 -0
- package/dist/lib-cjs/manager/eventManager.js.map +1 -0
- package/dist/lib-cjs/{api/manager → manager}/gltfExportManager.d.ts +29 -34
- package/dist/lib-cjs/{api/manager → manager}/gltfExportManager.js +99 -120
- package/dist/lib-cjs/manager/gltfExportManager.js.map +1 -0
- package/dist/lib-cjs/manager/materialManager.d.ts +35 -0
- package/dist/lib-cjs/manager/materialManager.js +126 -0
- package/dist/lib-cjs/manager/materialManager.js.map +1 -0
- package/dist/lib-cjs/manager/modelManager.d.ts +145 -0
- package/dist/lib-cjs/manager/modelManager.js +381 -0
- package/dist/lib-cjs/manager/modelManager.js.map +1 -0
- package/dist/lib-cjs/manager/parameterManager.d.ts +210 -0
- package/dist/lib-cjs/manager/parameterManager.js +515 -0
- package/dist/lib-cjs/manager/parameterManager.js.map +1 -0
- package/dist/lib-cjs/manager/sceneManager.d.ts +45 -0
- package/dist/lib-cjs/manager/sceneManager.js +65 -0
- package/dist/lib-cjs/manager/sceneManager.js.map +1 -0
- package/dist/lib-cjs/manager/screenshotManager.d.ts +36 -0
- package/dist/lib-cjs/manager/screenshotManager.js +40 -0
- package/dist/lib-cjs/manager/screenshotManager.js.map +1 -0
- package/dist/lib-cjs/manager/textureManager.d.ts +12 -0
- package/dist/lib-cjs/manager/textureManager.js +44 -0
- package/dist/lib-cjs/manager/textureManager.js.map +1 -0
- package/dist/lib-cjs/viewer.d.ts +117 -0
- package/dist/lib-cjs/viewer.js +222 -0
- package/dist/lib-cjs/viewer.js.map +1 -0
- package/dist/lib-cjs/{api/classes/viewerError.d.ts → viewerError.d.ts} +6 -1
- package/dist/lib-cjs/{api/classes/viewerError.js → viewerError.js} +6 -1
- package/dist/lib-cjs/viewerError.js.map +1 -0
- package/package.json +10 -11
- package/src/dev.ts +14 -37
- package/src/{types.d.ts → globalTypes.d.ts} +8 -18
- package/src/index.ts +79 -113
- package/src/internal/cbnCustomBabylonLoaderPlugin.ts +149 -0
- package/src/internal/cloningHelper.ts +225 -0
- package/src/internal/deviceHelper.ts +25 -0
- package/src/{api/util → internal}/geometryHelper.ts +63 -24
- package/src/internal/metadataHelper.ts +63 -0
- package/src/internal/paintableHelper.ts +310 -0
- package/src/internal/tagsHelper.ts +41 -0
- package/src/manager/cameraManager.ts +236 -0
- package/src/manager/debugManager.ts +245 -0
- package/src/manager/eventManager.ts +72 -0
- package/src/{api/manager → manager}/gltfExportManager.ts +132 -125
- package/src/manager/materialManager.ts +135 -0
- package/src/manager/modelManager.ts +456 -0
- package/src/manager/parameterManager.ts +652 -0
- package/src/manager/sceneManager.ts +101 -0
- package/src/manager/screenshotManager.ts +59 -0
- package/src/manager/textureManager.ts +32 -0
- package/src/viewer.ts +296 -0
- package/src/{api/classes/viewerError.ts → viewerError.ts} +6 -1
- package/dist/lib-cjs/api/classes/animationInterface.d.ts +0 -8
- package/dist/lib-cjs/api/classes/animationInterface.js +0 -3
- package/dist/lib-cjs/api/classes/animationInterface.js.map +0 -1
- package/dist/lib-cjs/api/classes/dottedPath.d.ts +0 -79
- package/dist/lib-cjs/api/classes/dottedPath.js +0 -167
- package/dist/lib-cjs/api/classes/dottedPath.js.map +0 -1
- package/dist/lib-cjs/api/classes/element.d.ts +0 -153
- package/dist/lib-cjs/api/classes/element.js +0 -703
- package/dist/lib-cjs/api/classes/element.js.map +0 -1
- package/dist/lib-cjs/api/classes/event.d.ts +0 -401
- package/dist/lib-cjs/api/classes/event.js +0 -425
- package/dist/lib-cjs/api/classes/event.js.map +0 -1
- package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +0 -26
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +0 -50
- package/dist/lib-cjs/api/classes/eventBroadcaster.js.map +0 -1
- package/dist/lib-cjs/api/classes/fuzzyMap.d.ts +0 -7
- package/dist/lib-cjs/api/classes/fuzzyMap.js +0 -22
- package/dist/lib-cjs/api/classes/fuzzyMap.js.map +0 -1
- package/dist/lib-cjs/api/classes/parameter.d.ts +0 -410
- package/dist/lib-cjs/api/classes/parameter.js +0 -643
- package/dist/lib-cjs/api/classes/parameter.js.map +0 -1
- package/dist/lib-cjs/api/classes/parameterObservable.d.ts +0 -36
- package/dist/lib-cjs/api/classes/parameterObservable.js +0 -73
- package/dist/lib-cjs/api/classes/parameterObservable.js.map +0 -1
- package/dist/lib-cjs/api/classes/parameterizable.d.ts +0 -15
- package/dist/lib-cjs/api/classes/parameterizable.js +0 -103
- package/dist/lib-cjs/api/classes/parameterizable.js.map +0 -1
- package/dist/lib-cjs/api/classes/placementAnimation.d.ts +0 -45
- package/dist/lib-cjs/api/classes/placementAnimation.js +0 -177
- package/dist/lib-cjs/api/classes/placementAnimation.js.map +0 -1
- package/dist/lib-cjs/api/classes/variant.d.ts +0 -261
- package/dist/lib-cjs/api/classes/variant.js +0 -873
- package/dist/lib-cjs/api/classes/variant.js.map +0 -1
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +0 -53
- package/dist/lib-cjs/api/classes/variantInstance.js +0 -126
- package/dist/lib-cjs/api/classes/variantInstance.js.map +0 -1
- package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +0 -17
- package/dist/lib-cjs/api/classes/variantParameterizable.js +0 -87
- package/dist/lib-cjs/api/classes/variantParameterizable.js.map +0 -1
- package/dist/lib-cjs/api/classes/viewer.d.ts +0 -215
- package/dist/lib-cjs/api/classes/viewer.js +0 -709
- package/dist/lib-cjs/api/classes/viewer.js.map +0 -1
- package/dist/lib-cjs/api/classes/viewerError.js.map +0 -1
- package/dist/lib-cjs/api/classes/viewerLight.d.ts +0 -66
- package/dist/lib-cjs/api/classes/viewerLight.js +0 -345
- package/dist/lib-cjs/api/classes/viewerLight.js.map +0 -1
- package/dist/lib-cjs/api/internal/lensRendering.d.ts +0 -8
- package/dist/lib-cjs/api/internal/lensRendering.js +0 -12
- package/dist/lib-cjs/api/internal/lensRendering.js.map +0 -1
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +0 -13
- package/dist/lib-cjs/api/internal/sceneSetup.js +0 -228
- package/dist/lib-cjs/api/internal/sceneSetup.js.map +0 -1
- package/dist/lib-cjs/api/manager/animationManager.d.ts +0 -30
- package/dist/lib-cjs/api/manager/animationManager.js +0 -127
- package/dist/lib-cjs/api/manager/animationManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/sceneManager.d.ts +0 -33
- package/dist/lib-cjs/api/manager/sceneManager.js +0 -129
- package/dist/lib-cjs/api/manager/sceneManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/tagManager.d.ts +0 -118
- package/dist/lib-cjs/api/manager/tagManager.js +0 -531
- package/dist/lib-cjs/api/manager/tagManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/textureLoadManager.d.ts +0 -22
- package/dist/lib-cjs/api/manager/textureLoadManager.js +0 -108
- package/dist/lib-cjs/api/manager/textureLoadManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +0 -106
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +0 -291
- package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +0 -1
- package/dist/lib-cjs/api/store/specStorage.d.ts +0 -32
- package/dist/lib-cjs/api/store/specStorage.js +0 -66
- package/dist/lib-cjs/api/store/specStorage.js.map +0 -1
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +0 -238
- package/dist/lib-cjs/api/util/babylonHelper.js +0 -826
- package/dist/lib-cjs/api/util/babylonHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/debugHelper.d.ts +0 -9
- package/dist/lib-cjs/api/util/debugHelper.js +0 -94
- package/dist/lib-cjs/api/util/debugHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/deviceHelper.d.ts +0 -9
- package/dist/lib-cjs/api/util/deviceHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/geometryHelper.d.ts +0 -17
- package/dist/lib-cjs/api/util/geometryHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +0 -490
- package/dist/lib-cjs/api/util/globalTypes.js +0 -2
- package/dist/lib-cjs/api/util/globalTypes.js.map +0 -1
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +0 -58
- package/dist/lib-cjs/api/util/resourceHelper.js +0 -215
- package/dist/lib-cjs/api/util/resourceHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +0 -58
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js +0 -229
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/stringHelper.d.ts +0 -13
- package/dist/lib-cjs/api/util/stringHelper.js +0 -33
- package/dist/lib-cjs/api/util/stringHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/structureHelper.d.ts +0 -9
- package/dist/lib-cjs/api/util/structureHelper.js +0 -58
- package/dist/lib-cjs/api/util/structureHelper.js.map +0 -1
- package/src/api/classes/animationInterface.ts +0 -10
- package/src/api/classes/dottedPath.ts +0 -181
- package/src/api/classes/element.ts +0 -766
- package/src/api/classes/event.ts +0 -457
- package/src/api/classes/eventBroadcaster.ts +0 -52
- package/src/api/classes/fuzzyMap.ts +0 -21
- package/src/api/classes/parameter.ts +0 -686
- package/src/api/classes/parameterObservable.ts +0 -73
- package/src/api/classes/parameterizable.ts +0 -87
- package/src/api/classes/placementAnimation.ts +0 -162
- package/src/api/classes/variant.ts +0 -965
- package/src/api/classes/variantInstance.ts +0 -123
- package/src/api/classes/variantParameterizable.ts +0 -83
- package/src/api/classes/viewer.ts +0 -751
- package/src/api/classes/viewerLight.ts +0 -335
- package/src/api/internal/debugViewer.ts +0 -90
- package/src/api/internal/lensRendering.ts +0 -9
- package/src/api/internal/sceneSetup.ts +0 -208
- package/src/api/manager/animationManager.ts +0 -143
- package/src/api/manager/sceneManager.ts +0 -134
- package/src/api/manager/tagManager.ts +0 -572
- package/src/api/manager/textureLoadManager.ts +0 -107
- package/src/api/manager/variantInstanceManager.ts +0 -306
- package/src/api/store/specStorage.ts +0 -68
- package/src/api/util/babylonHelper.ts +0 -915
- package/src/api/util/debugHelper.ts +0 -121
- package/src/api/util/deviceHelper.ts +0 -31
- package/src/api/util/globalTypes.ts +0 -566
- package/src/api/util/resourceHelper.ts +0 -201
- package/src/api/util/sceneLoaderHelper.ts +0 -247
- package/src/api/util/stringHelper.ts +0 -30
- package/src/api/util/structureHelper.ts +0 -62
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cloneNodeWithParents,
|
|
3
|
-
disableNodeWithParents,
|
|
4
|
-
enableNodeWithParents,
|
|
5
|
-
getRootNode,
|
|
6
|
-
injectMetadata,
|
|
7
|
-
transformTransformNode,
|
|
8
|
-
} from './../util/babylonHelper';
|
|
9
|
-
import { DottedPath } from './dottedPath';
|
|
10
|
-
import { Parameter } from './parameter';
|
|
11
|
-
import { Variant } from './variant';
|
|
12
|
-
import { VariantParameterizable } from './variantParameterizable';
|
|
13
|
-
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
|
|
14
|
-
import '@babylonjs/core/Lights/Shadows/shadowGeneratorSceneComponent';
|
|
15
|
-
import { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight';
|
|
16
|
-
import { Light } from '@babylonjs/core/Lights/light';
|
|
17
|
-
import { PointLight } from '@babylonjs/core/Lights/pointLight';
|
|
18
|
-
import { ShadowLight } from '@babylonjs/core/Lights/shadowLight';
|
|
19
|
-
import { Vector3 } from '@babylonjs/core/Maths/math.vector';
|
|
20
|
-
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
21
|
-
import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_lights_punctual';
|
|
22
|
-
import { get, isEmpty, isString, set } from 'lodash-es';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A {@link ViewerLight} of a {@link Variant}. Acts as a container for Babylon.js lights. Lives only in the context of a
|
|
26
|
-
* {@link Variant}.
|
|
27
|
-
*/
|
|
28
|
-
export class ViewerLight extends VariantParameterizable {
|
|
29
|
-
protected _light: Light | undefined;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Constructor.
|
|
33
|
-
*/
|
|
34
|
-
protected constructor(public readonly variant: Variant, public readonly name: string) {
|
|
35
|
-
super(variant, name);
|
|
36
|
-
this.addParameterObservers();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Creates a {@link ViewerLight} with given name.
|
|
41
|
-
*/
|
|
42
|
-
public static async create(variant: Variant, name: string): Promise<ViewerLight> {
|
|
43
|
-
const viewerLight = new ViewerLight(variant, name);
|
|
44
|
-
viewerLight._light = await viewerLight.createBabylonLightFromDefinition(viewerLight.definition);
|
|
45
|
-
return viewerLight;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The wrapped Light.
|
|
50
|
-
*/
|
|
51
|
-
get light(): Light {
|
|
52
|
-
if (!this._light) {
|
|
53
|
-
throw new Error(`Light for ViewerLight "${this.name}" has not been properly initialized.`);
|
|
54
|
-
}
|
|
55
|
-
return this._light!;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The {@link DottedPath} in the built tree of {@link ViewerLight}s.
|
|
60
|
-
* E.g. "_.top-1.sub-2.sub-sub-3.el-1"
|
|
61
|
-
*/
|
|
62
|
-
get dottedPath(): DottedPath {
|
|
63
|
-
return DottedPath.create(this.variant.dottedPath).addPart(this.name);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The id representing a {@link DottedPath}.
|
|
68
|
-
*/
|
|
69
|
-
get id(): string {
|
|
70
|
-
const dottedPath = DottedPath.create(this.dottedPath);
|
|
71
|
-
dottedPath.shiftPart(); // remove root
|
|
72
|
-
return dottedPath.path;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* The {@link LightDefinition} of the {@link ViewerLight}.
|
|
77
|
-
*/
|
|
78
|
-
get definition(): LightDefinition {
|
|
79
|
-
const definition = this.variant.structureJson.lights![this.name];
|
|
80
|
-
if (isString(definition)) {
|
|
81
|
-
return {
|
|
82
|
-
type: 'baked',
|
|
83
|
-
path: definition,
|
|
84
|
-
} as LightDefinition;
|
|
85
|
-
}
|
|
86
|
-
return definition as LightDefinition;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The type of the {@link ViewerLight}'s light.
|
|
91
|
-
*/
|
|
92
|
-
get type(): string {
|
|
93
|
-
return this.light.constructor.name.replace(/light/i, '').toLowerCase();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @see {@link VariantParameterizable.commitParameters}
|
|
98
|
-
* @emit {@link Event.VIEWER_LIGHT_PARAMETER_COMMITTED}
|
|
99
|
-
*/
|
|
100
|
-
public async commitParameters(parameters?: ParameterBag): Promise<VariantParameterizable> {
|
|
101
|
-
return super.commitParameters(parameters);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
|
|
106
|
-
*/
|
|
107
|
-
protected addParameterObservers(): ViewerLight {
|
|
108
|
-
this._parameterObservers.set(Parameter.VISIBLE, [
|
|
109
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
110
|
-
let visible;
|
|
111
|
-
try {
|
|
112
|
-
visible = Parameter.parseBoolean(newValue);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (visible === true) {
|
|
117
|
-
enableNodeWithParents(light.light);
|
|
118
|
-
} else if (visible === false) {
|
|
119
|
-
disableNodeWithParents(light.light);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
]);
|
|
123
|
-
this._parameterObservers.set(Parameter.INTENSITY, [
|
|
124
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
125
|
-
set(light.light, 'intensity', Parameter.parseNumber(newValue));
|
|
126
|
-
},
|
|
127
|
-
]);
|
|
128
|
-
this._parameterObservers.set(Parameter.SCALING, [
|
|
129
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
130
|
-
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
131
|
-
const rootNode = getRootNode(light.light);
|
|
132
|
-
if (rootNode instanceof TransformNode) {
|
|
133
|
-
transformTransformNode(rootNode, {
|
|
134
|
-
scaling: Parameter.parseScaling(newValue),
|
|
135
|
-
position: Parameter.parseVector(light.inheritedParameters[Parameter.POSITION] || '(0, 0, 0)'),
|
|
136
|
-
rotation: Parameter.parseRotation(light.inheritedParameters[Parameter.ROTATION] || '(0, 0, 0)'),
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
]);
|
|
141
|
-
this._parameterObservers.set(Parameter.POSITION, [
|
|
142
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
143
|
-
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
144
|
-
const rootNode = getRootNode(light.light);
|
|
145
|
-
if (rootNode instanceof TransformNode) {
|
|
146
|
-
transformTransformNode(rootNode, {
|
|
147
|
-
scaling: Parameter.parseVector(light.inheritedParameters[Parameter.SCALING] || '(1, 1, 1)'),
|
|
148
|
-
position: Parameter.parseVector(newValue),
|
|
149
|
-
rotation: Parameter.parseRotation(light.inheritedParameters[Parameter.ROTATION] || '(0, 0, 0)'),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
]);
|
|
154
|
-
this._parameterObservers.set(Parameter.ROTATION, [
|
|
155
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
156
|
-
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
157
|
-
const rootNode = getRootNode(light.light);
|
|
158
|
-
if (rootNode instanceof TransformNode) {
|
|
159
|
-
transformTransformNode(rootNode, {
|
|
160
|
-
scaling: Parameter.parseVector(light.inheritedParameters[Parameter.SCALING] || '(1, 1, 1)'),
|
|
161
|
-
position: Parameter.parseVector(light.inheritedParameters[Parameter.POSITION] || '(0, 0, 0)'),
|
|
162
|
-
rotation: Parameter.parseRotation(newValue),
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
]);
|
|
167
|
-
this._parameterObservers.set(Parameter.DIRECTION, [
|
|
168
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
169
|
-
if (
|
|
170
|
-
(light.light instanceof ShadowLight && !(light.light instanceof PointLight)) ||
|
|
171
|
-
light.light instanceof HemisphericLight
|
|
172
|
-
) {
|
|
173
|
-
set(light.light, 'direction', Parameter.parseVector(newValue));
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
]);
|
|
177
|
-
this._parameterObservers.set(Parameter.ANGLE, [
|
|
178
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
179
|
-
if (light.light.getClassName() === 'SpotLight') {
|
|
180
|
-
set(light.light, 'angle', Parameter.parseNumber(newValue));
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
]);
|
|
184
|
-
this._parameterObservers.set(Parameter.EXPONENT, [
|
|
185
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
186
|
-
if (light.light.getClassName() === 'SpotLight') {
|
|
187
|
-
set(light.light, 'exponent', Parameter.parseNumber(newValue));
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
]);
|
|
191
|
-
this._parameterObservers.set(Parameter.DIFFUSE, [
|
|
192
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
193
|
-
set(light.light, 'diffuse', Parameter.parseColor(newValue));
|
|
194
|
-
},
|
|
195
|
-
]);
|
|
196
|
-
this._parameterObservers.set(Parameter.SPECULAR, [
|
|
197
|
-
async (light: ViewerLight, oldValue: Undefinable<ParameterValue>, newValue: ParameterValue) => {
|
|
198
|
-
set(light.light, 'specular', Parameter.parseColor(newValue));
|
|
199
|
-
},
|
|
200
|
-
]);
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* @param definition
|
|
206
|
-
* @protected
|
|
207
|
-
*/
|
|
208
|
-
protected async createBabylonLightFromDefinition(definition: LightDefinition): Promise<Light> {
|
|
209
|
-
const parameters = Parameter.parseFromDeclarations(Parameter.declarations, this.inheritedParameters);
|
|
210
|
-
const scene = this.variant.viewer.scene;
|
|
211
|
-
let lightId = this.id;
|
|
212
|
-
let babylonLight;
|
|
213
|
-
switch (definition.type) {
|
|
214
|
-
case 'baked': {
|
|
215
|
-
if (!definition['path']) {
|
|
216
|
-
throw new Error(`The light "${lightId}" of type "${definition.type}" needs a "path".`);
|
|
217
|
-
}
|
|
218
|
-
const bakedLight = this.variant.inheritedLights.find(l => l.metadata.dottedPath.path === definition['path']);
|
|
219
|
-
if (bakedLight) {
|
|
220
|
-
lightId = bakedLight.metadata.dottedPath.clone().unshiftPart(this.id).path;
|
|
221
|
-
babylonLight = cloneNodeWithParents(bakedLight) as Light;
|
|
222
|
-
babylonLight!.name = lightId;
|
|
223
|
-
babylonLight!.id = lightId;
|
|
224
|
-
} else {
|
|
225
|
-
throw new Error(`No light found for path "${definition['path']}" in ViewerLight "${lightId}".`);
|
|
226
|
-
}
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
case 'hemispheric': {
|
|
230
|
-
if (!parameters['direction']) {
|
|
231
|
-
throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
|
|
232
|
-
}
|
|
233
|
-
const hemisphericLightModule = await import(
|
|
234
|
-
/* webpackChunkName: "hemispheric-light" */ '@babylonjs/core/Lights/hemisphericLight'
|
|
235
|
-
);
|
|
236
|
-
babylonLight = new hemisphericLightModule.HemisphericLight(lightId, parameters['direction'], scene);
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
case 'point': {
|
|
240
|
-
const pointLightModule = await import(
|
|
241
|
-
/* webpackChunkName: "point-light" */ '@babylonjs/core/Lights/pointLight'
|
|
242
|
-
);
|
|
243
|
-
babylonLight = new pointLightModule.PointLight(
|
|
244
|
-
lightId,
|
|
245
|
-
Vector3.Zero(), // position is set via parent TransformNode
|
|
246
|
-
scene
|
|
247
|
-
);
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
case 'directional': {
|
|
251
|
-
if (!parameters['direction']) {
|
|
252
|
-
throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
|
|
253
|
-
}
|
|
254
|
-
const directionalLightModule = await import(
|
|
255
|
-
/* webpackChunkName: "directional-light" */ '@babylonjs/core/Lights/directionalLight'
|
|
256
|
-
);
|
|
257
|
-
babylonLight = new directionalLightModule.DirectionalLight(lightId, parameters['direction'], scene);
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
case 'spot': {
|
|
261
|
-
if (!parameters['direction']) {
|
|
262
|
-
throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
|
|
263
|
-
}
|
|
264
|
-
if (!parameters['angle']) {
|
|
265
|
-
throw new Error(`A ViewerLight of type "${definition.type}" needs an "angle".`);
|
|
266
|
-
}
|
|
267
|
-
if (!parameters['exponent']) {
|
|
268
|
-
throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs an "exponent".`);
|
|
269
|
-
}
|
|
270
|
-
const spotLightModule = await import(/* webpackChunkName: "spot-light" */ '@babylonjs/core/Lights/spotLight');
|
|
271
|
-
babylonLight = new spotLightModule.SpotLight(
|
|
272
|
-
lightId,
|
|
273
|
-
Vector3.Zero(), // position is set via parent TransformNode
|
|
274
|
-
parameters['direction'],
|
|
275
|
-
parameters['angle'],
|
|
276
|
-
parameters['exponent'],
|
|
277
|
-
scene
|
|
278
|
-
);
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
default:
|
|
282
|
-
throw new Error(`The type "${definition.type}" for ViewerLight "${lightId}" is not implemented (yet).`);
|
|
283
|
-
}
|
|
284
|
-
if (!babylonLight) {
|
|
285
|
-
throw new Error(
|
|
286
|
-
`The Light for ViewerLight "${lightId}" of type "${definition.type}" could no be created ` + `or found.`
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
if (!babylonLight.parent) {
|
|
290
|
-
// Create pseudo parent since lights do not implement mutations like "rotation" by itself.
|
|
291
|
-
babylonLight.parent = new TransformNode('__light__', this.variant.viewer.scene, true);
|
|
292
|
-
}
|
|
293
|
-
injectMetadata(babylonLight.parent, {
|
|
294
|
-
variant: this.variant,
|
|
295
|
-
variantParameterizable: this,
|
|
296
|
-
});
|
|
297
|
-
// disable/hide by default
|
|
298
|
-
disableNodeWithParents(babylonLight);
|
|
299
|
-
// process shadow generator
|
|
300
|
-
const shadowGeneratorDefinition = get(definition, 'shadowGenerator') as ShadowGeneratorDefinition;
|
|
301
|
-
if (!isEmpty(shadowGeneratorDefinition)) {
|
|
302
|
-
if (!(babylonLight instanceof ShadowLight)) {
|
|
303
|
-
throw new Error(
|
|
304
|
-
`Using a ShadowGenerator with light type "${definition.type}" is not supported for ` +
|
|
305
|
-
`"${lightId}". Use lights deriving from ShadowLight.`
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
await this.processShadowGenerator(babylonLight, shadowGeneratorDefinition);
|
|
309
|
-
}
|
|
310
|
-
return babylonLight;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* @param babylonLight
|
|
315
|
-
* @param definition
|
|
316
|
-
* @protected
|
|
317
|
-
*/
|
|
318
|
-
protected async processShadowGenerator(
|
|
319
|
-
babylonLight: ShadowLight,
|
|
320
|
-
definition: ShadowGeneratorDefinition
|
|
321
|
-
): Promise<ShadowGenerator> {
|
|
322
|
-
const parameterDeclarations: ParameterDeclarations = {};
|
|
323
|
-
// define declarations here if needed in future
|
|
324
|
-
const parameterBag = definition as {} as ParameterBag;
|
|
325
|
-
const parameters = Parameter.parseFromDeclarations(parameterDeclarations, parameterBag);
|
|
326
|
-
const shadowGenerator = new ShadowGenerator(parameters['mapSize'], babylonLight);
|
|
327
|
-
for (const parameter in parameters) {
|
|
328
|
-
if (parameter === 'mapSize') {
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
set(shadowGenerator, parameter, get(parameters, parameter));
|
|
332
|
-
}
|
|
333
|
-
return shadowGenerator;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
/// <reference path="../util/globalTypes.ts" />
|
|
5
|
-
import { Event } from '../classes/event';
|
|
6
|
-
import { Viewer } from '../classes/viewer';
|
|
7
|
-
import { Scene } from '@babylonjs/core/scene';
|
|
8
|
-
|
|
9
|
-
export class DebugViewer extends Viewer {
|
|
10
|
-
constructor(canvas: HTMLCanvasElement, data: string | StructureJson) {
|
|
11
|
-
super(canvas, data);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public async bootstrap(): Promise<Viewer> {
|
|
15
|
-
for (const event of Event.all) {
|
|
16
|
-
this.eventEmitter.addListener(event, (...args) => console.debug(`Emitting ${event}`, ...args));
|
|
17
|
-
}
|
|
18
|
-
for (const event of [
|
|
19
|
-
Event.VARIANT_INSTANCE_DESTROYED,
|
|
20
|
-
Event.VARIANT_INSTANCE_CREATED,
|
|
21
|
-
Event.VARIANT_INSTANCE_CLONED,
|
|
22
|
-
Event.VARIANT_PARAMETER_COMMITTED,
|
|
23
|
-
]) {
|
|
24
|
-
this.eventEmitter.addListener(event, this.instanceDebugger.bind(this));
|
|
25
|
-
}
|
|
26
|
-
return super.bootstrap();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
protected async initScene(): Promise<Scene> {
|
|
30
|
-
const scene = await super.initScene();
|
|
31
|
-
|
|
32
|
-
scene.getEngine().runRenderLoop(() => {
|
|
33
|
-
this.fpsDebugger();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return scene;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
protected instanceDebugger(instance: VariantInstance) {
|
|
40
|
-
const instances: string[] = [];
|
|
41
|
-
this.variantInstances.all.forEach(variantInstance => {
|
|
42
|
-
instances.push(
|
|
43
|
-
`${variantInstance.name}${variantInstance.variant.visible ? '' : ' [hidden]'}${
|
|
44
|
-
variantInstance.variant.highlighted ? ' [highlighted]' : ''
|
|
45
|
-
}`
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
let debugContainer = document.getElementById('cyledge-combeenation-3d-viewer-instance-debugger');
|
|
49
|
-
if (!debugContainer) {
|
|
50
|
-
debugContainer = document.createElement('pre');
|
|
51
|
-
debugContainer.setAttribute('id', 'cyledge-combeenation-3d-viewer-instance-debugger');
|
|
52
|
-
debugContainer.setAttribute(
|
|
53
|
-
'style',
|
|
54
|
-
`
|
|
55
|
-
background: #454545;
|
|
56
|
-
color: #fff;
|
|
57
|
-
position: absolute;
|
|
58
|
-
bottom: 0;
|
|
59
|
-
right: 0;
|
|
60
|
-
padding: 10px;
|
|
61
|
-
margin: 0;
|
|
62
|
-
`
|
|
63
|
-
);
|
|
64
|
-
document.body.appendChild(debugContainer);
|
|
65
|
-
}
|
|
66
|
-
debugContainer.innerHTML = JSON.stringify(instances, null, 2);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
protected fpsDebugger() {
|
|
70
|
-
let debugContainer = document.getElementById('cyledge-combeenation-3d-viewer-fps-debugger');
|
|
71
|
-
if (!debugContainer) {
|
|
72
|
-
debugContainer = document.createElement('pre');
|
|
73
|
-
debugContainer.setAttribute('id', 'cyledge-combeenation-3d-viewer-fps-debugger');
|
|
74
|
-
debugContainer.setAttribute(
|
|
75
|
-
'style',
|
|
76
|
-
`
|
|
77
|
-
background: #454545;
|
|
78
|
-
color: #fff;
|
|
79
|
-
position: absolute;
|
|
80
|
-
bottom: 0;
|
|
81
|
-
left: 0;
|
|
82
|
-
padding: 10px;
|
|
83
|
-
margin: 0;
|
|
84
|
-
`
|
|
85
|
-
);
|
|
86
|
-
document.body.appendChild(debugContainer);
|
|
87
|
-
}
|
|
88
|
-
debugContainer.innerHTML = `${this.engine.getFps().toFixed(2)} fps`;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Group the required LensRendering dependencies into a single file to allow a single "import"
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
import { LensRenderingPipeline } from '@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline';
|
|
7
|
-
import '@babylonjs/core/Rendering/depthRendererSceneComponent';
|
|
8
|
-
|
|
9
|
-
export { LensRenderingPipeline };
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { Parameter } from '../classes/parameter';
|
|
2
|
-
import { Camera } from '@babylonjs/core/Cameras/camera';
|
|
3
|
-
import { Engine } from '@babylonjs/core/Engines/engine';
|
|
4
|
-
import '@babylonjs/core/Helpers/sceneHelpers';
|
|
5
|
-
import '@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader';
|
|
6
|
-
import { Color4 } from '@babylonjs/core/Maths/math.color';
|
|
7
|
-
import { Vector3 } from '@babylonjs/core/Maths/math.vector';
|
|
8
|
-
import { GroundMesh } from '@babylonjs/core/Meshes/groundMesh';
|
|
9
|
-
import { MeshBuilder } from '@babylonjs/core/Meshes/meshBuilder';
|
|
10
|
-
import { DefaultRenderingPipeline } from '@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline';
|
|
11
|
-
import { Scene } from '@babylonjs/core/scene';
|
|
12
|
-
import { get, isEmpty } from 'lodash-es';
|
|
13
|
-
|
|
14
|
-
const defaultSceneClearColor = new Color4(0, 0, 0, 0);
|
|
15
|
-
const defaultEnvHelperColor = new Color4(1, 1, 1, 0);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param scene
|
|
19
|
-
* @param name
|
|
20
|
-
* @param definition
|
|
21
|
-
*/
|
|
22
|
-
const processGround = async function (
|
|
23
|
-
scene: Scene,
|
|
24
|
-
name: string,
|
|
25
|
-
definition: GroundDefinition
|
|
26
|
-
): Promise<Mesh | GroundMesh> {
|
|
27
|
-
return new Promise(resolve => {
|
|
28
|
-
const _resolve = (ground: Mesh) => {
|
|
29
|
-
if (definition.receiveShadows !== undefined) {
|
|
30
|
-
ground.receiveShadows = definition.receiveShadows;
|
|
31
|
-
}
|
|
32
|
-
resolve(ground);
|
|
33
|
-
};
|
|
34
|
-
switch (definition.type) {
|
|
35
|
-
case 'baked':
|
|
36
|
-
if (!definition.meshId) {
|
|
37
|
-
throw new Error(`A baked ground must define a "meshId".`);
|
|
38
|
-
}
|
|
39
|
-
_resolve(scene.getMeshByID(definition.meshId) as Mesh);
|
|
40
|
-
break;
|
|
41
|
-
case 'ground':
|
|
42
|
-
_resolve(MeshBuilder.CreateGround(name, definition, scene));
|
|
43
|
-
break;
|
|
44
|
-
case 'heightmap':
|
|
45
|
-
if (!definition.url) {
|
|
46
|
-
throw new Error(`A heightmap ground must define an "url".`);
|
|
47
|
-
}
|
|
48
|
-
definition.onReady = (_ground: GroundMesh) => {
|
|
49
|
-
_resolve(_ground);
|
|
50
|
-
};
|
|
51
|
-
MeshBuilder.CreateGroundFromHeightMap(name, definition.url, definition, scene);
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
throw new Error(`Ground of type "${definition.type}" not implemented (yet).`);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @param scene
|
|
61
|
-
*/
|
|
62
|
-
const defaultCamera = async function (scene: Scene): Promise<Camera> {
|
|
63
|
-
const camera = (await processCamera(scene, 'default_camera', {
|
|
64
|
-
type: 'arc',
|
|
65
|
-
active: true,
|
|
66
|
-
})) as ArcRotateCamera;
|
|
67
|
-
|
|
68
|
-
// disables camera centering on double click
|
|
69
|
-
camera.useInputToRestoreState = false;
|
|
70
|
-
|
|
71
|
-
return camera;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @param scene
|
|
76
|
-
* @param name
|
|
77
|
-
* @param cameraSetup
|
|
78
|
-
*/
|
|
79
|
-
const processCamera = async function (scene: Scene, name: string, cameraSetup: CameraDefinition): Promise<Camera> {
|
|
80
|
-
let camera: Camera;
|
|
81
|
-
let target = Vector3.Zero();
|
|
82
|
-
if (cameraSetup.target) {
|
|
83
|
-
target = Parameter.parseVector(cameraSetup.target);
|
|
84
|
-
}
|
|
85
|
-
switch (cameraSetup.type) {
|
|
86
|
-
case 'arc': {
|
|
87
|
-
const arcCameraModule = await import(
|
|
88
|
-
/* webpackChunkName: "arc-rotate-camera" */ '@babylonjs/core/Cameras/arcRotateCamera'
|
|
89
|
-
);
|
|
90
|
-
camera = new arcCameraModule.ArcRotateCamera(name, Math.PI / 4, Math.PI / 4, 2, target, scene);
|
|
91
|
-
camera.metadata = {
|
|
92
|
-
alpha: Math.PI / 4,
|
|
93
|
-
beta: Math.PI / 4,
|
|
94
|
-
radius: 2,
|
|
95
|
-
};
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (cameraSetup.active) {
|
|
100
|
-
camera.attachControl(scene.getEngine().getRenderingCanvas()!, true);
|
|
101
|
-
}
|
|
102
|
-
if (cameraSetup.fov) {
|
|
103
|
-
camera.fov = cameraSetup.fov;
|
|
104
|
-
}
|
|
105
|
-
camera.storeState();
|
|
106
|
-
return camera;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @param engine
|
|
111
|
-
* @param sceneJson
|
|
112
|
-
*/
|
|
113
|
-
const sceneSetup = async function (engine: Engine, sceneJson: SceneJson): Promise<Scene> {
|
|
114
|
-
const scene = new Scene(engine);
|
|
115
|
-
scene.clearColor = defaultSceneClearColor;
|
|
116
|
-
// cameras
|
|
117
|
-
const cameras: Camera[] = [];
|
|
118
|
-
const cameraDefinitions = get(sceneJson.scene, 'cameras') as CameraDefinitions;
|
|
119
|
-
if (!isEmpty(cameraDefinitions)) {
|
|
120
|
-
for (const cameraName in cameraDefinitions) {
|
|
121
|
-
cameras.push(await processCamera(scene, cameraName, cameraDefinitions[cameraName]));
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
const camera = await defaultCamera(scene);
|
|
125
|
-
cameras.push(camera);
|
|
126
|
-
}
|
|
127
|
-
// grounds
|
|
128
|
-
const groundDefinitions = get(sceneJson.scene, 'grounds', {}) as GroundDefinitions;
|
|
129
|
-
if (!isEmpty(groundDefinitions)) {
|
|
130
|
-
for (const groundName in groundDefinitions) {
|
|
131
|
-
await processGround(scene, groundName, groundDefinitions[groundName]);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// TODO: try to split this away from the default rendering pipeline to save module imports
|
|
135
|
-
// The "hdr" setting had negative effect on rendering in Safari. Everything looked a little "edgy". I'm not completely
|
|
136
|
-
// sure if disabling it comes with other negative side effects I don't see right now, so we should probably
|
|
137
|
-
// investigate this a little more in detail at some point.
|
|
138
|
-
const defaultPipeline = new DefaultRenderingPipeline('default-rendering-pipeline', false, scene);
|
|
139
|
-
/* DISABLED: causes problems with Internet Explorer
|
|
140
|
-
defaultPipeline.imageProcessingEnabled = true;
|
|
141
|
-
*/
|
|
142
|
-
if (sceneJson.scene.globals.aa) {
|
|
143
|
-
defaultPipeline.fxaaEnabled = true; //implicitly does FxaaPostProcess()
|
|
144
|
-
}
|
|
145
|
-
// Set samples regardless of fxaa setting since we don't want to use fxaa but still increase the sample count
|
|
146
|
-
defaultPipeline.samples = 8;
|
|
147
|
-
if (sceneJson.scene.globals['camera-settings']) {
|
|
148
|
-
if (
|
|
149
|
-
sceneJson.scene.globals['camera-settings']!.sharpen &&
|
|
150
|
-
sceneJson.scene.globals['camera-settings']!.sharpen.enabled
|
|
151
|
-
) {
|
|
152
|
-
defaultPipeline.sharpenEnabled = true; //implicitly does SharpenPostProcess()
|
|
153
|
-
//defaultPipeline.sharpen.colorAmount = 1;
|
|
154
|
-
//defaultPipeline.sharpen.edgeAmount = 0;
|
|
155
|
-
}
|
|
156
|
-
if (
|
|
157
|
-
sceneJson.scene.globals['camera-settings']!.bloom &&
|
|
158
|
-
sceneJson.scene.globals['camera-settings']!.bloom.enabled
|
|
159
|
-
) {
|
|
160
|
-
defaultPipeline.bloomEnabled = true;
|
|
161
|
-
if (sceneJson.scene.globals['camera-settings']!.bloom.size) {
|
|
162
|
-
defaultPipeline.bloomScale = sceneJson.scene.globals['camera-settings']!.bloom.size;
|
|
163
|
-
}
|
|
164
|
-
if (sceneJson.scene.globals['camera-settings']!.bloom.threshold) {
|
|
165
|
-
defaultPipeline.bloomThreshold = sceneJson.scene.globals['camera-settings']!.bloom.threshold;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (sceneJson.scene.globals['camera-settings']!.contrast) {
|
|
169
|
-
scene.imageProcessingConfiguration.contrast = sceneJson.scene.globals['camera-settings']!.contrast;
|
|
170
|
-
}
|
|
171
|
-
if (sceneJson.scene.globals['camera-settings']!.exposure) {
|
|
172
|
-
scene.imageProcessingConfiguration.exposure = sceneJson.scene.globals['camera-settings']!.exposure;
|
|
173
|
-
}
|
|
174
|
-
if (sceneJson.scene.globals['camera-settings']!.dof && sceneJson.scene.globals['camera-settings']!.dof.enabled) {
|
|
175
|
-
const module = await import(/* webpackChunkName: "lens-rendering" */ './lensRendering');
|
|
176
|
-
new module.LensRenderingPipeline(
|
|
177
|
-
'lens-rendering',
|
|
178
|
-
sceneJson.scene.globals['camera-settings']!.dof.settings,
|
|
179
|
-
scene,
|
|
180
|
-
1.0,
|
|
181
|
-
cameras
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// TODO: make this dynamic
|
|
186
|
-
/*
|
|
187
|
-
const texture = new HDRCubeTexture("/assets/small_cave_1k.hdr", scene, 256);
|
|
188
|
-
texture.gammaSpace = false;
|
|
189
|
-
scene.environmentTexture = texture;
|
|
190
|
-
// scene.environmentTexture.
|
|
191
|
-
|
|
192
|
-
const skyboxMaterial = new StandardMaterial("skyBox", scene);
|
|
193
|
-
skyboxMaterial.backFaceCulling = false;
|
|
194
|
-
skyboxMaterial.reflectionTexture = texture;
|
|
195
|
-
skyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;
|
|
196
|
-
skyboxMaterial.disableLighting = false;
|
|
197
|
-
// TODO: replace with BoxBuilder
|
|
198
|
-
const skybox = MeshBuilder.CreateBox("skyBox", {size: 1000.0}, scene);
|
|
199
|
-
skybox.isPickable = false; //never pick a skybox
|
|
200
|
-
skybox.infiniteDistance = true;
|
|
201
|
-
skybox.material = skyboxMaterial;
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
// TODO: shadows don't work with HemishpericLight
|
|
205
|
-
return scene;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export { sceneSetup, defaultSceneClearColor, defaultEnvHelperColor };
|