|
@@ -41,7 +41,7 @@ export class SceneManager {
|
|
/**
|
|
/**
|
|
* Will notify after the lights were configured. Can be used to further configure lights
|
|
* Will notify after the lights were configured. Can be used to further configure lights
|
|
*/
|
|
*/
|
|
- onLightsConfiguredObservable: Observable<IPostConfigurationCallback<Array<Light>, { [name: string]: ILightConfiguration | boolean }>>;
|
|
|
|
|
|
+ onLightsConfiguredObservable: Observable<IPostConfigurationCallback<Array<Light>, { [name: string]: ILightConfiguration | boolean | number }>>;
|
|
/**
|
|
/**
|
|
* Will notify after the model(s) were configured. Can be used to further configure models
|
|
* Will notify after the model(s) were configured. Can be used to further configure models
|
|
*/
|
|
*/
|
|
@@ -93,6 +93,8 @@ export class SceneManager {
|
|
private _reflectionColor = Color3.White();
|
|
private _reflectionColor = Color3.White();
|
|
private readonly _white = Color3.White();
|
|
private readonly _white = Color3.White();
|
|
|
|
|
|
|
|
+ private _forceShadowUpdate: boolean = false;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The labs variable consists of objects that will have their API change.
|
|
* The labs variable consists of objects that will have their API change.
|
|
* Please be careful when using labs in production.
|
|
* Please be careful when using labs in production.
|
|
@@ -137,9 +139,10 @@ export class SceneManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
scene.registerBeforeRender(() => {
|
|
scene.registerBeforeRender(() => {
|
|
- if (scene.animatables && scene.animatables.length > 0) {
|
|
|
|
|
|
+ if (this._forceShadowUpdate || (scene.animatables && scene.animatables.length > 0)) {
|
|
// make sure all models are loaded
|
|
// make sure all models are loaded
|
|
updateShadows();
|
|
updateShadows();
|
|
|
|
+ this._forceShadowUpdate = false;
|
|
} else if (!(this.models.every((model) => {
|
|
} else if (!(this.models.every((model) => {
|
|
if (!model.shadowsRenderedAfterLoad) {
|
|
if (!model.shadowsRenderedAfterLoad) {
|
|
model.shadowsRenderedAfterLoad = true;
|
|
model.shadowsRenderedAfterLoad = true;
|
|
@@ -431,6 +434,15 @@ export class SceneManager {
|
|
let mainColor = new Color3().copyFrom(newConfiguration.lab.environmentMainColor as Color3);
|
|
let mainColor = new Color3().copyFrom(newConfiguration.lab.environmentMainColor as Color3);
|
|
this.environmentHelper.setMainColor(mainColor);
|
|
this.environmentHelper.setMainColor(mainColor);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (newConfiguration.lab.globalLightRotation !== undefined) {
|
|
|
|
+ // rotate all lights that are shadow lights
|
|
|
|
+ this.scene.lights.filter(light => light instanceof ShadowLight).forEach(light => {
|
|
|
|
+ // casting and '!' are safe, due to the constraints tested before
|
|
|
|
+ this.labs.rotateShadowLight(<ShadowLight>light, newConfiguration.lab!.globalLightRotation!);
|
|
|
|
+ });
|
|
|
|
+ this._forceShadowUpdate = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (this._defaultRenderingPipeline && this._defaultRenderingPipeline.imageProcessing) {
|
|
if (this._defaultRenderingPipeline && this._defaultRenderingPipeline.imageProcessing) {
|
|
@@ -789,7 +801,7 @@ export class SceneManager {
|
|
if (this.scene.imageProcessingConfiguration) {
|
|
if (this.scene.imageProcessingConfiguration) {
|
|
this.scene.imageProcessingConfiguration.colorCurvesEnabled = true;
|
|
this.scene.imageProcessingConfiguration.colorCurvesEnabled = true;
|
|
this.scene.imageProcessingConfiguration.vignetteEnabled = true;
|
|
this.scene.imageProcessingConfiguration.vignetteEnabled = true;
|
|
- this.scene.imageProcessingConfiguration.toneMappingEnabled = !!cameraConfig.toneMappingEnabled;
|
|
|
|
|
|
+ this.scene.imageProcessingConfiguration.toneMappingEnabled = !!getConfigurationKey("camera.toneMappingEnabled", this._viewer.configuration);
|
|
}
|
|
}
|
|
|
|
|
|
extendClassWithConfig(this.camera, cameraConfig);
|
|
extendClassWithConfig(this.camera, cameraConfig);
|
|
@@ -810,6 +822,11 @@ export class SceneManager {
|
|
this.camera.alpha = (this._viewer.configuration.camera && this._viewer.configuration.camera.alpha) || this.camera.alpha;
|
|
this.camera.alpha = (this._viewer.configuration.camera && this._viewer.configuration.camera.alpha) || this.camera.alpha;
|
|
this.camera.beta = (this._viewer.configuration.camera && this._viewer.configuration.camera.beta) || this.camera.beta;
|
|
this.camera.beta = (this._viewer.configuration.camera && this._viewer.configuration.camera.beta) || this.camera.beta;
|
|
this.camera.radius = (this._viewer.configuration.camera && this._viewer.configuration.camera.radius) || this.camera.radius;
|
|
this.camera.radius = (this._viewer.configuration.camera && this._viewer.configuration.camera.radius) || this.camera.radius;
|
|
|
|
+
|
|
|
|
+ /*this.scene.lights.filter(light => light instanceof ShadowLight).forEach(light => {
|
|
|
|
+ // casting ais safe, due to the constraints tested before
|
|
|
|
+ (<ShadowLight>light).setDirectionToTarget(center);
|
|
|
|
+ });*/
|
|
}
|
|
}
|
|
|
|
|
|
protected _configureEnvironment(skyboxConifguration?: ISkyboxConfiguration | boolean, groundConfiguration?: IGroundConfiguration | boolean) {
|
|
protected _configureEnvironment(skyboxConifguration?: ISkyboxConfiguration | boolean, groundConfiguration?: IGroundConfiguration | boolean) {
|
|
@@ -989,10 +1006,12 @@ export class SceneManager {
|
|
* @param lightsConfiguration the (new) light(s) configuration
|
|
* @param lightsConfiguration the (new) light(s) configuration
|
|
* @param model optionally use the model to configure the camera.
|
|
* @param model optionally use the model to configure the camera.
|
|
*/
|
|
*/
|
|
- protected _configureLights(lightsConfiguration: { [name: string]: ILightConfiguration | boolean } = {}) {
|
|
|
|
|
|
+ protected _configureLights(lightsConfiguration: { [name: string]: ILightConfiguration | boolean | number } = {}) {
|
|
|
|
|
|
// sanity check!
|
|
// sanity check!
|
|
- if (!Object.keys(lightsConfiguration).length) {
|
|
|
|
|
|
+ let lightKeys = Object.keys(lightsConfiguration).filter(name => name !== 'globalRotation');
|
|
|
|
+
|
|
|
|
+ if (!lightKeys.length) {
|
|
if (!this.scene.lights.length)
|
|
if (!this.scene.lights.length)
|
|
this.scene.createDefaultLight(true);
|
|
this.scene.createDefaultLight(true);
|
|
} else {
|
|
} else {
|
|
@@ -1008,11 +1027,14 @@ export class SceneManager {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- Object.keys(lightsConfiguration).forEach((name, idx) => {
|
|
|
|
|
|
+ lightKeys.forEach((name, idx) => {
|
|
let lightConfig: ILightConfiguration = { type: 0 };
|
|
let lightConfig: ILightConfiguration = { type: 0 };
|
|
if (typeof lightsConfiguration[name] === 'object') {
|
|
if (typeof lightsConfiguration[name] === 'object') {
|
|
lightConfig = <ILightConfiguration>lightsConfiguration[name];
|
|
lightConfig = <ILightConfiguration>lightsConfiguration[name];
|
|
}
|
|
}
|
|
|
|
+ if (typeof lightsConfiguration[name] === 'number') {
|
|
|
|
+ lightConfig.type = <number>lightsConfiguration[name];
|
|
|
|
+ }
|
|
|
|
|
|
lightConfig.name = name;
|
|
lightConfig.name = name;
|
|
|
|
|
|
@@ -1025,6 +1047,9 @@ export class SceneManager {
|
|
} else {
|
|
} else {
|
|
// available? get it from the scene
|
|
// available? get it from the scene
|
|
light = <Light>this.scene.getLightByName(name);
|
|
light = <Light>this.scene.getLightByName(name);
|
|
|
|
+ if (typeof lightsConfiguration[name] === 'boolean') {
|
|
|
|
+ lightConfig.type = light.getTypeID();
|
|
|
|
+ }
|
|
lightsAvailable = lightsAvailable.filter(ln => ln !== name);
|
|
lightsAvailable = lightsAvailable.filter(ln => ln !== name);
|
|
if (lightConfig.type !== undefined && light.getTypeID() !== lightConfig.type) {
|
|
if (lightConfig.type !== undefined && light.getTypeID() !== lightConfig.type) {
|
|
light.dispose();
|
|
light.dispose();
|