|
@@ -5,7 +5,7 @@ import { Observable, Observer } from "./Misc/observable";
|
|
import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "./Misc/smartArray";
|
|
import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "./Misc/smartArray";
|
|
import { StringDictionary } from "./Misc/stringDictionary";
|
|
import { StringDictionary } from "./Misc/stringDictionary";
|
|
import { Tags } from "./Misc/tags";
|
|
import { Tags } from "./Misc/tags";
|
|
-import { Color4, Color3, Plane, Vector2, Vector3, Matrix, Tmp, Frustum } from "./Maths/math";
|
|
|
|
|
|
+import { Color4, Color3, Plane, Vector2, Vector3, Matrix, Frustum } from "./Maths/math";
|
|
import { Geometry } from "./Meshes/geometry";
|
|
import { Geometry } from "./Meshes/geometry";
|
|
import { TransformNode } from "./Meshes/transformNode";
|
|
import { TransformNode } from "./Meshes/transformNode";
|
|
import { SubMesh } from "./Meshes/subMesh";
|
|
import { SubMesh } from "./Meshes/subMesh";
|
|
@@ -870,7 +870,8 @@ export class Scene extends AbstractScene implements IAnimatable {
|
|
/** All of the active cameras added to this scene. */
|
|
/** All of the active cameras added to this scene. */
|
|
public activeCameras = new Array<Camera>();
|
|
public activeCameras = new Array<Camera>();
|
|
|
|
|
|
- private _activeCamera: Nullable<Camera>;
|
|
|
|
|
|
+ /** @hidden */
|
|
|
|
+ public _activeCamera: Nullable<Camera>;
|
|
/** Gets or sets the current active camera */
|
|
/** Gets or sets the current active camera */
|
|
public get activeCamera(): Nullable<Camera> {
|
|
public get activeCamera(): Nullable<Camera> {
|
|
return this._activeCamera;
|
|
return this._activeCamera;
|
|
@@ -1113,17 +1114,17 @@ export class Scene extends AbstractScene implements IAnimatable {
|
|
public _activeAnimatables = new Array<Animatable>();
|
|
public _activeAnimatables = new Array<Animatable>();
|
|
|
|
|
|
private _transformMatrix = Matrix.Zero();
|
|
private _transformMatrix = Matrix.Zero();
|
|
- private _transformMatrixR = Matrix.Zero();
|
|
|
|
private _sceneUbo: UniformBuffer;
|
|
private _sceneUbo: UniformBuffer;
|
|
- private _multiviewSceneUbo: UniformBuffer;
|
|
|
|
|
|
|
|
- private _viewMatrix: Matrix;
|
|
|
|
|
|
+ /** @hidden */
|
|
|
|
+ public _viewMatrix: Matrix;
|
|
private _projectionMatrix: Matrix;
|
|
private _projectionMatrix: Matrix;
|
|
private _wheelEventName = "";
|
|
private _wheelEventName = "";
|
|
/** @hidden */
|
|
/** @hidden */
|
|
public _forcedViewPosition: Nullable<Vector3>;
|
|
public _forcedViewPosition: Nullable<Vector3>;
|
|
|
|
|
|
- private _frustumPlanes: Plane[];
|
|
|
|
|
|
+ /** @hidden */
|
|
|
|
+ public _frustumPlanes: Plane[];
|
|
/**
|
|
/**
|
|
* Gets the list of frustum planes (built from the active camera)
|
|
* Gets the list of frustum planes (built from the active camera)
|
|
*/
|
|
*/
|
|
@@ -1606,13 +1607,6 @@ export class Scene extends AbstractScene implements IAnimatable {
|
|
this._sceneUbo.addUniform("view", 16);
|
|
this._sceneUbo.addUniform("view", 16);
|
|
}
|
|
}
|
|
|
|
|
|
- private _createMultiviewUbo(): void {
|
|
|
|
- this._multiviewSceneUbo = new UniformBuffer(this._engine, undefined, true);
|
|
|
|
- this._multiviewSceneUbo.addUniform("viewProjection", 16);
|
|
|
|
- this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
|
|
|
|
- this._multiviewSceneUbo.addUniform("view", 16);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Pointers handling
|
|
// Pointers handling
|
|
private _setRayOnPointerInfo(pointerInfo: PointerInfo) {
|
|
private _setRayOnPointerInfo(pointerInfo: PointerInfo) {
|
|
if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
|
|
if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
|
|
@@ -2574,9 +2568,6 @@ export class Scene extends AbstractScene implements IAnimatable {
|
|
this._projectionMatrix = projectionL;
|
|
this._projectionMatrix = projectionL;
|
|
|
|
|
|
this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
|
|
this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
|
|
- if (viewR && projectionR) {
|
|
|
|
- viewR.multiplyToRef(projectionR, this._transformMatrixR);
|
|
|
|
- }
|
|
|
|
|
|
|
|
// Update frustum
|
|
// Update frustum
|
|
if (!this._frustumPlanes) {
|
|
if (!this._frustumPlanes) {
|
|
@@ -2585,16 +2576,8 @@ export class Scene extends AbstractScene implements IAnimatable {
|
|
Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
|
|
Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
|
|
}
|
|
}
|
|
|
|
|
|
- if (viewR && projectionR) {
|
|
|
|
- viewR.multiplyToRef(projectionR, Tmp.Matrix[0]);
|
|
|
|
- Frustum.GetRightPlaneToRef(Tmp.Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
|
|
if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
|
|
- this._multiviewSceneUbo.updateMatrix("viewProjection", this._transformMatrix);
|
|
|
|
- this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
|
|
|
|
- this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
|
|
|
|
- this._multiviewSceneUbo.update();
|
|
|
|
|
|
+ this._updateMultiviewUbo(viewR, projectionR);
|
|
} else if (this._sceneUbo.useUbo) {
|
|
} else if (this._sceneUbo.useUbo) {
|
|
this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
|
|
this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
|
|
this._sceneUbo.updateMatrix("view", this._viewMatrix);
|
|
this._sceneUbo.updateMatrix("view", this._viewMatrix);
|
|
@@ -4045,7 +4028,8 @@ export class Scene extends AbstractScene implements IAnimatable {
|
|
}
|
|
}
|
|
/** @hidden */
|
|
/** @hidden */
|
|
public _allowPostProcessClearColor = true;
|
|
public _allowPostProcessClearColor = true;
|
|
- private _renderForCamera(camera: Camera, rigParent?: Camera): void {
|
|
|
|
|
|
+ /** @hidden */
|
|
|
|
+ public _renderForCamera(camera: Camera, rigParent?: Camera): void {
|
|
if (camera && camera._skipRendering) {
|
|
if (camera && camera._skipRendering) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -4169,32 +4153,7 @@ export class Scene extends AbstractScene implements IAnimatable {
|
|
}
|
|
}
|
|
|
|
|
|
if (camera._useMultiviewToSingleView) {
|
|
if (camera._useMultiviewToSingleView) {
|
|
- // Multiview is only able to be displayed directly for API's such as webXR
|
|
|
|
- // This displays a multiview image by rendering to the multiview image and then
|
|
|
|
- // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
|
|
|
|
-
|
|
|
|
- // Render to a multiview texture
|
|
|
|
- camera._resizeOrCreateMultiviewTexture(
|
|
|
|
- (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.width > 0) ? camera._rigPostProcess.width / 2 : this.getEngine().getRenderWidth(true) / 2,
|
|
|
|
- (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.height > 0) ? camera._rigPostProcess.height : this.getEngine().getRenderHeight(true)
|
|
|
|
- );
|
|
|
|
- if (!this._multiviewSceneUbo) {
|
|
|
|
- this._createMultiviewUbo();
|
|
|
|
- }
|
|
|
|
- camera.outputRenderTarget = camera._multiviewTexture;
|
|
|
|
- this._renderForCamera(camera);
|
|
|
|
- camera.outputRenderTarget = null;
|
|
|
|
-
|
|
|
|
- // Consume the multiview texture through a shader for each eye
|
|
|
|
- for (var index = 0; index < camera._rigCameras.length; index++) {
|
|
|
|
- var engine = this._engine;
|
|
|
|
- this._activeCamera = camera._rigCameras[index];
|
|
|
|
- engine.setViewport(this._activeCamera.viewport);
|
|
|
|
- if (this.postProcessManager) {
|
|
|
|
- this.postProcessManager._prepareFrame();
|
|
|
|
- this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ this._renderMultiviewToSingleView(camera);
|
|
} else {
|
|
} else {
|
|
// rig cameras
|
|
// rig cameras
|
|
for (var index = 0; index < camera._rigCameras.length; index++) {
|
|
for (var index = 0; index < camera._rigCameras.length; index++) {
|