|
@@ -1,7 +1,7 @@
|
|
|
import { PBREnvironment, EnvironmentDeserializer } from "./environmentSerializer";
|
|
|
import { SceneManager } from '../viewer/sceneManager';
|
|
|
|
|
|
-import { Tools, Quaternion } from 'babylonjs';
|
|
|
+import { Tools, Quaternion, ShadowLight, Vector3, Axis, Matrix, SphericalPolynomial, Tmp } from 'babylonjs';
|
|
|
import { ViewerConfiguration } from "../configuration/configuration";
|
|
|
import { TextureUtils } from "./texture";
|
|
|
|
|
@@ -18,15 +18,15 @@ export class ViewerLabs {
|
|
|
public environment: PBREnvironment = {
|
|
|
//irradiance
|
|
|
irradiancePolynomialCoefficients: {
|
|
|
- x: new BABYLON.Vector3(0, 0, 0),
|
|
|
- y: new BABYLON.Vector3(0, 0, 0),
|
|
|
- z: new BABYLON.Vector3(0, 0, 0),
|
|
|
- xx: new BABYLON.Vector3(0, 0, 0),
|
|
|
- yy: new BABYLON.Vector3(0, 0, 0),
|
|
|
- zz: new BABYLON.Vector3(0, 0, 0),
|
|
|
- yz: new BABYLON.Vector3(0, 0, 0),
|
|
|
- zx: new BABYLON.Vector3(0, 0, 0),
|
|
|
- xy: new BABYLON.Vector3(0, 0, 0)
|
|
|
+ x: new Vector3(0, 0, 0),
|
|
|
+ y: new Vector3(0, 0, 0),
|
|
|
+ z: new Vector3(0, 0, 0),
|
|
|
+ xx: new Vector3(0, 0, 0),
|
|
|
+ yy: new Vector3(0, 0, 0),
|
|
|
+ zz: new Vector3(0, 0, 0),
|
|
|
+ yz: new Vector3(0, 0, 0),
|
|
|
+ zx: new Vector3(0, 0, 0),
|
|
|
+ xy: new Vector3(0, 0, 0)
|
|
|
},
|
|
|
|
|
|
textureIntensityScale: 1.0
|
|
@@ -93,7 +93,7 @@ export class ViewerLabs {
|
|
|
if (!this.environment) return;
|
|
|
|
|
|
//set orientation
|
|
|
- let rotatquatRotationionY = Quaternion.RotationAxis(BABYLON.Axis.Y, rotationY || 0);
|
|
|
+ let rotatquatRotationionY = Quaternion.RotationAxis(Axis.Y, rotationY || 0);
|
|
|
|
|
|
// Add env texture to the scene.
|
|
|
if (this.environment.specularTexture) {
|
|
@@ -106,7 +106,7 @@ export class ViewerLabs {
|
|
|
this._sceneManager.scene.environmentTexture.invertZ = true;
|
|
|
this._sceneManager.scene.environmentTexture.lodLevelInAlpha = true;
|
|
|
|
|
|
- var poly = this._sceneManager.scene.environmentTexture.sphericalPolynomial || new BABYLON.SphericalPolynomial();
|
|
|
+ var poly = this._sceneManager.scene.environmentTexture.sphericalPolynomial || new SphericalPolynomial();
|
|
|
poly.x = this.environment.irradiancePolynomialCoefficients.x;
|
|
|
poly.y = this.environment.irradiancePolynomialCoefficients.y;
|
|
|
poly.z = this.environment.irradiancePolynomialCoefficients.z;
|
|
@@ -119,7 +119,7 @@ export class ViewerLabs {
|
|
|
this._sceneManager.scene.environmentTexture.sphericalPolynomial = poly;
|
|
|
|
|
|
//set orientation
|
|
|
- BABYLON.Matrix.FromQuaternionToRef(rotatquatRotationionY, this._sceneManager.scene.environmentTexture.getReflectionTextureMatrix());
|
|
|
+ Matrix.FromQuaternionToRef(rotatquatRotationionY, this._sceneManager.scene.environmentTexture.getReflectionTextureMatrix());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -143,4 +143,20 @@ export class ViewerLabs {
|
|
|
return returnUrl;
|
|
|
}
|
|
|
|
|
|
+ public rotateShadowLight(shadowLight: ShadowLight, amount: number, point = Vector3.Zero(), axis = Axis.Y, target = Vector3.Zero()) {
|
|
|
+ axis.normalize();
|
|
|
+ point.subtractToRef(shadowLight.position, Tmp.Vector3[0]);
|
|
|
+ Matrix.TranslationToRef(Tmp.Vector3[0].x, Tmp.Vector3[0].y, Tmp.Vector3[0].z, Tmp.Matrix[0]);
|
|
|
+ Tmp.Matrix[0].invertToRef(Tmp.Matrix[2]);
|
|
|
+ Matrix.RotationAxisToRef(axis, amount, Tmp.Matrix[1]);
|
|
|
+ Tmp.Matrix[2].multiplyToRef(Tmp.Matrix[1], Tmp.Matrix[2]);
|
|
|
+ Tmp.Matrix[2].multiplyToRef(Tmp.Matrix[0], Tmp.Matrix[2]);
|
|
|
+
|
|
|
+ Tmp.Matrix[2].decompose(Tmp.Vector3[0], Tmp.Quaternion[0], Tmp.Vector3[1]);
|
|
|
+
|
|
|
+ shadowLight.position.addInPlace(Tmp.Vector3[1]);
|
|
|
+
|
|
|
+ shadowLight.setDirectionToTarget(target);
|
|
|
+ }
|
|
|
+
|
|
|
}
|