Take the 2-minute tour ×

I need to identify the overlapping region of two geometries in a canvas and show the overlapping region with different color/texture.

sample code: http://jsfiddle.net/v4B3d/1/

var camera, scene, renderer, geometry, material, mesh,mesh2;

init(); animate();

function init() {

scene = new THREE.Scene();

camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 500;

geometry = new THREE.CubeGeometry(100, 100, 100);
material = new THREE.MeshNormalMaterial();

mesh = new THREE.Mesh(geometry, material);
mesh2 = new THREE.Mesh(geometry, material);
mesh.position.y = -30;
mesh2.position.y = 40;

renderer = new THREE.CanvasRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);



function animate() {



function render() {

mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
mesh2.rotation.x += 0.01;
mesh2.rotation.y += 0.02;

renderer.render(scene, camera);


Please let me know how to achieve this.

Thanks in advance.

share|improve this question

1 Answer 1

You probably want to make a third geometry from the overlapping region. You can then render that however you want.

This can be achieved using Constructive Solid Geometry (CSG) boolean operations (namely, intersection). If you only want to render the overlapping part, you can render only the intersection result.

There is a Three.js wrapper for CSG.js library, that should make it easy. See http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometry-with-csg-js/ , http://www.chandlerprall.com/2011/12/constructive-solid-geometry-with-three-js/ and http://en.wikipedia.org/wiki/Constructive_solid_geometry for more information.

share|improve this answer

Your Answer


