Skip to content

Commit

Permalink
Merge branch 'master' into greenbech/fix-typos-130824
Browse files Browse the repository at this point in the history
  • Loading branch information
greenbech authored Aug 13, 2024
2 parents 493c819 + c0688a4 commit bde9146
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 43 deletions.
2 changes: 1 addition & 1 deletion react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.4.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-promise": "^7.0.0",
"eslint-plugin-react": "^7.34.1",
"happy-dom": "^14.7.1",
"locize-cli": "^8.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useSDK } from '../components/RevealCanvas/SDKProvider';
import { getAssetsList } from '../hooks/network/getAssetsList';
import { useAssetMappedNodesForRevisions } from '../components/CacheProvider/AssetMappingAndNode3DCacheProvider';
import { isDefined } from '../utilities/isDefined';
import { uniq } from 'lodash';

export type ModelMappings = {
model: AddModelOptions;
Expand All @@ -43,7 +44,7 @@ export const useSearchMappedEquipmentAssetMappings = (
models: AddModelOptions[],
limit: number = 100,
userSdk?: CogniteClient
): UseInfiniteQueryResult<InfiniteData<AssetPage[]>, Error> => {
): UseInfiniteQueryResult<InfiniteData<AssetPage>, Error> => {
const sdk = useSDK(userSdk);
const { data: assetMappingList, isFetched } = useAssetMappedNodesForRevisions(
models.map((model) => ({ ...model, type: 'cad' }))
Expand All @@ -64,11 +65,7 @@ export const useSearchMappedEquipmentAssetMappings = (
}
if (query === '') {
const assets = initialAssetMappings.data?.pages.flatMap((modelWithAssets) =>
modelWithAssets
.map((modelWithAsset) =>
modelWithAsset.modelsAssets.flatMap((modelsAsset) => modelsAsset.assets)
)
.flat()
modelWithAssets.modelsAssets.flatMap((modelsAsset) => modelsAsset.assets).flat()
);
return { assets, nextCursor: undefined };
}
Expand All @@ -89,8 +86,11 @@ export const useSearchMappedEquipmentAssetMappings = (
.filter(isDefined);
});

// Remove duplicates
const uniqueFilteredSearchedAssets = uniq(filteredSearchedAssets);

return {
assets: filteredSearchedAssets,
assets: uniqueFilteredSearchedAssets,
nextCursor: assetsResponse.nextCursor
};
},
Expand All @@ -108,7 +108,7 @@ export const useAllMappedEquipmentAssetMappings = (
models: AddModelOptions[],
userSdk?: CogniteClient,
limit: number = 1000
): UseInfiniteQueryResult<InfiniteData<ModelAssetPage[]>, Error> => {
): UseInfiniteQueryResult<InfiniteData<ModelAssetPage>, Error> => {
const sdk = useSDK(userSdk);
const usedCursors = useRef(new Set());

Expand Down
10 changes: 5 additions & 5 deletions react-components/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"@rajesh896/broprint.js": "^2.1.1",
"@tweenjs/tween.js": "^23.1.1",
"@tweenjs/tween.js": "^25.0.0",
"assert": "^2.1.0",
"async-mutex": "^0.5.0",
"glslify": "^7.1.1",
Expand Down Expand Up @@ -96,7 +96,6 @@
"@types/skmeans": "^0.11.7",
"@types/stats": "^0.16.30",
"@types/three": "^0.166.0",
"@types/tween.js": "^18.6.1",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"concurrently": "^8.2.2",
Expand Down
2 changes: 2 additions & 0 deletions viewer/packages/camera-manager/src/DefaultCameraManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export class DefaultCameraManager implements CameraManager {
document.removeEventListener('keydown', stopTween);
})
.start(TWEEN.now());
TWEEN.add(tween);
tween.update(TWEEN.now());
}

Expand Down Expand Up @@ -417,6 +418,7 @@ export class DefaultCameraManager implements CameraManager {
document.removeEventListener('keydown', stopTween);
})
.start(TWEEN.now());
TWEEN.add(tween);
tween.update(TWEEN.now());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export class FlexibleCameraManager extends PointerEvents implements IFlexibleCam
this.controls.rotateCameraTo(startDirection, endDirection, 1);
})
.start(TWEEN.now());
TWEEN.add(tween);
tween.update(TWEEN.now());
}

Expand Down
17 changes: 3 additions & 14 deletions viewer/packages/tools/src/Timeline/TimelineTool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,14 @@ describe('TimelineTool', () => {

timelineTool.stop();

expect(TWEEN.update()).toBeFalse();
TWEEN.update();

expect(unassignStyledNodeCollectionSpy).toBeCalledTimes(1);
});

test('pause() & resume() pauses & resumes the Timeline', () => {
timelineTool.play(new Date('2021-10-25'), new Date('2021-10-27'), 40000);
const current = TWEEN.now();
TWEEN.update(current + 10000);

expect(TWEEN.update()).toBeTrue();

timelineTool.pause();
expect(TWEEN.update()).toBeFalse();
TWEEN.update(current + 20000);

timelineTool.resume();
expect(TWEEN.update()).toBeTrue();
TWEEN.update(current + 30000);
// With updates to TweenJS 24.0.0, we no longer receieve a return value from `TWEEN.update`
// Disabling this test for now.
});

test('play() while play is active', () => {
Expand Down
1 change: 1 addition & 0 deletions viewer/packages/tools/src/Timeline/TimelineTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class TimelineTool extends Cognite3DViewerToolBase {

this._playback = tween;
tween.start();
TWEEN.add(tween);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion viewer/packages/tools/src/utilities/moveCameraTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ export function moveCameraTo(
cameraManager.setCameraState({ position: tmpPosition, target: target });
})
.start(TWEEN.now());

TWEEN.add(tween);
tween.update(TWEEN.now());
}
21 changes: 9 additions & 12 deletions viewer/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bde9146

Please sign in to comment.