Incorrect lighting on translated object
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.2k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Description
A lighting bug was introduced recently. Models that used to render correctly started showing "double lighting" across parallel surfaces.
Expected Behavior
Consistent global lighting as shown here in @jscad/web@2.4.3 and before:

Actual Behavior
A double reflection of the light source on the translated cylinder on @jscad/web@2.4.4 and after:

Steps to Reproduce the Problem
const jscad = require("@jscad/modeling")
const { cylinder } = jscad.primitives
const { rotateY, translate } = jscad.transforms
function main() {
const radius = 20
const height = 80
const segments = 80
return [
rotateY(Math.PI / 2, cylinder({radius, height, segments})),
rotateY(Math.PI / 2, cylinder({radius, height, segments, center: [0, 0, 82]})), // good lighting
translate([-82, 0, 0], rotateY(Math.PI / 2, cylinder({radius, height, segments}))), // bad lighting
]
}
module.exports = { main }
The problem only appears on the translated cylinder, not the re-centered cylinder. Also worth noting that these are all independently constructed objects, so this does not appear to be a caching, or copying bug.
Specifications
- Version: @jscad/web 2.4.4...2.5.3 (current)
- Platform: web
- Environment: browser
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the JavaScript reproduction in the issue with @jscad/modeling and compare the translated cylinder with the re-centered cylinder in the browser. Trace the rendering path responsible for lighting and verify that translated objects show consistent global lighting like @jscad/web 2.4.3 and earlier.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100