Skip to content

Conversation

@alvarosabu
Copy link
Member

@alvarosabu alvarosabu commented Dec 23, 2025

Add primitivePrefix option for customizable primitive component names

Summary

Adds a new options prop to <TresCanvas> with a primitivePrefix configuration that allows users to customize the primitive component name.

Changes

  • Core: Added TresCustomRendererOptions interface with primitivePrefix option
  • TresCanvas: New options prop for custom renderer configuration
  • Context: Pass options through to the custom renderer's nodeOps
  • NodeOps: Check for prefixed primitive tag (e.g., myprimitive when prefix is "my")
  • Types: Fixed module augmentation (removed incorrect export keyword in GlobalComponents)
  • Docs: Added documentation to TresCanvas API and Primitives advanced guide
  • Playground: Added example demonstrating the feature with TypeScript support

Usage

<script setup lang="ts">
const options = {
  primitivePrefix: 'my', // Use <myprimitive> instead of <primitive>
}
</script>

<template>
  <TresCanvas :options="options">
    <myprimitive :object="threeObject" />
  </TresCanvas>
</template>

TypeScript Support

Users can extend Vue's global components for full intellisense:

  // types/tres.d.ts
  import type { TresPrimitive } from '@tresjs/core'
  import type { DefineComponent } from 'vue'

  declare module 'vue' {
    interface GlobalComponents {
      myprimitive: DefineComponent<TresPrimitive>
    }
  }

  export {}

Benefits

  • Avoid naming conflicts with other libraries
  • Support custom naming conventions
  • Maintain full TypeScript intellisense support

TRES-186

@alvarosabu alvarosabu requested a review from Tinoooo December 23, 2025 10:26
@alvarosabu alvarosabu added the core Issues related to @tresjs/core label Dec 23, 2025
@netlify
Copy link

netlify bot commented Dec 23, 2025

Deploy Preview for tresjs-docs ready!

Name Link
🔨 Latest commit 6418b5a
🔍 Latest deploy log https://app.netlify.com/projects/tresjs-docs/deploys/6958f7bcefa66c0008b9a0c1
😎 Deploy Preview https://deploy-preview-1262--tresjs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 23, 2025

Deploy Preview for tresjs-lab ready!

Name Link
🔨 Latest commit 6418b5a
🔍 Latest deploy log https://app.netlify.com/projects/tresjs-lab/deploys/6958f7bc8ffa970008a6ef70
😎 Deploy Preview https://deploy-preview-1262--tresjs-lab.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 23, 2025

Deploy Preview for cientos-tresjs ready!

Name Link
🔨 Latest commit 6418b5a
🔍 Latest deploy log https://app.netlify.com/projects/cientos-tresjs/deploys/6958f7bc6eee9000085a298c
😎 Deploy Preview https://deploy-preview-1262--cientos-tresjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@alvarosabu alvarosabu linked an issue Dec 23, 2025 that may be closed by this pull request
4 tasks
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 23, 2025

Open in StackBlitz

@tresjs/cientos

npm i https://pkg.pr.new/@tresjs/cientos@1262

@tresjs/core

npm i https://pkg.pr.new/@tresjs/core@1262

@tresjs/eslint-config

npm i https://pkg.pr.new/@tresjs/eslint-config@1262

@tresjs/leches

npm i https://pkg.pr.new/@tresjs/leches@1262

@tresjs/nuxt

npm i https://pkg.pr.new/@tresjs/nuxt@1262

@tresjs/post-processing

npm i https://pkg.pr.new/@tresjs/post-processing@1262

commit: 6418b5a

Copy link
Member

@Tinoooo Tinoooo left a comment

Choose a reason for hiding this comment

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

I created #1265 to show how I would solve the review threads I created.

@alvarosabu alvarosabu requested a review from Tinoooo January 3, 2026 10:51
@alvarosabu
Copy link
Member Author

@Tinoooo can you help me solve the conflicts with the typescript PR?

@Tinoooo
Copy link
Member

Tinoooo commented Jan 3, 2026

@Tinoooo can you help me solve the conflicts with the typescript PR?

done ✅

@Tinoooo Tinoooo merged commit 7a7e86e into main Jan 3, 2026
9 checks passed
@Tinoooo Tinoooo deleted the bugfix/add-prefix-option-for-primitives branch January 3, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues related to @tresjs/core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a way to add prefix to primitive tags?

3 participants