Skip to content

Commit

Permalink
Merge pull request #13162 from sebavan/master
Browse files Browse the repository at this point in the history
Fix Camera Order Back Compat
  • Loading branch information
sebavan committed Oct 25, 2022
2 parents bb2e8dc + 3506741 commit d098e3d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/dev/core/src/Debug/debugLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Scene } from "../scene";
import { Engine } from "../Engines/engine";
import { EngineStore } from "../Engines/engineStore";
import type { IInspectable } from "../Misc/iInspectable";
import type { Camera } from "../Cameras/camera";

// declare INSPECTOR namespace for compilation issue
declare let INSPECTOR: any;
Expand Down Expand Up @@ -123,6 +124,10 @@ export interface IInspectorOptions {
* Optional initial tab (default to DebugLayerTab.Properties)
*/
initialTab?: DebugLayerTab;
/**
* Optional camera to use to render the gizmos from the inspector (default to the scene.activeCamera or the latest from scene.activeCameras)
*/
gizmoCamera?: Camera;
}

declare module "../scene" {
Expand Down
3 changes: 0 additions & 3 deletions packages/dev/core/src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4540,8 +4540,6 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
}

// Multi-cameras?
// save current active camera, following calls will change it, discarding user settings
const activeCamera = this._activeCamera;
if (this.activeCameras && this.activeCameras.length > 0) {
for (let cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
this._processSubCameras(this.activeCameras[cameraIndex], cameraIndex > 0);
Expand All @@ -4553,7 +4551,6 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold

this._processSubCameras(this.activeCamera, !!this.activeCamera.outputRenderTarget);
}
this._activeCamera = activeCamera;

// Intersection checks
this._checkIntersections();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import { UtilityLayerRenderer } from "core/Rendering/utilityLayerRenderer";
import { PropertyChangedEvent } from "../../../components/propertyChangedEvent";
import type { LightGizmo } from "core/Gizmos/lightGizmo";
import type { CameraGizmo } from "core/Gizmos/cameraGizmo";
import type { Camera } from "core/Cameras/camera";
import { TmpVectors, Vector3 } from "core/Maths/math";

interface ISceneTreeItemComponentProps {
scene: Scene;
gizmoCamera?: Camera;
onRefresh: () => void;
selectedEntity?: any;
extensibilityGroups?: IExplorerExtensibilityGroup[];
Expand Down Expand Up @@ -233,7 +235,10 @@ export class SceneTreeItemComponent extends React.Component<ISceneTreeItemCompon

if (!scene.reservedDataStore.gizmoManager) {
scene.reservedDataStore.gizmoManager = new GizmoManager(scene);
scene.reservedDataStore.gizmoManager.utilityLayer.setRenderCamera(scene.activeCamera);
}

if (this.props.gizmoCamera) {
scene.reservedDataStore.gizmoManager.utilityLayer.setRenderCamera(this.props.gizmoCamera);
}

const manager: GizmoManager = scene.reservedDataStore.gizmoManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { StandardMaterial } from "core/Materials/standardMaterial";
import { PBRMaterial } from "core/Materials/PBR/pbrMaterial";
import { SpriteManager } from "core/Sprites/spriteManager";
import type { TargetCamera } from "core/Cameras/targetCamera";
import type { Camera } from "core/Cameras/camera";

// side effects
import "core/Sprites/spriteSceneComponent";
Expand Down Expand Up @@ -54,6 +55,7 @@ export class SceneExplorerFilterComponent extends React.Component<ISceneExplorer

interface ISceneExplorerComponentProps {
scene: Scene;
gizmoCamera?: Camera;
noCommands?: boolean;
noHeader?: boolean;
noExpand?: boolean;
Expand Down Expand Up @@ -441,6 +443,7 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
<SceneExplorerFilterComponent onFilter={(filter) => this.filterContent(filter)} />
<SceneTreeItemComponent
globalState={this.props.globalState}
gizmoCamera={this.props.gizmoCamera}
extensibilityGroups={this.props.extensibilityGroups}
selectedEntity={this.state.selectedEntity}
scene={scene}
Expand Down
2 changes: 2 additions & 0 deletions packages/dev/inspector/src/inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class Inspector {
enablePopup: options.enablePopup,
enableClose: options.enableClose,
explorerExtensibility: options.explorerExtensibility,
gizmoCamera: options.gizmoCamera,
};
}

Expand All @@ -131,6 +132,7 @@ export class Inspector {
this._OpenedPane++;
const sceneExplorerElement = React.createElement(SceneExplorerComponent, {
scene,
gizmoCamera: options.gizmoCamera,
globalState: this._GlobalState,
extensibilityGroups: options.explorerExtensibility,
noClose: !options.enableClose,
Expand Down

0 comments on commit d098e3d

Please sign in to comment.