-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add metallic material rendering to URDF robot #33
Merged
+26
−5
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
e18af74
feat: add metallic material rendering to URDF robot
devin-ai-integration[bot] 17ce882
Merge branch 'staging' into devin/1733943454-add-metallic-materials
codekansas 080716c
fix: restore code comments for robot positioning and joint updates
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,24 @@ const RobotRenderer: React.FC = () => { | |
|
||
const loader = new URDFLoader(); | ||
loader.load(URDF_URL, (robot: THREE.Object3D) => { | ||
const updateMaterials = () => { | ||
robot.traverse((child) => { | ||
if (child instanceof THREE.Mesh) { | ||
const originalColor = | ||
child.material instanceof THREE.Material | ||
? (child.material as THREE.MeshPhysicalMaterial).color | ||
: new THREE.Color(0x808080); | ||
child.material = new THREE.MeshPhysicalMaterial({ | ||
metalness: 0.4, | ||
roughness: 0.5, | ||
color: originalColor, | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
scene.add(robot); | ||
updateMaterials(); | ||
|
||
// Correcting for the robot initial size and position. | ||
robot.rotateY(Math.PI / 2); | ||
|
@@ -109,12 +126,16 @@ const RobotRenderer: React.FC = () => { | |
animate(); | ||
}); | ||
|
||
const light = new THREE.AmbientLight(0x404040); | ||
scene.add(light); | ||
const ambientLight = new THREE.AmbientLight(0xffffff, 0.3); | ||
scene.add(ambientLight); | ||
|
||
const mainLight = new THREE.DirectionalLight(0xffffff, 2.0); | ||
mainLight.position.set(5, 5, 5); | ||
scene.add(mainLight); | ||
|
||
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5); | ||
directionalLight.position.set(1, 1, 1).normalize(); | ||
scene.add(directionalLight); | ||
const fillLight = new THREE.DirectionalLight(0xffffff, 0.8); | ||
fillLight.position.set(-5, 2, -5); | ||
scene.add(fillLight); | ||
Comment on lines
-112
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems unrelated to the pr but is a good change. can we make this into a separare pr, with a screenshot of how it looks? |
||
|
||
camera.position.z = 5; | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need to delete this comment