Skip to content

Commit

Permalink
filter elemetns by name equals to column
Browse files Browse the repository at this point in the history
  • Loading branch information
juanse1904 committed May 27, 2023
1 parent ecad59b commit d348386
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ const ColumnGroup = () => {
function hoverPointer() {
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(scene.children);

for (let i = 0; i < intersects.length; i += 1) {
const intObject = intersects[i].object as any;
intObject.material.color?.set(COLORS.NOTICE_SOFT_yellow);
if (intObject.name === 'column') {
intObject.material.color?.set(COLORS.NOTICE_SOFT_yellow);
}
}
}

Expand All @@ -52,6 +53,7 @@ const ColumnGroup = () => {
const myCoordy = event.clientY - clientRects.y;
mouse.x = (myCoordx / clientRects.width) * 2 - 1;
mouse.y = -(myCoordy / clientRects.height) * 2 + 1;
hoverPointer();
return null;
}

Expand Down Expand Up @@ -173,14 +175,13 @@ const ColumnGroup = () => {
const columnGroup = ColumnsGroup({ columns });
scene.add(columnGroup);

window.addEventListener('mousemove', onPointerMove, false);
window.addEventListener('click', onPointerMove, false);
function animate() {
requestAnimationFrame(animate);
controls.update();
// cssControls.update();
// cssRenderer.render(scene, camera);
renderer.render(scene, camera);
hoverPointer();
}
animate();
}, []);
Expand Down
1 change: 1 addition & 0 deletions src/renderer/three/components/column/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Column = ({ width, height, coorX, coorY, color }: ColumnOptions) => {
const geometry = new BoxGeometry(width, height, 0);
const material = new MeshBasicMaterial({ color });
const square = new Mesh(geometry, material);
square.name = 'column';
square.position.set(coorX, coorY, 0);

return square;
Expand Down

0 comments on commit d348386

Please sign in to comment.