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

FaceAlignedSectionPlanesPlugin #1088

Merged
merged 10 commits into from
Jun 29, 2023
Merged

FaceAlignedSectionPlanesPlugin #1088

merged 10 commits into from
Jun 29, 2023

Conversation

xeolabs
Copy link
Member

@xeolabs xeolabs commented Jun 22, 2023

Description

Screencast from 28 06 2023 23_52_04 (online-video-cutter com)

This PR adds the capability to create face-aligned section planes using pointer input. These section planes are easier to use than those created by the existing ScenePlanesPlugin. When we click on an object, this plugin will create a section plane that aligns with the surface that was clicked. Then, using the mouse wheel, or by dragging in an application-supplied DIV, we can move the section plane back and forth along its direction vector. There is no facility for otherwise rotating the section plane, or dragging it along any other axis than its direction vector.

Usage

 import {Viewer, XKTLoaderPlugin, FaceAlignedSectionPlanesPlugin} from "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/xeokit-sdk.es.js";

    //------------------------------------------------------------------------------------------------------------------
    // Create a Viewer
    //------------------------------------------------------------------------------------------------------------------

    const viewer = new Viewer({
        canvasId: "myCanvas",
        transparent: true
    });

    viewer.camera.eye = [-3.933, 2.855, 27.018];
    viewer.camera.look = [4.400, 3.724, 8.899];
    viewer.camera.up = [-0.018, 0.999, 0.039];

    //------------------------------------------------------------------------------------------------------------------
    // Add a XKTModelsPlugin - we'll use this to load the model geometry
    //------------------------------------------------------------------------------------------------------------------

    const xktLoader = new XKTLoaderPlugin(viewer);

    //------------------------------------------------------------------------------------------------------------------
    // Add a FaceAlignedSectionPlanesPlugin - we'll use this to create cross-section planes
    //------------------------------------------------------------------------------------------------------------------

    const sectionPlanes = new FaceAlignedSectionPlanesPlugin(viewer, {
        overviewCanvasId: "mySectionPlanesOverviewCanvas",
        controlElementId: "mySectionPlaneControlDiv",
        overviewVisible: true
    });

    //------------------------------------------------------------------------------------------------------------------
    // Load the .xkt model and IFC metadata
    //------------------------------------------------------------------------------------------------------------------

    const sceneModel = xktLoader.load({
        id: "myModel",
        src: "../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
        edges: true,
        backfaces: true // Sometimes it's best to show backfaces, so that sliced objects look less odd
    });

    //------------------------------------------------------------------------------------------------------------------
    // Create a couple of cross-section planes
    //------------------------------------------------------------------------------------------------------------------

    const sectionPlane = sectionPlanes.createSectionPlane({
        id: "mySectionPlane",
        pos: [1.8933897259414376, 3.8494953147158935, 16.297288643481703],
        dir: [0.007873527603475804, 0.007873527603475804, -0.9999380056414271]
    });

    sectionPlanes.showControl(sectionPlane.id);

@xeolabs xeolabs self-assigned this Jun 22, 2023
@xeolabs xeolabs marked this pull request as draft June 22, 2023 22:05
@xeolabs xeolabs added the enhancement New feature or request label Jun 22, 2023
@xeolabs xeolabs added this to the 2.4.0 milestone Jun 22, 2023
@ghost
Copy link

ghost commented Jun 23, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@xeolabs xeolabs marked this pull request as ready for review June 29, 2023 01:14
@xeolabs xeolabs merged commit ea2ae6a into master Jun 29, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant