From 14a7dbfdef6c1a2984c081bfb2b263535546074b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Fri, 28 Jun 2024 16:57:28 +0200 Subject: [PATCH 1/2] Revert "feat(react-components): Add ground plane rotation 0.52.0 (#4638)" This reverts commit 5d0d7b9f81f53ac13acb547b8753903bc328f414. --- react-components/package.json | 2 +- .../src/hooks/useGroundPlaneFromScene.tsx | 15 +++++---- .../utilities/transformation3dToMatrix4.ts | 33 ------------------- 3 files changed, 9 insertions(+), 41 deletions(-) delete mode 100644 react-components/src/utilities/transformation3dToMatrix4.ts diff --git a/react-components/package.json b/react-components/package.json index 4cc0c4105fc..e139099319b 100644 --- a/react-components/package.json +++ b/react-components/package.json @@ -1,6 +1,6 @@ { "name": "@cognite/reveal-react-components", - "version": "0.52.0", + "version": "0.51.0", "exports": { ".": { "import": "./dist/index.js", diff --git a/react-components/src/hooks/useGroundPlaneFromScene.tsx b/react-components/src/hooks/useGroundPlaneFromScene.tsx index 3a70b211dcf..fbf6650efd8 100644 --- a/react-components/src/hooks/useGroundPlaneFromScene.tsx +++ b/react-components/src/hooks/useGroundPlaneFromScene.tsx @@ -18,7 +18,6 @@ import { useSDK } from '../components/RevealCanvas/SDKProvider'; import { CDF_TO_VIEWER_TRANSFORMATION, CustomObject } from '@cognite/reveal'; import { useReveal } from '../components/RevealCanvas/ViewerContext'; import { clear } from '../architecture/base/utilities/extensions/arrayExtensions'; -import { transformation3dToMatrix4 } from '../utilities/transformation3dToMatrix4'; export const useGroundPlaneFromScene = (sceneExternalId: string, sceneSpaceId: string): void => { const { data: scene } = useSceneConfig(sceneExternalId, sceneSpaceId); @@ -84,17 +83,19 @@ export const useGroundPlaneFromScene = (sceneExternalId: string, sceneSpaceId: s } const texture = groundPlaneTextures[index]; const material = new MeshBasicMaterial({ map: texture, side: DoubleSide }); - const geometry = new PlaneGeometry(10000, 10000); + const geometry = new PlaneGeometry(10000 * groundPlane.scaleX, 10000 * groundPlane.scaleY); geometry.name = `CogniteGroundPlane`; const mesh = new Mesh(geometry, material); - - const matrix4 = transformation3dToMatrix4(groundPlane).premultiply( - CDF_TO_VIEWER_TRANSFORMATION + mesh.position.set( + groundPlane.translationX, + groundPlane.translationY, + groundPlane.translationZ ); - mesh.matrix.copy(matrix4); - mesh.matrixAutoUpdate = false; + mesh.rotation.set(-Math.PI / 2, 0, 0); + + mesh.position.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); const customObject = new CustomObject(mesh); customObject.isPartOfBoundingBox = false; diff --git a/react-components/src/utilities/transformation3dToMatrix4.ts b/react-components/src/utilities/transformation3dToMatrix4.ts deleted file mode 100644 index 813be0f8972..00000000000 --- a/react-components/src/utilities/transformation3dToMatrix4.ts +++ /dev/null @@ -1,33 +0,0 @@ -/*! - * Copyright 2024 Cognite AS - */ - -import { Euler, MathUtils, Matrix4, Quaternion, Vector3 } from 'three'; -import { type Transformation3d } from '../hooks/types'; - -export const transformation3dToMatrix4 = ({ - translationX, - translationY, - translationZ, - eulerRotationX, - eulerRotationY, - eulerRotationZ, - scaleX, - scaleY, - scaleZ -}: Transformation3d): Matrix4 => { - const quaternion = new Quaternion().setFromEuler( - new Euler( - MathUtils.degToRad(eulerRotationX), - MathUtils.degToRad(eulerRotationY), - MathUtils.degToRad(eulerRotationZ), - 'XYZ' - ) - ); - - return new Matrix4().compose( - new Vector3(translationX, translationY, translationZ), - quaternion, - new Vector3(scaleX, scaleY, scaleZ) - ); -}; From c900b91b80c5c94a4eac6e8b99583a8ba78a70dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Fri, 28 Jun 2024 16:57:47 +0200 Subject: [PATCH 2/2] chore: bump react components to 0.52.1 --- react-components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-components/package.json b/react-components/package.json index e139099319b..a8b06f71287 100644 --- a/react-components/package.json +++ b/react-components/package.json @@ -1,6 +1,6 @@ { "name": "@cognite/reveal-react-components", - "version": "0.51.0", + "version": "0.52.1", "exports": { ".": { "import": "./dist/index.js",