WebGPU is the next-generation graphics API for the web, designed to provide high-performance 3D graphics and general-purpose computing capabilities directly in web browsers. It offers several advantages over WebGL:
WebGPU is currently supported in:
TresJS supports WebGPU through Three.js's WebGPU renderer. You can enable WebGPU by providing a custom renderer factory to the <TresCanvas> component.
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { WebGPURenderer } from 'three/webgpu'
import type { TresRendererSetupContext } from '@tresjs/core'
// Create WebGPU renderer factory
const createWebGPURenderer = (ctx: TresRendererSetupContext) => {
const renderer = new WebGPURenderer({
canvas: toValue(ctx.canvas),
// WebGPU specific configuration
alpha: true,
antialias: true,
})
return renderer
}
</script>
<template>
<TresCanvas :renderer="createWebGPURenderer">
<TresPerspectiveCamera :position="[3, 3, 3]" />
<TresBoxGeometry :args="[1, 1, 1]" />
<TresMeshBasicMaterial color="hotpink" />
<!-- Your 3D scene here -->
</TresCanvas>
</template>
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { WebGPURenderer } from 'three/webgpu'
import type { ShadowMapType, ToneMapping } from 'three'
import type { TresRendererSetupContext } from '@tresjs/core'
import HologramCube from './HologramCube.vue'
const createWebGPURenderer = (ctx: TresRendererSetupContext) => {
const renderer = new WebGPURenderer({
canvas: toValue(ctx.canvas),
// WebGPU specific configuration
alpha: true,
antialias: true,
})
return renderer
}
</script>
<template>
<TresCanvas :renderer="createWebGPURenderer">
<TresPerspectiveCamera
:position="[3, 3, 3]"
:look-at="[0, 0, 0]"
/>
<Suspense>
<HologramCube />
</Suspense>
</TresCanvas>
</template>
Primitives
Use the primitive component to directly integrate any Three.js object within your Vue application.
Cookbook 🍳🧑🍳
Discover guided recipes to help you get started with the basics of using Tres. Each recipe is designed to help you understand the core concepts of Tres and how to use them in your projects.