"ALWAYS use when writing code importing \"@tresjs/core\". Consult for debugging, best practices, or modifying @tresjs/core, tresjs/core, tresjs core, tres."
Install
npx skillscat add harlan-zw/vue-ecosystem-skills/tresjs-core-skilld Install via the SkillsCat registry.
Tresjs/tres @tresjs/core
Version: 5.5.0 (Feb 2026)
Deps: @pmndrs/pointer-events@^6.6.17, @vue/devtools-api@^7.7.2, @vueuse/core@^13.9.0, radashi@^12.6.2
Tags: beta: 2.0.0-beta.13 (Apr 2023), next: 5.0.0-next.6 (Jun 2025), alpha: 5.0.0-alpha.2 (Sep 2025), rc: 5.0.0-rc.0 (Sep 2025), latest: 5.5.0 (Feb 2026)
References: Docs — API reference, guides • GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
API Changes
This section documents version-specific API changes — prioritize recent major/minor releases.
BREAKING:
useLoader— returns reactive state{ state, isLoading, error, progress }since v5, no longer returns a Promise sourceBREAKING: Pointer Events — renamed to native DOM names (e.g.,
@pointerdowninstead of@pointer-down) in v5 sourceBREAKING:
useTexture— removed from core in v5, moved to@tresjs/cientospackage sourceBREAKING: ESM-only — TresJS v5 is ESM-only; UMD build and CommonJS
require()are no longer supported sourceBREAKING:
TresCanvasProps — WebGL context props likealpha,antialias,stencil, anddepthare now readonly and non-reactive in v5 sourceBREAKING:
useTresContext().camera— returns a state object in v5; useuseTres().camerafor the active camera instance sourceBREAKING: Renderer Context —
rendereris now readonly inuseTresContext();performancestate was removed from context in v5 sourceBREAKING: Event Bubbling — only the first intersected element triggers pointer events since v5 to align with standard behavior source
NEW:
ContextComponent — exported in v5.5.0 (asTresCanvasContext) for advanced scene and state management sourceNEW: Kebab-case Support — support for components written in kebab-case (e.g.,
<tres-mesh>) added in v5.1.0 sourceNEW:
primitivePrefix — addedprefixoption for primitives in v5.3.0 to avoid name collisions sourceNEW:
TresCanvasProps/TresCanvasEmits— explicitly exported types added in v5.2.0 for better TypeScript integration sourceREMOVED: Legacy Composables —
useRenderLoop,useCamera,useTresReady,useSeek,useRaycaster, anduseLoggerremoved in v5 sourceNEW:
useForwardPropsEmits— integrated intoTresCanvasin v5.3.0 for streamlined event and prop handling source
Also changed: useLoop replaces useRenderLoop · useGraph replaces useSeek · @ready event replaces useTresReady · useTres() replaces common useTresContext() usage · TresCanvas supports useLegacyLights prop (deprecated) · useLoader supports extensions and reactive paths.
Best Practices
- Use
shallowRefwith template refs to access Three.js instances directly in high-frequency render loops. This avoids Vue's deep proxy overhead, which can be significantly slower than direct property access source
<script setup lang="ts">
const meshRef = shallowRef<TresInstance | null>(null)
const { onBeforeRender } = useLoop()
onBeforeRender(({ elapsed }) => {
if (meshRef.value) meshRef.value.rotation.y = elapsed
})
</script>
<template>
<TresMesh ref="meshRef" />
</template>Prefer
shallowRefandshallowReactiveoverreforreactivefor Three.js objects. This maintains reactivity for the reference itself while preventing expensive deep tracking of complex internal Three.js properties sourceSet
renderMode="on-demand"on<TresCanvas>for non-game applications to reduce CPU/GPU usage. The scene will only re-render when props change or when manual invalidation is explicitly triggered sourceManually trigger a render using
invalidate()fromuseLooporuseTreswhen modifying instances via template refs or direct mutations inon-demandmode, as these changes are invisible to Vue's reactivity system sourceEnsure animations are frame-rate independent by using the
deltaparameter inuseLoopcallbacks. This guarantees consistent movement speed across different display refresh rates (e.g., 60Hz vs 144Hz) source
onBeforeRender(({ delta }) => {
// Moves 2 units per second regardless of frame rate
mesh.position.x += delta * 2
})Use the
argsprop for values required at Three.js instantiation (like geometry dimensions). Note that changing these reactive values at runtime forces TresJS to recreate the entire instance, which is performance-heavy sourceTake complete control of the render process using
renderfromuseLoopfor custom post-processing or multi-pass setups. You must callnotifySuccess()at the end of the function to maintain the loop state sourceOrchestrate complex update sequences using the
priorityargument inonBeforeRender(default 0). Higher priority numbers ensure a callback runs after those with lower priorities within the same frame sourceExplicitly call
dispose()from@tresjs/corefor Three.js objects created programmatically and used via<primitive />. TresJS automatically disposes of template-defined components but cannot track lifecycle for raw objects sourceUse
useGraphto generate a reactive map of named meshes, materials, and nodes from a complex hierarchy (like a loaded GLTF). This enables direct, named access without manually traversing the object tree source