Skip to content

add texture support for Box component#649

Open
anzal787 wants to merge 2 commits intotscircuit:mainfrom
anzal787:3d-viewer
Open

add texture support for Box component#649
anzal787 wants to merge 2 commits intotscircuit:mainfrom
anzal787:3d-viewer

Conversation

@anzal787
Copy link

closes #534

This PR implements texture support for the Box component as requested in issue tscircuit#534.
@vercel
Copy link

vercel bot commented Jan 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
3d-viewer Error Error Jan 13, 2026 5:35am

(boardOutlineBounds.maxY - pcbY) * traceTextureResolution
export const Box = ({ width, height, depth, textureUrl }: Props) => {
// UseLoader wuxuu soo rarayaa sawirka PNG-ga ah ee textureUrl laga keenay
const texture = textureUrl ? useLoader(THREE.TextureLoader, textureUrl) : null
Copy link
Contributor

Choose a reason for hiding this comment

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

React hook useLoader is being called conditionally, which violates the Rules of Hooks and will cause runtime errors. Hooks must be called at the top level of the component unconditionally.

Fix:

const texture = useLoader(THREE.TextureLoader, textureUrl || '')

Then conditionally use the texture only if textureUrl is provided:

const actualTexture = textureUrl ? texture : null

Or use a separate component for the texture loading case.

Suggested change
const texture = textureUrl ? useLoader(THREE.TextureLoader, textureUrl) : null
const texture = useLoader(THREE.TextureLoader, textureUrl || '')
const actualTexture = textureUrl ? texture : null

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

@rushabhcodes rushabhcodes left a comment

Choose a reason for hiding this comment

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

Type check is failing,
Format check is failing,
Also you removed already existing texture

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.

Texture Support (PCB should have texture on box)

2 participants