Giter Site home page Giter Site logo

cvdlab / react-planner Goto Github PK

View Code? Open in Web Editor NEW
1.2K 54.0 438.0 50.28 MB

:pencil2: A React Component for plans design. Draw a 2D floorplan and navigate it in 3D mode.

Home Page: https://cvdlab.github.io/react-planner

License: MIT License

JavaScript 99.95% CSS 0.05%
component interface react react-component reactjs ui webgl threejs svg floorplans draw

react-planner's Introduction

react-planner

react-planner is a React component which can be used to draw model buildings. Drag & drop from a catalog of customizable and ready-to-use objects, you can start from 2D wireframes and land on 3D models. As a developer you can provide your users with new objects by adding them to the catalog.

npm javascript react-version

Demo

Demo

react-planner

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import {Map} from 'immutable';
import {createStore} from 'redux';
import {Provider} from 'react-redux';

//download this demo catalog https://github.com/cvdlab/react-planner/tree/master/demo/src/catalog
import MyCatalog from './catalog/mycatalog';

import {
  Models as PlannerModels,
  reducer as PlannerReducer,
  ReactPlanner,
  Plugins as PlannerPlugins,
} from 'react-planner';


//define state
let AppState = Map({
  'react-planner': new PlannerModels.State()
});

//define reducer
let reducer = (state, action) => {
  state = state || AppState;
  state = state.update('react-planner', plannerState => PlannerReducer(plannerState, action));
  return state;
};

let store = createStore(reducer, null, window.devToolsExtension ? window.devToolsExtension() : f => f);

let plugins = [
  PlannerPlugins.Keyboard(),
  PlannerPlugins.Autosave('react-planner_v0'),
  PlannerPlugins.ConsoleDebugger(),
];

//render
ReactDOM.render(
  (
    <Provider store={store}>
      <ReactPlanner
        catalog={MyCatalog}
        width={800}
        height={600}
        plugins={plugins}
        stateExtractor={state => state.get('react-planner')}
      />
    </Provider>
  ),
  document.getElementById('app')
);

Docs

Authors

Developed @ CVDLAB

Contributing

Your contributions (issues and pull request) are very appreciated!

Contributors

License

MIT

react-planner's People

Contributors

alessiocarrafa avatar cbosse-skwirrel avatar chrvadala avatar danilosalvati avatar enricomarino avatar federicospini avatar jikkujose avatar stefanoperrone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-planner's Issues

Fix snaps

  • Fix collinear
  • Fix double vertices on same position
  • Fix obliques snap

Check state consistent

vertex reference an inexistent line

ReactPlanner.store.subscribe(() => {
    console.log('update');
    let s = ReactPlanner.getState().scene;
    let vv = s.layers['layer-1'].vertices;
    let ll = s.layers['layer-1'].lines;
    for(let vn in vv){
        let v = vv[vn];
        v.lines.forEach(lineID => {
             if (!ll.hasOwnProperty(lineID)) console.warn(lineID); else console.log('ok')})
    }         
})
ReactPlanner.do([
    ReactPlanner.projectActions.newProject(),
    ReactPlanner.linesActions.selectToolDrawingLine('wall'),
    ReactPlanner.linesActions.beginDrawingLine('layer-1', 80, 1900),
    ReactPlanner.linesActions.endDrawingLine(300, 1700),
    ReactPlanner.linesActions.beginDrawingLine('layer-1', 300, 1900),
    ReactPlanner.linesActions.updateDrawingLine(300, 1700),
    ReactPlanner.linesActions.endDrawingLine(300, 1700),
]);

Bug walls with 0 length

ReactPlanner.do([
    ReactPlanner.linesActions.selectToolDrawingLine('wall'),
    ReactPlanner.linesActions.beginDrawingLine('layer-1', 80, 1850),
    ReactPlanner.linesActions.endDrawingLine(100, 1800),
    ReactPlanner.linesActions.beginDrawingLine('layer-1', 300, 1800),
    ReactPlanner.linesActions.endDrawingLine(100, 1800),
    ReactPlanner.editingActions.selectToolEdit()
]); 

Add layer property window

  • Add transparency property
  • Add altitude property window
  • Add name property window
  • Add order property window

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.