While attempting to configure the raycaster layer to only cast on a single layer, as outlined in the threejs documentation: - I encountered the following error
Uncaught TypeError: Cannot read properties of undefined (reading 'set')
What could be causing this issue? It appears to be a straightforward task
var scene = new THREE.Scene(); // Creating the scene
// Configuring Camera
var camera = new THREE.PerspectiveCamera(
90, // Field of View (FOV)
window.innerWidth / window.innerHeight, // Aspect Ratio
0.1, // Inner Plane
1000, // Far Plane
);
// Configuring renderer
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setClearColor("#e5e5e5");
renderer.setSize(window.innerWidth, window.innerHeight);
// Configuring camera controls
var controls = new OrbitControls( camera, renderer.domElement );
camera.position.set( 5, 0, 3 );
camera.layers.enable(1);
controls.minDistance = 5;
controls.maxDistance = 50;
controls.maxPolarAngle = 1.5;
controls.enablePan = false; // Disables right mouse drag movement
controls.update();
document.body.appendChild(renderer.domElement); // Attaching the renderer to the body
window.addEventListener('resize', () => { // Dynamically adjusting canvas size to window
renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
})
var raycaster = new THREE.Raycaster();
raycaster.layers.set(0);