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

Basic viewer functionality #63

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/Containers/CadView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import gtag from '../utils/gtag.js';
import SnackBarMessage from '../Components/SnackbarMessage';
import { setupParentLinks } from '../utils/TreeUtils';


const debug = 0;

const useStyles = makeStyles((theme) => ({
Expand Down Expand Up @@ -173,7 +172,6 @@ const CadView = () => {
setShowItemPanel(true);
};


const onModelLoad = (rootElt, viewer) => {
setRootElement(rootElt);
setupParentLinks(rootElt);
Expand Down Expand Up @@ -217,9 +215,31 @@ const CadView = () => {
viewer.IFC.setWasmPath('./static/js/');
viewer.addAxes();
viewer.addGrid();
window.onmousemove = viewer.prepickIfcItem;
window.ondblclick = viewer.addClippingPlane;
window.onkeydown = (event) => viewer.removeClippingPlane();
viewer.clipper.active = true;

const handleKeyDown = (event) => {
//add a plane
if (event.code === 'KeyQ') {
viewer.clipper.createPlane();
}
//delete all planes
if (event.code === 'KeyW') {
viewer.clipper.deletePlane();
}
if (event.code == 'KeyA') {
viewer.IFC.unpickIfcItems();
}
};

// Highlight items when hovering over them
window.onmousemove = viewer.IFC.prePickIfcItem;
window.onkeydown = handleKeyDown;

// Select items
window.ondblclick = async () => {
const item = await viewer.IFC.pickIfcItem(true);
if (item.modelID === undefined || item.id === undefined) return;
};

// Expanded version of viewer.loadIfcUrl('/index.ifc'). Using
// this to get access to progress and error.
Expand Down