All Projects → wolfwind521 → Indoor3d

wolfwind521 / Indoor3d

Licence: gpl-2.0
a js lib based on three.js to show 3D indoor map

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Indoor3d

Fe Daily Record
📚前端书籍汇集点 + 每日好文推荐 + 公开课学习资料 + 各种大会资料
Stars: ✭ 94 (-77.88%)
Mutual labels:  webgl, threejs, canvas
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-64.24%)
Mutual labels:  webgl, threejs, canvas
Earthjs
D3 Earth JS
Stars: ✭ 128 (-69.88%)
Mutual labels:  webgl, threejs, canvas
Troika
A JavaScript framework for interactive 3D and 2D visualizations
Stars: ✭ 342 (-19.53%)
Mutual labels:  webgl, threejs, canvas
R3f Next Starter
Repo is moving to https://github.com/pmndrs/react-three-next
Stars: ✭ 137 (-67.76%)
Mutual labels:  webgl, threejs, canvas
Demos
One repo to rule them all.
Stars: ✭ 204 (-52%)
Mutual labels:  webgl, threejs, canvas
Melonjs
a fresh & lightweight javascript game engine
Stars: ✭ 3,721 (+775.53%)
Mutual labels:  webgl, canvas
Three Elements
Web Components-powered custom HTML elements for building Three.js-powered games and interactive experiences. 🎉
Stars: ✭ 331 (-22.12%)
Mutual labels:  webgl, threejs
Xi Electron
A front-end for the xi-editor built with modern web technologies.
Stars: ✭ 333 (-21.65%)
Mutual labels:  webgl, canvas
Grimoirejs
A WebGL framework for Web development.
Stars: ✭ 339 (-20.24%)
Mutual labels:  webgl, canvas
React Postprocessing
📬 postprocessing for react-three-fiber
Stars: ✭ 311 (-26.82%)
Mutual labels:  webgl, threejs
Three.phenomenon
⭐️ A tiny wrapper around three.js built for high-performance WebGL experiences.
Stars: ✭ 338 (-20.47%)
Mutual labels:  webgl, threejs
Graphosaurus
3D graph viewer powered by WebGL (three.js)
Stars: ✭ 340 (-20%)
Mutual labels:  webgl, threejs
Duckhunt Js
DuckHunt ported to JS and HTML5
Stars: ✭ 390 (-8.24%)
Mutual labels:  webgl, canvas
Spoke
Easily create custom 3D environments
Stars: ✭ 321 (-24.47%)
Mutual labels:  webgl, threejs
React Particles Webgl
🔆 A 2D/3D particle library built on React, Three.js and WebGL
Stars: ✭ 330 (-22.35%)
Mutual labels:  threejs, canvas
Map33.js
A JavaScript library to make 3D maps with three.js.
Stars: ✭ 317 (-25.41%)
Mutual labels:  webgl, threejs
Phaser3 Docs
Phaser 3 Documentation and TypeScript Defs
Stars: ✭ 339 (-20.24%)
Mutual labels:  webgl, canvas
Plasio
Drag-n-drop In-browser LAS/LAZ point cloud viewer. http://plas.io
Stars: ✭ 349 (-17.88%)
Mutual labels:  webgl, threejs
Infinitetubes
A tunnel experiment in WebGL inspired by the effect seen on http://www.fornasetti.com/](Fornasetti.
Stars: ✭ 348 (-18.12%)
Mutual labels:  webgl, threejs

indoor3D

This is a javascript lib based on three.js to show an indoor map.

This was an experimental project when I was learning javascript and webgl, and I haven't updated it since then. Thanks for the followers and feedbacks, I decide to update it again.

A GUI map eidtor written by QT is under development. And I'm working on supporting the popular GeoJson format

Demo

2D Map Demo Page: http://wolfwind521.github.io/2dmap

3D Map Demo Page: http://wolfwind521.github.io

Usage

a simplest example:

<!DOCTYPE html>
<html>
<body>
<script src="js/three.min.js"></script>
<script src="js/Detector.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/IndoorMap.js"></script>
<script src="js/Projector.js"></script>
<script src="js/IndoorMap2d.js"></script>
<script src="js/IndoorMap3d.js"></script>
<script>
    var map = new IndoorMap();
    map.load('data/testMapData.json').showFloor(1);
</script>
</body>
</html>

a little more complex example:

<!DOCTYPE html>
<html>
<body>
<script src="js/three.min.js"></script>
<script src="js/Detector.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/Projector.js"></script>
<script src="js/IndoorMap.js"></script>
<script src="js/IndoorMap2d.js"></script>
<script src="js/IndoorMap3d.js"></script>
<link href="css/indoor3D.css" rel="stylesheet">

<div id="indoor3d" style="width: 800px; height: 500px"></div>
<script>
    var params = {
        mapDiv:"indoor3d",
        dim:"3d"
    }
    var map = IndoorMap(params);
    map.load('data/testMapData.json', function(){
        map.showAllFloors().showAreaNames(true).setSelectable(true);
        var ul = IndoorMap.getUI(map);
        document.body.appendChild(ul);
    });
</script>

</body>
</html>

The explanation is as follows:

  1. include the required js files
<script src="js/three.min.js"></script>
<script src="js/Detector.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/Projector.js"></script>
<script src="js/IndoorMap.js"></script>
<script src="js/IndoorMap2d.js"></script>
<script src="js/IndoorMap3d.js"></script>
<link href="css/indoor3D.css" rel="stylesheet">
  • three.min.js: a 3D javascript library
  • Detector: detects whether the browser support the webgl. if it does not, threejs switches to a normal canvas renderer.
  • OrbitControls: handles the user interactions to zoom, pan and pivot. (Only used in 3D version)
  • Projector: user selection detection used by threejs. (Only used in 3D version)
  1. set up the parameters of the indoor map and pass it to the creator
var params={mapDiv:"indoor3d",dim:"3d"};
var indoorMap = IndoorMap(params);

optional parameters:
@mapDiv: if you have create your own <div> as a map container, you can specify its id here, otherwise it will create a full screen map.
@dim: "2d" or "3d". "3d" as default value. But the final result depends on your device. If it doesn't support WebGL, it will show a 2d map even if u set "3d".

So if there is no params passed to IndoorMap, it will create a fullscreen 3D map by default:

var indoorMap = IndoorMap();
  1. load the map data, and set up its styles.
indoorMap.load('data/testMapData.json', function(){
        map.setTheme(myTheme).showAllFloors().showAreaNames(true).setSelectable(true);
        var ul = IndoorMap.getUI(indoorMap);
        document.body.appendChild(ul);
    });

the second parameter of the load() function is a callback function when the data is successfully loaded. You can customize the style and interaction of your indoor map in it. You may call the functions separately:

map.setTheme(myTheme);
map.showAllFloors();
map.showAreaNames(true);
map.setSelectable(true);

or in a chain for convenience:

map.setTheme(myTheme).showAllFloors().showAreaNames(true).setSelectable(true);

The UI is the buttons for switching floors. Its style is defined in the css file. so you can customize it by yourself.

User Reference

There are Three main classes:
-IndoorMap
-IndoorMap2d
-IndoorMap3d

IndoorMap2d

methods:

.load(fileName, callback)

loads a file. When it finishes loading, the callback functon is called. Since the ui can only be constructed after the data is fully loaded, so the getUI() function must be called in the callback.

if the file is already loaded by other modules, you should use the .parse(jsonData) method instead

.parse(jsonData)

parse the json Data. if the jsonData is loaded by other modules, you can just use this function to pass it to the indoor map

.setDefaultView()

reset the camera to default view (Default perspective view for a 3d map and default top view for a 2d map)

.setTopView()

set the camera to the top view. this function is only valid in the 3d map.

.zoomIn(zoomScale)

zoom in. zoom Scale is not necessary. so you can just call .zoomIn()

.zoomOut(zoomScale)

zoom out. Same as the zoomIn() function, zoom Scale is not necessary.

.adjustCamera

Resets the camera to its default settings. This function is called when switching floors

.setSelectable(selectable)

selectable- a boolean parameter to specify whether the rooms are selectable

.showLabels(showLabels)

showLabels- a boolean parameter to specify whether to show the labels. The labels are the icons and texts in the map.

.getUI()

returns a <ul> tag with all the floor id. The user can switch the floor by clicking the <li> You can insert the <ul> to anywhere in the html. Make sure to call this method only after the map is loaded.

.setSelectionListener(callback)

set the call back function when a shop is selected.

the shop id is passed as the parameter of callback. and -1 for nothing is selected.

.getSelectedId()

get the selected shop's id

.selectById(id)

select the shop by its id

.showFloor(id)

id-the floor id shows the floor by id. Notice this does not handle the labels.

.showAllFloors()

shows all the floors together. Notice this does not handle the labels.

Mall:

Properties

.floors

This is an array with all the floors of [THREE.Object3D](http://threejs.org/docs/#Reference/Core/Object3D) type.

Methods:

.getCurFloorId()

gets the id of the current floor. Notice: the id is a signed integers. -1 means Floor B1, and 1 means Floor F1. 0 is preserved for showing all the floors.

.getFloor(id)

id-the floor id gets the floor of [THREE.Object3D](http://threejs.org/docs/#Reference/Core/Object3D) type by its id.

.getCurFloor()

gets the current floor of [THREE.Object3D](http://threejs.org/docs/#Reference/Core/Object3D) type.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].