Skip to content
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

Uncaught RangeError: Maximum call stack size exceeded when using normalNode with only scene environment #30255

Closed
gnansai opened this issue Jan 3, 2025 · 1 comment · Fixed by #30277
Milestone

Comments

@gnansai
Copy link

gnansai commented Jan 3, 2025

Description

I get Uncaught RangeError: Maximum call stack size exceeded when assigning NomralMap texture to material using material.normalNode.
This error occurs when I light the scene using only scene.environment.
The error does not occur when I add a directional light in the scene scene.add( new THREE.DirectionalLight( 0xffffff, 0 ) );

Reproduction steps

1.Create mesh with geometry and a MeshStandardNodeMaterial
2.Assign a normal map to MeshStandardNodeMaterial using material.normalNode = normalMap(texture(tex))
3.Add a hdri to scene using scene.background = texture;

Code

const rgbeLoader = new RGBELoader();
 		rgbeLoader.load(
        'https://cdn.jsdelivr.net/gh/mrdoob/three.js@r171/examples/textures/equirectangular/royal_esplanade_1k.hdr', // Replace with your HDR URL
        (texture) => {
            texture.mapping = THREE.EquirectangularReflectionMapping;
            scene.background = texture;
           	scene.environment = texture;
        }
    );
    
    // geometry
    const geometry = new THREE.BoxGeometry( 5, 5, 5);
    
    // material
    const material = new THREE.MeshStandardNodeMaterial( {
    
    } );
    
    let tex = new THREE.TextureLoader().load("https://i.postimg.cc/Fz4NsfDg/Bricks097-1-K-JPG-Normal-GL-result.jpg")
    material.normalNode = normalMap(texture(tex));
    // mesh
    mesh = new THREE.Mesh( geometry, material );
    scene.add( mesh );

Live example

Screenshots

image

Version

r172

Device

Desktop

Browser

Chrome

OS

Windows

@gnansai gnansai changed the title Uncaught RangeError: Maximum call stack size exceeded when using normalNode with only scene background Uncaught RangeError: Maximum call stack size exceeded when using normalNode with only scene environment Jan 3, 2025
@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 3, 2025

This also happens in the more general case when using envNode and normalMapNode at the same time: https://jsfiddle.net/23mdztra/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants