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

[developer] Create the beginner Typescript guide #114

Merged
merged 100 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
a650393
typescript breakout
anselm Jan 10, 2024
5d4f9c8
Merge branch 'main' into new-TypescriptBeginner
heysokam Jan 30, 2024
4380697
fmt: Change 00_intro to the new index+nolink system
heysokam Jan 30, 2024
3617966
fmt: Remove unnecesary folder at docs/ root
heysokam Jan 30, 2024
56e3ae1
rmv: Remove the Pong guide, which is worked on at #99 as intermediate
heysokam Jan 30, 2024
de485fd
fmt: Restructured the tutorial files/folders/titles
heysokam Jan 30, 2024
4faee3d
fmt: Formatting changes to fit the Markdown guidelines
heysokam Jan 30, 2024
c636682
new: Quickstart sketch
heysokam Jan 31, 2024
be6846b
chg: Turn the confusing install instructions into a simple bash script
heysokam Feb 1, 2024
dfa324a
chg: Move installation intro to the intro page
heysokam Feb 1, 2024
d1f4ea7
Merge branch 'main' into new-TypescriptBeginner
heysokam Feb 1, 2024
2618904
chg: Move the UbuntuEasyInstall instructions to a partial file
heysokam Feb 1, 2024
43f243b
new: Create the gettingStarted/extras section
heysokam Feb 1, 2024
c3cb073
fix: Typo in developer/typescript/start/extras category file
heysokam Feb 1, 2024
dea0af3
fix: Remove id from developer/typescript/start/extras category file
heysokam Feb 1, 2024
4d82dd4
fmt: Move tutorial-basic instructions out of the ubuntu installer file
heysokam Feb 1, 2024
4c52183
new: Add typescript/start/hello section
heysokam Feb 1, 2024
e392085
chg: Small changes to the hello world tutorial
heysokam Feb 2, 2024
208fd70
fix: Incorrect todo link to the ubuntu install script. rmv: whitespace
heysokam Feb 2, 2024
b6972b7
new: Add instructions on how to confirm the hello world installation
heysokam Feb 2, 2024
daa8f5d
new: Add todo note for explaining the Controlled Context concept
heysokam Feb 3, 2024
979d102
new: Hello World Tutorial (phase1)
heysokam Feb 3, 2024
9b52595
chg: Improvements to the ECS definitions
heysokam Feb 6, 2024
cb3dd30
chg: General improvements to the ECS page
heysokam Feb 6, 2024
471712d
new: Add TechnicalNote custom mdx component
heysokam Feb 6, 2024
4b12554
new: Merge modules+worldInjection into a single file. Write their text
heysokam Feb 6, 2024
f41459f
fmt: Add notes on achieving docusaurus <details> CSS for components
heysokam Feb 6, 2024
c771dde
fmt: Markdown formatting changes for the ECS and Systems pages
heysokam Feb 6, 2024
7870779
new: Add UnstyledDetails component
heysokam Feb 6, 2024
c3e9d27
chg: Small wording change in the ECS page
heysokam Feb 6, 2024
a5c25b3
new: Add source modification section. Improve module imports section
heysokam Feb 6, 2024
3b32385
fix: Small typo in the engine page
heysokam Feb 6, 2024
555496a
chg: Small typo in the quickstart page
heysokam Feb 7, 2024
4f10fd0
new: Add the "First System" section text
heysokam Feb 7, 2024
c234a5f
fmt: Refactor the folder structure to match the new learning path
heysokam Feb 7, 2024
4880842
fix: Sidebar ordering numbers
heysokam Feb 7, 2024
6437112
fmt: Move foreign folders into the _todo temporary subfolder
heysokam Feb 7, 2024
b06c363
fmt: Reorganize the extras folder to build up to networking (sketch)
heysokam Feb 8, 2024
96e2b8a
requested changes
heysokam Feb 8, 2024
ad7b558
chg: Reword `sub-projects` to `projects`
heysokam Feb 8, 2024
7f7a999
rmv: Remove test.js from the root folder
heysokam Feb 8, 2024
b91a830
rmv: Remove Entity clarification for its definition
heysokam Feb 8, 2024
25679e0
doc: improve todo note/comment about entity clarification alternatives
heysokam Feb 8, 2024
9e8310c
new: Add Congratulations page to the HelloWorld tutorial
heysokam Feb 8, 2024
4d45fd4
chg: Convert the Extras section into the Basics section
heysokam Feb 8, 2024
149fbfe
fix: Missing imports in the new Basics pages
heysokam Feb 8, 2024
9e86e87
chg: Congrats and Basics pages formatting improvements
heysokam Feb 8, 2024
810af0b
new: Physics Basics tutorial page
heysokam Feb 8, 2024
ea6b41a
new: Debugging and Locations Basics tutorial pages sketches
heysokam Feb 8, 2024
d48a640
new: Better instructions on the Physics Basics page
heysokam Feb 8, 2024
db34134
chg: Small changes to the files
heysokam Feb 9, 2024
1361b68
chg: Wording and instructions changes to the Physics page
heysokam Feb 9, 2024
f9c7d60
chg: Move locations instructions to the new basics/locations page
heysokam Feb 9, 2024
26e55cc
new: Basics/state early sketch (tbd)
heysokam Feb 10, 2024
8dab2aa
new: Early sketch of the Intermediate tutorials structure
heysokam Feb 12, 2024
baa946c
chg: Cleanup the folders to remove the _todo temporary folder
heysokam Feb 13, 2024
e4a3bd4
chg: Move the Basics tutorial out of Getting Started
heysokam Feb 15, 2024
585913c
chg: Remove worldInjection instructions
heysokam Feb 15, 2024
6ce1703
new: Add HelloWorld/Component page sketch
heysokam Feb 15, 2024
e79e0cd
chg: Improvements to the HelloWorld/Component page
heysokam Feb 15, 2024
cfd6e19
fix: Missing UnstyledDetails in the Basics section
heysokam Feb 15, 2024
80b5927
doc: Add todo note to the HelloWorld/components page
heysokam Feb 15, 2024
c2d7fb6
chg: Improvements to the Quickstart guide
heysokam Feb 16, 2024
b7d46e1
new: Intermediate Section structure/skeleton
heysokam Feb 16, 2024
3c10960
fix: DocCardList on empty Networking category crashed the builder
heysokam Feb 16, 2024
92e0054
chg: Remove leftover mentions to worldInjection
heysokam Feb 16, 2024
ecdb568
new: Add code sketch to the HelloComponent page
heysokam Feb 17, 2024
fe3ca7a
Merge branch 'main' into new-TypescriptBeginner
heysokam Feb 21, 2024
b27f56b
fmt: Remove incorrectly added folders
heysokam Feb 21, 2024
9684cd2
fix: Broken links and GettingStarted title
heysokam Feb 21, 2024
2fd8c05
fmt: Small styling changes to the hello/component page
heysokam Feb 22, 2024
fa85c26
new: basics/Recap section
heysokam Feb 22, 2024
9ac5867
fix: Broken links on Recap and GettingStarted
heysokam Feb 23, 2024
38e7ae1
chg: Small wording improvements
heysokam Feb 23, 2024
beaae37
new: jsonID naming requirements
heysokam Feb 23, 2024
d547137
new: Component+Query pages for the HelloWorld guide
heysokam Feb 23, 2024
f7ceaf5
new: Component+Query sketch for the Basics guide
heysokam Feb 23, 2024
8638039
fix: Ubuntu Installation instructions command
heysokam Feb 24, 2024
8852c39
chg: Edit pass. Small wording changes and fixes for all sections
heysokam Feb 24, 2024
ae3f4bd
new: Basics/component page and Basics/query skeleton
heysokam Feb 27, 2024
3f401f1
new: Basics/location creation instructions
heysokam Feb 27, 2024
e800a93
chg: Improve the Basics/query page
heysokam Feb 27, 2024
d14f8c3
new: Write the Basics/recap/query page
heysokam Feb 27, 2024
f8ba519
new: Write the Basics/recap/next page
heysokam Feb 27, 2024
8e6ff27
new: Add ee-tutorial-hello/Step0 branch instructions
heysokam Feb 28, 2024
d6c9d6e
chg: Add A-to-B overview instructions for the HelloWorld/introduction
heysokam Feb 28, 2024
a818f5f
chg: Move modules/engine/testing into typescript/mastery/testing
heysokam Feb 29, 2024
4397999
chg: Move modules/engine/state to developer/typescript/ecs/state
heysokam Feb 29, 2024
4aa8324
new: Create developer/typescript/reactivity section
heysokam Feb 29, 2024
a28c6e9
chg: Move parts of manual/ecs to the typescript/ecs intermediate guide
heysokam Feb 29, 2024
f34053f
chg: Hello/query editing pass
heysokam Feb 29, 2024
aa7d7ae
fmt: Change Basics/physics to fit the CustomComponent previous code
heysokam Mar 1, 2024
c609b2f
chg: Remove noise from the developer/typescript index page
heysokam Mar 1, 2024
c011873
chg: Basics/state page improvements
heysokam Mar 1, 2024
1ac9763
new: Port tldraw list of events to execution order page
heysokam Mar 4, 2024
57024fe
chg: Progress on the Basics/state page
heysokam Mar 4, 2024
e0db654
chg: UX cleanup (phase1)
heysokam Mar 7, 2024
b486715
chg: UX cleanup (phase2)
heysokam Mar 7, 2024
abf1fe5
fix: Leftover old code
heysokam Mar 8, 2024
8d64e49
Merge branch 'main' into new-TypescriptBeginner
DanielBelmes Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/_partials/defaultProjects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Ethereal Engine has a few scenes that are installed by default.
With the engine running, open the Studio by navigating to https://localhost:3000/studio, and you will see the engine's default project listed in that page.

Lets give them a test run:
- Open one of the default project by clicking on its card
- Click on one of the scenes to open it
- Click on the `Play` button to enter the scene with an Avatar
- Move around the scene with `WASD` and/or clicking on the ground
19 changes: 19 additions & 0 deletions docs/_partials/installUbuntu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:::important
Ethereal Engine is a web application.
We are going to install and run a local version of the engine.
But this setup might not reflect how you will use the engine on a day to day basis.
:::

:::note
These installation instructions assume you are using Ubuntu Linux.
You can find alternative _(and more advanced)_ installation instructions for [Windows](/manual/install/windowsWSL), [Mac](/manual/install/macOSX) and [Linux](/manual/install/linux) in the Manual.
:::

If you are on Ubuntu Linux, there is an automatic installation script to setup and run a local version of Ethereal Engine.
Open a terminal window and run these two lines:
> Make sure that you open the terminal in the folder where you want to install the engine
```bash
wget https://raw.githubusercontent.com/EtherealEngine/etherealengine/dev/scripts/ubuntu-install.sh && bash -i ./ubuntu-install.sh
npm run reinit && npm run dev
```
You can now open Ethereal Engine on your web browser by navigating to https://localhost:3000
2 changes: 0 additions & 2 deletions docs/developer/typescript/01_gettingStarted/01_file.md

This file was deleted.

43 changes: 43 additions & 0 deletions docs/developer/typescript/01_gettingStarted/01_quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
sidebar_label: Quickstart
---
import UbuntuInstall from '../../../_partials/installUbuntu.md'
import DefaultProjects from '../../../_partials/defaultProjects.md'

# Typescript Quickstart
This QuickStart guide will teach you the basics of Ethereal Engine, and how to run the engine for the first time.

## Installation
<UbuntuInstall />

## Projects
### Default Projects
<DefaultProjects />

### Install and Run the tutorial project
Whether you installed the engine with method above, or with the installation instructions for your specific system, your next step will be to install the tutorial project.

:::danger
This `HelloWorld` project should never be installed in a remote deployment.
A local version of the engine is required to follow this introductory tutorial.
:::

The previous commands will have the engine running locally.
Lets stop it by pressing `Ctrl+C`, and then run these commands to install and run the tutorial's template project:
```bash
git clone -b Step0 https://github.com/EtherealEngine/ee-tutorial-hello packages/projects/projects/ee-tutorial-hello
npm run dev
```

You should now be able to see the `ee-tutorial-hello` project listed in Ethereal Engine's Studio by navigating to https://localhost:3000/studio.

## Confirm the installation
Lets make sure that our `hello world` code is running:
1. Open the project from the Studio by clicking on its card
2. Create a new empty scene

You will know that the code is running if you can see a white sphere in the middle of the scene.

:::note
You can also enter the scene and move around with an avatar by pressing the `Play` button in the editor like we did before.
:::
2 changes: 0 additions & 2 deletions docs/developer/typescript/01_gettingStarted/02_file2.md

This file was deleted.

87 changes: 87 additions & 0 deletions docs/developer/typescript/01_gettingStarted/02_hello/01_ecs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { TechnicalNote } from '@site/src/components/TechnicalNote';

# The ECS Pattern
The [Entity Component System](https://en.wikipedia.org/wiki/Entity_component_system) is a pattern used to organize our code when writing software.
In this pattern:
- Logic is represented as `Systems`, and they define the behavior of the application
- Data is represented as `Components` that have no behavior or identifiers attached to them
- Components are attached to Entities
- `Entities` are identifiers

<TechnicalNote title="Technical Summary">
The ECS pattern represents [Objects](https://en.wikipedia.org/wiki/Object_(computer_science)) by attaching Components (data) to an Entity (identifiers) without behavior.
The behavior of the application is then controlled by having separate Systems (logic) that process that data.
Systems don't need to know where that data is coming from. They only know what data is stored in the Components that they can operate on.
</TechnicalNote>

:::note
Clicking on the `Technical Summary` note right above will open a drop-down with information about what the ECS pattern is in more advanced/technical terms.

You will find a lot of these `Technical` drop-downs throughout the guides.
Their goal is to give you extra information that is not mandatory to understand to follow the guide, but is very useful to achieve a deeper understanding of the content.

Don't worry if you don't fully understand what some of them explain just yet. We will get there.
:::

## Creating an Entity
Creating an Entity is as simple as calling the `createEntity()` function from Ethereal Engine's `ECS`.
This function will return an identifier that can be used to group Components into a unique and distinct Object.
```ts
const entity = ECS.createEntity()
```

## Adding Components
Components represent data that has no behavior or identification.
The way to attach Components to Entities is by calling the `setComponent` function from Ethereal Engine's `ECS`.

<TechnicalNote>
The `setComponent` function will not return anything, but it will:
- Add the given Component to the Entity.
- Store the Component's data in the internal records of the ECS, so it can used by the engine or accessed through the API _(eg: with `getComponent` and similar functions)_.
</TechnicalNote>

Ethereal Engine requires a specific set of Components in order to create an object that can be presented on the screen:
- **VisibleComponent**
- **TransformComponent**
- **PrimitiveGeometryComponent** or **MeshComponent**
- _(optional)_ **NameComponent**: Not required, but good practice.


### `NameComponent`
Gives a human-readable identifier to an Entity.
Whatever name you add on this field is the name that will show up in the Studio and the debugger.
They are not mandatory, but it is good practice to add them to all your entities.
```ts
ECS.setComponent(entity, NameComponent, 'hello-world')
```
<TechnicalNote title="Clarification">
We said that an entity is an identifier, but we are also giving that identifier a `NameComponent`.
Every Entity represents its internal "name" _(aka identifier)_ as an [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier), which does not need to be human-readable.
And `NameComponents` give a human-readable identifier to an Entity, independent of what its UUID is.
</TechnicalNote>


### `VisibleComponent`
Gives the Entity the ability to be visible on the screen.
Entities without this Component will be ignored by the renderer.
```ts
ECS.setComponent(entity, VisibleComponent)
```

### `TransformComponent`
In simple terms, `TransformComponents` give an Entity the ability to have a [position in the world](https://en.wikipedia.org/wiki/Transformation_matrix).
There would be no way to position the Entity in 3D space without attaching this Component to the Entity.
```ts
ECS.setComponent(entity, TransformComponent, { position: new Vector3(0, 1, 0) })
```
> In more technical terms, `TransformComponents` give the Entity the ability to be affected by [linear transformations](https://en.wikipedia.org/wiki/Linear_transformation).

### `PrimitiveGeometryComponent`
This Component gives Entities a primitive "visual body".
Entities without it would not have any [3D geometry](https://en.wikipedia.org/wiki/Polygon_mesh), so the renderer would not be able to draw them on the screen.
```ts
ECS.setComponent(entity, PrimitiveGeometryComponent, { geometryType: 1 })
```
> The `1` here means that we are creating a [`SphereGeometry`](https://github.com/EtherealEngine/etherealengine/blob/dev/packages/engine/src/scene/constants/GeometryTypeEnum.ts#L28) object.
> We will create the component using a more readable name in the next section of the tutorial.

205 changes: 205 additions & 0 deletions docs/developer/typescript/01_gettingStarted/02_hello/02_engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
---
sidebar_label: The Engine
---
import { TechnicalNote } from '@site/src/components/TechnicalNote';
import { UnstyledDetails } from '@site/src/components/UnstyledDetails';

# Working with Ethereal Engine
You will need three very important steps for creating a project with Ethereal Engine:
1. Installing Ethereal Engine
2. Installing (or creating) a project
3. Modify and run the source code of your project

We already solved #1 and #2 in the [Quickstart](../quickstart) guide.
Lets do a quick review of how #1 and #2 work, and we will start programming with the engine right after.

## Requirements and Dependencies
We will use `git` and `npm` a lot throughout the guides on this website.

Whether you followed the Quickstart guide for Ubuntu, or installed the engine with the Manual instructions, you will have both `git` and `npm` already installed.

You don't need to understand either of them to get started. This guide will teach you what to do every time they are needed.
Just remember that they are used a lot to work with the engine locally.

## Installing and running Ethereal Engine
Ethereal Engine is a web application.
Just like any other web application, it needs to be run in a server. And that server will provide access to the engine remotely to anyone with access to its address.

We will eventually learn how to work with "deployed" versions of the engine.
But we need to follow this tutorial in a `local development server` instead.

That's exactly what the Quickstart installation guide automated for us.
As the `localhost` part of the URL indicates, we are running a `local` version of the engine.

## Installing and running projects
Ethereal Engine can be **extended** with projects.
They are equivalent to the concept of "projects" in other engines, except they are modular like npm packages _(they are npm packages too)_.

The engine scans for projects mounted in the `/packages/projects/projects` sub-folder.
This means that we can install and run new projects by executing the following commands inside our Ethereal Engine installation folder:
```bash
git clone https://github.com/EtherealEngine/ee-tutorial-hello packages/projects/projects/ee-tutorial-hello
npm run dev
```
:::note
You will need to stop the engine and re-run it whenever you install a new project.
:::

<TechnicalNote>
Please note that, in the [Quickstart](../quickstart) guide, we cloned the `Step0` branch from the `ee-tutorial-hello` project specifically, and not the whole project.
We did this by adding `-b Step0` to the `git clone` command:

```bash
git clone -b Step0 https://github.com/EtherealEngine/ee-tutorial-hello packages/projects/projects/ee-tutorial-hello
```

This step won't be needed for your own projects.
</TechnicalNote>

These steps will:
- Download a copy of the project's git repository, so the engine can load it
- Install all `npm` packages required by the project
- Run a local development version of the engine

:::note
This is also the process recommended for installation of your own projects.
The difference will be that, instead of starting your project from the minimal HelloWorld example like we are doing now, you will start from a pre-made template.
:::

:::important
Each project's source code is executed globally.
This will become very important later on in this guide.
:::


## Programming with Ethereal Engine
There are two very important steps to take in order to connect the source code of our project to the engine:
- We need to import some Ethereal Engine's modules
- We need to export our code so the engine can run it

### Project Configuration File
Every project has an `xrengine.config.ts` file that defines how it will behave in the engine.
There are multiple options available, but the important thing to remember is that our `src/Hello.ts` code will be connected to the engine from here.

<TechnicalNote title="Config File">

```ts title="ee-tutorial-hello/xrengine.config.ts"
import type { ProjectConfigInterface } from '@etherealengine/projects/ProjectConfigInterface'

const config: ProjectConfigInterface = {
onEvent: undefined,
thumbnail: '/static/etherealengine_thumbnail.jpg',
routes: {},
services: undefined,
databaseSeed: undefined,
// highlight-start
worldInjection: () => import('./src/Hello') // Import our Hello World code
// highlight-end
}

export default config
```
</TechnicalNote>

We don't need to know much more about this file for now. We will explore it further in the `Beyond the Basics` guide.

### Module Imports
In this minimal tutorial we are adding a sphere primitive to the scene.
As this sphere will be a `Spatial` object, we will import a few components from the Spatial engine module:

```ts title="ee-tutorial-hello/src/Hello.ts"
import { NameComponent } from '@etherealengine/spatial/src/common/NameComponent'
import { VisibleComponent } from '@etherealengine/spatial/src/renderer/components/VisibleComponent'
import { TransformComponent } from '@etherealengine/spatial/src/transform/components/TransformComponent'
import { PrimitiveGeometryComponent } from '@etherealengine/engine/src/scene/components/PrimitiveGeometryComponent'
```
We will be adding these Components to our Entity, and Components are part of the ECS pattern.
As such, we will need to use the Ethereal Engine ECS management functions.
The engine provides a convenient way to import all ECS related functions at once through the `ECS` [namespace](https://www.typescriptlang.org/docs/handbook/namespaces.html).
```ts title="ee-tutorial-hello/src/Hello.ts"
import { ECS } from '@etherealengine/ecs'
```

## Modifying our Source Code
We have learned how our minimal example works, but so far we haven't needed to modify any of its source code.
This will be our first modification to the code of the project.

:::important
This guide uses [`Project-based Learning`](https://en.wikipedia.org/wiki/Project-based_learning) as its core teaching philosophy.
From now on, you will be actively modifying the source code of the `ee-tutorial-hello` in every step of the way.
:::

Lets start with a simple change.
We will modify our Sphere `PrimitiveGeometryComponent` to load our geometry with a name, instead of the hardcoded number `1` that we used before.

In order to do this, we need to:
- Open the file `ee-tutorial-hello/src/Hello.ts` with a text editor.
- Import the `GeometryTypeEnum` from the `scene/constants/` sub-module inside the `engine` module.
- Replace the `1` with a call to the `SphereGeometry` name that is stored inside it `GeometryTypeEnum`.

Try to figure out the changes by yourself before looking at the solution.
I don't expect you to know where that enum is stored, so here are some hints to make it easier:
```ts
// The full path to the GeometryTypeEnum is:
'@etherealengine/engine/src/scene/constants/GeometryTypeEnum'

// Getting the ID number of a Sphere by its enum name will look like:
GeometryTypeEnum.SphereGeometry

// To be certain that your changes are working, set the geometry to be a cylinder instead:
GeometryTypeEnum.CylinderGeometry
```
> As we said before, you will need to stop the engine and re-run it whenever you _install_ a new project.
> But you can just refresh the webpage when you update your source code and the engine will load your changes correctly.

:::note
`VSCode` is the recommended editor for programming with Ethereal Engine.
It is not required, but it is highly recommended.
VSCode has support for some important features and plugins that make the Ethereal Engine programming workflow really smooth and featureful.
:::

<TechnicalNote title="Solution">

The imports section of our code will now be:
```ts title="ee-tutorial-hello/src/Hello.ts"
// ... our other imports
import { PrimitiveGeometryComponent } from '@etherealengine/engine/src/scene/components/PrimitiveGeometryComponent'
import { Vector3 } from 'three'
// highlight-start
import { GeometryTypeEnum } from '@etherealengine/engine/src/scene/constants/GeometryTypeEnum'
// highlight-end
```
The `PrimitiveGeometryComponent` call will now be:
```ts title="ee-tutorial-hello/src/Hello.ts"
const entity = ECS.createEntity()
// ... our other calls to setComponent
// highlight-start
ECS.setComponent(entity, PrimitiveGeometryComponent, { geometryType: GeometryTypeEnum.SphereGeometry })
// highlight-end
```

<UnstyledDetails title="Full Solution">

```ts title="ee-tutorial-hello/src/Hello.ts" showLineNumbers
import { ECS } from '@etherealengine/ecs'
import { NameComponent } from '@etherealengine/spatial/src/common/NameComponent'
import { VisibleComponent } from '@etherealengine/spatial/src/renderer/components/VisibleComponent'
import { TransformComponent } from '@etherealengine/spatial/src/transform/components/TransformComponent'
import { PrimitiveGeometryComponent } from '@etherealengine/engine/src/scene/components/PrimitiveGeometryComponent'
// highlight-start
import { GeometryTypeEnum } from '@etherealengine/engine/src/scene/constants/GeometryTypeEnum'
// highlight-end

const entity = ECS.createEntity()
ECS.setComponent(entity, NameComponent, 'hello-world')
ECS.setComponent(entity, VisibleComponent)
ECS.setComponent(entity, TransformComponent, { position: new Vector3(0, 1, 0) })
// highlight-start
ECS.setComponent(entity, PrimitiveGeometryComponent, { geometryType: GeometryTypeEnum.SphereGeometry })
// highlight-end
```
</UnstyledDetails>
<!-- Full Solution End -->
</TechnicalNote>
<!-- Solution End -->

Loading
Loading