Skip to content

Migrated Github Globe code to use tresjs#264

Open
rahul-vashishtha wants to merge 2 commits intomainfrom
github-globe-migration-to-tresjs
Open

Migrated Github Globe code to use tresjs#264
rahul-vashishtha wants to merge 2 commits intomainfrom
github-globe-migration-to-tresjs

Conversation

@rahul-vashishtha
Copy link
Copy Markdown
Member

@rahul-vashishtha rahul-vashishtha commented Dec 29, 2025

This PR contains the migration of Github Globe to Tresjs.
This is the first step in improving the Inspira UI threejs DX and integrating it tightly with Vue ecosystem.

Looking forward for the review from the community.

@rahul-vashishtha
Copy link
Copy Markdown
Member Author

Hi @alvarosabu,
I'd love to have your feedback on how can I improve this implementation. I believe that this implementation has a lot of scope of improvement.

:class="[props.class]"
>
<TresCanvas
class="h-full w-full"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rahul-vashishtha the TresCanvas should take the container width and height automatically, I believe you do not need to add this classes.

Copy link
Copy Markdown

@alvarosabu alvarosabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rahul-vashishtha I added some best practices comments that would make your life ways easier when implementing Tres.

Let me know if you have any questions

});

const handleCanvasReady = (context: TresContext) => {
tresContext.value = context;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rahul-vashishtha Although is technically possible to access the context this way, we recommend splitting complex scenes which require access to the context this way:

  • Parent -> ui/github-globe/index.vue
<TresCanvas>
  <GithubGloveExperience />
</TresCanvas>
  • Children-> ui/github-globe/Experience.vue
<script setup lang="ts">
const { camera } = useTres() 

console.log(camera) // useTres returns the active camera
</script>
.... 

https://docs.tresjs.org/api/composables/use-tres#usage

This way the children have complete access to the composables like useLoop, useTres and all the ones depending to the context

if (!activeCamera) return;

const instance = context.renderer.instance;
const orbitControls = new OrbitControls(activeCamera, instance.domElement);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use <OrbitControls /> from the cientos package https://cientos.tresjs.org/guide/controls/orbit-controls.html#orbitcontrols

lat: arc.endLat,
lng: arc.endLng,
});
function setupLoop(context: TresContext) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the comment above about the parent child approach, that way you can avoid all this setup and just use useLoop directly on the children.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants