Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react-components): don't add axis gizmo and use event listeners if no flexible camera manager and bump to 0.46.1 #4540

Merged
merged 6 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
type Cognite3DViewer,
type IFlexibleCameraManager
} from '@cognite/reveal';
import { AxisGizmoTool } from '@cognite/reveal/tools';
import { NavigationTool } from '../commands/NavigationTool';
import {
Vector3,
Expand All @@ -27,6 +26,7 @@ import { getResizeCursor } from '../utilities/geometry/getResizeCursor';
import { VisualDomainObject } from '../domainObjects/VisualDomainObject';
import { ThreeView } from '../views/ThreeView';
import { type DomainObject } from '../domainObjects/DomainObject';
import { AxisGizmoTool } from '@cognite/reveal/tools';

const DIRECTIONAL_LIGHT_NAME = 'DirectionalLight';

Expand All @@ -38,11 +38,11 @@ export class RevealRenderTarget {
private readonly _viewer: Cognite3DViewer;
private readonly _toolController: ToolControllers;
private readonly _rootDomainObject: RootDomainObject;
private _axisGizmoTool: AxisGizmoTool | undefined;
private _ambientLight: AmbientLight | undefined;
private _directionalLight: DirectionalLight | undefined;
private _cropBoxBoundingBox: Box3 | undefined;
private _cropBoxName: string | undefined = undefined;
private _axisGizmoTool: AxisGizmoTool | undefined;

// ==================================================
// CONTRUCTORS
Expand All @@ -62,6 +62,11 @@ export class RevealRenderTarget {
this.initializeLights();
this._viewer.on('cameraChange', this.cameraChangeHandler);
this._viewer.on('beforeSceneRendered', this.beforeSceneRenderedHandler);

const navigationTool = new NavigationTool();
navigationTool.attach(this);
this.toolController.add(navigationTool);
this.toolController.setDefaultTool(navigationTool);
}

// ==================================================
Expand Down Expand Up @@ -124,14 +129,9 @@ export class RevealRenderTarget {
// INSTANCE METHODS
// ==================================================

public initialize(): void {
public addAxisGizmo(): void {
this._axisGizmoTool = new AxisGizmoTool();
this._axisGizmoTool.connect(this._viewer);

const navigationTool = new NavigationTool();
navigationTool.attach(this);
this.toolController.add(navigationTool);
this.toolController.setDefaultTool(navigationTool);
}

public dispose(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,17 @@ const useRevealFromKeepAlive = ({
function getOrInitializeRenderTarget(): RevealRenderTarget {
let renderTarget = revealKeepAliveData?.renderTargetRef.current;
if (renderTarget === undefined) {
const viewer = new Cognite3DViewer({ ...viewerOptions, sdk, hasEventListeners: false });
const viewer = new Cognite3DViewer({
...viewerOptions,
sdk,
hasEventListeners: !viewerOptions?.useFlexibleCameraManager
});
renderTarget = new RevealRenderTarget(viewer);
if (revealKeepAliveData !== undefined) {
revealKeepAliveData.renderTargetRef.current = renderTarget;
}
}
renderTarget.viewer.setBackgroundColor({ color, alpha: 1 });
renderTarget.initialize();
setRenderTarget(renderTarget);
return renderTarget;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const RevealStoryContext = ({
useFlexibleCameraManager: true
});
const renderTarget = new RevealRenderTarget(newViewer);
renderTarget.initialize();
renderTarget.addAxisGizmo();
return renderTarget;
}
}, [viewer]);
Expand Down
Loading