Rogue Engine - Component Basics - In Two Minutes
Components in Rogue Engine enable you to add code to objects in your scene.
The Rogue Engine framework is built on top of the Three.js library. Any object in a Rogue scene can have code attached to it to use the power of Three.js. These bits of code are called components.
Here is a very simple example of a Rogue Engine component.
You can use the default cube for this example.
First right click in the Assets panel and create a new component. Components can be javascript or typescript. We will use typescript. Give it a name and confirm.
That will create a blank component in the asset panel.
If you double click this icon it will open up in your default code editor. If you don't have one installed I would recommend downloading Visual Studio Code from Microsoft.
The blank component already has somethings set up. All components import the Rogue Engine
The component already has its class Export set up and three methods, awake, start and update. For this example we just need the update method.
We are going to rotate the cube in the scene so in the update method that runs each time the screen updates, we can write this.object3d.rotateY and then give it an angle.
This is fine but we don't know how fast the scene is updating so if we want to keep the rotation consistent whatever speed the scene is running, we can ask Rogue how long since the last update and use that value.
We get this delta value by reading RE.Runtime.deltaTime.
So that's our code - save it and go back to the Rogue Editor.
If we run our scene without the component attached to the cube, nothing happens. But if we add the component to the cube by dragging and dropping it and then run the scene, you will see that the cube rotates smoothly.
So that's how you add a basic component to an object in Rogue Engine.
-
2:42:08
vivafrei
9 hours agoThe Trump "Bullet Shot" Controversy! Live with Veteran, Combat Photographer Michael Yon - Viva Frei
93.2K146 -
2:23:13
Jewels Jones Live ®
1 day agoTHE CHOICE 2024 | A Political Rendezvous - Ep. 84
73.3K27 -
14:57
Standpoint with Gabe Groisman
3 days agoEp. 37. Failed Assassination was a Revealed Miracle
81.9K27 -
13:43
Scammer Payback
4 days agoDeleting this Scammer Scumbags personal photos
93.3K71 -
42:39
The Why Files
5 days agoWe Are the Aliens | Life's Interstellar Journey to Earth: Panspermia
117K89 -
1:24:34
Michael Franzese
1 day agoTrump speech, assassination attempt updates, and foreign threats | MF LIVE | Ep. 12
112K132 -
1:53:06
Tactical Advisor
10 hours agoBattleHawk Build Of The Month and Giveaway - Vault Room Live Stream
114K27 -
19:55
My Self Reliance
1 day agoNow What?!
117K31 -
10:03
After Skool
1 month agoWhy Good People Comply With Evil - Daniel Schmachtenberger
210K275 -
15:32
Winston Marshall
2 days agoHollywood’s DEAFENING Silence On Trump's Assassination Attempt
195K293