Can you use the godot engine with a react js web app?

255 views Asked by At

Im looking at building an in browser digital twin application using React JS, and am looking into possible options for rendering a 3D model which the user can freely manipulate and move the camera about.

Could I add in godot as a component to act as a model viewer and then use that to trigger responses and changes in the rest of my UI?

Ive got the react UI set up and ready to go, I basically just need a viewer to add into it

1

There are 1 answers

0
Sampath On

Below are the steps to integrate Godot Engine into a React JS web application using a digital twin application:

  • Create a new React app by running:
npx create-react-app my-app
cd my-app
  • Install a package named react-godot using npm for integrating Godot Engine with React applications.
npm install --save react-godot
  • Refer to this for the Godot engine within the React.

  • Code taken from the DOC.

  • Azure Digital Twins Single-page Application.

Below is the code for a digital twin application using React JS. Code:

const myComponent = {
  "@id": "dtmi:my_component;1",
  "@type": "Interface",
  "@context": "dtmi:dtdl:context;2",
  displayName: "Component1",
  contents: [
    {
      "@type": "Property",
      name: "ComponentProp1",
      schema: "string"
    }
  ]
};

const createModels = async () => {
  const models = await serviceClient.createModels([myComponent]);
  console.log("Models created:");
  for await (const model of models) {
    console.log(`Model ID: ${model.id}`);
  }
};

// List models
const listModels = async () => {
  const models = await serviceClient.listModels();
  console.log("List of models:");
  for await (const model of models) {
    console.log(`Model ID: ${model.id}`);
  }
};



Output: enter image description here

enter image description here

enter image description here

  • For more details, refer to this for Azure Digital Twins 3D Scenes: Studio.