@combeenation/3d-viewer 4.0.0-rc1 → 4.1.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/README.md +114 -114
- package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
- package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
- package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-cjs/api/classes/dottedPath.js +190 -190
- package/dist/lib-cjs/api/classes/element.d.ts +130 -130
- package/dist/lib-cjs/api/classes/element.js +746 -743
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -14
- package/dist/lib-cjs/api/classes/elementParameterizable.js +134 -134
- package/dist/lib-cjs/api/classes/event.d.ts +326 -326
- package/dist/lib-cjs/api/classes/event.js +371 -371
- package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
- package/dist/lib-cjs/api/classes/parameter.d.ts +259 -259
- package/dist/lib-cjs/api/classes/parameter.js +387 -387
- package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
- package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-cjs/api/classes/parameterObservable.js +101 -101
- package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
- package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
- package/dist/lib-cjs/api/classes/placementAnimation.d.ts +43 -38
- package/dist/lib-cjs/api/classes/placementAnimation.js +160 -149
- package/dist/lib-cjs/api/classes/placementAnimation.js.map +1 -1
- package/dist/lib-cjs/api/classes/variant.d.ts +234 -234
- package/dist/lib-cjs/api/classes/variant.js +1147 -1147
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +45 -45
- package/dist/lib-cjs/api/classes/variantInstance.js +108 -108
- package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-cjs/api/classes/variantParameterizable.js +99 -92
- package/dist/lib-cjs/api/classes/variantParameterizable.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewer.d.ts +131 -131
- package/dist/lib-cjs/api/classes/viewer.js +567 -567
- package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
- package/dist/lib-cjs/api/classes/viewerLight.js +392 -389
- package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
- package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
- package/dist/lib-cjs/api/internal/debugViewer.js +87 -87
- package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +10 -10
- package/dist/lib-cjs/api/internal/sceneSetup.js +231 -231
- package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
- package/dist/lib-cjs/api/manager/animationManager.js +121 -121
- package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +35 -0
- package/dist/lib-cjs/api/manager/gltfExportManager.js +108 -0
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -0
- package/dist/lib-cjs/api/manager/sceneManager.d.ts +32 -32
- package/dist/lib-cjs/api/manager/sceneManager.js +132 -132
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +90 -90
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +321 -321
- package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
- package/dist/lib-cjs/api/store/specStorage.js +51 -51
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +166 -175
- package/dist/lib-cjs/api/util/babylonHelper.js +500 -520
- package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +338 -333
- package/dist/lib-cjs/api/util/globalTypes.js +1 -1
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +53 -53
- package/dist/lib-cjs/api/util/resourceHelper.js +240 -240
- package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/stringHelper.js +25 -25
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/index.d.ts +48 -48
- package/dist/lib-cjs/index.js +86 -86
- package/package.json +83 -83
- package/src/api/classes/animationInterface.ts +11 -11
- package/src/api/classes/dottedPath.ts +189 -189
- package/src/api/classes/element.ts +648 -644
- package/src/api/classes/event.ts +370 -370
- package/src/api/classes/eventBroadcaster.ts +54 -54
- package/src/api/classes/parameter.ts +408 -408
- package/src/api/classes/parameterObservable.ts +99 -99
- package/src/api/classes/parameterizable.ts +89 -89
- package/src/api/classes/placementAnimation.ts +157 -143
- package/src/api/classes/variant.ts +817 -817
- package/src/api/classes/variantInstance.ts +88 -88
- package/src/api/classes/variantParameterizable.ts +80 -73
- package/src/api/classes/viewer.ts +487 -487
- package/src/api/classes/viewerLight.ts +334 -330
- package/src/api/internal/debugViewer.ts +81 -81
- package/src/api/internal/lensRendering.ts +10 -10
- package/src/api/internal/sceneSetup.ts +193 -193
- package/src/api/manager/animationManager.ts +116 -116
- package/src/api/manager/sceneManager.ts +105 -105
- package/src/api/manager/variantInstanceManager.ts +236 -236
- package/src/api/store/specStorage.ts +53 -53
- package/src/api/util/babylonHelper.ts +534 -555
- package/src/api/util/globalTypes.ts +385 -379
- package/src/api/util/resourceHelper.ts +184 -184
- package/src/api/util/stringHelper.ts +25 -25
- package/src/buildinfo.json +2 -2
- package/src/commonjs.tsconfig.json +13 -13
- package/src/declaration.tsconfig.json +10 -10
- package/src/dev.ts +42 -42
- package/src/es6.tsconfig.json +13 -13
- package/src/index.ts +91 -91
- package/src/pagesconfig.json +65 -61
- package/src/tsconfig.json +43 -43
- package/src/tsconfig.types.json +9 -9
- package/src/types.d.ts +4 -4
- package/dist/webpack-stats.json +0 -0
|
@@ -1,232 +1,232 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sceneSetup = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
require("@babylonjs/core/Helpers/sceneHelpers");
|
|
6
|
-
require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader");
|
|
7
|
-
var math_color_1 = require("@babylonjs/core/Maths/math.color");
|
|
8
|
-
var math_vector_1 = require("@babylonjs/core/Maths/math.vector");
|
|
9
|
-
var meshBuilder_1 = require("@babylonjs/core/Meshes/meshBuilder");
|
|
10
|
-
var defaultRenderingPipeline_1 = require("@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline");
|
|
11
|
-
var scene_1 = require("@babylonjs/core/scene");
|
|
12
|
-
var lodash_es_1 = require("lodash-es");
|
|
13
|
-
var parameter_1 = require("../classes/parameter");
|
|
14
|
-
/**
|
|
15
|
-
* @param scene
|
|
16
|
-
* @param name
|
|
17
|
-
* @param definition
|
|
18
|
-
*/
|
|
19
|
-
var processGround = function (scene, name, definition) {
|
|
20
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
21
|
-
return tslib_1.__generator(this, function (_a) {
|
|
22
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
23
|
-
var _resolve = function (ground) {
|
|
24
|
-
if (definition.receiveShadows !== undefined) {
|
|
25
|
-
ground.receiveShadows = definition.receiveShadows;
|
|
26
|
-
}
|
|
27
|
-
resolve(ground);
|
|
28
|
-
};
|
|
29
|
-
switch (definition.type) {
|
|
30
|
-
case 'baked':
|
|
31
|
-
if (!definition.meshId) {
|
|
32
|
-
throw new Error("A baked ground must define a \"meshId\".");
|
|
33
|
-
}
|
|
34
|
-
_resolve(scene.getMeshByID(definition.meshId));
|
|
35
|
-
break;
|
|
36
|
-
case 'ground':
|
|
37
|
-
_resolve(meshBuilder_1.MeshBuilder.CreateGround(name, definition, scene));
|
|
38
|
-
break;
|
|
39
|
-
case 'heightmap':
|
|
40
|
-
if (!definition.url) {
|
|
41
|
-
throw new Error("A heightmap ground must define an \"url\".");
|
|
42
|
-
}
|
|
43
|
-
definition.onReady = function (_ground) {
|
|
44
|
-
_resolve(_ground);
|
|
45
|
-
};
|
|
46
|
-
meshBuilder_1.MeshBuilder.CreateGroundFromHeightMap(name, definition.url, definition, scene);
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
throw new Error("Ground of type \"" + definition.type + "\" not implemented (yet).");
|
|
50
|
-
}
|
|
51
|
-
})];
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* @param scene
|
|
57
|
-
*/
|
|
58
|
-
var defaultCamera = function (scene) {
|
|
59
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
60
|
-
return tslib_1.__generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0: return [4 /*yield*/, processCamera(scene, 'default_camera', {
|
|
63
|
-
type: 'arc',
|
|
64
|
-
active: true,
|
|
65
|
-
})];
|
|
66
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* @param scene
|
|
73
|
-
* @param name
|
|
74
|
-
* @param cameraSetup
|
|
75
|
-
*/
|
|
76
|
-
var processCamera = function (scene, name, cameraSetup) {
|
|
77
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var camera, target, _a, arcCameraModule;
|
|
79
|
-
return tslib_1.__generator(this, function (_b) {
|
|
80
|
-
switch (_b.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
target = math_vector_1.Vector3.Zero();
|
|
83
|
-
if (cameraSetup.target) {
|
|
84
|
-
target = parameter_1.Parameter.parseVector(cameraSetup.target);
|
|
85
|
-
}
|
|
86
|
-
_a = cameraSetup.type;
|
|
87
|
-
switch (_a) {
|
|
88
|
-
case 'arc': return [3 /*break*/, 1];
|
|
89
|
-
}
|
|
90
|
-
return [3 /*break*/, 3];
|
|
91
|
-
case 1: return [4 /*yield*/, Promise.resolve().then(function () { return require(/* webpackChunkName: "arc-rotate-camera" */ '@babylonjs/core/Cameras/arcRotateCamera'); })];
|
|
92
|
-
case 2:
|
|
93
|
-
arcCameraModule = _b.sent();
|
|
94
|
-
camera = new arcCameraModule.ArcRotateCamera(name, Math.PI / 4, Math.PI / 4, 2, target, scene);
|
|
95
|
-
camera.metadata = {
|
|
96
|
-
alpha: Math.PI / 4,
|
|
97
|
-
beta: Math.PI / 4,
|
|
98
|
-
radius: 2
|
|
99
|
-
};
|
|
100
|
-
return [3 /*break*/, 3];
|
|
101
|
-
case 3:
|
|
102
|
-
if (cameraSetup.active) {
|
|
103
|
-
camera.attachControl(scene.getEngine().getRenderingCanvas(), true);
|
|
104
|
-
}
|
|
105
|
-
if (cameraSetup.fov) {
|
|
106
|
-
camera.fov = cameraSetup.fov;
|
|
107
|
-
}
|
|
108
|
-
camera.storeState();
|
|
109
|
-
return [2 /*return*/, camera];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* @param engine
|
|
116
|
-
* @param sceneJson
|
|
117
|
-
*/
|
|
118
|
-
var sceneSetup = function (engine, sceneJson) {
|
|
119
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
120
|
-
var scene, cameras, cameraDefinitions, _a, _b, _i, cameraName, _c, _d, camera, groundDefinitions, _e, _f, _g, groundName, defaultPipeline, module_1;
|
|
121
|
-
return tslib_1.__generator(this, function (_h) {
|
|
122
|
-
switch (_h.label) {
|
|
123
|
-
case 0:
|
|
124
|
-
scene = new scene_1.Scene(engine);
|
|
125
|
-
scene.clearColor = new math_color_1.Color4(0, 0, 0, 0);
|
|
126
|
-
cameras = [];
|
|
127
|
-
cameraDefinitions = lodash_es_1.get(sceneJson.scene, 'cameras');
|
|
128
|
-
if (!!lodash_es_1.isEmpty(cameraDefinitions)) return [3 /*break*/, 5];
|
|
129
|
-
_a = [];
|
|
130
|
-
for (_b in cameraDefinitions)
|
|
131
|
-
_a.push(_b);
|
|
132
|
-
_i = 0;
|
|
133
|
-
_h.label = 1;
|
|
134
|
-
case 1:
|
|
135
|
-
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
136
|
-
cameraName = _a[_i];
|
|
137
|
-
_d = (_c = cameras).push;
|
|
138
|
-
return [4 /*yield*/, processCamera(scene, cameraName, cameraDefinitions[cameraName])];
|
|
139
|
-
case 2:
|
|
140
|
-
_d.apply(_c, [_h.sent()]);
|
|
141
|
-
_h.label = 3;
|
|
142
|
-
case 3:
|
|
143
|
-
_i++;
|
|
144
|
-
return [3 /*break*/, 1];
|
|
145
|
-
case 4: return [3 /*break*/, 7];
|
|
146
|
-
case 5: return [4 /*yield*/, defaultCamera(scene)];
|
|
147
|
-
case 6:
|
|
148
|
-
camera = _h.sent();
|
|
149
|
-
cameras.push(camera);
|
|
150
|
-
_h.label = 7;
|
|
151
|
-
case 7:
|
|
152
|
-
groundDefinitions = lodash_es_1.get(sceneJson.scene, 'grounds');
|
|
153
|
-
if (!!lodash_es_1.isEmpty(groundDefinitions)) return [3 /*break*/, 11];
|
|
154
|
-
_e = [];
|
|
155
|
-
for (_f in groundDefinitions)
|
|
156
|
-
_e.push(_f);
|
|
157
|
-
_g = 0;
|
|
158
|
-
_h.label = 8;
|
|
159
|
-
case 8:
|
|
160
|
-
if (!(_g < _e.length)) return [3 /*break*/, 11];
|
|
161
|
-
groundName = _e[_g];
|
|
162
|
-
return [4 /*yield*/, processGround(scene, groundName, groundDefinitions[groundName])];
|
|
163
|
-
case 9:
|
|
164
|
-
_h.sent();
|
|
165
|
-
_h.label = 10;
|
|
166
|
-
case 10:
|
|
167
|
-
_g++;
|
|
168
|
-
return [3 /*break*/, 8];
|
|
169
|
-
case 11:
|
|
170
|
-
defaultPipeline = new defaultRenderingPipeline_1.DefaultRenderingPipeline('default-rendering-pipeline', false, scene);
|
|
171
|
-
/* DISABLED: causes problems with Internet Explorer
|
|
172
|
-
defaultPipeline.imageProcessingEnabled = true;
|
|
173
|
-
*/
|
|
174
|
-
if (sceneJson.scene.globals.aa) {
|
|
175
|
-
defaultPipeline.fxaaEnabled = true; //implicitly does FxaaPostProcess()
|
|
176
|
-
}
|
|
177
|
-
// Set samples regardless of fxaa setting since we don't want to use fxaa but still increase the sample count
|
|
178
|
-
defaultPipeline.samples = 8;
|
|
179
|
-
if (!sceneJson.scene.globals['camera-settings']) return [3 /*break*/, 13];
|
|
180
|
-
if (sceneJson.scene.globals['camera-settings'].sharpen && sceneJson.scene.globals['camera-settings'].sharpen.enabled) {
|
|
181
|
-
defaultPipeline.sharpenEnabled = true; //implicitly does SharpenPostProcess()
|
|
182
|
-
//defaultPipeline.sharpen.colorAmount = 1;
|
|
183
|
-
//defaultPipeline.sharpen.edgeAmount = 0;
|
|
184
|
-
}
|
|
185
|
-
if (sceneJson.scene.globals['camera-settings'].bloom && sceneJson.scene.globals['camera-settings'].bloom.enabled) {
|
|
186
|
-
defaultPipeline.bloomEnabled = true;
|
|
187
|
-
if (sceneJson.scene.globals['camera-settings'].bloom.size) {
|
|
188
|
-
defaultPipeline.bloomScale = sceneJson.scene.globals['camera-settings'].bloom.size;
|
|
189
|
-
}
|
|
190
|
-
if (sceneJson.scene.globals['camera-settings'].bloom.threshold) {
|
|
191
|
-
defaultPipeline.bloomThreshold = sceneJson.scene.globals['camera-settings'].bloom.threshold;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (sceneJson.scene.globals['camera-settings'].contrast) {
|
|
195
|
-
scene.imageProcessingConfiguration.contrast = sceneJson.scene.globals['camera-settings'].contrast;
|
|
196
|
-
}
|
|
197
|
-
if (sceneJson.scene.globals['camera-settings'].exposure) {
|
|
198
|
-
scene.imageProcessingConfiguration.exposure = sceneJson.scene.globals['camera-settings'].exposure;
|
|
199
|
-
}
|
|
200
|
-
if (!(sceneJson.scene.globals['camera-settings'].dof && sceneJson.scene.globals['camera-settings'].dof.enabled)) return [3 /*break*/, 13];
|
|
201
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return require(/* webpackChunkName: "lens-rendering" */ './lensRendering'); })];
|
|
202
|
-
case 12:
|
|
203
|
-
module_1 = _h.sent();
|
|
204
|
-
new module_1.LensRenderingPipeline('lens-rendering', sceneJson.scene.globals['camera-settings'].dof.settings, scene, 1.0, cameras);
|
|
205
|
-
_h.label = 13;
|
|
206
|
-
case 13:
|
|
207
|
-
// TODO: make this dynamic
|
|
208
|
-
/*
|
|
209
|
-
const texture = new HDRCubeTexture("/assets/small_cave_1k.hdr", scene, 256);
|
|
210
|
-
texture.gammaSpace = false;
|
|
211
|
-
scene.environmentTexture = texture;
|
|
212
|
-
// scene.environmentTexture.
|
|
213
|
-
|
|
214
|
-
const skyboxMaterial = new StandardMaterial("skyBox", scene);
|
|
215
|
-
skyboxMaterial.backFaceCulling = false;
|
|
216
|
-
skyboxMaterial.reflectionTexture = texture;
|
|
217
|
-
skyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;
|
|
218
|
-
skyboxMaterial.disableLighting = false;
|
|
219
|
-
// TODO: replace with BoxBuilder
|
|
220
|
-
const skybox = MeshBuilder.CreateBox("skyBox", {size: 1000.0}, scene);
|
|
221
|
-
skybox.isPickable = false; //never pick a skybox
|
|
222
|
-
skybox.infiniteDistance = true;
|
|
223
|
-
skybox.material = skyboxMaterial;
|
|
224
|
-
*/
|
|
225
|
-
// TODO: shadows don't work with HemishpericLight
|
|
226
|
-
return [2 /*return*/, scene];
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
exports.sceneSetup = sceneSetup;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sceneSetup = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
require("@babylonjs/core/Helpers/sceneHelpers");
|
|
6
|
+
require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader");
|
|
7
|
+
var math_color_1 = require("@babylonjs/core/Maths/math.color");
|
|
8
|
+
var math_vector_1 = require("@babylonjs/core/Maths/math.vector");
|
|
9
|
+
var meshBuilder_1 = require("@babylonjs/core/Meshes/meshBuilder");
|
|
10
|
+
var defaultRenderingPipeline_1 = require("@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline");
|
|
11
|
+
var scene_1 = require("@babylonjs/core/scene");
|
|
12
|
+
var lodash_es_1 = require("lodash-es");
|
|
13
|
+
var parameter_1 = require("../classes/parameter");
|
|
14
|
+
/**
|
|
15
|
+
* @param scene
|
|
16
|
+
* @param name
|
|
17
|
+
* @param definition
|
|
18
|
+
*/
|
|
19
|
+
var processGround = function (scene, name, definition) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
21
|
+
return tslib_1.__generator(this, function (_a) {
|
|
22
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
23
|
+
var _resolve = function (ground) {
|
|
24
|
+
if (definition.receiveShadows !== undefined) {
|
|
25
|
+
ground.receiveShadows = definition.receiveShadows;
|
|
26
|
+
}
|
|
27
|
+
resolve(ground);
|
|
28
|
+
};
|
|
29
|
+
switch (definition.type) {
|
|
30
|
+
case 'baked':
|
|
31
|
+
if (!definition.meshId) {
|
|
32
|
+
throw new Error("A baked ground must define a \"meshId\".");
|
|
33
|
+
}
|
|
34
|
+
_resolve(scene.getMeshByID(definition.meshId));
|
|
35
|
+
break;
|
|
36
|
+
case 'ground':
|
|
37
|
+
_resolve(meshBuilder_1.MeshBuilder.CreateGround(name, definition, scene));
|
|
38
|
+
break;
|
|
39
|
+
case 'heightmap':
|
|
40
|
+
if (!definition.url) {
|
|
41
|
+
throw new Error("A heightmap ground must define an \"url\".");
|
|
42
|
+
}
|
|
43
|
+
definition.onReady = function (_ground) {
|
|
44
|
+
_resolve(_ground);
|
|
45
|
+
};
|
|
46
|
+
meshBuilder_1.MeshBuilder.CreateGroundFromHeightMap(name, definition.url, definition, scene);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error("Ground of type \"" + definition.type + "\" not implemented (yet).");
|
|
50
|
+
}
|
|
51
|
+
})];
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* @param scene
|
|
57
|
+
*/
|
|
58
|
+
var defaultCamera = function (scene) {
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
60
|
+
return tslib_1.__generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0: return [4 /*yield*/, processCamera(scene, 'default_camera', {
|
|
63
|
+
type: 'arc',
|
|
64
|
+
active: true,
|
|
65
|
+
})];
|
|
66
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @param scene
|
|
73
|
+
* @param name
|
|
74
|
+
* @param cameraSetup
|
|
75
|
+
*/
|
|
76
|
+
var processCamera = function (scene, name, cameraSetup) {
|
|
77
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var camera, target, _a, arcCameraModule;
|
|
79
|
+
return tslib_1.__generator(this, function (_b) {
|
|
80
|
+
switch (_b.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
target = math_vector_1.Vector3.Zero();
|
|
83
|
+
if (cameraSetup.target) {
|
|
84
|
+
target = parameter_1.Parameter.parseVector(cameraSetup.target);
|
|
85
|
+
}
|
|
86
|
+
_a = cameraSetup.type;
|
|
87
|
+
switch (_a) {
|
|
88
|
+
case 'arc': return [3 /*break*/, 1];
|
|
89
|
+
}
|
|
90
|
+
return [3 /*break*/, 3];
|
|
91
|
+
case 1: return [4 /*yield*/, Promise.resolve().then(function () { return require(/* webpackChunkName: "arc-rotate-camera" */ '@babylonjs/core/Cameras/arcRotateCamera'); })];
|
|
92
|
+
case 2:
|
|
93
|
+
arcCameraModule = _b.sent();
|
|
94
|
+
camera = new arcCameraModule.ArcRotateCamera(name, Math.PI / 4, Math.PI / 4, 2, target, scene);
|
|
95
|
+
camera.metadata = {
|
|
96
|
+
alpha: Math.PI / 4,
|
|
97
|
+
beta: Math.PI / 4,
|
|
98
|
+
radius: 2
|
|
99
|
+
};
|
|
100
|
+
return [3 /*break*/, 3];
|
|
101
|
+
case 3:
|
|
102
|
+
if (cameraSetup.active) {
|
|
103
|
+
camera.attachControl(scene.getEngine().getRenderingCanvas(), true);
|
|
104
|
+
}
|
|
105
|
+
if (cameraSetup.fov) {
|
|
106
|
+
camera.fov = cameraSetup.fov;
|
|
107
|
+
}
|
|
108
|
+
camera.storeState();
|
|
109
|
+
return [2 /*return*/, camera];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* @param engine
|
|
116
|
+
* @param sceneJson
|
|
117
|
+
*/
|
|
118
|
+
var sceneSetup = function (engine, sceneJson) {
|
|
119
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var scene, cameras, cameraDefinitions, _a, _b, _i, cameraName, _c, _d, camera, groundDefinitions, _e, _f, _g, groundName, defaultPipeline, module_1;
|
|
121
|
+
return tslib_1.__generator(this, function (_h) {
|
|
122
|
+
switch (_h.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
scene = new scene_1.Scene(engine);
|
|
125
|
+
scene.clearColor = new math_color_1.Color4(0, 0, 0, 0);
|
|
126
|
+
cameras = [];
|
|
127
|
+
cameraDefinitions = lodash_es_1.get(sceneJson.scene, 'cameras');
|
|
128
|
+
if (!!lodash_es_1.isEmpty(cameraDefinitions)) return [3 /*break*/, 5];
|
|
129
|
+
_a = [];
|
|
130
|
+
for (_b in cameraDefinitions)
|
|
131
|
+
_a.push(_b);
|
|
132
|
+
_i = 0;
|
|
133
|
+
_h.label = 1;
|
|
134
|
+
case 1:
|
|
135
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
136
|
+
cameraName = _a[_i];
|
|
137
|
+
_d = (_c = cameras).push;
|
|
138
|
+
return [4 /*yield*/, processCamera(scene, cameraName, cameraDefinitions[cameraName])];
|
|
139
|
+
case 2:
|
|
140
|
+
_d.apply(_c, [_h.sent()]);
|
|
141
|
+
_h.label = 3;
|
|
142
|
+
case 3:
|
|
143
|
+
_i++;
|
|
144
|
+
return [3 /*break*/, 1];
|
|
145
|
+
case 4: return [3 /*break*/, 7];
|
|
146
|
+
case 5: return [4 /*yield*/, defaultCamera(scene)];
|
|
147
|
+
case 6:
|
|
148
|
+
camera = _h.sent();
|
|
149
|
+
cameras.push(camera);
|
|
150
|
+
_h.label = 7;
|
|
151
|
+
case 7:
|
|
152
|
+
groundDefinitions = lodash_es_1.get(sceneJson.scene, 'grounds');
|
|
153
|
+
if (!!lodash_es_1.isEmpty(groundDefinitions)) return [3 /*break*/, 11];
|
|
154
|
+
_e = [];
|
|
155
|
+
for (_f in groundDefinitions)
|
|
156
|
+
_e.push(_f);
|
|
157
|
+
_g = 0;
|
|
158
|
+
_h.label = 8;
|
|
159
|
+
case 8:
|
|
160
|
+
if (!(_g < _e.length)) return [3 /*break*/, 11];
|
|
161
|
+
groundName = _e[_g];
|
|
162
|
+
return [4 /*yield*/, processGround(scene, groundName, groundDefinitions[groundName])];
|
|
163
|
+
case 9:
|
|
164
|
+
_h.sent();
|
|
165
|
+
_h.label = 10;
|
|
166
|
+
case 10:
|
|
167
|
+
_g++;
|
|
168
|
+
return [3 /*break*/, 8];
|
|
169
|
+
case 11:
|
|
170
|
+
defaultPipeline = new defaultRenderingPipeline_1.DefaultRenderingPipeline('default-rendering-pipeline', false, scene);
|
|
171
|
+
/* DISABLED: causes problems with Internet Explorer
|
|
172
|
+
defaultPipeline.imageProcessingEnabled = true;
|
|
173
|
+
*/
|
|
174
|
+
if (sceneJson.scene.globals.aa) {
|
|
175
|
+
defaultPipeline.fxaaEnabled = true; //implicitly does FxaaPostProcess()
|
|
176
|
+
}
|
|
177
|
+
// Set samples regardless of fxaa setting since we don't want to use fxaa but still increase the sample count
|
|
178
|
+
defaultPipeline.samples = 8;
|
|
179
|
+
if (!sceneJson.scene.globals['camera-settings']) return [3 /*break*/, 13];
|
|
180
|
+
if (sceneJson.scene.globals['camera-settings'].sharpen && sceneJson.scene.globals['camera-settings'].sharpen.enabled) {
|
|
181
|
+
defaultPipeline.sharpenEnabled = true; //implicitly does SharpenPostProcess()
|
|
182
|
+
//defaultPipeline.sharpen.colorAmount = 1;
|
|
183
|
+
//defaultPipeline.sharpen.edgeAmount = 0;
|
|
184
|
+
}
|
|
185
|
+
if (sceneJson.scene.globals['camera-settings'].bloom && sceneJson.scene.globals['camera-settings'].bloom.enabled) {
|
|
186
|
+
defaultPipeline.bloomEnabled = true;
|
|
187
|
+
if (sceneJson.scene.globals['camera-settings'].bloom.size) {
|
|
188
|
+
defaultPipeline.bloomScale = sceneJson.scene.globals['camera-settings'].bloom.size;
|
|
189
|
+
}
|
|
190
|
+
if (sceneJson.scene.globals['camera-settings'].bloom.threshold) {
|
|
191
|
+
defaultPipeline.bloomThreshold = sceneJson.scene.globals['camera-settings'].bloom.threshold;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (sceneJson.scene.globals['camera-settings'].contrast) {
|
|
195
|
+
scene.imageProcessingConfiguration.contrast = sceneJson.scene.globals['camera-settings'].contrast;
|
|
196
|
+
}
|
|
197
|
+
if (sceneJson.scene.globals['camera-settings'].exposure) {
|
|
198
|
+
scene.imageProcessingConfiguration.exposure = sceneJson.scene.globals['camera-settings'].exposure;
|
|
199
|
+
}
|
|
200
|
+
if (!(sceneJson.scene.globals['camera-settings'].dof && sceneJson.scene.globals['camera-settings'].dof.enabled)) return [3 /*break*/, 13];
|
|
201
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require(/* webpackChunkName: "lens-rendering" */ './lensRendering'); })];
|
|
202
|
+
case 12:
|
|
203
|
+
module_1 = _h.sent();
|
|
204
|
+
new module_1.LensRenderingPipeline('lens-rendering', sceneJson.scene.globals['camera-settings'].dof.settings, scene, 1.0, cameras);
|
|
205
|
+
_h.label = 13;
|
|
206
|
+
case 13:
|
|
207
|
+
// TODO: make this dynamic
|
|
208
|
+
/*
|
|
209
|
+
const texture = new HDRCubeTexture("/assets/small_cave_1k.hdr", scene, 256);
|
|
210
|
+
texture.gammaSpace = false;
|
|
211
|
+
scene.environmentTexture = texture;
|
|
212
|
+
// scene.environmentTexture.
|
|
213
|
+
|
|
214
|
+
const skyboxMaterial = new StandardMaterial("skyBox", scene);
|
|
215
|
+
skyboxMaterial.backFaceCulling = false;
|
|
216
|
+
skyboxMaterial.reflectionTexture = texture;
|
|
217
|
+
skyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;
|
|
218
|
+
skyboxMaterial.disableLighting = false;
|
|
219
|
+
// TODO: replace with BoxBuilder
|
|
220
|
+
const skybox = MeshBuilder.CreateBox("skyBox", {size: 1000.0}, scene);
|
|
221
|
+
skybox.isPickable = false; //never pick a skybox
|
|
222
|
+
skybox.infiniteDistance = true;
|
|
223
|
+
skybox.material = skyboxMaterial;
|
|
224
|
+
*/
|
|
225
|
+
// TODO: shadows don't work with HemishpericLight
|
|
226
|
+
return [2 /*return*/, scene];
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
exports.sceneSetup = sceneSetup;
|
|
232
232
|
//# sourceMappingURL=sceneSetup.js.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { Scene as BabylonScene, Scene } from '@babylonjs/core/scene';
|
|
2
|
-
export declare class AnimationManager {
|
|
3
|
-
protected scene: Scene;
|
|
4
|
-
animations: AnimationInterface[];
|
|
5
|
-
/**
|
|
6
|
-
* Constructor.
|
|
7
|
-
*/
|
|
8
|
-
protected constructor(scene: Scene);
|
|
9
|
-
/**
|
|
10
|
-
* Creates an {@link AnimationManager} based on given BabylonJS scene.
|
|
11
|
-
*/
|
|
12
|
-
static create(scene: BabylonScene): Promise<AnimationManager>;
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Use viewer.moveCameraTo().
|
|
15
|
-
*/
|
|
16
|
-
resetCamera(animate?: boolean): void;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Use viewer.moveCameraTo().
|
|
19
|
-
*/
|
|
20
|
-
animateArcRotateCamera(targetAlpha: number, targetBeta: number, targetRadius: number): void;
|
|
21
|
-
/**
|
|
22
|
-
* Stops and kills all running animations.
|
|
23
|
-
*/
|
|
24
|
-
killAllAnimations(): void;
|
|
25
|
-
/**
|
|
26
|
-
* @see {@link PlacementAnimation.play}
|
|
27
|
-
*/
|
|
28
|
-
animateToPlacement(mutable: object, placement: PlacementDefinition | string, animation?: AnimationDefinition | string): Promise<AnimationInterface>;
|
|
29
|
-
}
|
|
1
|
+
import { Scene as BabylonScene, Scene } from '@babylonjs/core/scene';
|
|
2
|
+
export declare class AnimationManager {
|
|
3
|
+
protected scene: Scene;
|
|
4
|
+
animations: AnimationInterface[];
|
|
5
|
+
/**
|
|
6
|
+
* Constructor.
|
|
7
|
+
*/
|
|
8
|
+
protected constructor(scene: Scene);
|
|
9
|
+
/**
|
|
10
|
+
* Creates an {@link AnimationManager} based on given BabylonJS scene.
|
|
11
|
+
*/
|
|
12
|
+
static create(scene: BabylonScene): Promise<AnimationManager>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use viewer.moveCameraTo().
|
|
15
|
+
*/
|
|
16
|
+
resetCamera(animate?: boolean): void;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use viewer.moveCameraTo().
|
|
19
|
+
*/
|
|
20
|
+
animateArcRotateCamera(targetAlpha: number, targetBeta: number, targetRadius: number): void;
|
|
21
|
+
/**
|
|
22
|
+
* Stops and kills all running animations.
|
|
23
|
+
*/
|
|
24
|
+
killAllAnimations(): void;
|
|
25
|
+
/**
|
|
26
|
+
* @see {@link PlacementAnimation.play}
|
|
27
|
+
*/
|
|
28
|
+
animateToPlacement(mutable: object, placement: PlacementDefinition | string, animation?: AnimationDefinition | string): Promise<AnimationInterface>;
|
|
29
|
+
}
|