TresJS, a declarative way of creating 3D scenes from Vue components

Rate this content
Bookmark

Meet TresJS ▲ ■ ●, a declarative way of bringing the magic of ThreeJS using everyday Vue Components and composables. Think of it as React-three-fiber or Lunchbox but without the need of a custom renderer. It just works.

Are you ready to add a new dimension to your Vue Apps?

FAQ

Alvaro Saborido is originally from Venezuela and currently serves as a Dev Rel Engineer at StudyBlock. He is based in Barcelona, Spain, and actively creates content on Alvaro.Dev labs.

Troy.js is a custom renderer that allows the creation of 3GS scenes using Vue components and composites. Key features include up-to-date compatibility with the latest 3GS, lightweight design, TypeScript support, and optimized performance for web applications.

Developers can begin using Troy.js by adding it to their project with the command 'pnpm add 3GS core'. As a pure dependency, they also need to install the '3' package separately, ensuring it's not part of the initial bundle.

Alvaro was motivated by the need to create a 3D ecosystem specifically for the Vue community, enabling the creation of 3GS scenes within Vue applications without the complexities typically associated with 3D development.

Yes, Troy.js can be used with older versions of Three.js provided that these versions are manually installed. However, it is designed to work seamlessly with the latest version of Three.js by default.

Troy.js can be used for product customization interfaces, such as allowing users to customize colors and materials of products like shoes or cars. It also supports immersive, interactive 3D experiences for storytelling and brand engagement in web applications.

Alvaro Saburido
Alvaro Saburido
27 min
12 May, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The speaker discovered 3D with 3GS and was inspired to create a 3D ecosystem for the Vue community using Troy.js. The process of setting up a 3D scene and objects in Tress was explained, along with creating and configuring 3D objects. The talk also covered animating objects with Tress and the 'Cientos' package, as well as the future of Tress.js and its compatibility with older versions of Three. The speaker expressed gratitude to sponsors and contributors and highlighted the potential for product customization with Tress.js.

1. Introduction to 3D with WebGL and View Components

Short description:

Hello, London. How's it going? I'm from Venezuela, so my Venezuelan accent will arise. I create a lot of content in Alvaro.Dev labs. I really wanted to learn how to create video games. I ended up being a telecommunications engineer and then being a front end development where I'm here right now, I'm super happy. But I left like 3D on the side, okay, I thought it was for people that were truly brilliant in genesis, like how they do that stuff, until I discovered 3GS, okay?

Hello, London. How's it going? So first of all, I will apologize by my really bad English. Unfortunately, I don't have a charming accent as Daniel Rowe or British accent, so sorry for murdering your language. I will try my best.

Okay, I'm from Venezuela, so my Venezuelan accent will arise. So how many of you have done 3D with WebGL or...okay. More than I expected, so what if I told you that this scene right here that is kind of a potion wizardy scene is entirely done with View Components and Composers? Okay.

So in the beginning, the name of my presentation today was going to be Trace.Yes a declarative way of doing 3D with Web Components. But I have been playing Whole World Legacy like crazy the last year and I thought to myself, well, let's change it. Okay. Boring naming, let's change that. And I come up, well, no, Chad GPT come up with this. Trace.Yes and the Chamber of View unlocking the mysteries of 3D rendering. So with that, I present myself. My name is Alvaro Saborido. I'm a dev rel engineer at StudyBlock. I'm from Barcelona, Spain, but originally from Venezuela. I create a lot of content in Alvaro.Dev labs. Some links if you want to follow, say hi, always welcome. Okay.

Yeah, that's actually me. I don't know what happened. But that's the boy who lives playing video games, because yeah, I was a kid that loved to play video games. And to be honest, that kid never grew up. This is me playing with my cat, Geralt. So what was my motivation when I was a kid? I really wanted to learn how to create video games. Okay, I was fascinated by that golden era of PS1 games like Crash Bandicoot, Spider the Dragon, and who will forget that good game of Hogwarts like Harry Potter with those amazing graphics. Look at that. HD right away, right?

So something to point here, I wanted to study that, but it was really expensive in Minnesota to be a game developer, so I ended up being a telecommunications engineer and then being a front end development where I'm here right now, I'm super happy. But I left like 3D on the side, okay, I thought it was for people that were truly brilliant in genesis, like how they do that stuff, until I discovered 3GS, okay? So 3GS is a library that leverages the WebGL part, okay, the difficult part, and make it available for JavaScript developers to code and make their scenes.

2. Introduction to Troy.js and its Benefits

Short description:

I found an amazing course by Bruno Simon that taught me how to create my own scenes in 3D. Then I discovered React 3Fiber, a library that allows you to create scenes with React components. But since I prefer Vue, I looked for a similar solution and found Troy.js, a custom render that allows you to create 3GS declaratively using Vue components. Troy.js is lightweight, up-to-date, and provides a great developer experience with TypeScript support. It's performant and works well with reactivity thanks to bit.

And I found out this amazing course by Bruno Simon, it's the one in the picture, to learn to do it. And six months after that I was learning, and I was able to create my own scenes.

Then I discovered React 3Fiber, and wait, before you say why you're talking about React in a Vue conference, right? I know. But React 3Fiber is an amazing library made by PoeMandress, which is an amazing studio, and they made something that blew my mind. They were basically able to create a scene with their React components. So instead of using plain JavaScript, they were able to use that. But there is a catch here, is that I will never use React. No, I'm joking. I use React but I prefer Vue, okay? Never!

So I was trying to find something that would work for Vue, okay? So I came up with this amazing library, Yes, this is probably the one you know because it was the first one to try to do a wrapper. So it was a manual wrapper that tried to replicate all the different components. And then I found Lunchbox, that is the other one, that is a custom render. And stay with that phrase, custom render, okay? But the thing was that Troy.js was really difficult to maintain. Because it was a manual wrapper and to be honest, 3GS is always a old, every week there is a new version. It's really difficult to keep up with the changes. So that's how Troy.js was born.

Okay, so what is Troy.js? It's basically a custom render that allows you to create the 3GS declaratively by using your favorite framework. Using view components and composites. The word is the Spanish word for tree. So it's 3GS. And it's based on the 3GS library and as well because the French war was already taken. So I came up with that. Why Troy.js? Look, why not using another one? I wanted to create something that was up to date with the latest 3GS with fewer to non-maintainers because also maintain a library like this is really time-consuming and a lot of effort, right? It's lightweight that you could install it and the performance of your web application or page is not affected. That was verbose and easy to use. That's really important for the developer experience. Of course, developer experience focus. We needed something that was enjoyable to do 3D. TypeScript support. Everyone that has worked with 3GS knows what I'm talking about. And that could be performant even with reactivity because 3GS is powered with bit. So bit makes it possible that all goes well.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Everything Beyond State Management in Stores with Pinia
Vue.js London Live 2021Vue.js London Live 2021
34 min
Everything Beyond State Management in Stores with Pinia
Top Content
When we think about Vuex, Pinia, or stores in general we often think about state management and the Flux patterns but not only do stores not always follow the Flux pattern, there is so much more about stores that make them worth using! Plugins, Devtools, server-side rendering, TypeScript integrations... Let's dive into everything beyond state management with Pinia with practical examples about plugins and Devtools to get the most out of your stores.
Welcome to Nuxt 3
Vue.js London Live 2021Vue.js London Live 2021
29 min
Welcome to Nuxt 3
Top Content
Explain about NuxtJS codebase refactor and challenges facing to implement Vue 3, Vite and other packages.
One Year Into Vue 3
Vue.js London Live 2021Vue.js London Live 2021
20 min
One Year Into Vue 3
Top Content
Vue 3 may still sound new to many users, but it's actually been released for over a year already. How did Vue 3 evolve during this period? Why did it take so long for the ecosystem to catch up? What did we learn from this process? What's coming next? We will discuss these questions in this talk!
Utilising Rust from Vue with WebAssembly
Vue.js London Live 2021Vue.js London Live 2021
8 min
Utilising Rust from Vue with WebAssembly
Top Content
Rust is a new language for writing high-performance code, that can be compiled to WebAssembly, and run within the browser. In this talk you will be taken through how you can integrate Rust, within a Vue application, in a way that's painless and easy. With examples on how to interact with Rust from JavaScript, and some of the gotchas to be aware of.
Vue: Feature Updates
Vue.js London 2023Vue.js London 2023
44 min
Vue: Feature Updates
Top Content
The creator of Vue js gives an update on the new features of the technology.
Local State and Server Cache: Finding a Balance
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
How many times did you implement the same flow in your application: check, if data is already fetched from the server, if yes - render the data, if not - fetch this data and then render it? I think I've done it more than ten times myself and I've seen the question about this flow more than fifty times. Unfortunately, our go-to state management library, Vuex, doesn't provide any solution for this.For GraphQL-based application, there was an alternative to use Apollo client that provided tools for working with the cache. But what if you use REST? Luckily, now we have a Vue alternative to a react-query library that provides a nice solution for working with server cache. In this talk, I will explain the distinction between local application state and local server cache and do some live coding to show how to work with the latter.

Workshops on related topic

Vue3: Modern Frontend App Development
Vue.js London Live 2021Vue.js London Live 2021
169 min
Vue3: Modern Frontend App Development
Top Content
Featured WorkshopFree
Mikhail Kuznetcov
Mikhail Kuznetcov
The Vue3 has been released in mid-2020. Besides many improvements and optimizations, the main feature of Vue3 brings is the Composition API – a new way to write and reuse reactive code. Let's learn more about how to use Composition API efficiently.

Besides core Vue3 features we'll explain examples of how to use popular libraries with Vue3.

Table of contents:
- Introduction to Vue3
- Composition API
- Core libraries
- Vue3 ecosystem

Prerequisites:
IDE of choice (Inellij or VSC) installed
Nodejs + NPM
How to make amazing generative art with simple JavaScript code
JS GameDev Summit 2022JS GameDev Summit 2022
165 min
How to make amazing generative art with simple JavaScript code
Top Content
WorkshopFree
Frank Force
Frank Force
Instead of manually drawing each image like traditional art, generative artists write programs that are capable of producing a variety of results. In this workshop you will learn how to create incredible generative art using only a web browser and text editor. Starting with basic concepts and building towards advanced theory, we will cover everything you need to know.
Using Nitro – Building an App with the Latest Nuxt Rendering Engine
Vue.js London Live 2021Vue.js London Live 2021
117 min
Using Nitro – Building an App with the Latest Nuxt Rendering Engine
Top Content
Workshop
Daniel Roe
Daniel Roe
We'll build a Nuxt project together from scratch using Nitro, the new Nuxt rendering engine, and Nuxt Bridge. We'll explore some of the ways that you can use and deploy Nitro, whilst building a application together with some of the real-world constraints you'd face when deploying an app for your enterprise. Along the way, fire your questions at me and I'll do my best to answer them.
Going on an adventure with Nuxt 3, Motion UI and Azure
JSNation 2022JSNation 2022
141 min
Going on an adventure with Nuxt 3, Motion UI and Azure
WorkshopFree
Melanie de Leeuw
Melanie de Leeuw
We love easily created and deployed web applications! So, let’s see what a very current tech stack like Nuxt 3, Motion UI and Azure Static Web Apps can do for us. It could very well be a golden trio in modern day web development. Or it could be a fire pit of bugs and errors. Either way it will be a learning adventure for us all. Nuxt 3 has been released just a few months ago, and we cannot wait any longer to explore its new features like its acceptance of Vue 3 and the Nitro Engine. We add a bit of pizzazz to our application with the Sass library Motion UI, because static design is out, and animations are in again.Our driving power of the stack will be Azure. Azure static web apps are new, close to production and a nifty and quick way for developers to deploy their websites. So of course, we must try this out.With some sprinkled Azure Functions on top, we will explore what web development in 2022 can do.
TresJS create 3D experiences declaratively with Vue Components
Vue.js London 2023Vue.js London 2023
137 min
TresJS create 3D experiences declaratively with Vue Components
Workshop
Alvaro Saburido
Alvaro Saburido
- Intro 3D - Intro WebGL- ThreeJS- Why TresJS- Installation or Stackblitz setup - Core Basics- Setting up the Canvas- Scene- Camera- Adding an object- Geometries- Arguments- Props- Slots- The Loop- UseRenderLoop composable- Before and After rendering callbacks- Basic Animations- Materials- Basic Material- Normal Material- Toon Material- Lambert Material- Standard and Physical Material- Metalness, roughness - Lights- AmbientLight- DirectionalLight- PointLights- Shadows- Textures- Loading textures with useTextures- Tips and tricks- Misc- Orbit Controls- Loading models with Cientos- Debugging your scene- Performance
Building Vue forms with VeeValidate
Vue.js London Live 2021Vue.js London Live 2021
176 min
Building Vue forms with VeeValidate
Workshop
Abdelrahman Awad
Abdelrahman Awad
In this workshop, you will learn how to use vee-validate to handle form validation, manage form values and handle submissions effectively. We will start from the basics with a simple login form all the way to using the composition API and building repeatable and multistep forms.

Table of contents:
- Introduction to vee-validate
- Building a basic form with vee-validate components
- Handling validation and form submissions
- Building validatable input components with the composition API
- Field Arrays and repeatable inputs
- Building a multistep form
Prerequisites:
VSCode setup and an empty Vite + Vue project.