0.0.75 • Published 9 months ago

svgeditor-client3d v0.0.75

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Simple 3D Scene Client for SVG Editor

This is a simple client for the create a SVG interactive map or schemes. It is based on SVG files with a specific structure. In SVG files, you can define a group of elements with a specific ID. For default use interactive layer (group in SVG) Id named => "interactive". But you can use any other name. Нou must specify this name in the configuration file (For example - "interactiveLayer: 'MyInteractiveLayer'"). See "Set up Client" section.

Install

npm i svgeditor-client3d

Demo

Use case of this library is to create a simple interactive map.

Use Client

import { ClientSVG3D } from 'svgeditor-client3d'

Set up Client

   const nodeMap = document.getElementById('map'); // Get Node where you insert SVG map
      const baloonTheme = {
        colorBG: '#eeeeee', // Baloon background color
        colorTitle: '#000000', // Baloon title color
        colorDescription: '#000000', // Baloon description color
        isPositionFixed: false, // Baloon position fixed
        top: 0, // Baloon top position
        left: 0, // Baloon left position
      }
      const dataShops = [
      {
        id: '0',
        idmap: 'item-01',
        title: 'Bruen - Kessler',
        slug: '/bruen-kessler',
        description: 'Sample text description for this item',
        image: 'https://loremflickr.com/128/128/abstract?73275',
      },
       ...
      ];

      const map = new ClientSVGEditor(
        nodeMap, // node - dom element to insert svg
        dataShops, // dataItems - data to render in Baloon when hover on Item
        {
          title: 'Sample map', // Head Title this map
          urlmap: './public/Shelkovsky-float-0.svg', // Path to map svg
          stringSVG: '', // String SVG map if isSVGFromSring => true
          interactiveLayer: '#interactive', // Layer for interactive items in SVG map. Default: #interactive
          isRemoveUnuseItem: false, // Remove unuse item from map?
          funcClick: gotoURLClick, // Function for click on item
          funcParams: 'https://www.google.com', // Params for function click on item
          mapTheme: {
            // Theme for map
            colorBG: '#ffdd3d', // Background color this map
            colorItem: '#aaa', // Fill Color for item
            colorHoverItem: '#9e3232', // Fill Color for item on hover
            colorSelectItem: '#0000ff', // Fill Color for item on select
            opacityItem: 0.0, // Opacity for item
            opacityHoverItem: 0.3, // Opacity for item on hover
            opacitySelectItem: 1, // Opacity for item on select
            colorBorderItem: '#000000', // Border color for item
            colorBorderHoverItem: '#ffffff', // Border color for item on hover
            colorBorderSelectItem: '#ffffff', // Border color for item on select
            isBorderItem: false, // Is set Border for item
            isBorderHoverItem: false, // Is set Border for item on hover
            isBorderSelectItem: false, // Is set Border for item on select
            widthBorderItem: 2, // Width for border item
            widthBorderHoverItem: 2, // Width for border item on hover
            widthBorderSelectItem: 2, // Width for border item on select
          },
              isCustomBalloon: false, // Is you use custom baloon?
              nodeCustomBalloon: null, // Node HTMLElement for custom baloon
              dataStructureCustomBalloon: null, // Data structure for custom baloon
              isMobileZoom: false, // Is turn on zoom swipe on mobile?
              isSVGFromSring: false, // Is load SVG from string? 
        },
        baloonTheme // Theme for defaul baloon
      )

      map.start(); // Start map

Sample custom select single item

      map.clearInteractiveLayer() // Clear interactive layer if you use select single item before next select
      // You can change default options for map
      map.options!.mapTheme!.colorSelectItem = '#ff0000' // Set color for select item if you  need
      map.options!.mapTheme!.opacitySelectItem = 1 // Set opacity for select item if you  need
      map.options!.mapTheme!.widthBorderSelectItem = 2 // Set width border for select item if you  need
      
      map.selectItem('Shape-2-01') // Select item by id item in SVG map

Sample custom multyselect items.

...
const dataArraySelect = [
  'Shape-2-04',
  'Shape-2-06',
  'Shape-2-29',
  'Shape-2-14',
  'Shape-2-21',
  'Shape-2-08',
  'Shape-2-27',
  'Shape-2-20',
  'Shape-2-31',
  'Shape-2-56',
  'Shape-2-22',
  'Shape-2-23',
  'Shape-2-24',
  'Shape-2-89',
  'Shape-2-26',
]

      map.clearInteractiveLayer() // Clear interactive layer if you use select single item before next select
      // You can change default options for map
      map.options.mapTheme.colorSelectItem = '#ff400с' // Set color for select item if you  need
      map.options.mapTheme.widthBorderSelectItem = 1.1 // Set width border for select item if you  need
      map.options.mapTheme.opacitySelectItem = 1 // Set opacity for select item if you  need
      map.options.mapTheme.widthBorderSelectItem = 2 // Set width border for select item if you  need

      map.multySelectItem(dataArraySelect) // Select group items by array id items in SVG map
      

Example custom function click on item

      function gotoURLClick(dataelement) { // Sample callback function when you click on active item on map
        window.open(dataelement.slug, '_self')
      }
0.0.40

11 months ago

0.0.41

11 months ago

0.0.42

11 months ago

0.0.43

11 months ago

0.0.44

10 months ago

0.0.45

10 months ago

0.0.46

10 months ago

0.0.47

10 months ago

0.0.38

11 months ago

0.0.39

11 months ago

0.0.73

9 months ago

0.0.74

9 months ago

0.0.30

11 months ago

0.0.75

9 months ago

0.0.31

11 months ago

0.0.32

11 months ago

0.0.33

11 months ago

0.0.34

11 months ago

0.0.35

11 months ago

0.0.36

11 months ago

0.0.70

10 months ago

0.0.71

9 months ago

0.0.72

9 months ago

0.0.26

12 months ago

0.0.27

12 months ago

0.0.28

12 months ago

0.0.29

12 months ago

0.0.62

10 months ago

0.0.63

10 months ago

0.0.64

10 months ago

0.0.65

10 months ago

0.0.66

10 months ago

0.0.67

10 months ago

0.0.68

10 months ago

0.0.69

10 months ago

0.0.25

12 months ago

0.0.60

10 months ago

0.0.61

10 months ago

0.0.59

10 months ago

0.0.51

10 months ago

0.0.52

10 months ago

0.0.53

10 months ago

0.0.55

10 months ago

0.0.56

10 months ago

0.0.57

10 months ago

0.0.58

10 months ago

0.0.50

10 months ago

0.0.48

10 months ago

0.0.49

10 months ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago