1.6.2 • Published 2 years ago

@wework/floormap-utils v1.6.2

Weekly downloads
22
License
WeWork
Repository
-
Last release
2 years ago

Floormap Utils

These are utility functions to be used for rendering floor map using FloormapGL

createRenderObjects(params)

Returns an array of renderer objects to be used for FloormapGL render() function

Example usage

import FloormapGL from '@wework/floormap.gl';
import { createRenderObjects } from '@wework/floormap-utils';

let objs = createRenderObjects({
  id: '83719599-420f-11e8-9d13-0642b0acf810',
  shapes: [
    [
      { x: 74.5, y: 31.00 },
      { x: 71.8, y: 30.29 },
      { x: 57.4, y: 30.5 },
      ...
    ],
    [
      { x: 86.2, y: 31.0 },
      { x: 74.4, y: 31.0 },
      { x: 56.4, y: 30.5 },
      ...
    ]
  ],
  type: 'space',
  subType: 'PRIVATE OFFICE',
  programType: 'WORK',
  roomNumber: '04-104',
  hasWindow: true
});

let renderer = new FloormapGL({
  target: document.getElementById('my-map'),
  size: {
    width: 1024,
    height: 768
  },
  antialias: true,
  pixelRatio: 2,
  backgroundColor: 'rgb(248,248,248)'
});

renderer.render(objs);

applyInstancing(objs, renderer)

This will enable mesh instancing for those mesh with similar geometries

Example usage

import FloormapGL from '@wework/floormap.gl';
import { createRenderObjects, applyInstancing } from '@wework/floormap-utils';

...

let renderer = new FloormapGL({
  target: document.getElementById('my-map'),
  size: {
    width: 1024,
    height: 768
  },
  antialias: true,
  pixelRatio: 2,
  backgroundColor: 'rgb(248,248,248)'
});

let renderObjects = []
rooms.forEach((room) => {
  const objectType = room.attributes.objectType;
  const roomType = room.attributes.roomType;
  let objs = createRenderObjects({
    id: room.id,
    shapes: room.attributes.boundaries,
    type: room.type,
    subType: objectType ? objectType : roomType,
    programType: room.attributes.programType,
    roomNumber: room.attributes.number,
    hasWindow: room.attributes.content.hasWindow,
    centroid: room.attributes.centroid,
    locationAngle: room.attributes.locationAngle,
  });
  objs.forEach((o) => {
    renderObjects.push(o);
  })
})

applyInstancing(renderObjects, renderer);

renderer.render(renderObjects);

getCenter(points)

Returns the { x, y } center of the geometry. Sample use case is, if you want to place an image or a text on the center of the room.

getSize(points)

Returns the box { width, height } given the points.

3.13.2

2 years ago

3.2.4

2 years ago

3.4.0

2 years ago

3.7.1

2 years ago

2.27.0

2 years ago

2.30.6

2 years ago

2.30.10

2 years ago

2.26.0

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

2.25.5

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.28.0

2 years ago

2.6.2-rc.1

3 years ago

2.6.2-rc.0

3 years ago

2.5.1-rc.5

3 years ago

1.6.3-rc.9

4 years ago

2.1.0

4 years ago

2.0.1-v2.459

4 years ago

2.0.1-v2.446

4 years ago

1.6.2

4 years ago

1.6.2-rc.48

4 years ago

1.6.1

4 years ago

1.6.1-rc.21

4 years ago

1.6.0

4 years ago

1.5.1-rc.2

4 years ago

1.5.0

4 years ago

1.4.2-rc.24

4 years ago

1.4.2-rc.23

4 years ago

1.4.2-rc.14

4 years ago

1.4.1

4 years ago

1.4.1-rc.2

4 years ago

1.4.0

4 years ago

1.3.7-rc.20

4 years ago

1.3.6

4 years ago

1.3.6-rc.5

4 years ago

1.3.5

4 years ago

1.3.5-rc.17

4 years ago

1.3.4-rc.4

5 years ago

1.3.4

5 years ago

1.3.4-rc.0

5 years ago

1.3.4-rc.1

5 years ago

1.3.3-rc.2

5 years ago

1.3.3

5 years ago

1.3.3-rc.3

5 years ago

1.3.1-rc.12

5 years ago

1.3.2

5 years ago

1.3.1-rc.8

5 years ago

1.3.1-rc.7

5 years ago

1.3.1-rc.6

5 years ago

1.3.1

5 years ago

1.3.1-next.3

5 years ago

1.3.1-next.2

5 years ago

1.3.1-rc.0

5 years ago

1.3.0

5 years ago

1.2.1-rc.13

5 years ago

1.1.1-rc.9

5 years ago

1.2.0

5 years ago

1.1.1-rc.7

5 years ago

1.0.3-rc.34

5 years ago

1.1.0

5 years ago

1.0.3-rc.30

5 years ago

1.0.2

5 years ago

1.0.1-next.48

5 years ago

1.0.1-next.47

5 years ago

1.0.1-next.46

5 years ago

1.0.1-next.45

5 years ago

1.0.1-next.44

5 years ago

1.0.1-next.40

5 years ago

1.0.1

5 years ago

1.0.1-rc.1

5 years ago

1.0.0-rc.1

5 years ago

1.0.1-next.39

5 years ago

1.0.1-next.38

5 years ago

1.0.1-next.37

5 years ago

1.0.1-next.36

5 years ago

1.0.1-next.35

5 years ago

1.0.1-next.34

5 years ago

1.0.1-rc.30

5 years ago

1.0.0

5 years ago

1.0.0-rc3

5 years ago

1.0.0-rc2

5 years ago

1.0.0-rc1

5 years ago

0.10.0

5 years ago

0.10.0-rc2

5 years ago

0.9.5

5 years ago

0.9.5-rc1

5 years ago

0.9.4

5 years ago

0.9.4-rc1

5 years ago

0.9.3

5 years ago

0.9.2-rc1

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.3

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago