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

refactor (react-components): Used latest changes in Reveal (OnWheel, movement of Vector3Pool) + Final touch on the course material #4586

Merged
merged 10 commits into from
Jun 10, 2024
4 changes: 2 additions & 2 deletions react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"peerDependencies": {
"@cognite/cogs.js": ">=9.84.3",
"@cognite/reveal": "4.14.6",
"@cognite/reveal": "4.14.7",
"react": ">=18",
"react-dom": ">=18",
"styled-components": ">=5"
Expand All @@ -44,7 +44,7 @@
"@cognite/cdf-i18n-utils": "^0.7.5",
"@cognite/cdf-utilities": "^3.6.0",
"@cognite/cogs.js": "^9.84.3",
"@cognite/reveal": "^4.14.6",
"@cognite/reveal": "^4.14.7",
"@cognite/sdk": "^9.13.0",
"@playwright/test": "^1.43.1",
"@storybook/addon-essentials": "^8.0.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export abstract class BaseEditTool extends NavigationTool {
if (!isDomainObjectIntersection(intersection)) {
return undefined;
}
const domainObject = this.getIntersectedDomainObject(intersection);
const domainObject = this.getIntersectedSelectableDomainObject(intersection);
if (domainObject === undefined) {
return undefined;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ export abstract class BaseEditTool extends NavigationTool {
* @param intersection - The intersection to retrieve the domain object from.
* @returns The intersected visual domain object, or undefined if no valid domain object is found.
*/
protected getIntersectedDomainObject(
protected getIntersectedSelectableDomainObject(
intersection: AnyIntersection | undefined
): VisualDomainObject | undefined {
if (!isDomainObjectIntersection(intersection)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export abstract class BaseTool extends RenderTargetCommand {
await Promise.resolve();
}

public async onWheel(_event: WheelEvent): Promise<void> {
public async onWheel(_event: WheelEvent, _delta: number): Promise<void> {
await Promise.resolve();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class NavigationTool extends BaseTool {
await this.cameraManager.onPointerUp(event, leftButton);
}

public override async onWheel(event: WheelEvent): Promise<void> {
await this.cameraManager.onWheel(event);
public override async onWheel(event: WheelEvent, delta: number): Promise<void> {
await this.cameraManager.onWheel(event, delta);
}

public override onKey(event: KeyboardEvent, down: boolean): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,11 @@ export abstract class DomainObject {

public toggleVisibleInteractive(renderTarget: RevealRenderTarget): void {
const visibleState = this.getVisibleState(renderTarget);
if (visibleState === VisibleState.None) this.setVisibleInteractive(true, renderTarget);
else if (visibleState === VisibleState.Some || visibleState === VisibleState.All)
if (visibleState === VisibleState.None) {
this.setVisibleInteractive(true, renderTarget);
} else if (visibleState === VisibleState.Some || visibleState === VisibleState.All) {
this.setVisibleInteractive(false, renderTarget);
}
}

// ==================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export enum VisibleState {
Some, // Partly visible
None, // None visible
CanNotBeVisibleNow, // Can not be checked on, but it can be visible
Disabled // Visible disabled
Disabled // Visible disabled, none of the children can be visible or no children
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* CommandsController: Holds the tools, the active tool and the previous tool
*/

import { PointerEvents, PointerEventsTarget } from '@cognite/reveal';
import { PointerEvents, PointerEventsTarget, getWheelEventDelta } from '@cognite/reveal';
import { type BaseTool } from '../commands/BaseTool';
import { type BaseCommand } from '../commands/BaseCommand';

Expand Down Expand Up @@ -215,7 +215,8 @@ export class CommandsController extends PointerEvents {
};

private readonly _onWheel = async (event: WheelEvent): Promise<void> => {
await this.activeTool?.onWheel(event);
const delta = getWheelEventDelta(event);
await this.activeTool?.onWheel(event, delta);
event.stopPropagation();
event.preventDefault();
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import { TrianglesBuffers } from '../../base/utilities/geometry/TrianglesBuffers';
import { type DomainObjectChange } from '../../base/domainObjectsHelpers/DomainObjectChange';
import { Changes } from '../../base/domainObjectsHelpers/Changes';
import { Vector3Pool } from '../../base/utilities/geometry/Vector3Pool';
import { Vector3Pool } from '@cognite/reveal';

const FACE_INDEX_NAME1 = 'faceIndex1';
const FACE_INDEX_NAME2 = 'faceIndex2';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FocusType } from '../../base/domainObjectsHelpers/FocusType';
import { type BoxPickInfo } from '../../base/utilities/box/BoxPickInfo';
import { forceBetween0AndPi } from '../../base/utilities/extensions/mathExtensions';
import { horizontalAngle } from '../../base/utilities/extensions/vectorExtensions';
import { Vector3Pool } from '../../base/utilities/geometry/Vector3Pool';
import { MeasureType } from './MeasureType';
import { getClosestPointOnLine } from '../../base/utilities/extensions/rayExtensions';
import { type MeasureBoxDomainObject } from './MeasureBoxDomainObject';
Expand All @@ -18,6 +17,7 @@ import {
type VisualDomainObject,
type CreateDraggerProps
} from '../../base/domainObjects/VisualDomainObject';
import { Vector3Pool } from '@cognite/reveal';

/**
* The `BoxDragger` class represents a utility for dragging and manipulating a box in a 3D space.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import { GroupThreeView } from '../../base/views/GroupThreeView';
import {
CDF_TO_VIEWER_TRANSFORMATION,
type CustomObjectIntersectInput,
type CustomObjectIntersection
type CustomObjectIntersection,
Vector3Pool
} from '@cognite/reveal';
import { type DomainObjectIntersection } from '../../base/domainObjectsHelpers/DomainObjectIntersection';
import { BoxFace } from '../../base/utilities/box/BoxFace';
import { FocusType } from '../../base/domainObjectsHelpers/FocusType';
import { clear } from '../../base/utilities/extensions/arrayExtensions';
import { Vector3Pool } from '../../base/utilities/geometry/Vector3Pool';
import { createSpriteWithText } from '../../base/utilities/sprites/createSprite';
import {
createLineSegmentsBufferGeometryForBox,
Expand Down
Loading
Loading