Skip to main content
Seasoned ⭐️
February 2, 2024
Solved

Cognite/Reveal: e.BufferGeometry is not a constructor TypeError: e.BufferGeometry is not a constructor

  • February 2, 2024
  • 18 replies
  • 328 views

I’m using cognite/reveal and cognite/sdk for a project developed in react (18.x).

While connecting cognite/reveal with react application I’m encountering this error:

e.BufferGeometry is not a constructor

TypeError: e.BufferGeometry is not a constructor

 

I would like to know what is causing this error.

 

code attached below:-

 

 

 

A help to figure out the issue would be helpful.

Thank you,

 

Regards,
Hariharan B P

 

Best answer by pramod.s

Hi Hariharan,

I feel this is an authentication issue, I would recommend you to raise new post tagging authentication.

I would be glad to help on Reveal SDK further.

Best Regards,

Pramod S

18 replies

Practitioner ⭐️⭐️⭐️
February 6, 2024

Hi Hariharan,

While looking into your package.json, is your application based on JavaScript not TypeScript?

Best Regards,

Pramod S

Seasoned ⭐️
February 6, 2024

Hi Pramod,

Yes it is based on JavaScript.

I presume it wont be an issue while integrating.

Regards,

Hariharan 

Practitioner ⭐️⭐️⭐️
February 6, 2024

Hi Hariharan,

I find it hard to reproduce the issue in JavaScript application, can you share your config-overrides.js file or even better simple application with this issue.

Best Regards,

Pramod S

Seasoned ⭐️
February 9, 2024

Hi, 
Pramod. 

My apologies for the delay in response.

I have solved the BufferGeometry issue, apparently the react-app-wired was not the latest which is why the override was not working.

 

But, now when I try to connect to cognite/reveal using the project, appId and all other details. The server responds with 

This api.cognitedata.com page can’t be found

 

I’m attaching the component’s source code from where I’m trying to connect to cognite. And I would appreciate if I can be enlightened with a way to work this out.

 

import React, { useEffect } from "react"
import { Cognite3DViewer } from "@cognite/reveal"
import { CogniteClient, CogniteAuthentication } from "@cognite/sdk"

import { getToken } from "../../utils/MsGraphApiCall"

import "./Models.css"

function Models() {
const appId = "KPI-Dev"
const project = "celanese-dev"
const clientId = "my-client-id"
const tenantId = "my-tenant-id"
const cluster = "az-eastus-1"
const modelId = 7575155737800092
const revisionId = 3624517118008353

async function start() {
await client.authenticate(clientId, tenantId, cluster)

const viewer = new Cognite3DViewer({
sdk: client,
domElement: document.querySelector("#your-element-for-viewer"),
})
viewer.addModel({ modelId: modelId, revisionId: revisionId })
}

const legacyInstance = new CogniteAuthentication({
project,
})

// getToken();

const getToken = async () => {
await legacyInstance.handleLoginRedirect()
let token = await legacyInstance.getCDFToken()
console.log("Token: ", token)
if (token) {
console.log("Token: ", token.accessToken)
return token.accessToken
}
token = await legacyInstance.login({ onAuthenticate: "REDIRECT" })
if (token) {
return token.accessToken
}
throw new Error("authentication error")
}

console.log("TOken: ", getToken())

const client = new CogniteClient({
appId,
project,
getToken,
})

useEffect(() => {
start()
}, []) // Empty dependency array to ensure it runs only once after mounting

return <div id='your-element-for-viewer'>Models</div>
}

export default Models

 

The error it throws:-

3D model page response

I kindly, request to enlighten me with the process.

 

Thank you

Regards,
Hariharan

 

 

pramod.sAnswer
Practitioner ⭐️⭐️⭐️
February 13, 2024

Hi Hariharan,

I feel this is an authentication issue, I would recommend you to raise new post tagging authentication.

I would be glad to help on Reveal SDK further.

Best Regards,

Pramod S

Seasoned ⭐️
February 13, 2024

Hi Pramod,

Thank you for the response.

Sure, I would raise another Q’s on the authentication part.

 

Regards,

Hariharan B P

Sharizan Mohd Redzuan
Practitioner ⭐️
Practitioner ⭐️
November 6, 2024

Hi @Hariharan B P , May I know if you able to resolve all those issue and make your React app able to display the reveal? 

I am working on a project that related to utilize the Reveal as well. Hope you can update on this and able to help me for my project.

 

Thank you.

Regards,

Sharizan

 

Mithila Jayalath
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
November 6, 2024

@Sharizan Mohd Redzuan feel free to create new posts if you observe specific errors/ issues along the way.