0.7.0 • Published 2 years ago

@pixano/graphics-3d v0.7.0

Weekly downloads
25
License
CECILL-C
Repository
github
Last release
2 years ago

@pixano/graphics-3d

Set of web components for 3D point cloud annotations.

Import

import "@pixano/graphics-3d";
// or a specific element
import "@pixano/graphics-3d/lib/pxn-cuboid";

Example: Rectangle annotation

Example usage:

import { css, html, LitElement} from 'lit-element';
import '@pixano/graphics-3d';

const colors = [
  'blue', 'green', 'purple',
  'yellow', 'pink', 'orange', 'tan'
];

class MyDemocuboid extends LitElement {

  firstUpdated() {
    fetch('pointcloud.bin').then((response) => {
      return response.ok ? response.arrayBuffer() : Promise.reject(response.status);
    }).then((points) => {
      this.element.pcl = new Float32Array(points);
    });
  }

  onCreate(evt) {
    // listening to the create event dispatched
    // by the element to assign a nice color to
    // the new cuboid.
    const newObj = evt.detail;
    newObj.color = colors[this.element.editableCuboids.size % colors.length];
  }

  get element() {
    // Utility getter of the element
    return this.shadowRoot.querySelector('pxn-cuboid-editor');
  }

  render() {
    // Render the template with the cuboid element
    // enriched with some buttons to interact with it.
    return html`
    <pxn-cuboid-editor @create=${this.onCreate}></pxn-cuboid-editor>
    <div>
        <button @click=${() => this.element.mode = 'create'}>Add</button>
    </div>`;
  }
}

customElements.define('my-demo-cuboid', MyDemocuboid);

API

Properties/Attributes

pxn-cuboid-editor

NameTypeDefaultDescription
pclFloat32ArraynullPoint cloud as one-dimensional array in the XYZ order
editableCuboidsSet<Cuboid*>[]Cuboids rendered in the scene
editTargetCuboid|nullnullSelected cuboid
cameraModeorthographic|perspectiveperspectiveCamera type
modeInteractionMode**editSets the canvas interaction mode. Use none for no interactions at all.

*Cuboid format:

interface Cuboid {
  id: string;
  // x, y, z
  position: number[];
  // length, width, height
  size: number[];
  // rotation around z axis (trigometric)
  heading: number;
  // optional color
  color?: number;
}

**InteractionMode is a string with the following possible values:

type InteractiveMode =  "edit" | "create" | "none";

Methods

pxn-cuboid-editor

NameDescription
rotate() => voidRotate selected cuboid by 90°
swap() => voidSwap selected cuboid coordinates

Events

pxn-canvas-2d

Event NameDetailDescription
createEditionDetailFired when a shape has been created.
updateEditionDetailFired when a shapes update has been made.
deleteEditionDetailFired when shapes are deleted. Detail is the list of the deleted shape ids.
selectionSelectionDetailFired when shapes are selected.
modeInteractionModeFired when user interaction mode changed
interface EditionDetail {
  // cuboid being created/edited/deleted
  detail: Cuboid;
}
interface SelectionDetail {
  // cuboids being selected
  detail: Cuboid[];
}

Shortcuts

pxn-cuboid-editor

KeyDescription
nSwitch to create mode
EscapeUnselect shapes
DeleteDelete selected shapes
Ctrl+CCopy in clipboard currently selected cuboid
Ctrl+VCreate new cuboid (with new id) from the clipboard content
+Scale up size of points in pointcloud
-Scale down size of points in pointcloud
0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.17

3 years ago

0.5.16

3 years ago

0.5.15

3 years ago

0.5.14

3 years ago

0.5.13

3 years ago

0.5.12

3 years ago

0.5.11

3 years ago

0.5.10

3 years ago

0.5.9

3 years ago

0.5.8

3 years ago

0.5.7

3 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago