• Stars
    star
    560
  • Rank 79,541 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A maptalks layer to render with three.js.

maptalks.three

CircleCI NPM Version

A maptalks Layer to render with three.js

20220116_213033.mp4

Examples

Install

  • Install with npm: npm install maptalks.three.
  • Download from dist directory.
  • Use unpkg CDN: https://unpkg.com/maptalks.three/dist/maptalks.three.min.js

Incompatible changes

  • three.js >=128 the default umd package is ES6
  • Starting from version 0.16.0, the default umd package is ES6,To fit the new version of three.js about three umd package change
  • If your running environment does not support ES6, we also provide Es5 version maptalks.three.es5.js,This requires the version of three.js < = 127,

Migration from <=v0.5.x to v0.6.0

  • Re-implementated locateCamera, sync with map's projMatrix and viewMatrix.
  • Model's z position is reversed from v0.5.0. So if you have models rendered with v0.5.x, rotation needs to be updated.
  • For THREE <= 0.94, material's side need to set to THREE.BackSide or THREE.DoubleSide to render correctly
    • THREE >= 0.95 doesn't need, maybe due to #14379
  • Add support for THREE >= 0.93
  • Add support for GroupGLLayer

Usage

As a plugin, maptalks.three must be loaded after maptalks.js and three.js in browsers.

<script type="text/javascript" src="https://unpkg.com/[email protected]/build/three.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/maptalks/dist/maptalks.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/maptalks.three/dist/maptalks.three.js"></script>
<script>
var threeLayer = new maptalks.ThreeLayer('t');
threeLayer.prepareToDraw = function (gl, scene, camera) {
    var light = new THREE.DirectionalLight(0xffffff);
    light.position.set(0, -10, -10).normalize();
    scene.add(light);

    var material = new THREE.MeshPhongMaterial();
    countries.features.forEach(function (g) {
        //g is geojson Feature
        var num = g.properties.population;

        var extrudePolygon=threeLayer.toExtrudePolygon(g, { height: num }, material);
        threeLayer.addMesh(extrudePolygon)
    });
};

map.addLayer(threeLayer);
</script>

With ES Modules:

import * as THREE from 'three';
import * as maptalks from 'maptalks';
import { ThreeLayer } from 'maptalks.three';

const map = new maptalks.Map('map', { /* options */ });

const threeLayer = new ThreeLayer('t');
threeLayer.prepareToDraw = function (gl, scene, camera) {
    const light = new THREE.DirectionalLight(0xffffff);
    light.position.set(0, -10, -10).normalize();
    scene.add(light);
    //...
};

threeLayer.addTo(map);

Supported Browsers

IE 11, Chrome, Firefox, other modern and mobile browsers that support WebGL;

API Reference

API

Contributing

We welcome any kind of contributions including issue reportings, pull requests, documentation corrections, feature requests and any other helps.

Develop

The only source file is index.js.

It is written in ES6, transpiled by babel and tested with mocha and expect.js.

Scripts

  • Install dependencies
$ npm install
  • Watch source changes and generate runnable bundle repeatedly
$ npm run dev
  • Package and generate minified bundles to dist directory
$ npm run build
  • Lint
$ npm run lint

Publication

npm version ${version}
npm publish
npm push master ${version}

More Repositories

1

maptalks.js

A light and plugable JavaScript library for integrated 2D/3D maps.
TypeScript
4,259
star
2

raster-collection

A collection of raster tile services
100
star
3

examples

maptalks examples
JavaScript
67
star
4

maptalks.mapboxgl

MapboxglLayer for maptalks.js
JavaScript
57
star
5

maptalks.markercluster

A layer of maptalks to cluster markers.
JavaScript
49
star
6

maptalks.heatmap

A heatmap layer plugin for maptalks.js
JavaScript
47
star
7

maptalks.e3

The plugin to integerate Echarts3 as a layer with maptalks.js
JavaScript
46
star
8

awesome-maptalks

Curated list of awesome maptalks resources
46
star
9

maptalks-gl-layers

All-in-one package for maptalks webgl layers
JavaScript
46
star
10

maptalks.biglayer

A maptalks layer to render millions of data with WebGL
JavaScript
30
star
11

proj4m

proj4 minimal/maptalks
JavaScript
26
star
12

maptalks.routeplayer

The route player plugin for maptalks.js
JavaScript
26
star
13

maptalks.gridlayer

A GridLayer plugin for maptalks.js. A layer draws grids.
JavaScript
13
star
14

maptalks.animatemarker

A plugin of maptalks.js to draw markers with animation.
JavaScript
11
star
15

maptalks.esri

A maptalks plugin to load esri ArcGIS services.
JavaScript
11
star
16

maptalks.e4

A plugin for echarts 4.0
JavaScript
9
star
17

maptalks.snap

JavaScript
9
star
18

maptalks.d3

A maptalks Layer to render with great d3js library.
JavaScript
8
star
19

maptalks.odline

A maptalks layer to draw OD(Origin-Destination) lines.
JavaScript
7
star
20

mapresty-docs

Documentation of mapresty
5
star
21

maptalks.mapresty

A javascript client for mapresty
JavaScript
5
star
22

maptalks.isects

A plugin of maptalks.js to find self-intersections in a polygon or multipolygon
JavaScript
5
star
23

docs.maptalks.org

Documentation site for maptalks
4
star
24

issues

Repo of issues for webgl layers
3
star
25

mapresty-client-java

Java SDK for mapresty restful service
Java
3
star
26

expect-maptalks

A plugin of expect.js for maptalks with assertions for Coordinate/GeoJSON/Layer
JavaScript
3
star
27

to-geojson

TypeScript
2
star
28

colorin

a simple colors interpolate lib
HTML
2
star
29

demo-of-loves

demo from loves everywhere.
2
star
30

maptalks-plugin

A simple maptalks plugin scaffolding project
JavaScript
2
star
31

maptalks.vectorgl

A webgl renderer for maptalks VectorLayer
1
star
32

geojson4j

GeoJSON Serilization and mutual conversion with JSON
Java
1
star
33

eslint-config-maptalks

An ESLint config for MapTalks javascript projects
JavaScript
1
star
34

function-type

function type support for maptalks
JavaScript
1
star
35

maptalks.github.io

Source of maptalks.org
JavaScript
1
star
36

msd-json-loader

A utility to parse maptalks msd json data
JavaScript
1
star
37

maptalks-build-helpers

Helpers to build for maptalks.js and plugins.
JavaScript
1
star
38

mapresty-client-dotnet

.Net client for mapresty
C#
1
star
39

servletrest

A simple, light-weighted restful servlet framework for JAVA
Java
1
star
40

geojson-bbox

JavaScript
1
star