feat(label): add textlayer

This commit is contained in:
thinkinggis 2019-08-19 10:16:40 +08:00
commit 8376961a4f
328 changed files with 982 additions and 31975 deletions

View File

@ -1,6 +1,6 @@
{
"extends": [
"egg"
"eslint-config-egg"
],
"globals": {
"$": true,
@ -44,6 +44,7 @@
"error",
"never"
],
"jsdoc/require-param": 0,
"linebreak-style": [
0
]

2
.gitignore vendored
View File

@ -65,7 +65,6 @@ dist
temp
.DS_Store
.idea
lib
*.sw*
*.un~
demos/gd.html
@ -75,6 +74,7 @@ demos/image
demos/hexagon.html
demos/model
testdemo
lib
webpack-dev.config.js
webpack.config.js
.si.yml

View File

@ -1,82 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# lock
package-lock.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.DS_Store
# npmignore - content above this line is automatically generated and modifications may be omitted
# see npmjs.com/npmignore for more details.
test
*.sw*
*.un~
.idea
bin
bundler
demos
docs
src
temp
webpack-dev.config.js
webpack.config.js
testdemo
rollup
.si.yml

11
.si.yml
View File

@ -1,11 +0,0 @@
before_deploy:
- tnpm install
- tnpm run build
- rm -rf ./vis/
- mkdir vis
- cp -r demos build vis/
- cd ./vis/
- node ./demos/list.js
options:
dist: 'vis'
branch: 'dev'

View File

@ -1,7 +1,7 @@
language: node_js
node_js:
- "8"
- "12"
env:
matrix:
@ -11,6 +11,7 @@ addons:
apt:
packages:
- xvfb
- libgconf-2-4
install:
- export DISPLAY=':99.0'

View File

@ -1 +1,3 @@
#### 0.0.1
## changelog
[changelog](https://www.yuque.com/antv/l7/rdg5db)

2
LICENSE Executable file → Normal file
View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017 Alipay.inc
Copyright (c) 2019 AntV team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

47
README.md Executable file → Normal file
View File

@ -1,3 +1,48 @@
# L7 Large-scale WebGL-powered Geospatial Data Visualization
[L7官网](http://antv.alipay.com/zh-cn/l7/1.x/index.html)
## 安装
###
### 加载高德地图
L7 目前底图采用高德地图,因此使用之前你还需要使用开发者 Key你可以使用适用于『Web端』开发者 Key。如果没有可以点击 [这里申请](https://lbs.amap.com/dev/key/)。
申请开发者 Key 是免费的。如果指定错误的版本号和开发者 Key将无法加载 L7。目前最新版本请参考[这里](https://lbs.amap.com/api/loca-api/changelog),如果不指定版本号,则使用最新版本。
在你的页面引入高德地图API
```html
<script src="https://webapi.amap.com/maps?v=1.4.8&key=您申请的key值"></script>
```
### HTML 引入 L7
既可以通过将脚本下载到本地也可以直接引入在线资源;
```html
<!-- 引入在线资源 -->
<script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.l7-1.2.2/dist/l7.min.js"></script>
```
### 通过 npm 安装
我们提供了 L7 npm 包,通过下面的命令即可完成安装
```bash
npm i @antv/l7 --save
```
成功安装完成之后,即可使用 `import` 或 `require` 进行引用。
```javascript
import L7 from '@antv/l7';
// 新建Scene
```
[L7官网](http://antv.alipay.com/zh-cn/l7/1.x/index.html)
# L7
@ -16,5 +61,3 @@ $ npm run start
$ npm run demos
```
## How to Contribute

View File

@ -13,7 +13,6 @@
<script>/*Fixing iframe window.innerHeight 0 issue in Safari*/ document.body.clientHeight; </script>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="https://gw.alipayobjects.com/os/antv/assets/lib/jquery-3.2.1.min.js"></script>
<link rel=stylesheet type=text/css href='../build/l7.css'>
<script src="../build/l7.js"></script>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
@ -21,9 +20,11 @@
<script>
var scene = new L7.Scene({
id: 'map',
mapStyle: 'light', // 样式URL
mapStyle: 'dark', // 样式URL
center: [120.19382669582967, 30.258134],
pitch: 0,
minZoom:5,
maxZoom:15,
zoom: 12
});
window.scene = scene;
@ -45,6 +46,41 @@
strokeWidth: 1,
opacity: 0.9
}).render();
scene.TextLayer({
zIndex: 5
})
.source(data)
.shape('name', 'text')
.active(true)
.filter('value', function(v) {
return v * 1 > 10000;
})
.size(20)
.color('#FFF')
.style({
// fontFamily: 'Monaco, monospace', // 字体
fontWeight: 500,
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [ 0, 0 ], // 文本相对锚点的偏移量 [水平, 垂直]
spacing: 2, // 字符间距
padding: [ 4, 4 ], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
strokeColor: 'white', // 描边颜色
strokeWidth: 1, // 描边宽度
opacity: 1.0
})
.render();
const popup = new L7.Popup({anchor:'left'}).setText('hello world')
const marker = new L7.Marker({color:'blue'})
.setLnglat( [120.19382669582967, 30.258134])
.setPopup(popup)
.addTo(scene);
layer.on('click',(e) => {
const { lnglat, feature } = e;
const popup = new L7.Popup()

View File

@ -53,23 +53,16 @@ const scene = new L7.Scene({
window.scene = scene;
scene.on('loaded', () => {
$.get('https://gw.alipayobjects.com/os/rmsportal/epnZEheZeDgsiSjSPcCv.json', data => {
console.log(data);
const circleLayer = scene.PointLayer({
zIndex: 0,
})
.source(data,{
isCluster:true
})
// .shape('circle')
.shape('point_count', [ 'circle', 'triangle', 'hexagon' ])
// .shape('triangle')
// .shape('square')
// .shape('hexagon')
// .shape('octogon')
// .shape('hexagram')
// .shape('pentagon')
.shape('circle')
.size('point_count', [ 5, 40]) // default 1
//.size('value', [ 10, 300]) // default 1
.active(true)
.active(false)
.color('point_count',["#002466","#105CB3","#2894E0","#CFF6FF","#FFF5B8","#FFAB5C","#F27049","#730D1C"])
.style({
stroke: 'rgb(255,255,255)',
@ -77,30 +70,30 @@ scene.on('loaded', () => {
opacity: 1
})
.render();
window.circleLayer = circleLayer;
const layerText = scene.PointLayer({
zIndex: 3
scene.TextLayer({
zIndex: 5
})
.source(circleLayer.layerSource)
.source(circleLayer.layerSource)
.shape('point_count', 'text')
.active(false)
.filter('point_count',(p)=>{
return p > 50
})
.size('point_count', [ 5, 20]) // default 1
.color('#fff')
.active(true)
.size('point_count', [ 10, 20, 24 ])
.color('#FFF')
.style({
stroke: '#999',
strokeWidth: 1,
// fontFamily: 'Monaco, monospace', // 字体
fontWeight: 200,
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [ 0, 0 ], // 文本相对锚点的偏移量 [水平, 垂直]
spacing: 2, // 字符间距
padding: [ 4, 4 ], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
strokeColor: 'white', // 描边颜色
strokeWidth: 1, // 描边宽度
opacity: 1.0
})
.render();
console.log(layerText);
});
});
});
</script>
</body>
</html>

View File

@ -17,7 +17,7 @@
<div id="map">
<div id ="info" class ="tooltip" style="display:none">
</div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="../build/L7.js"></script>
<script>

View File

@ -18,34 +18,42 @@
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/dat.gui.min.js"></script>
<script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.l7-1.2.0-beta.1/build/l7.js"></script>
<script src="../build/l7.js"></script>
<script>
var buildLayer =null;
const scene = new L7.Scene({
id: 'map',
mapStyle: 'dark', // 样式URL
center: [120.173104, 30.244072],
pitch: 66.50572,
zoom: 15.79,
minZoom:10
center: [
120.15935897827148,
30.261736090037477
],
pitch:0,
zoom: 5,
showBuildingBlock:false,
minZoom: 0,
maxZoom: 18
});
scene.on('loaded', () => {
$.get('https://gw.alipayobjects.com/os/basement_prod/40ef2173-df66-4154-a8c0-785e93a5f18e.json', data => {
scene.LineLayer({
zIndex: 2
})
.source(data)
.size(2)
.size(1)
.shape('line')
.color('#ff893a')
.animate({
enable:false,
interval:0.2,
duration:5,
trailLength:0.1
enable:true,
interval:0.4,
duration:1,
trailLength:0.8
})
.render();
});
$.get('https://gw.alipayobjects.com/os/rmsportal/ggFwDClGjjvpSMBIrcEx.json', data => {
buildLayer = scene.PolygonLayer({
zIndex: 2
@ -65,6 +73,7 @@ scene.on('loaded', () => {
});
});
</script>

63
demos/line_bug.html Normal file
View File

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="geometry" content="diagram">
<link rel="stylesheet" href="./assets/common.css">
<title>city demo</title>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
#timepannel {
background: white;
z-index: 10;
position: absolute;
right:50px;
padding: 10px;
}
</style>
</head>
<body>
<div id ='timepannel'>时间: 6时</div>
<div id="map">
</div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=f28fca5384129d180ad82915156a9baf&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="../build/L7.js"></script>
<script>
var buildLayer =null;
const scene = new L7.Scene({
id: 'map',
mapStyle: 'amap://styles/c9f1d10cae34f8ab05e425462c5a58d7', // 样式URL
center: [120.102915,30.261396],
pitch: 0,
zoom: 3,
minZoom: 5,
maxZoom: 18
});
scene.on('loaded', () => {
scene.image.addImage('arrow', '/demos/assets/arrow.png');
scene.image.addImage('right', '/demos/assets/right.png');
$.get('https://gw.alipayobjects.com/os/basement_prod/3ed18d7c-bce4-48ca-8716-5248b584481d.json',(data)=>{
const linelayer = scene.LineLayer({
zIndex: 2
})
.shape('line')
.size(10)
.source(data)
.color('#2b83ba')
.pattern('arrow')
.style({
patternSpacing: 20
})
.render();
});
})
</script>
</body>
</html>

111
demos/marker.html Normal file
View File

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://gw.alipayobjects.com/os/rmsportal/PqLCOJpqoOUfuPRacUzE.css" />
<title>气泡图</title>
<style> ::-webkit-scrollbar{display:none;}html,body{overflow:hidden;margin:0;}
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>/*Fixing iframe window.innerHeight 0 issue in Safari*/ document.body.clientHeight; </script>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="https://gw.alipayobjects.com/os/antv/assets/lib/jquery-3.2.1.min.js"></script>
<script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.g2-3.5.1/dist/g2.min.js"></script>
<script src="../build/l7.js"></script>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
G2.Global.renderer = 'svg'
var scene = new L7.Scene({
id: 'map',
mapStyle: 'light', // 样式URL
center: [120.19382669582967, 30.258134],
pitch: 0,
minZoom:5,
maxZoom:15,
zoom: 3
});
window.scene = scene;
scene.on('loaded', function() {
$.getJSON('https://gw.alipayobjects.com/os/rmsportal/UpapMomPYUeiBjbHNAma.json', region => {
const color = [ 'rgb(22,32,101)', 'rgb(28,43,127)', 'rgb(36,68,142)', 'rgb(45,94,158)', 'rgb(53,119,174)', 'rgb(61,145,190)', 'rgb(70,170,206)', 'rgb(98,190,210)', 'rgb(138,205,206)', 'rgb(179,221,204)', 'rgb(220,236,201)' ];
var points = region.features.map((feature)=>{
return feature.properties;
})
const layer = scene.PolygonLayer({
zIndex:1,
})
.source(region)
.color('cname',(value)=>{
return (value =='中国' ? 'rgba(46,149,169,0.45)': 'rgba(227,244,244,0.1)');
})
.shape('fill')
.render();
});
$.getJSON('https://gw.alipayobjects.com/os/basement_prod/0b96cca4-7e83-449a-93d0-2a77053e74ab.json', function(data) {
console.log(data);
data.nodes.forEach(item=>{
const el = document.createElement('div');
const total = item.gdp.Agriculture + item.gdp.Industry + item.gdp.Service;
const size =Math.max(Math.min(parseInt(total / 20000), 150),40)
var data = [{
item: 'Agriculture',
count: item.gdp.Agriculture,
percent: item.gdp.Agriculture / total
}, {
item: 'Industry',
count: item.gdp.Industry,
percent: item.gdp.Industry / total
}, {
item: 'Service',
count: item.gdp.Service,
percent: item.gdp.Service / total
}];
var chart = new G2.Chart({
container: el,
width:size,
height:size,
render:'svg',
padding:5,
});
chart.source(data, {
percent: {
formatter: function formatter(val) {
val = val * 100 + '%';
return val;
}
}
});
chart.coord('theta', {
radius: 1.0
});
chart.legend(false);
chart.tooltip(false);
chart.intervalStack().position('percent').color('item').style({
lineWidth: 1,
stroke: '#fff'
});
chart.render();
const popup = new L7.Popup({anchor:'left'}).setText(item.name);
const marker = new L7.Marker({color:'blue', element:el})
.setLnglat( item.coordinates)
.setPopup(popup)
.addTo(scene);
})
})
});
</script>
</body>
</html>

View File

@ -57,12 +57,12 @@
"geometry": {
"type": "LineString",
"coordinates": [
[120.294931, 30.224459],
[120.194847, 30.224384],
[120.294931, 30.224459],[120.294931, 30.224459],
[120.194847, 30.224384],[120.194847, 30.224384],[120.194847, 30.224384],
[120.294847, 30.274384],
[120.344847, 30.34384],
[120.364847, 30.374384],
[120.364847, 30.074384],
[120.364847, 30.074384],[120.364847, 30.074384],[120.364847, 30.074384],
]
}
}, {
@ -73,7 +73,9 @@
"coordinates": [
[120.394931, 30.324459],
[120.494847, 30.324384],
[120.494847, 30.374384],
[120.494847, 30.324384],[120.494847, 30.324384],
[120.45, 30.324384],
[120.45, 30.374384],
]
}
}]
@ -92,7 +94,19 @@
patternSpacing: 20
})
.render();
$.get('https://gw.alipayobjects.com/os/basement_prod/3ed18d7c-bce4-48ca-8716-5248b584481d.json', data => {
const linelayer = scene.LineLayer({
zIndex: 2
}).shape('line')
.size([10, 0])
.source(data)
.color('#fff')
.pattern('right')
.style({
patternSpacing: 20
})
.render();
})
})
</script>
</body>

View File

@ -31,16 +31,23 @@ const scene = new L7.Scene({
maxZoom: 18
});
scene.on('loaded', () => {
$.get('https://gw.alipayobjects.com/os/rmsportal/kNDVHmyUWAKhWmWXmjxM.json', data => {
$.get('https://gw.alipayobjects.com/os/basement_prod/40ef2173-df66-4154-a8c0-785e93a5f18e.json', data => {
scene.LineLayer({
zIndex: 2
})
.source(data)
//.color('#F08D41')
.size([2, 0])
.shape('line')
.color('#ff893a')
.animate({enable:true})
//.render();
.animate({
enable:true,
interval:0.2,
duration:5,
trailLength:0.1
})
.render();
});
$.get('https://gw.alipayobjects.com/os/rmsportal/vmvAxgsEwbpoSWbSYvix.json', data => {
buildLayer = scene.PolygonLayer({
zIndex: 2

86
demos/text.html Normal file
View File

@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="geometry" content="diagram">
<link rel="stylesheet" href="./assets/common.css">
<title>text layer</title>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/dat.gui.min.js"></script>
<script src="../build/L7.js"></script>
<script>
const scene = new L7.Scene({
id: 'map',
mapStyle: 'dark', // 样式URL
center: [ 120.19382669582967, 30.258134 ],
pitch: 0,
zoom: 10
});
window.scene = scene;
scene.on('loaded', () => {
$.get('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json', data => {
scene.PointLayer({
zIndex: 3
})
.source(data.list, {
parser:{
type: 'json',
x: 'j',
y: 'w',
}
})
.shape('circle')
.active(true)
.size(3)
.color('#CFF6FF')
.style({
stroke: '#999',
strokeWidth: 1,
opacity: 1.0
})
.render();
scene.TextLayer({
zIndex: 5
})
.source(data.list, {
parser:{
type: 'json',
x: 'j',
y: 'w',
}
})
.shape('m', 'text')
.active(true)
.size('w', [ 10, 20, 24 ])
.color('#F27049')
.style({
// fontFamily: 'Monaco, monospace', // 字体
fontWeight: 200,
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [ 0, 0 ], // 文本相对锚点的偏移量 [水平, 垂直]
spacing: 2, // 字符间距
padding: [ 4, 4 ], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
strokeColor: 'white', // 描边颜色
strokeWidth: 1, // 描边宽度
opacity: 1.0
})
.render();
});
});
</script>
</body>
</html>

View File

@ -25,7 +25,7 @@
const scene = new L7.Scene({
id: 'map',
mapStyle: 'light', // 样式URL
mapStyle: 'dark', // 样式URL
center: [104.838088,34.075889 ],
pitch: 0,
hash:false,
@ -42,7 +42,7 @@ scene.on('loaded', () => {
attributeCtr.addTo(scene);
scene.addTileSource('test',{
url:'http://127.0.0.1:8080/{z}/{x}/{y}.pbf',
url:' https://mvt.amap.com/district/CHN2/{z}/{x}/{y}/4096?key=608d75903d29ad471362f8c58c550daf',
type:'vector',
minZoom: 0,
maxZoom:9
@ -54,8 +54,8 @@ scene.on('loaded', () => {
.source('test',{
parser:{
type: 'mvt',
sourceLayer:'boundaries_admin_3',
idField:'id'
sourceLayer:'CHN_Cities',
idField:'adcode'
}
})
.shape('fill')
@ -70,20 +70,21 @@ scene.on('loaded', () => {
const { lnglat, feature } = e;
const popup = new L7.Popup()
.setLnglat([lnglat.lng, lnglat.lat])
.setHTML(feature.properties.id).addTo(scene);
.setHTML(feature.properties.NAME_CHN.toString()).addTo(scene);
})
const layer2 = scene.PolygonLayer({
const layer2 = scene.LineLayer({
zIndex:10,
})
.source('test',{
parser:{
type: 'mvt',
sourceLayer:'boundaries_admin_3',
idField:'id'
sourceLayer:'CHN_L',
idField:'adcode'
}
})
.shape('line')
.size(1)
.size(2)
.active(false)
.color('#fff')
.style({
@ -91,6 +92,7 @@ scene.on('loaded', () => {
})
.render();
/**
const layer3 = scene.PointLayer({
zIndex:10,
})
@ -109,11 +111,18 @@ scene.on('loaded', () => {
opacity:1.0
})
.render();
**/
const overlayers = {
"行政区划": layer,
"标注": layer3,
"行政区边界": layer2,
};
const layerContr = new L7.Control.Layers({overlayers}).addTo(scene);
const popup = new L7.Popup({anchor:'left'}).setText('hello world')
const marker = new L7.Marker({color:'blue'})
.setLnglat([104.838088,34.075889 ])
.setPopup(popup)
.addTo(scene);
});

View File

View File

@ -1,257 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _colorUtil = _interopRequireDefault(require("./color-util"));
var _util = _interopRequireDefault(require("../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function toScaleString(scale, value) {
if (_util["default"].isString(value)) {
return value;
}
return scale.invert(scale.scale(value));
}
/**
* 所有视觉通道属性的基类
* @class Attr
*/
var AttributeBase =
/*#__PURE__*/
function () {
function AttributeBase(cfg) {
_classCallCheck(this, AttributeBase);
/**
* 属性的类型
* @type {String}
*/
this.type = 'base';
/**
* 属性的名称
* @type {String}
*/
this.name = null;
/**
* 回调函数
* @type {Function}
*/
this.method = null;
/**
* 备选的值数组
* @type {Array}
*/
this.values = [];
/**
* 属性内部的度量
* @type {Array}
*/
this.scales = [];
/**
* 是否通过线性取值, 如果未指定则根据数值的类型判定
* @type {Boolean}
*/
this.linear = null;
_util["default"].mix(this, cfg);
}
_createClass(AttributeBase, [{
key: "get",
value: function get(name) {
return this[name];
}
}, {
key: "set",
value: function set(name, value) {
this[name] = value;
} // 获取属性值,将值映射到视觉通道
}, {
key: "_getAttrValue",
value: function _getAttrValue(scale, value) {
var values = this.values;
if (scale.isCategory && !this.linear) {
var index = scale.translate(value);
return values[index % values.length];
}
var percent = scale.scale(value);
return this.getLinearValue(percent);
}
/**
* 如果进行线性映射返回对应的映射值
* @protected
* @param {Number} percent 百分比
* @return {*} 颜色值形状大小等
*/
}, {
key: "getLinearValue",
value: function getLinearValue(percent) {
var values = this.values;
var steps = values.length - 1;
var step = Math.floor(steps * percent);
var leftPercent = steps * percent - step;
var start = values[step];
var end = step === steps ? start : values[step + 1];
var rstValue = start + (end - start) * leftPercent;
return rstValue;
}
/**
* 默认的回调函数
* @param {*} value 回调函数的值
* @type {Function}
* @return {Array} 返回映射后的值
*/
}, {
key: "callback",
value: function callback(value) {
var self = this;
var scale = self.scales[0];
var rstValue = null;
if (scale.type === 'identity') {
rstValue = scale.value;
} else {
rstValue = self._getAttrValue(scale, value);
}
return rstValue;
}
/**
* 根据度量获取属性名
* @return {Array} dims of this Attribute
*/
}, {
key: "getNames",
value: function getNames() {
var scales = this.scales;
var names = this.names;
var length = Math.min(scales.length, names.length);
var rst = [];
for (var i = 0; i < length; i++) {
rst.push(names[i]);
}
return rst;
}
/**
* 根据度量获取维度名
* @return {Array} dims of this Attribute
*/
}, {
key: "getFields",
value: function getFields() {
var scales = this.scales;
var rst = [];
_util["default"].each(scales, function (scale) {
rst.push(scale.field);
});
return rst;
}
/**
* 根据名称获取度量
* @param {String} name the name of scale
* @return {Scale} scale
*/
}, {
key: "getScale",
value: function getScale(name) {
var scales = this.scales;
var names = this.names;
var index = names.indexOf(name);
return scales[index];
}
/**
* 映射数据
* @param {*} param1...paramn 多个数值
* @return {Array} 映射的值组成的数组
*/
}, {
key: "mapping",
value: function mapping() {
var scales = this.scales;
var callback = this.callback;
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
params[_key] = arguments[_key];
}
var values = params;
if (callback) {
for (var i = 0; i < params.length; i++) {
params[i] = this._toOriginParam(params[i], scales[i]);
}
values = callback.apply(this, params);
}
if (this.type === 'color' && !_util["default"].isArray(values)) {
values = _colorUtil["default"].toRGB(values).map(function (e) {
return e / 255;
}); // values[3] = values[3] * 255;
}
if (!_util["default"].isArray(values)) {
values = [values];
}
return values;
} // 原始的参数
}, {
key: "_toOriginParam",
value: function _toOriginParam(param, scale) {
var rst = param;
if (!scale.isLinear) {
if (_util["default"].isArray(param)) {
rst = [];
for (var i = 0; i < param.length; i++) {
rst.push(toScaleString(scale, param[i]));
}
} else {
rst = toScaleString(scale, param);
}
}
return rst;
}
}]);
return AttributeBase;
}();
var _default = AttributeBase;
exports["default"] = _default;

View File

@ -1,282 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/**
* @fileOverview 颜色计算的辅助方法
* @author dxq613@gmail.com
*/
var RGB_REG = /rgba?\(([\s.,0-9]+)\)/;
var ColorKeywords = {
aliceblue: '#F0F8FF',
antiquewhite: '#FAEBD7',
aqua: '#00FFFF',
aquamarine: '#7FFFD4',
azure: '#F0FFFF',
beige: '#F5F5DC',
bisque: '#FFE4C4',
black: '#000000',
blanchedalmond: '#FFEBCD',
blue: '#0000FF',
blueviolet: '#8A2BE2',
brown: '#A52A2A',
burlywood: '#DEB887',
cadetblue: '#5F9EA0',
chartreuse: '#7FFF00',
chocolate: '#D2691E',
coral: '#FF7F50',
cornflowerblue: '#6495ED',
cornsilk: '#FFF8DC',
crimson: '#DC143C',
cyan: '#00FFFF',
darkblue: '#00008B',
darkcyan: '#008B8B',
darkgoldenrod: '#B8860B',
darkgray: '#A9A9A9',
darkgreen: '#006400',
darkgrey: '#A9A9A9',
darkkhaki: '#BDB76B',
darkmagenta: '#8B008B',
darkolivegreen: '#556B2F',
darkorange: '#FF8C00',
darkorchid: '#9932CC',
darkred: '#8B0000',
darksalmon: '#E9967A',
darkseagreen: '#8FBC8F',
darkslateblue: '#483D8B',
darkslategray: '#2F4F4F',
darkslategrey: '#2F4F4F',
darkturquoise: '#00CED1',
darkviolet: '#9400D3',
deeppink: '#FF1493',
deepskyblue: '#00BFFF',
dimgray: '#696969',
dimgrey: '#696969',
dodgerblue: '#1E90FF',
firebrick: '#B22222',
floralwhite: '#FFFAF0',
forestgreen: '#228B22',
fuchsia: '#FF00FF',
gainsboro: '#DCDCDC',
ghostwhite: '#F8F8FF',
gold: '#FFD700',
goldenrod: '#DAA520',
gray: '#808080',
green: '#008000',
greenyellow: '#ADFF2F',
grey: '#808080',
honeydew: '#F0FFF0',
hotpink: '#FF69B4',
indianred: '#CD5C5C',
indigo: '#4B0082',
ivory: '#FFFFF0',
khaki: '#F0E68C',
lavender: '#E6E6FA',
lavenderblush: '#FFF0F5',
lawngreen: '#7CFC00',
lemonchiffon: '#FFFACD',
lightblue: '#ADD8E6',
lightcoral: '#F08080',
lightcyan: '#E0FFFF',
lightgoldenrodyellow: '#FAFAD2',
lightgray: '#D3D3D3',
lightgreen: '#90EE90',
lightgrey: '#D3D3D3',
lightpink: '#FFB6C1',
lightsalmon: '#FFA07A',
lightseagreen: '#20B2AA',
lightskyblue: '#87CEFA',
lightslategray: '#778899',
lightslategrey: '#778899',
lightsteelblue: '#B0C4DE',
lightyellow: '#FFFFE0',
lime: '#00FF00',
limegreen: '#32CD32',
linen: '#FAF0E6',
magenta: '#FF00FF',
maroon: '#800000',
mediumaquamarine: '#66CDAA',
mediumblue: '#0000CD',
mediumorchid: '#BA55D3',
mediumpurple: '#9370DB',
mediumseagreen: '#3CB371',
mediumslateblue: '#7B68EE',
mediumspringgreen: '#00FA9A',
mediumturquoise: '#48D1CC',
mediumvioletred: '#C71585',
midnightblue: '#191970',
mintcream: '#F5FFFA',
mistyrose: '#FFE4E1',
moccasin: '#FFE4B5',
navajowhite: '#FFDEAD',
navy: '#000080',
oldlace: '#FDF5E6',
olive: '#808000',
olivedrab: '#6B8E23',
orange: '#FFA500',
orangered: '#FF4500',
orchid: '#DA70D6',
palegoldenrod: '#EEE8AA',
palegreen: '#98FB98',
paleturquoise: '#AFEEEE',
palevioletred: '#DB7093',
papayawhip: '#FFEFD5',
peachpuff: '#FFDAB9',
peru: '#CD853F',
pink: '#FFC0CB',
plum: '#DDA0DD',
powderblue: '#B0E0E6',
purple: '#800080',
rebeccapurple: '#663399',
red: '#FF0000',
rosybrown: '#BC8F8F',
royalblue: '#4169E1',
saddlebrown: '#8B4513',
salmon: '#FA8072',
sandybrown: '#F4A460',
seagreen: '#2E8B57',
seashell: '#FFF5EE',
sienna: '#A0522D',
silver: '#C0C0C0',
skyblue: '#87CEEB',
slateblue: '#6A5ACD',
slategray: '#708090',
slategrey: '#708090',
snow: '#FFFAFA',
springgreen: '#00FF7F',
steelblue: '#4682B4',
tan: '#D2B48C',
teal: '#008080',
thistle: '#D8BFD8',
tomato: '#FF6347',
turquoise: '#40E0D0',
violet: '#EE82EE',
wheat: '#F5DEB3',
white: '#FFFFFF',
whitesmoke: '#F5F5F5',
yellow: '#FFFF00',
yellowgreen: '#9ACD32'
}; // 获取颜色之间的插值
function getValue(start, end, percent, index) {
var value = start[index] + (end[index] - start[index]) * percent;
return value;
}
function calColor(colors, percent) {
if (_util["default"].isNaN(percent) || !_util["default"].isNumber(percent)) {
percent = 0;
}
var steps = colors.length - 1;
var step = Math.floor(steps * percent);
var left = steps * percent - step;
var start = colors[step];
var end = step === steps ? start : colors[step + 1];
return [getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2), getValue(start, end, left, 3)];
} // rgb 颜色转换成数组
function rgb2arr(str) {
var arr = [];
if (str.length === 4) {
str = "#".concat(str[1]).concat(str[1]).concat(str[2]).concat(str[2]).concat(str[3]).concat(str[3]);
}
arr.push(parseInt(str.substr(1, 2), 16));
arr.push(parseInt(str.substr(3, 2), 16));
arr.push(parseInt(str.substr(5, 2), 16));
return arr;
}
var colorCache = {};
var ColorUtil = {
/**
* 将颜色转换到 rgb 的格式
* @param {String} color 颜色
* @return {String} 将颜色转换到 '#ffffff' 的格式
*/
toRGB: function toRGB(color) {
// 如果已经是 rgb的格式
var colorArray = [255, 255, 255, 255];
if (ColorKeywords[color]) {
// color name 2 hex
var hexColor = ColorKeywords[color];
colorArray = rgb2arr(hexColor);
colorArray.push(255.0);
}
if (color[0] === '#' && (color.length === 7 || color.length === 4)) {
// hex2array
colorArray = rgb2arr(color);
colorArray.push(255.0);
return colorArray;
}
if (RGB_REG.test(color)) {
var matchs = RGB_REG.exec(color);
colorArray = matchs[1].split(/\s*,\s*/);
if (colorArray.length === 4) {
colorArray[3] *= 255;
}
if (colorArray.length === 3) {
colorArray.push(255.0);
}
}
colorCache[color] = colorArray;
return colorArray;
},
// 转成 WebGl color buffer
color2Arr: function color2Arr(str) {
var rgba = this.toRGB(str);
return rgba.map(function (v) {
return v / 255;
});
},
colorArray2RGBA: function colorArray2RGBA(arr) {
return "rgba(".concat(arr[0] * 255, ",").concat(arr[1] * 255, ",").concat(arr[2] * 255, ",").concat(arr[3], ")");
},
color2RGBA: function color2RGBA(str) {
return this.color2Arr(str);
},
rgb2arr: rgb2arr,
/**
* 获取渐变函数
* @param {Array} colors 多个颜色
* @return {String} 颜色值
*/
gradient: function gradient(colors) {
var points = [];
if (_util["default"].isString(colors)) {
colors = colors.split('-');
}
_util["default"].each(colors, function (color) {
var colorArray = ColorUtil.toRGB(color).map(function (e) {
return e / 255;
}); // colorArray[3] = colorArray[3] * 255;
points.push(colorArray);
});
return function (percent) {
return calColor(points, percent);
};
}
};
var _default = ColorUtil;
exports["default"] = _default;

View File

@ -1,84 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _colorUtil = _interopRequireDefault(require("./color-util"));
var _base = _interopRequireDefault(require("./base"));
var _util = _interopRequireDefault(require("../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 视觉通道 color
* @class Attr.Color
*/
var Color =
/*#__PURE__*/
function (_Base) {
_inherits(Color, _Base);
function Color(cfg) {
var _this;
_classCallCheck(this, Color);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Color).call(this, cfg));
_this.names = ['color'];
_this.type = 'color';
_this.gradient = null;
if (_util["default"].isString(_this.values)) {
_this.linear = true;
}
return _this;
}
/**
* @override
*/
_createClass(Color, [{
key: "getLinearValue",
value: function getLinearValue(percent) {
var gradient = this.gradient;
if (!gradient) {
var values = this.values;
gradient = _colorUtil["default"].gradient(values);
this.gradient = gradient;
}
var color = gradient(percent);
return color;
}
}]);
return Color;
}(_base["default"]);
var _default = Color;
exports["default"] = _default;

View File

@ -1,107 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.colorScales = void 0;
// code from https://github.com/santilland/plotty/blob/master/src/colorscales.js
var colorScales = {
viridis: new Uint8Array([68, 1, 84, 255, 68, 2, 86, 255, 69, 4, 87, 255, 69, 5, 89, 255, 70, 7, 90, 255, 70, 8, 92, 255, 70, 10, 93, 255, 70, 11, 94, 255, 71, 13, 96, 255, 71, 14, 97, 255, 71, 16, 99, 255, 71, 17, 100, 255, 71, 19, 101, 255, 72, 20, 103, 255, 72, 22, 104, 255, 72, 23, 105, 255, 72, 24, 106, 255, 72, 26, 108, 255, 72, 27, 109, 255, 72, 28, 110, 255, 72, 29, 111, 255, 72, 31, 112, 255, 72, 32, 113, 255, 72, 33, 115, 255, 72, 35, 116, 255, 72, 36, 117, 255, 72, 37, 118, 255, 72, 38, 119, 255, 72, 40, 120, 255, 72, 41, 121, 255, 71, 42, 122, 255, 71, 44, 122, 255, 71, 45, 123, 255, 71, 46, 124, 255, 71, 47, 125, 255, 70, 48, 126, 255, 70, 50, 126, 255, 70, 51, 127, 255, 70, 52, 128, 255, 69, 53, 129, 255, 69, 55, 129, 255, 69, 56, 130, 255, 68, 57, 131, 255, 68, 58, 131, 255, 68, 59, 132, 255, 67, 61, 132, 255, 67, 62, 133, 255, 66, 63, 133, 255, 66, 64, 134, 255, 66, 65, 134, 255, 65, 66, 135, 255, 65, 68, 135, 255, 64, 69, 136, 255, 64, 70, 136, 255, 63, 71, 136, 255, 63, 72, 137, 255, 62, 73, 137, 255, 62, 74, 137, 255, 62, 76, 138, 255, 61, 77, 138, 255, 61, 78, 138, 255, 60, 79, 138, 255, 60, 80, 139, 255, 59, 81, 139, 255, 59, 82, 139, 255, 58, 83, 139, 255, 58, 84, 140, 255, 57, 85, 140, 255, 57, 86, 140, 255, 56, 88, 140, 255, 56, 89, 140, 255, 55, 90, 140, 255, 55, 91, 141, 255, 54, 92, 141, 255, 54, 93, 141, 255, 53, 94, 141, 255, 53, 95, 141, 255, 52, 96, 141, 255, 52, 97, 141, 255, 51, 98, 141, 255, 51, 99, 141, 255, 50, 100, 142, 255, 50, 101, 142, 255, 49, 102, 142, 255, 49, 103, 142, 255, 49, 104, 142, 255, 48, 105, 142, 255, 48, 106, 142, 255, 47, 107, 142, 255, 47, 108, 142, 255, 46, 109, 142, 255, 46, 110, 142, 255, 46, 111, 142, 255, 45, 112, 142, 255, 45, 113, 142, 255, 44, 113, 142, 255, 44, 114, 142, 255, 44, 115, 142, 255, 43, 116, 142, 255, 43, 117, 142, 255, 42, 118, 142, 255, 42, 119, 142, 255, 42, 120, 142, 255, 41, 121, 142, 255, 41, 122, 142, 255, 41, 123, 142, 255, 40, 124, 142, 255, 40, 125, 142, 255, 39, 126, 142, 255, 39, 127, 142, 255, 39, 128, 142, 255, 38, 129, 142, 255, 38, 130, 142, 255, 38, 130, 142, 255, 37, 131, 142, 255, 37, 132, 142, 255, 37, 133, 142, 255, 36, 134, 142, 255, 36, 135, 142, 255, 35, 136, 142, 255, 35, 137, 142, 255, 35, 138, 141, 255, 34, 139, 141, 255, 34, 140, 141, 255, 34, 141, 141, 255, 33, 142, 141, 255, 33, 143, 141, 255, 33, 144, 141, 255, 33, 145, 140, 255, 32, 146, 140, 255, 32, 146, 140, 255, 32, 147, 140, 255, 31, 148, 140, 255, 31, 149, 139, 255, 31, 150, 139, 255, 31, 151, 139, 255, 31, 152, 139, 255, 31, 153, 138, 255, 31, 154, 138, 255, 30, 155, 138, 255, 30, 156, 137, 255, 30, 157, 137, 255, 31, 158, 137, 255, 31, 159, 136, 255, 31, 160, 136, 255, 31, 161, 136, 255, 31, 161, 135, 255, 31, 162, 135, 255, 32, 163, 134, 255, 32, 164, 134, 255, 33, 165, 133, 255, 33, 166, 133, 255, 34, 167, 133, 255, 34, 168, 132, 255, 35, 169, 131, 255, 36, 170, 131, 255, 37, 171, 130, 255, 37, 172, 130, 255, 38, 173, 129, 255, 39, 173, 129, 255, 40, 174, 128, 255, 41, 175, 127, 255, 42, 176, 127, 255, 44, 177, 126, 255, 45, 178, 125, 255, 46, 179, 124, 255, 47, 180, 124, 255, 49, 181, 123, 255, 50, 182, 122, 255, 52, 182, 121, 255, 53, 183, 121, 255, 55, 184, 120, 255, 56, 185, 119, 255, 58, 186, 118, 255, 59, 187, 117, 255, 61, 188, 116, 255, 63, 188, 115, 255, 64, 189, 114, 255, 66, 190, 113, 255, 68, 191, 112, 255, 70, 192, 111, 255, 72, 193, 110, 255, 74, 193, 109, 255, 76, 194, 108, 255, 78, 195, 107, 255, 80, 196, 106, 255, 82, 197, 105, 255, 84, 197, 104, 255, 86, 198, 103, 255, 88, 199, 101, 255, 90, 200, 100, 255, 92, 200, 99, 255, 94, 201, 98, 255, 96, 202, 96, 255, 99, 203, 95, 255, 101, 203, 94, 255, 103, 204, 92, 255, 105, 205, 91, 255, 108, 205, 90, 255, 110, 206, 88, 255, 112, 207, 87, 255, 115, 208, 86, 255, 117, 208, 84, 255, 119, 209, 83, 255, 122, 209, 81, 255, 124, 210, 80, 255, 127, 211, 78, 255, 129, 211, 77, 255, 132, 212, 75, 255, 134, 213, 73, 255, 137, 213, 72, 255, 139, 214, 70, 255, 142, 214, 69, 255, 144, 215, 67, 255, 147, 215, 65, 255, 149, 216, 64, 255, 152, 216, 62, 255, 155, 217, 60, 255, 157, 217, 59, 255, 160, 218, 57, 255, 162, 218, 55, 255, 165, 219, 54, 255, 168, 219, 52, 255, 170, 220, 50, 255, 173, 220, 48, 255, 176, 221, 47, 255, 178, 221, 45, 255, 181, 222, 43, 255, 184, 222, 41, 255, 186, 222, 40, 255, 189, 223, 38, 255, 192, 223, 37, 255, 194, 223, 35, 255, 197, 224, 33, 255, 200, 224, 32, 255, 202, 225, 31, 255, 205, 225, 29, 255, 208, 225, 28, 255, 210, 226, 27, 255, 213, 226, 26, 255, 216, 226, 25, 255, 218, 227, 25, 255, 221, 227, 24, 255, 223, 227, 24, 255, 226, 228, 24, 255, 229, 228, 25, 255, 231, 228, 25, 255, 234, 229, 26, 255, 236, 229, 27, 255, 239, 229, 28, 255, 241, 229, 29, 255, 244, 230, 30, 255, 246, 230, 32, 255, 248, 230, 33, 255, 251, 231, 35, 255, 253, 231, 37, 255]),
inferno: new Uint8Array([0, 0, 4, 255, 1, 0, 5, 255, 1, 1, 6, 255, 1, 1, 8, 255, 2, 1, 10, 255, 2, 2, 12, 255, 2, 2, 14, 255, 3, 2, 16, 255, 4, 3, 18, 255, 4, 3, 20, 255, 5, 4, 23, 255, 6, 4, 25, 255, 7, 5, 27, 255, 8, 5, 29, 255, 9, 6, 31, 255, 10, 7, 34, 255, 11, 7, 36, 255, 12, 8, 38, 255, 13, 8, 41, 255, 14, 9, 43, 255, 16, 9, 45, 255, 17, 10, 48, 255, 18, 10, 50, 255, 20, 11, 52, 255, 21, 11, 55, 255, 22, 11, 57, 255, 24, 12, 60, 255, 25, 12, 62, 255, 27, 12, 65, 255, 28, 12, 67, 255, 30, 12, 69, 255, 31, 12, 72, 255, 33, 12, 74, 255, 35, 12, 76, 255, 36, 12, 79, 255, 38, 12, 81, 255, 40, 11, 83, 255, 41, 11, 85, 255, 43, 11, 87, 255, 45, 11, 89, 255, 47, 10, 91, 255, 49, 10, 92, 255, 50, 10, 94, 255, 52, 10, 95, 255, 54, 9, 97, 255, 56, 9, 98, 255, 57, 9, 99, 255, 59, 9, 100, 255, 61, 9, 101, 255, 62, 9, 102, 255, 64, 10, 103, 255, 66, 10, 104, 255, 68, 10, 104, 255, 69, 10, 105, 255, 71, 11, 106, 255, 73, 11, 106, 255, 74, 12, 107, 255, 76, 12, 107, 255, 77, 13, 108, 255, 79, 13, 108, 255, 81, 14, 108, 255, 82, 14, 109, 255, 84, 15, 109, 255, 85, 15, 109, 255, 87, 16, 110, 255, 89, 16, 110, 255, 90, 17, 110, 255, 92, 18, 110, 255, 93, 18, 110, 255, 95, 19, 110, 255, 97, 19, 110, 255, 98, 20, 110, 255, 100, 21, 110, 255, 101, 21, 110, 255, 103, 22, 110, 255, 105, 22, 110, 255, 106, 23, 110, 255, 108, 24, 110, 255, 109, 24, 110, 255, 111, 25, 110, 255, 113, 25, 110, 255, 114, 26, 110, 255, 116, 26, 110, 255, 117, 27, 110, 255, 119, 28, 109, 255, 120, 28, 109, 255, 122, 29, 109, 255, 124, 29, 109, 255, 125, 30, 109, 255, 127, 30, 108, 255, 128, 31, 108, 255, 130, 32, 108, 255, 132, 32, 107, 255, 133, 33, 107, 255, 135, 33, 107, 255, 136, 34, 106, 255, 138, 34, 106, 255, 140, 35, 105, 255, 141, 35, 105, 255, 143, 36, 105, 255, 144, 37, 104, 255, 146, 37, 104, 255, 147, 38, 103, 255, 149, 38, 103, 255, 151, 39, 102, 255, 152, 39, 102, 255, 154, 40, 101, 255, 155, 41, 100, 255, 157, 41, 100, 255, 159, 42, 99, 255, 160, 42, 99, 255, 162, 43, 98, 255, 163, 44, 97, 255, 165, 44, 96, 255, 166, 45, 96, 255, 168, 46, 95, 255, 169, 46, 94, 255, 171, 47, 94, 255, 173, 48, 93, 255, 174, 48, 92, 255, 176, 49, 91, 255, 177, 50, 90, 255, 179, 50, 90, 255, 180, 51, 89, 255, 182, 52, 88, 255, 183, 53, 87, 255, 185, 53, 86, 255, 186, 54, 85, 255, 188, 55, 84, 255, 189, 56, 83, 255, 191, 57, 82, 255, 192, 58, 81, 255, 193, 58, 80, 255, 195, 59, 79, 255, 196, 60, 78, 255, 198, 61, 77, 255, 199, 62, 76, 255, 200, 63, 75, 255, 202, 64, 74, 255, 203, 65, 73, 255, 204, 66, 72, 255, 206, 67, 71, 255, 207, 68, 70, 255, 208, 69, 69, 255, 210, 70, 68, 255, 211, 71, 67, 255, 212, 72, 66, 255, 213, 74, 65, 255, 215, 75, 63, 255, 216, 76, 62, 255, 217, 77, 61, 255, 218, 78, 60, 255, 219, 80, 59, 255, 221, 81, 58, 255, 222, 82, 56, 255, 223, 83, 55, 255, 224, 85, 54, 255, 225, 86, 53, 255, 226, 87, 52, 255, 227, 89, 51, 255, 228, 90, 49, 255, 229, 92, 48, 255, 230, 93, 47, 255, 231, 94, 46, 255, 232, 96, 45, 255, 233, 97, 43, 255, 234, 99, 42, 255, 235, 100, 41, 255, 235, 102, 40, 255, 236, 103, 38, 255, 237, 105, 37, 255, 238, 106, 36, 255, 239, 108, 35, 255, 239, 110, 33, 255, 240, 111, 32, 255, 241, 113, 31, 255, 241, 115, 29, 255, 242, 116, 28, 255, 243, 118, 27, 255, 243, 120, 25, 255, 244, 121, 24, 255, 245, 123, 23, 255, 245, 125, 21, 255, 246, 126, 20, 255, 246, 128, 19, 255, 247, 130, 18, 255, 247, 132, 16, 255, 248, 133, 15, 255, 248, 135, 14, 255, 248, 137, 12, 255, 249, 139, 11, 255, 249, 140, 10, 255, 249, 142, 9, 255, 250, 144, 8, 255, 250, 146, 7, 255, 250, 148, 7, 255, 251, 150, 6, 255, 251, 151, 6, 255, 251, 153, 6, 255, 251, 155, 6, 255, 251, 157, 7, 255, 252, 159, 7, 255, 252, 161, 8, 255, 252, 163, 9, 255, 252, 165, 10, 255, 252, 166, 12, 255, 252, 168, 13, 255, 252, 170, 15, 255, 252, 172, 17, 255, 252, 174, 18, 255, 252, 176, 20, 255, 252, 178, 22, 255, 252, 180, 24, 255, 251, 182, 26, 255, 251, 184, 29, 255, 251, 186, 31, 255, 251, 188, 33, 255, 251, 190, 35, 255, 250, 192, 38, 255, 250, 194, 40, 255, 250, 196, 42, 255, 250, 198, 45, 255, 249, 199, 47, 255, 249, 201, 50, 255, 249, 203, 53, 255, 248, 205, 55, 255, 248, 207, 58, 255, 247, 209, 61, 255, 247, 211, 64, 255, 246, 213, 67, 255, 246, 215, 70, 255, 245, 217, 73, 255, 245, 219, 76, 255, 244, 221, 79, 255, 244, 223, 83, 255, 244, 225, 86, 255, 243, 227, 90, 255, 243, 229, 93, 255, 242, 230, 97, 255, 242, 232, 101, 255, 242, 234, 105, 255, 241, 236, 109, 255, 241, 237, 113, 255, 241, 239, 117, 255, 241, 241, 121, 255, 242, 242, 125, 255, 242, 244, 130, 255, 243, 245, 134, 255, 243, 246, 138, 255, 244, 248, 142, 255, 245, 249, 146, 255, 246, 250, 150, 255, 248, 251, 154, 255, 249, 252, 157, 255, 250, 253, 161, 255, 252, 255, 164, 255]),
rainbow: {
colors: ['#96005A', '#0000C8', '#0019FF', '#0098FF', '#2CFF96', '#97FF00', '#FFEA00', '#FF6F00', '#FF0000'],
positions: [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1]
},
jet: {
colors: ['#000083', '#003CAA', '#05FFFF', '#FFFF00', '#FA0000', '#800000'],
positions: [0, 0.125, 0.375, 0.625, 0.875, 1]
},
hsv: {
colors: ['#ff0000', '#fdff02', '#f7ff02', '#00fc04', '#00fc0a', '#01f9ff', '#0200fd', '#0800fd', '#ff00fb', '#ff00f5', '#ff0006'],
positions: [0, 0.169, 0.173, 0.337, 0.341, 0.506, 0.671, 0.675, 0.839, 0.843, 1]
},
hot: {
colors: ['#000000', '#e60000', '#ffd200', '#ffffff'],
positions: [0, 0.3, 0.6, 1]
},
cool: {
colors: ['#00ffff', '#ff00ff'],
positions: [0, 1]
},
spring: {
colors: ['#ff00ff', '#ffff00'],
positions: [0, 1]
},
summer: {
colors: ['#008066', '#ffff66'],
positions: [0, 1]
},
autumn: {
colors: ['#ff0000', '#ffff00'],
positions: [0, 1]
},
winter: {
colors: ['#0000ff', '#00ff80'],
positions: [0, 1]
},
bone: {
colors: ['#000000', '#545474', '#a9c8c8', '#ffffff'],
positions: [0, 0.376, 0.753, 1]
},
copper: {
colors: ['#000000', '#ffa066', '#ffc77f'],
positions: [0, 0.804, 1]
},
greys: {
colors: ['#000000', '#ffffff'],
positions: [0, 1]
},
yignbu: {
colors: ['#081d58', '#253494', '#225ea8', '#1d91c0', '#41b6c4', '#7fcdbb', '#c7e9b4', '#edf8d9', '#ffffd9'],
positions: [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1]
},
greens: {
colors: ['#00441b', '#006d2c', '#238b45', '#41ab5d', '#74c476', '#a1d99b', '#c7e9c0', '#e5f5e0', '#f7fcf5'],
positions: [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1]
},
wind: {
colors: ['#3288bd', '#66c2a5', '#abdda4', '#e6f598', '#fee08b', '#fdae61', '#f46d43', '#d53e4f'],
positions: [0, 0.1, 0.2, 0.6, 0.7, 0.8, 0.9, 1]
},
yiorrd: {
colors: ['#800026', '#bd0026', '#e31a1c', '#fc4e2a', '#fd8d3c', '#feb24c', '#fed976', '#ffeda0', '#ffffcc'],
positions: [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1]
},
bluered: {
colors: ['#0000ff', '#ff0000'],
positions: [0, 1]
},
rdbu: {
colors: ['#050aac', '#6a89f7', '#bebebe', '#dcaa84', '#e6915a', '#b20a1c'],
positions: [0, 0.35, 0.5, 0.6, 0.7, 1]
},
picnic: {
colors: ['#0000ff', '#3399ff', '#66ccff', '#99ccff', '#ccccff', '#ffffff', '#ffccff', '#ff99ff', '#ff66cc', '#ff6666', '#ff0000'],
positions: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
},
portland: {
colors: ['#0c3383', '#0a88ba', '#f2d338', '#f28f38', '#d91e1e'],
positions: [0, 0.25, 0.5, 0.75, 1]
},
blackbody: {
colors: ['#000000', '#e60000', '#e6d200', '#ffffff', '#a0c8ff'],
positions: [0, 0.2, 0.4, 0.7, 1]
},
earth: {
colors: ['#000082', '#00b4b4', '#28d228', '#e6e632', '#784614', '#ffffff'],
positions: [0, 0.1, 0.2, 0.4, 0.6, 1]
},
electric: {
colors: ['#000000', '#1e0064', '#780064', '#a05a00', '#e6c800', '#fffadc'],
positions: [0, 0.15, 0.4, 0.6, 0.8, 1]
},
magma: new Uint8Array([0, 0, 4, 255, 1, 0, 5, 255, 1, 1, 6, 255, 1, 1, 8, 255, 2, 1, 9, 255, 2, 2, 11, 255, 2, 2, 13, 255, 3, 3, 15, 255, 3, 3, 18, 255, 4, 4, 20, 255, 5, 4, 22, 255, 6, 5, 24, 255, 6, 5, 26, 255, 7, 6, 28, 255, 8, 7, 30, 255, 9, 7, 32, 255, 10, 8, 34, 255, 11, 9, 36, 255, 12, 9, 38, 255, 13, 10, 41, 255, 14, 11, 43, 255, 16, 11, 45, 255, 17, 12, 47, 255, 18, 13, 49, 255, 19, 13, 52, 255, 20, 14, 54, 255, 21, 14, 56, 255, 22, 15, 59, 255, 24, 15, 61, 255, 25, 16, 63, 255, 26, 16, 66, 255, 28, 16, 68, 255, 29, 17, 71, 255, 30, 17, 73, 255, 32, 17, 75, 255, 33, 17, 78, 255, 34, 17, 80, 255, 36, 18, 83, 255, 37, 18, 85, 255, 39, 18, 88, 255, 41, 17, 90, 255, 42, 17, 92, 255, 44, 17, 95, 255, 45, 17, 97, 255, 47, 17, 99, 255, 49, 17, 101, 255, 51, 16, 103, 255, 52, 16, 105, 255, 54, 16, 107, 255, 56, 16, 108, 255, 57, 15, 110, 255, 59, 15, 112, 255, 61, 15, 113, 255, 63, 15, 114, 255, 64, 15, 116, 255, 66, 15, 117, 255, 68, 15, 118, 255, 69, 16, 119, 255, 71, 16, 120, 255, 73, 16, 120, 255, 74, 16, 121, 255, 76, 17, 122, 255, 78, 17, 123, 255, 79, 18, 123, 255, 81, 18, 124, 255, 82, 19, 124, 255, 84, 19, 125, 255, 86, 20, 125, 255, 87, 21, 126, 255, 89, 21, 126, 255, 90, 22, 126, 255, 92, 22, 127, 255, 93, 23, 127, 255, 95, 24, 127, 255, 96, 24, 128, 255, 98, 25, 128, 255, 100, 26, 128, 255, 101, 26, 128, 255, 103, 27, 128, 255, 104, 28, 129, 255, 106, 28, 129, 255, 107, 29, 129, 255, 109, 29, 129, 255, 110, 30, 129, 255, 112, 31, 129, 255, 114, 31, 129, 255, 115, 32, 129, 255, 117, 33, 129, 255, 118, 33, 129, 255, 120, 34, 129, 255, 121, 34, 130, 255, 123, 35, 130, 255, 124, 35, 130, 255, 126, 36, 130, 255, 128, 37, 130, 255, 129, 37, 129, 255, 131, 38, 129, 255, 132, 38, 129, 255, 134, 39, 129, 255, 136, 39, 129, 255, 137, 40, 129, 255, 139, 41, 129, 255, 140, 41, 129, 255, 142, 42, 129, 255, 144, 42, 129, 255, 145, 43, 129, 255, 147, 43, 128, 255, 148, 44, 128, 255, 150, 44, 128, 255, 152, 45, 128, 255, 153, 45, 128, 255, 155, 46, 127, 255, 156, 46, 127, 255, 158, 47, 127, 255, 160, 47, 127, 255, 161, 48, 126, 255, 163, 48, 126, 255, 165, 49, 126, 255, 166, 49, 125, 255, 168, 50, 125, 255, 170, 51, 125, 255, 171, 51, 124, 255, 173, 52, 124, 255, 174, 52, 123, 255, 176, 53, 123, 255, 178, 53, 123, 255, 179, 54, 122, 255, 181, 54, 122, 255, 183, 55, 121, 255, 184, 55, 121, 255, 186, 56, 120, 255, 188, 57, 120, 255, 189, 57, 119, 255, 191, 58, 119, 255, 192, 58, 118, 255, 194, 59, 117, 255, 196, 60, 117, 255, 197, 60, 116, 255, 199, 61, 115, 255, 200, 62, 115, 255, 202, 62, 114, 255, 204, 63, 113, 255, 205, 64, 113, 255, 207, 64, 112, 255, 208, 65, 111, 255, 210, 66, 111, 255, 211, 67, 110, 255, 213, 68, 109, 255, 214, 69, 108, 255, 216, 69, 108, 255, 217, 70, 107, 255, 219, 71, 106, 255, 220, 72, 105, 255, 222, 73, 104, 255, 223, 74, 104, 255, 224, 76, 103, 255, 226, 77, 102, 255, 227, 78, 101, 255, 228, 79, 100, 255, 229, 80, 100, 255, 231, 82, 99, 255, 232, 83, 98, 255, 233, 84, 98, 255, 234, 86, 97, 255, 235, 87, 96, 255, 236, 88, 96, 255, 237, 90, 95, 255, 238, 91, 94, 255, 239, 93, 94, 255, 240, 95, 94, 255, 241, 96, 93, 255, 242, 98, 93, 255, 242, 100, 92, 255, 243, 101, 92, 255, 244, 103, 92, 255, 244, 105, 92, 255, 245, 107, 92, 255, 246, 108, 92, 255, 246, 110, 92, 255, 247, 112, 92, 255, 247, 114, 92, 255, 248, 116, 92, 255, 248, 118, 92, 255, 249, 120, 93, 255, 249, 121, 93, 255, 249, 123, 93, 255, 250, 125, 94, 255, 250, 127, 94, 255, 250, 129, 95, 255, 251, 131, 95, 255, 251, 133, 96, 255, 251, 135, 97, 255, 252, 137, 97, 255, 252, 138, 98, 255, 252, 140, 99, 255, 252, 142, 100, 255, 252, 144, 101, 255, 253, 146, 102, 255, 253, 148, 103, 255, 253, 150, 104, 255, 253, 152, 105, 255, 253, 154, 106, 255, 253, 155, 107, 255, 254, 157, 108, 255, 254, 159, 109, 255, 254, 161, 110, 255, 254, 163, 111, 255, 254, 165, 113, 255, 254, 167, 114, 255, 254, 169, 115, 255, 254, 170, 116, 255, 254, 172, 118, 255, 254, 174, 119, 255, 254, 176, 120, 255, 254, 178, 122, 255, 254, 180, 123, 255, 254, 182, 124, 255, 254, 183, 126, 255, 254, 185, 127, 255, 254, 187, 129, 255, 254, 189, 130, 255, 254, 191, 132, 255, 254, 193, 133, 255, 254, 194, 135, 255, 254, 196, 136, 255, 254, 198, 138, 255, 254, 200, 140, 255, 254, 202, 141, 255, 254, 204, 143, 255, 254, 205, 144, 255, 254, 207, 146, 255, 254, 209, 148, 255, 254, 211, 149, 255, 254, 213, 151, 255, 254, 215, 153, 255, 254, 216, 154, 255, 253, 218, 156, 255, 253, 220, 158, 255, 253, 222, 160, 255, 253, 224, 161, 255, 253, 226, 163, 255, 253, 227, 165, 255, 253, 229, 167, 255, 253, 231, 169, 255, 253, 233, 170, 255, 253, 235, 172, 255, 252, 236, 174, 255, 252, 238, 176, 255, 252, 240, 178, 255, 252, 242, 180, 255, 252, 244, 182, 255, 252, 246, 184, 255, 252, 247, 185, 255, 252, 249, 187, 255, 252, 251, 189, 255, 252, 253, 191, 255]),
plasma: new Uint8Array([13, 8, 135, 255, 16, 7, 136, 255, 19, 7, 137, 255, 22, 7, 138, 255, 25, 6, 140, 255, 27, 6, 141, 255, 29, 6, 142, 255, 32, 6, 143, 255, 34, 6, 144, 255, 36, 6, 145, 255, 38, 5, 145, 255, 40, 5, 146, 255, 42, 5, 147, 255, 44, 5, 148, 255, 46, 5, 149, 255, 47, 5, 150, 255, 49, 5, 151, 255, 51, 5, 151, 255, 53, 4, 152, 255, 55, 4, 153, 255, 56, 4, 154, 255, 58, 4, 154, 255, 60, 4, 155, 255, 62, 4, 156, 255, 63, 4, 156, 255, 65, 4, 157, 255, 67, 3, 158, 255, 68, 3, 158, 255, 70, 3, 159, 255, 72, 3, 159, 255, 73, 3, 160, 255, 75, 3, 161, 255, 76, 2, 161, 255, 78, 2, 162, 255, 80, 2, 162, 255, 81, 2, 163, 255, 83, 2, 163, 255, 85, 2, 164, 255, 86, 1, 164, 255, 88, 1, 164, 255, 89, 1, 165, 255, 91, 1, 165, 255, 92, 1, 166, 255, 94, 1, 166, 255, 96, 1, 166, 255, 97, 0, 167, 255, 99, 0, 167, 255, 100, 0, 167, 255, 102, 0, 167, 255, 103, 0, 168, 255, 105, 0, 168, 255, 106, 0, 168, 255, 108, 0, 168, 255, 110, 0, 168, 255, 111, 0, 168, 255, 113, 0, 168, 255, 114, 1, 168, 255, 116, 1, 168, 255, 117, 1, 168, 255, 119, 1, 168, 255, 120, 1, 168, 255, 122, 2, 168, 255, 123, 2, 168, 255, 125, 3, 168, 255, 126, 3, 168, 255, 128, 4, 168, 255, 129, 4, 167, 255, 131, 5, 167, 255, 132, 5, 167, 255, 134, 6, 166, 255, 135, 7, 166, 255, 136, 8, 166, 255, 138, 9, 165, 255, 139, 10, 165, 255, 141, 11, 165, 255, 142, 12, 164, 255, 143, 13, 164, 255, 145, 14, 163, 255, 146, 15, 163, 255, 148, 16, 162, 255, 149, 17, 161, 255, 150, 19, 161, 255, 152, 20, 160, 255, 153, 21, 159, 255, 154, 22, 159, 255, 156, 23, 158, 255, 157, 24, 157, 255, 158, 25, 157, 255, 160, 26, 156, 255, 161, 27, 155, 255, 162, 29, 154, 255, 163, 30, 154, 255, 165, 31, 153, 255, 166, 32, 152, 255, 167, 33, 151, 255, 168, 34, 150, 255, 170, 35, 149, 255, 171, 36, 148, 255, 172, 38, 148, 255, 173, 39, 147, 255, 174, 40, 146, 255, 176, 41, 145, 255, 177, 42, 144, 255, 178, 43, 143, 255, 179, 44, 142, 255, 180, 46, 141, 255, 181, 47, 140, 255, 182, 48, 139, 255, 183, 49, 138, 255, 184, 50, 137, 255, 186, 51, 136, 255, 187, 52, 136, 255, 188, 53, 135, 255, 189, 55, 134, 255, 190, 56, 133, 255, 191, 57, 132, 255, 192, 58, 131, 255, 193, 59, 130, 255, 194, 60, 129, 255, 195, 61, 128, 255, 196, 62, 127, 255, 197, 64, 126, 255, 198, 65, 125, 255, 199, 66, 124, 255, 200, 67, 123, 255, 201, 68, 122, 255, 202, 69, 122, 255, 203, 70, 121, 255, 204, 71, 120, 255, 204, 73, 119, 255, 205, 74, 118, 255, 206, 75, 117, 255, 207, 76, 116, 255, 208, 77, 115, 255, 209, 78, 114, 255, 210, 79, 113, 255, 211, 81, 113, 255, 212, 82, 112, 255, 213, 83, 111, 255, 213, 84, 110, 255, 214, 85, 109, 255, 215, 86, 108, 255, 216, 87, 107, 255, 217, 88, 106, 255, 218, 90, 106, 255, 218, 91, 105, 255, 219, 92, 104, 255, 220, 93, 103, 255, 221, 94, 102, 255, 222, 95, 101, 255, 222, 97, 100, 255, 223, 98, 99, 255, 224, 99, 99, 255, 225, 100, 98, 255, 226, 101, 97, 255, 226, 102, 96, 255, 227, 104, 95, 255, 228, 105, 94, 255, 229, 106, 93, 255, 229, 107, 93, 255, 230, 108, 92, 255, 231, 110, 91, 255, 231, 111, 90, 255, 232, 112, 89, 255, 233, 113, 88, 255, 233, 114, 87, 255, 234, 116, 87, 255, 235, 117, 86, 255, 235, 118, 85, 255, 236, 119, 84, 255, 237, 121, 83, 255, 237, 122, 82, 255, 238, 123, 81, 255, 239, 124, 81, 255, 239, 126, 80, 255, 240, 127, 79, 255, 240, 128, 78, 255, 241, 129, 77, 255, 241, 131, 76, 255, 242, 132, 75, 255, 243, 133, 75, 255, 243, 135, 74, 255, 244, 136, 73, 255, 244, 137, 72, 255, 245, 139, 71, 255, 245, 140, 70, 255, 246, 141, 69, 255, 246, 143, 68, 255, 247, 144, 68, 255, 247, 145, 67, 255, 247, 147, 66, 255, 248, 148, 65, 255, 248, 149, 64, 255, 249, 151, 63, 255, 249, 152, 62, 255, 249, 154, 62, 255, 250, 155, 61, 255, 250, 156, 60, 255, 250, 158, 59, 255, 251, 159, 58, 255, 251, 161, 57, 255, 251, 162, 56, 255, 252, 163, 56, 255, 252, 165, 55, 255, 252, 166, 54, 255, 252, 168, 53, 255, 252, 169, 52, 255, 253, 171, 51, 255, 253, 172, 51, 255, 253, 174, 50, 255, 253, 175, 49, 255, 253, 177, 48, 255, 253, 178, 47, 255, 253, 180, 47, 255, 253, 181, 46, 255, 254, 183, 45, 255, 254, 184, 44, 255, 254, 186, 44, 255, 254, 187, 43, 255, 254, 189, 42, 255, 254, 190, 42, 255, 254, 192, 41, 255, 253, 194, 41, 255, 253, 195, 40, 255, 253, 197, 39, 255, 253, 198, 39, 255, 253, 200, 39, 255, 253, 202, 38, 255, 253, 203, 38, 255, 252, 205, 37, 255, 252, 206, 37, 255, 252, 208, 37, 255, 252, 210, 37, 255, 251, 211, 36, 255, 251, 213, 36, 255, 251, 215, 36, 255, 250, 216, 36, 255, 250, 218, 36, 255, 249, 220, 36, 255, 249, 221, 37, 255, 248, 223, 37, 255, 248, 225, 37, 255, 247, 226, 37, 255, 247, 228, 37, 255, 246, 230, 38, 255, 246, 232, 38, 255, 245, 233, 38, 255, 245, 235, 39, 255, 244, 237, 39, 255, 243, 238, 39, 255, 243, 240, 39, 255, 242, 242, 39, 255, 241, 244, 38, 255, 241, 245, 37, 255, 240, 247, 36, 255, 240, 249, 33, 255])
}; // export default colorScales;
exports.colorScales = colorScales;

View File

@ -1,51 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 视觉通道 filter
* @class Attr.filter
*/
var Filter =
/*#__PURE__*/
function (_Base) {
_inherits(Filter, _Base);
function Filter(cfg) {
var _this;
_classCallCheck(this, Filter);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Filter).call(this, cfg));
_this.names = ['filter'];
_this.type = 'filter';
_this.gradient = null;
return _this;
}
return Filter;
}(_base["default"]);
var _default = Filter;
exports["default"] = _default;

View File

@ -1,37 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
var _color = _interopRequireDefault(require("./color"));
var _size = _interopRequireDefault(require("./size"));
var _opacity = _interopRequireDefault(require("./opacity"));
var _shape = _interopRequireDefault(require("./shape"));
var _position = _interopRequireDefault(require("./position"));
var _symbol = _interopRequireDefault(require("./symbol"));
var _filter = _interopRequireDefault(require("./filter"));
var _pattern = _interopRequireDefault(require("./pattern"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
_base["default"].Color = _color["default"];
_base["default"].Size = _size["default"];
_base["default"].Opacity = _opacity["default"];
_base["default"].Shape = _shape["default"];
_base["default"].Position = _position["default"];
_base["default"].Symbol = _symbol["default"];
_base["default"].Filter = _filter["default"];
_base["default"].Pattern = _pattern["default"];
var _default = _base["default"];
exports["default"] = _default;

View File

@ -1,51 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 视觉通道 Opacity
* @class Attr.Opacity
*/
var Opacity =
/*#__PURE__*/
function (_Base) {
_inherits(Opacity, _Base);
function Opacity(cfg) {
var _this;
_classCallCheck(this, Opacity);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Opacity).call(this, cfg));
_this.names = ['opacity'];
_this.type = 'opacity';
_this.gradient = null;
return _this;
}
return Opacity;
}(_base["default"]);
var _default = Opacity;
exports["default"] = _default;

View File

@ -1,51 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 视觉通道 pattern
* @class Attr.pattern
*/
var Pattern =
/*#__PURE__*/
function (_Base) {
_inherits(Pattern, _Base);
function Pattern(cfg) {
var _this;
_classCallCheck(this, Pattern);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Pattern).call(this, cfg));
_this.names = ['pattern'];
_this.type = 'pattern';
_this.gradient = null;
return _this;
}
return Pattern;
}(_base["default"]);
var _default = Pattern;
exports["default"] = _default;

View File

@ -1,140 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
var _util = _interopRequireDefault(require("../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Position =
/*#__PURE__*/
function (_Base) {
_inherits(Position, _Base);
function Position(cfg) {
var _this;
_classCallCheck(this, Position);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Position).call(this, cfg));
_this.names = ['x', 'y'];
_this.type = 'position';
return _this;
}
_createClass(Position, [{
key: "mapping",
value: function mapping(x, y) {
var scales = this.scales;
var coord = this.coord;
var scaleX = scales[0];
var scaleY = scales[1];
var rstX;
var rstY;
var obj;
if (_util["default"].isNil(x) || _util["default"].isNil(y)) {
return [];
}
if (_util["default"].isArray(y) && _util["default"].isArray(x)) {
rstX = [];
rstY = [];
for (var i = 0, j = 0; i < x.length && j < y.length; i++, j++) {
obj = coord.convertPoint({
x: scaleX.scale(x[i]),
y: scaleY.scale(y[j])
});
rstX.push(obj.x);
rstY.push(obj.y);
}
} else if (_util["default"].isArray(y)) {
x = scaleX.scale(x);
rstY = [];
_util["default"].each(y, function (yVal) {
yVal = scaleY.scale(yVal);
obj = coord.convertPoint({
x: x,
y: yVal
});
if (rstX && rstX !== obj.x) {
if (!_util["default"].isArray(rstX)) {
rstX = [rstX];
}
rstX.push(obj.x);
} else {
rstX = obj.x;
}
rstY.push(obj.y);
});
} else if (_util["default"].isArray(x)) {
y = scaleY.scale(y);
rstX = [];
_util["default"].each(x, function (xVal) {
xVal = scaleX.scale(xVal);
obj = coord.convertPoint({
x: xVal,
y: y
});
if (rstY && rstY !== obj.y) {
if (!_util["default"].isArray(rstY)) {
rstY = [rstY];
}
rstY.push(obj.y);
} else {
rstY = obj.y;
}
rstX.push(obj.x);
});
} else {
x = scaleX.scale(x);
y = scaleY.scale(y);
var point = coord.convertPoint({
x: x,
y: y
});
rstX = point.x;
rstY = point.y;
}
return [rstX, rstY];
}
}]);
return Position;
}(_base["default"]);
var _default = Position;
exports["default"] = _default;

View File

@ -1,89 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 视觉通道 Shape
* @class Attr.Shape
*/
var Shape =
/*#__PURE__*/
function (_Base) {
_inherits(Shape, _Base);
function Shape(cfg) {
var _this;
_classCallCheck(this, Shape);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Shape).call(this, cfg));
_this.names = ['shape'];
_this.type = 'shape';
_this.gradient = null;
return _this;
}
/**
* @override
*/
_createClass(Shape, [{
key: "getLinearValue",
value: function getLinearValue(percent) {
var values = this.values;
var index = Math.round((values.length - 1) * percent);
return values[index];
}
/**
* @override
*/
}, {
key: "_getAttrValue",
value: function _getAttrValue(scale, value) {
if (this.values === 'text') {
return value;
}
var values = this.values;
if (scale.isCategory && !this.linear) {
var index = scale.translate(value);
return values[index % values.length];
}
var percent = scale.scale(value);
return this.getLinearValue(percent);
}
}]);
return Shape;
}(_base["default"]);
var _default = Shape;
exports["default"] = _default;

View File

@ -1,107 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
var _util = _interopRequireDefault(require("../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 视觉通道 size
* @class Attr.Size
*/
var Size =
/*#__PURE__*/
function (_Base) {
_inherits(Size, _Base);
function Size(cfg) {
var _this;
_classCallCheck(this, Size);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Size).call(this, cfg));
_this.names = ['size'];
_this.type = 'size';
_this.gradient = null;
_this.domainIndex = 0;
return _this;
}
_createClass(Size, [{
key: "mapping",
value: function mapping() {
// 重构
var self = this;
var outputs = [];
var scales = self.scales;
if (self.values.length === 0) {
var callback = this.callback.bind(this);
outputs.push(callback.apply(void 0, arguments));
} else {
if (!_util["default"].isArray(self.values[0])) {
self.values = [self.values];
}
for (var i = 0; i < scales.length; i++) {
outputs.push(self._scaling(scales[i], arguments[i]));
}
}
this.domainIndex = 0;
return outputs;
}
}, {
key: "_scaling",
value: function _scaling(scale, v) {
if (scale.type === 'identity') {
return v;
}
var percent = scale.scale(v);
return this.getLinearValue(percent); // else if (scale.type === 'linear') {
}
}, {
key: "getLinearValue",
value: function getLinearValue(percent) {
var values = this.values[this.domainIndex];
var steps = values.length - 1;
var step = Math.floor(steps * percent);
var leftPercent = steps * percent - step;
var start = values[step];
var end = step === steps ? start : values[step + 1];
var rstValue = start + (end - start) * leftPercent;
this.domainIndex += 1;
return rstValue;
}
}]);
return Size;
}(_base["default"]);
var _default = Size;
exports["default"] = _default;

View File

@ -1,51 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 视觉通道 symbol
* @class Attr.symbol
*/
var _Symbol =
/*#__PURE__*/
function (_Base) {
_inherits(_Symbol, _Base);
function _Symbol(cfg) {
var _this;
_classCallCheck(this, _Symbol);
_this = _possibleConstructorReturn(this, _getPrototypeOf(_Symbol).call(this, cfg));
_this.names = ['symbol'];
_this.type = 'symbol';
_this.gradient = null;
return _this;
}
return _Symbol;
}(_base["default"]);
var _default = _Symbol;
exports["default"] = _default;

View File

@ -1 +0,0 @@
"use strict";

View File

@ -1 +0,0 @@
"use strict";

View File

@ -1 +0,0 @@
"use strict";

View File

@ -1,14 +0,0 @@
"use strict";
/**
* @fileOverview chart component module
* @author sima.zhang1990@gmail.com
*/
module.exports = {
Axis: require('./axis/index'),
Guide: require('./guide/index'),
Label: require('./label/index'),
Legend: require('./legend/index'),
Plot: require('./plot'),
Tooltip: require('./tooltip/index')
};

View File

@ -1,693 +0,0 @@
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* @fileOverview The class of tooltip
* @author sima.zhang
*/
var Util = require('../../util');
var Base = require('../../base');
var Global = require('../../global');
var _require = require('@antv/g'),
DomUtil = _require.DomUtil;
var CONTAINER_CLASS = 'g2-tooltip';
var TITLE_CLASS = 'g2-tooltip-title';
var LIST_CLASS = 'g2-tooltip-list';
var MARKER_CLASS = 'g2-tooltip-marker';
var LIST_ITEM_CLASS = 'g2-tooltip-list-item';
function find(dom, cls) {
return dom.getElementsByClassName(cls)[0];
}
function refixTooltipPosition(x, y, el, viewWidth, viewHeight) {
var width = el.clientWidth;
var height = el.clientHeight;
var gap = 20;
if (x + width + gap > viewWidth) {
x -= width + gap;
x = x < 0 ? 0 : x;
} else {
x += gap;
}
if (y + height + gap > viewHeight) {
y -= height + gap;
y = x < 0 ? 0 : y;
} else {
y += gap;
}
return [x, y];
}
function calcTooltipPosition(x, y, position, dom, target) {
var domWidth = dom.clientWidth;
var domHeight = dom.clientHeight;
var rectWidth = 0;
var rectHeight = 0;
var gap = 20;
if (target) {
var rect = target.getBBox();
rectWidth = rect.width;
rectHeight = rect.height;
x = rect.x;
y = rect.y;
gap = 5;
}
switch (position) {
case 'inside':
x = x + rectWidth / 2 - domWidth / 2;
y = y + rectHeight / 2 - domHeight / 2;
break;
case 'top':
x = x + rectWidth / 2 - domWidth / 2;
y = y - domHeight - gap;
break;
case 'left':
x = x - domWidth - gap;
y = y + rectHeight / 2 - domHeight / 2;
break;
case 'right':
x = x + rectWidth + gap;
y = y + rectHeight / 2 - domHeight / 2;
break;
case 'bottom':
default:
x = x + rectWidth / 2 - domWidth / 2;
y = y + rectHeight + gap;
break;
}
return [x, y];
}
function confineTooltipPosition(x, y, el, plotRange) {
var gap = 20;
var width = el.clientWidth;
var height = el.clientHeight;
if (x + width > plotRange.tr.x) {
x -= width + 2 * gap;
}
if (x < plotRange.tl.x) {
x = plotRange.tl.x;
}
if (y + height > plotRange.bl.y) {
y -= height + 2 * gap;
}
if (y < plotRange.tl.y) {
y = plotRange.tl.y;
}
return [x, y];
}
var Tooltip =
/*#__PURE__*/
function (_Base) {
_inherits(Tooltip, _Base);
_createClass(Tooltip, [{
key: "getDefaultCfg",
value: function getDefaultCfg() {
return {
/**
* 右下角坐标
* @type {Number}
*/
x: 0,
/**
* y 右下角坐标
* @type {Number}
*/
y: 0,
/**
* tooltip 记录项
* @type {Array}
*/
items: null,
/**
* 是否展示 title
* @type {Boolean}
*/
showTitle: true,
/**
* tooltip 辅助线配置
* @type {Object}
*/
crosshairs: null,
/**
* 视图范围
* @type {Object}
*/
plotRange: null,
/**
* x轴上移动到位置的偏移量
* @type {Number}
*/
offset: 10,
/**
* 时间戳
* @type {Number}
*/
timeStamp: 0,
/**
* tooltip 容器模板
* @type {String}
*/
containerTpl: '<div class="' + CONTAINER_CLASS + '">' + '<div class="' + TITLE_CLASS + '"></div>' + '<ul class="' + LIST_CLASS + '"></ul>' + '</div>',
/**
* tooltip 列表项模板
* @type {String}
*/
itemTpl: '<li data-index={index}>' + '<span style="background-color:{color};" class=' + MARKER_CLASS + '></span>' + '{name}: {value}</li>',
/**
* tooltip 展示在指定区域内
* @type {Boolean}
*/
inPlot: true,
/**
* tooltip 内容跟随鼠标移动
* @type {Boolean}
*/
follow: true,
/**
* 是否允许鼠标停留在 tooltip 默认不允许
* @type {Boolean}
*/
enterable: false
};
}
}, {
key: "_initTooltipWrapper",
value: function _initTooltipWrapper() {
var self = this;
var containerTpl = self.get('containerTpl');
var outterNode = self.get('canvas').get('el').parentNode;
var container;
if (/^\#/.test(containerTpl)) {
// 如果传入 dom 节点的 id
var id = containerTpl.replace('#', '');
container = document.getElementById(id);
} else {
container = DomUtil.createDom(containerTpl);
DomUtil.modifyCSS(container, self.get(CONTAINER_CLASS));
outterNode.appendChild(container);
outterNode.style.position = 'relative';
}
self.set('container', container);
}
}, {
key: "_init",
value: function _init() {
var crosshairs = this.get('crosshairs');
var frontPlot = this.get('frontPlot');
var backPlot = this.get('backPlot');
var crosshairsGroup;
if (crosshairs) {
if (crosshairs.type === 'rect') {
this.set('crosshairs', Util.deepMix({}, Global.tooltipCrosshairsRect, crosshairs));
crosshairsGroup = backPlot.addGroup({
zIndex: 0
});
} else {
this.set('crosshairs', Util.deepMix({}, Global.tooltipCrosshairsLine, crosshairs));
crosshairsGroup = frontPlot.addGroup();
}
}
this.set('crosshairsGroup', crosshairsGroup);
this._initTooltipWrapper();
}
}]);
function Tooltip(cfg) {
var _this;
_classCallCheck(this, Tooltip);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Tooltip).call(this, cfg));
_this._init(); // 初始化属性
if (_this.get('items')) {
_this._renderTooltip();
}
_this._renderCrosshairs();
return _this;
}
_createClass(Tooltip, [{
key: "_clearDom",
value: function _clearDom() {
var container = this.get('container');
var titleDom = find(container, TITLE_CLASS);
var listDom = find(container, LIST_CLASS);
if (titleDom) {
titleDom.innerHTML = '';
}
if (listDom) {
listDom.innerHTML = '';
}
}
}, {
key: "_addItem",
value: function _addItem(item, index) {
var itemTpl = this.get('itemTpl'); // TODO: 有可能是个回调函数
var itemDiv = Util.substitute(itemTpl, Util.mix({
index: index
}, item));
var itemDOM = DomUtil.createDom(itemDiv);
DomUtil.modifyCSS(itemDOM, this.get(LIST_ITEM_CLASS));
var markerDom = find(itemDOM, MARKER_CLASS);
if (markerDom) {
DomUtil.modifyCSS(markerDom, this.get(MARKER_CLASS));
}
return itemDOM;
}
}, {
key: "_renderTooltip",
value: function _renderTooltip() {
var self = this;
var showTitle = self.get('showTitle');
var titleContent = self.get('titleContent');
var container = self.get('container');
var titleDom = find(container, TITLE_CLASS);
var listDom = find(container, LIST_CLASS);
var items = self.get('items');
self._clearDom();
if (titleDom && showTitle) {
DomUtil.modifyCSS(titleDom, self.get(TITLE_CLASS));
titleDom.innerHTML = titleContent;
}
if (listDom) {
DomUtil.modifyCSS(listDom, self.get(LIST_CLASS));
Util.each(items, function (item, index) {
listDom.appendChild(self._addItem(item, index));
});
}
}
}, {
key: "_clearCrosshairsGroup",
value: function _clearCrosshairsGroup() {
var crosshairsGroup = this.get('crosshairsGroup');
this.set('crossLineShapeX', null);
this.set('crossLineShapeY', null);
this.set('crosshairsRectShape', null);
crosshairsGroup.clear();
}
}, {
key: "_renderCrosshairs",
value: function _renderCrosshairs() {
var crosshairs = this.get('crosshairs');
var canvas = this.get('canvas');
var plotRange = this.get('plotRange');
var isTransposed = this.get('isTransposed');
if (crosshairs) {
this._clearCrosshairsGroup();
switch (crosshairs.type) {
case 'x':
this._renderHorizontalLine(canvas, plotRange);
break;
case 'y':
this._renderVerticalLine(canvas, plotRange);
break;
case 'cross':
this._renderHorizontalLine(canvas, plotRange);
this._renderVerticalLine(canvas, plotRange);
break;
case 'rect':
this._renderBackground(canvas, plotRange);
break;
default:
isTransposed ? this._renderHorizontalLine(canvas, plotRange) : this._renderVerticalLine(canvas, plotRange);
}
}
}
}, {
key: "_addCrossLineShape",
value: function _addCrossLineShape(attrs, type) {
var crosshairsGroup = this.get('crosshairsGroup');
var shape = crosshairsGroup.addShape('line', {
attrs: attrs
});
shape.hide();
this.set('crossLineShape' + type, shape);
return shape;
}
}, {
key: "_renderVerticalLine",
value: function _renderVerticalLine(canvas, plotRange) {
var _this$get = this.get('crosshairs'),
style = _this$get.style;
var attrs = Util.mix({
x1: 0,
y1: plotRange ? plotRange.bl.y : canvas.get('height'),
x2: 0,
y2: plotRange ? plotRange.tl.y : 0
}, style);
this._addCrossLineShape(attrs, 'Y');
}
}, {
key: "_renderHorizontalLine",
value: function _renderHorizontalLine(canvas, plotRange) {
var _this$get2 = this.get('crosshairs'),
style = _this$get2.style;
var attrs = Util.mix({
x1: plotRange ? plotRange.bl.x : canvas.get('width'),
y1: 0,
x2: plotRange ? plotRange.br.x : 0,
y2: 0
}, style);
this._addCrossLineShape(attrs, 'X');
}
}, {
key: "_renderBackground",
value: function _renderBackground(canvas, plotRange) {
var _this$get3 = this.get('crosshairs'),
style = _this$get3.style;
var crosshairsGroup = this.get('crosshairsGroup');
var attrs = Util.mix({
x: plotRange ? plotRange.tl.x : 0,
y: plotRange ? plotRange.tl.y : canvas.get('height'),
width: plotRange ? plotRange.br.x - plotRange.bl.x : canvas.get('width'),
height: plotRange ? Math.abs(plotRange.tl.y - plotRange.bl.y) : canvas.get('height')
}, style);
var shape = crosshairsGroup.addShape('rect', {
attrs: attrs
});
shape.hide();
this.set('crosshairsRectShape', shape);
return shape;
}
}, {
key: "isContentChange",
value: function isContentChange(title, items) {
var titleContent = this.get('titleContent');
var lastItems = this.get('items');
var isChanged = !(title === titleContent && lastItems.length === items.length);
if (!isChanged) {
Util.each(items, function (item, index) {
var preItem = lastItems[index];
isChanged = item.value !== preItem.value || item.color !== preItem.color || item.name !== preItem.name || item.title !== preItem.title;
if (isChanged) {
return false;
}
});
}
return isChanged;
}
}, {
key: "setContent",
value: function setContent(title, items) {
// const isChange = this.isContentChange(title, items);
// if (isChange) {
// 在外面进行判断是否内容发生改变
var timeStamp = +new Date();
this.set('items', items);
this.set('titleContent', title);
this.set('timeStamp', timeStamp);
this._renderTooltip(); // }
return this;
}
}, {
key: "setMarkers",
value: function setMarkers(markerItems, markerCfg) {
var self = this;
var markerGroup = self.get('markerGroup');
var frontPlot = self.get('frontPlot');
if (!markerGroup) {
markerGroup = frontPlot.addGroup({
zIndex: 1,
capture: false // 不进行拾取
});
self.set('markerGroup', markerGroup);
} else {
markerGroup.clear();
}
Util.each(markerItems, function (item) {
markerGroup.addShape('marker', {
color: item.color,
attrs: Util.mix({}, markerCfg, {
x: item.x,
y: item.y
})
});
});
this.set('markerItems', markerItems);
}
}, {
key: "clearMarkers",
value: function clearMarkers() {
var markerGroup = this.get('markerGroup');
markerGroup && markerGroup.clear();
}
}, {
key: "setPosition",
value: function setPosition(x, y, target) {
var container = this.get('container');
var crossLineShapeX = this.get('crossLineShapeX');
var crossLineShapeY = this.get('crossLineShapeY');
var crosshairsRectShape = this.get('crosshairsRectShape');
var endx = x;
var endy = y; // const outterNode = this.get('canvas').get('el').parentNode;
var outterNode = this.get('canvas').get('el');
var viewWidth = DomUtil.getWidth(outterNode);
var viewHeight = DomUtil.getHeight(outterNode);
var offset = this.get('offset');
var position;
if (this.get('position')) {
position = calcTooltipPosition(x, y, this.get('position'), container, target);
x = position[0];
y = position[1];
} else if (!this.get('position')) {
position = refixTooltipPosition(x, y, container, viewWidth, viewHeight);
x = position[0];
y = position[1];
}
if (this.get('inPlot')) {
// tooltip 必须限制在绘图区域内
var plotRange = this.get('plotRange');
position = confineTooltipPosition(x, y, container, plotRange);
x = position[0];
y = position[1];
}
if (this.get('x') !== x || this.get('y') !== y) {
var markerItems = this.get('markerItems');
if (!Util.isEmpty(markerItems)) {
endx = markerItems[0].x;
endy = markerItems[0].y;
}
if (crossLineShapeY) {
// 第一次进入时画布需要单独绘制所以需要先设定corss的位置
crossLineShapeY.move(endx, 0);
}
if (crossLineShapeX) {
crossLineShapeX.move(0, endy);
}
if (crosshairsRectShape) {
// 绘制矩形辅助框,只在直角坐标系下生效
var isTransposed = this.get('isTransposed');
var items = this.get('items');
var firstItem = items[0];
var lastItem = items[items.length - 1];
var dim = isTransposed ? 'y' : 'x';
var attr = isTransposed ? 'height' : 'width';
var startDim = firstItem[dim];
if (items.length > 1 && firstItem[dim] > lastItem[dim]) {
startDim = lastItem[dim];
}
if (this.get('crosshairs').width) {
// 用户定义了 width
crosshairsRectShape.attr(dim, startDim - this.get('crosshairs').width / 2);
crosshairsRectShape.attr(attr, this.get('crosshairs').width);
} else {
if (Util.isArray(firstItem.point[dim]) && !firstItem.size) {
// 直方图
var width = firstItem.point[dim][1] - firstItem.point[dim][0];
crosshairsRectShape.attr(dim, firstItem.point[dim][0]);
crosshairsRectShape.attr(attr, width);
} else {
offset = 3 * firstItem.size / 4;
crosshairsRectShape.attr(dim, startDim - offset);
if (items.length === 1) {
crosshairsRectShape.attr(attr, 3 * firstItem.size / 2);
} else {
crosshairsRectShape.attr(attr, Math.abs(lastItem[dim] - firstItem[dim]) + 2 * offset);
}
}
}
}
var follow = this.get('follow');
container.style.left = follow ? x + 'px' : 0;
container.style.top = follow ? y + 'px' : 0;
}
}
}, {
key: "show",
value: function show() {
var crossLineShapeX = this.get('crossLineShapeX');
var crossLineShapeY = this.get('crossLineShapeY');
var crosshairsRectShape = this.get('crosshairsRectShape');
var markerGroup = this.get('markerGroup');
var container = this.get('container');
var canvas = this.get('canvas');
crossLineShapeX && crossLineShapeX.show();
crossLineShapeY && crossLineShapeY.show();
crosshairsRectShape && crosshairsRectShape.show();
markerGroup && markerGroup.show();
_get(_getPrototypeOf(Tooltip.prototype), "show", this).call(this);
container.style.visibility = 'visible'; // canvas.sort();
canvas.draw();
}
}, {
key: "hide",
value: function hide() {
var self = this;
var container = self.get('container');
var crossLineShapeX = self.get('crossLineShapeX');
var crossLineShapeY = self.get('crossLineShapeY');
var crosshairsRectShape = this.get('crosshairsRectShape');
var markerGroup = self.get('markerGroup');
var canvas = self.get('canvas');
container.style.visibility = 'hidden';
crossLineShapeX && crossLineShapeX.hide();
crossLineShapeY && crossLineShapeY.hide();
crosshairsRectShape && crosshairsRectShape.hide();
markerGroup && markerGroup.hide();
_get(_getPrototypeOf(Tooltip.prototype), "hide", this).call(this);
canvas.draw();
}
}, {
key: "destroy",
value: function destroy() {
var self = this;
var crossLineShapeX = self.get('crossLineShapeX');
var crossLineShapeY = self.get('crossLineShapeY');
var markerGroup = self.get('markerGroup');
var crosshairsRectShape = self.get('crosshairsRectShape');
var container = self.get('container');
var containerTpl = self.get('containerTpl');
if (container && !/^\#/.test(containerTpl)) {
container.parentNode.removeChild(container);
}
crossLineShapeX && crossLineShapeX.remove();
crossLineShapeY && crossLineShapeY.remove();
markerGroup && markerGroup.remove();
crosshairsRectShape && crosshairsRectShape.remove(); // super.remove();
_get(_getPrototypeOf(Tooltip.prototype), "destroy", this).call(this);
}
}]);
return Tooltip;
}(Base);
module.exports = Tooltip;

View File

@ -1,326 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.DEFAULT_RADIUS = exports.DEFAULT_CUTOFF = exports.DEFAULT_BUFFER = exports.DEFAULT_FONT_SIZE = exports.DEFAULT_FONT_WEIGHT = exports.DEFAULT_FONT_FAMILY = exports.DEFAULT_CHAR_SET = void 0;
var _tinySdf = _interopRequireDefault(require("@mapbox/tiny-sdf"));
var _fontUtil = require("../../util/font-util");
var THREE = _interopRequireWildcard(require("../../core/three"));
var _lruCache = _interopRequireDefault(require("../../util/lru-cache"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var DEFAULT_CHAR_SET = getDefaultCharacterSet();
exports.DEFAULT_CHAR_SET = DEFAULT_CHAR_SET;
var DEFAULT_FONT_FAMILY = 'sans-serif';
exports.DEFAULT_FONT_FAMILY = DEFAULT_FONT_FAMILY;
var DEFAULT_FONT_WEIGHT = 'normal';
exports.DEFAULT_FONT_WEIGHT = DEFAULT_FONT_WEIGHT;
var DEFAULT_FONT_SIZE = 24;
exports.DEFAULT_FONT_SIZE = DEFAULT_FONT_SIZE;
var DEFAULT_BUFFER = 3;
exports.DEFAULT_BUFFER = DEFAULT_BUFFER;
var DEFAULT_CUTOFF = 0.25;
exports.DEFAULT_CUTOFF = DEFAULT_CUTOFF;
var DEFAULT_RADIUS = 8;
exports.DEFAULT_RADIUS = DEFAULT_RADIUS;
var MAX_CANVAS_WIDTH = 1024;
var BASELINE_SCALE = 0.9;
var HEIGHT_SCALE = 1.2;
var CACHE_LIMIT = 3;
var cache = new _lruCache["default"](CACHE_LIMIT);
var VALID_PROPS = ['fontFamily', 'fontWeight', 'characterSet', 'fontSize', 'sdf', 'buffer', 'cutoff', 'radius'];
function getDefaultCharacterSet() {
var charSet = [];
for (var i = 32; i < 128; i++) {
charSet.push(String.fromCharCode(i));
}
return charSet;
}
function setTextStyle(ctx, fontFamily, fontSize, fontWeight) {
ctx.font = "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily);
ctx.fillStyle = '#000';
ctx.textBaseline = 'baseline';
ctx.textAlign = 'left';
}
function getNewChars(key, characterSet) {
var cachedFontAtlas = cache.get(key);
if (!cachedFontAtlas) {
return characterSet;
}
var newChars = [];
var cachedMapping = cachedFontAtlas.mapping;
var cachedCharSet = Object.keys(cachedMapping);
cachedCharSet = new Set(cachedCharSet);
var charSet = characterSet;
if (charSet instanceof Array) {
charSet = new Set(charSet);
}
charSet.forEach(function (_char) {
if (!cachedCharSet.has(_char)) {
newChars.push(_char);
}
});
return newChars;
}
function populateAlphaChannel(alphaChannel, imageData) {
// populate distance value from tinySDF to image alpha channel
for (var i = 0; i < alphaChannel.length; i++) {
imageData.data[4 * i + 3] = alphaChannel[i];
}
}
var FontAtlasManager =
/*#__PURE__*/
function () {
function FontAtlasManager() {
_classCallCheck(this, FontAtlasManager);
// font settings
this.props = {
fontFamily: DEFAULT_FONT_FAMILY,
fontWeight: DEFAULT_FONT_WEIGHT,
characterSet: DEFAULT_CHAR_SET,
fontSize: DEFAULT_FONT_SIZE,
buffer: DEFAULT_BUFFER,
// sdf only props
// https://github.com/mapbox/tiny-sdf
sdf: true,
cutoff: DEFAULT_CUTOFF,
radius: DEFAULT_RADIUS
}; // key is used for caching generated fontAtlas
this._key = null;
this._texture = new THREE.Texture();
}
_createClass(FontAtlasManager, [{
key: "setProps",
value: function setProps() {
var _this = this;
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
VALID_PROPS.forEach(function (prop) {
if (prop in props) {
_this.props[prop] = props[prop];
}
}); // update cache key
var oldKey = this._key;
this._key = this._getKey();
var charSet = getNewChars(this._key, this.props.characterSet);
var cachedFontAtlas = cache.get(this._key); // if a fontAtlas associated with the new settings is cached and
// there are no new chars
if (cachedFontAtlas && charSet.length === 0) {
// update texture with cached fontAtlas
if (this._key !== oldKey) {
this._updateTexture(cachedFontAtlas);
}
return;
} // update fontAtlas with new settings
var fontAtlas = this._generateFontAtlas(this._key, charSet, cachedFontAtlas);
this._fontAtlas = fontAtlas;
this._updateTexture(fontAtlas); // update cache
cache.set(this._key, fontAtlas);
}
}, {
key: "_updateTexture",
value: function _updateTexture(_ref) {
var canvas = _ref.data;
this._texture = new THREE.CanvasTexture(canvas);
this._texture.wrapS = THREE.ClampToEdgeWrapping;
this._texture.wrapT = THREE.ClampToEdgeWrapping;
this._texture.minFilter = THREE.LinearFilter;
this._texture.flipY = false;
this._texture.needUpdate = true;
}
}, {
key: "_generateFontAtlas",
value: function _generateFontAtlas(key, characterSet, cachedFontAtlas) {
var _this$props = this.props,
fontFamily = _this$props.fontFamily,
fontWeight = _this$props.fontWeight,
fontSize = _this$props.fontSize,
buffer = _this$props.buffer,
sdf = _this$props.sdf,
radius = _this$props.radius,
cutoff = _this$props.cutoff;
var canvas = cachedFontAtlas && cachedFontAtlas.data;
if (!canvas) {
canvas = document.createElement('canvas');
canvas.width = MAX_CANVAS_WIDTH;
}
var ctx = canvas.getContext('2d');
setTextStyle(ctx, fontFamily, fontSize, fontWeight); // 1. build mapping
var _buildMapping = (0, _fontUtil.buildMapping)(Object.assign({
getFontWidth: function getFontWidth(_char2) {
return ctx.measureText(_char2).width;
},
fontHeight: fontSize * HEIGHT_SCALE,
buffer: buffer,
characterSet: characterSet,
maxCanvasWidth: MAX_CANVAS_WIDTH
}, cachedFontAtlas && {
mapping: cachedFontAtlas.mapping,
xOffset: cachedFontAtlas.xOffset,
yOffset: cachedFontAtlas.yOffset
})),
mapping = _buildMapping.mapping,
canvasHeight = _buildMapping.canvasHeight,
xOffset = _buildMapping.xOffset,
yOffset = _buildMapping.yOffset; // 2. update canvas
// copy old canvas data to new canvas only when height changed
if (canvas.height !== canvasHeight) {
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
canvas.height = canvasHeight;
ctx.putImageData(imageData, 0, 0);
}
setTextStyle(ctx, fontFamily, fontSize, fontWeight); // 3. layout characters
if (sdf) {
var tinySDF = new _tinySdf["default"](fontSize, buffer, radius, cutoff, fontFamily, fontWeight); // used to store distance values from tinySDF
// tinySDF.size equals `fontSize + buffer * 2`
var _imageData = ctx.getImageData(0, 0, tinySDF.size, tinySDF.size);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = characterSet[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _char3 = _step.value;
populateAlphaChannel(tinySDF.draw(_char3), _imageData);
ctx.putImageData(_imageData, mapping[_char3].x - buffer, mapping[_char3].y - buffer);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} else {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = characterSet[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _char4 = _step2.value;
ctx.fillText(_char4, mapping[_char4].x, mapping[_char4].y + fontSize * BASELINE_SCALE);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
return {
xOffset: xOffset,
yOffset: yOffset,
mapping: mapping,
data: canvas,
width: canvas.width,
height: canvas.height
};
}
}, {
key: "_getKey",
value: function _getKey() {
var _this$props2 = this.props,
fontFamily = _this$props2.fontFamily,
fontWeight = _this$props2.fontWeight,
fontSize = _this$props2.fontSize,
buffer = _this$props2.buffer,
sdf = _this$props2.sdf,
radius = _this$props2.radius,
cutoff = _this$props2.cutoff;
if (sdf) {
return "".concat(fontFamily, " ").concat(fontWeight, " ").concat(fontSize, " ").concat(buffer, " ").concat(radius, " ").concat(cutoff);
}
return "".concat(fontFamily, " ").concat(fontWeight, " ").concat(fontSize, " ").concat(buffer);
}
}, {
key: "texture",
get: function get() {
return this._texture;
}
}, {
key: "mapping",
get: function get() {
var data = cache.get(this._key);
return data && data.mapping;
}
}, {
key: "scale",
get: function get() {
return HEIGHT_SCALE;
}
}, {
key: "fontAtlas",
get: function get() {
return this._fontAtlas;
}
}]);
return FontAtlasManager;
}();
exports["default"] = FontAtlasManager;

View File

@ -1,102 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _fontUtil = require("../../util/font-util");
var THREE = _interopRequireWildcard(require("../../../../core/three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var BUFFER = 3;
var MAX_CANVAS_WIDTH = 1024;
var IconManager =
/*#__PURE__*/
function () {
function IconManager() {
_classCallCheck(this, IconManager);
this._getIcon = null;
this._mapping = {};
this._autoPacking = false;
this.iconData = {};
this._canvas = document.createElement('canvas');
this._texture = new THREE.Texture(this._canvas);
this.ctx = this._canvas.getContext('2d');
}
_createClass(IconManager, [{
key: "getTexture",
value: function getTexture() {
return this._texture;
}
}, {
key: "_updateIconAtlas",
value: function _updateIconAtlas() {
this._canvas.width = MAX_CANVAS_WIDTH;
this._canvas.height = this._canvasHeigth;
for (var key in this.mapping) {
var icon = this.mapping[key];
var x = icon.x,
y = icon.y,
image = icon.image;
this.ctx.drawImage(image, x, y, this.imageWidth, this.imageWidth);
}
this.texture.magFilter = THREE.LinearFilter;
this.texture.minFilter = THREE.LinearFilter;
this.texture.needsUpdate = true;
}
}, {
key: "addImage",
value: function addImage(id, opt) {
var _this = this;
this._loadImage(opt).then(function (image) {
_this.iconData.push({
id: id,
image: image
});
var _buildIconMaping = (0, _fontUtil.buildIconMaping)(_this.iconData, BUFFER, MAX_CANVAS_WIDTH),
mapping = _buildIconMaping.mapping,
canvasHeight = _buildIconMaping.canvasHeight;
_this._mapping = mapping;
_this._canvasHeigth = canvasHeight;
});
}
}, {
key: "_loadImage",
value: function _loadImage(url) {
return new Promise(function (resolve, reject) {
var image = new Image();
image.onload = function () {
resolve(image);
};
image.onerror = function () {
reject(new Error('Could not load image at ' + url));
};
image.src = url;
});
}
}]);
return IconManager;
}();
exports["default"] = IconManager;

View File

@ -1,86 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _wolfy87Eventemitter = _interopRequireDefault(require("wolfy87-eventemitter"));
var _util = _interopRequireDefault(require("../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Base =
/*#__PURE__*/
function (_EventEmitter) {
_inherits(Base, _EventEmitter);
_createClass(Base, [{
key: "getDefaultCfg",
value: function getDefaultCfg() {
return {};
}
}]);
function Base(cfg) {
var _this;
_classCallCheck(this, Base);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Base).call(this));
var attrs = {
visible: true
};
var defaultCfg = _this.getDefaultCfg();
_this._attrs = attrs;
_util["default"].assign(attrs, defaultCfg, cfg);
return _this;
}
_createClass(Base, [{
key: "get",
value: function get(name) {
return this._attrs[name];
}
}, {
key: "set",
value: function set(name, value) {
this._attrs[name] = value;
}
}, {
key: "destroy",
value: function destroy() {
this._attrs = {};
this.removeAllListeners();
this.destroyed = true;
}
}]);
return Base;
}(_wolfy87Eventemitter["default"]);
var _default = Base;
exports["default"] = _default;

View File

@ -1,97 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
var _object3dUtil = require("../../util/object3d-util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var BufferController =
/*#__PURE__*/
function () {
function BufferController(cfg) {
_classCallCheck(this, BufferController);
// defs 列定义
_util["default"].assign(this, cfg);
if (!this.mesh) this.mesh = this.layer;
}
_createClass(BufferController, [{
key: "_updateColorAttributes",
value: function _updateColorAttributes() {
var _this = this;
var filterData = this.mesh.layerData;
var colorKey = {};
for (var e = 0; e < filterData.length; e++) {
var item = filterData[e];
colorKey[item.id] = item.color;
}
this.layer._activeIds = null; // 清空选中元素xwxw
var colorAttr = this.mesh.mesh.geometry.attributes.a_color;
var pickAttr = this.mesh.mesh.geometry.attributes.pickingId;
pickAttr.array.forEach(function (id, index) {
var newId = Math.abs(id);
var item = null;
var color = null;
if (_this.mesh.layerSource.data.featureKeys) {
// hash数据映射
newId = _this.mesh.layerSource.data.featureKeys[newId].index;
item = filterData[newId];
color = colorKey[item.id];
} else {
item = filterData[newId - 1];
color = colorKey[newId];
}
if (item.hasOwnProperty('filter') && item.filter === false) {
colorAttr.array[index * 4 + 0] = 0;
colorAttr.array[index * 4 + 1] = 0;
colorAttr.array[index * 4 + 2] = 0;
colorAttr.array[index * 4 + 3] = 0;
pickAttr.array[index] = -id; // 通过Id数据过滤 id<0 不显示
} else {
colorAttr.array[index * 4 + 0] = color[0];
colorAttr.array[index * 4 + 1] = color[1];
colorAttr.array[index * 4 + 2] = color[2];
colorAttr.array[index * 4 + 3] = color[3];
pickAttr.array[index] = id;
}
});
colorAttr.needsUpdate = true;
pickAttr.needsUpdate = true;
}
}, {
key: "_updateStyle",
value: function _updateStyle(option) {
var newOption = {};
for (var key in option) {
newOption['u_' + key] = option[key];
}
(0, _object3dUtil.updateObjecteUniform)(this.mesh._object3D, newOption);
}
}]);
return BufferController;
}();
exports["default"] = BufferController;

View File

@ -1,76 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var EventContoller =
/*#__PURE__*/
function () {
function EventContoller(cfg) {
_classCallCheck(this, EventContoller);
_util["default"].assign(this, cfg);
}
_createClass(EventContoller, [{
key: "_init",
value: function _init() {
var _this = this;
this.layer.scene.on('pick-' + this.layer.layerId, function (e) {
var featureId = e.featureId,
point2d = e.point2d,
type = e.type;
if (featureId < 0 && _this._activeIds !== null) {
type = 'mouseleave';
}
_this._activeIds = featureId; // TODO 瓦片图层获取选中数据信息
var lnglat = _this.layer.scene.containerToLngLat(point2d);
var _this$layer$getSelect = _this.layer.getSelectFeature(featureId, lnglat),
feature = _this$layer$getSelect.feature,
style = _this$layer$getSelect.style; // const style = this.layerData[featureId - 1];
var target = {
featureId: featureId,
feature: feature,
style: style,
pixel: point2d,
type: type,
lnglat: {
lng: lnglat.lng,
lat: lnglat.lat
}
};
if (featureId >= 0 || _this._activeIds >= 0) {
// 拾取到元素,或者离开元素
_this.layer.emit(type, target);
}
});
}
}, {
key: "_initMapEvent",
value: function _initMapEvent() {}
}]);
return EventContoller;
}();
exports["default"] = EventContoller;

View File

@ -1,56 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = polygonGeom;
exports.pointGeom = pointGeom;
var _geom = _interopRequireDefault(require("../../geom/geom"));
var _index = require("../../geom/index");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// geom shape buffer geometry material
// shape name type()
// buffer 1:n geometry
// geometry
//
function polygonGeom(shape, coordinates, properties, layerid) {
var polygongeom = _geom.default.polygon;
var _polygongeom$shape = polygongeom[shape],
buffer = _polygongeom$shape.buffer,
geometry = _polygongeom$shape.geometry,
material = _polygongeom$shape.material; // polygon 映射表
var bufferData = new _index.GeoBuffer[buffer]({
coordinates: coordinates,
properties: properties,
shape: shape
});
bufferData.bufferStruct.name = layerid;
var bg = new _index.bufferGeometry[geometry](bufferData.bufferStruct);
var mtl = _index.Material[material]();
return {
geometry: bg,
mtl: mtl
};
}
function pointGeom(shape, bufferData) {
var pointgeom = _geom.default.point;
var _pointgeom$shape = pointgeom[shape],
geometry = _pointgeom$shape.geometry,
material = _pointgeom$shape.material;
var bg = new _index.bufferGeometry[geometry](bufferData.bufferStruct);
var mtl = _index.Material[material]();
return {
geometry: bg,
mtl: mtl
};
}

View File

@ -1,30 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _scale = _interopRequireDefault(require("./scale"));
var _mapping = _interopRequireDefault(require("./mapping"));
var _pick = _interopRequireDefault(require("./pick"));
var _interaction = _interopRequireDefault(require("./interaction"));
var _event = _interopRequireDefault(require("./event"));
var _buffer = _interopRequireDefault(require("./buffer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _default = {
Scale: _scale["default"],
Mapping: _mapping["default"],
Picking: _pick["default"],
Interaction: _interaction["default"],
Event: _event["default"],
Buffer: _buffer["default"]
};
exports["default"] = _default;

View File

@ -1,83 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
var _index = require("../../interaction/index");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var InteractionController =
/*#__PURE__*/
function () {
function InteractionController(cfg) {
_classCallCheck(this, InteractionController);
// defs 列定义
_util["default"].assign(this, cfg);
} // interaction 方法
_createClass(InteractionController, [{
key: "clearAllInteractions",
value: function clearAllInteractions() {
var interactions = this.layer.get('interactions');
_util["default"].each(interactions, function (interaction, key) {
interaction.destory();
delete interactions[key];
});
return this;
}
}, {
key: "clearInteraction",
value: function clearInteraction(type) {
var interactions = this.layer.get('interactions');
if (interactions[type]) {
interactions[type].destory();
delete interactions[type];
}
return this;
}
}, {
key: "addInteraction",
value: function addInteraction(type) {
var cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
cfg.layer = this.layer;
var Ctor = (0, _index.getInteraction)(type);
var interaction = new Ctor(cfg);
this._setInteraction(type, interaction);
return this;
}
}, {
key: "_setInteraction",
value: function _setInteraction(type, interaction) {
var interactions = this.layer.get('interactions');
if (interactions[type]) {
interactions[type].destory();
}
interactions[type] = interaction;
}
}]);
return InteractionController;
}();
exports["default"] = InteractionController;

View File

@ -1,14 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.layerControl = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var layerControl = function layerControl() {
_classCallCheck(this, layerControl);
};
exports.layerControl = layerControl;

View File

@ -1,70 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _map = require("../../map");
var _base = _interopRequireDefault(require("../base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var MapContorller =
/*#__PURE__*/
function (_Base) {
_inherits(MapContorller, _Base);
function MapContorller(cfg, engine, scene) {
var _this;
_classCallCheck(this, MapContorller);
_this = _possibleConstructorReturn(this, _getPrototypeOf(MapContorller).call(this, cfg));
_this._engine = engine;
_this.scene = scene;
return _this;
}
_createClass(MapContorller, [{
key: "_init",
value: function _init() {
var mapType = this.get('mapType');
var mapCfg = this.get('mapCfg');
this.map = new _map.getMap(mapType)(mapCfg);
this.map('mapLoad', this._mapload.bind(this));
}
}, {
key: "_mapload",
value: function _mapload() {
this.map.asyncCamera(this._engine);
this.emit('loaded');
}
}, {
key: "_bindMapMethod",
value: function _bindMapMethod() {}
}]);
return MapContorller;
}(_base.default);
exports.default = MapContorller;

View File

@ -1,279 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
var _global = _interopRequireDefault(require("../../global"));
var _scale = _interopRequireDefault(require("./scale"));
var _index = _interopRequireDefault(require("../../attr/index"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Mapping =
/*#__PURE__*/
function () {
/** mapping
* 初始化mapping
* @param {*} cfg 配置
* @param {*} cfg.layer layer对象
* @param {*} cfg.mesh mesh对象
*/
function Mapping(cfg) {
_classCallCheck(this, Mapping);
_util["default"].assign(this, cfg);
if (!this.mesh) this.mesh = this.layer;
this._init();
}
_createClass(Mapping, [{
key: "_init",
value: function _init() {
this._initControllers();
this._initTileAttrs();
this._mapping();
}
}, {
key: "update",
value: function update() {
this.mesh.set('scales', {});
this._initTileAttrs();
this._updateMaping();
}
}, {
key: "_initControllers",
value: function _initControllers() {
var scalesOption = this.layer.get('scaleOptions');
var scaleController = new _scale["default"]({
defs: _objectSpread({}, scalesOption)
});
this.mesh.set('scaleController', scaleController);
}
}, {
key: "_createScale",
value: function _createScale(field) {
var scales = this.mesh.get('scales');
this._initControllers(); // scale更新
var scale = scales[field];
if (!scale) {
scale = this.createScale(field);
scales[field] = scale;
}
return scale;
}
}, {
key: "createScale",
value: function createScale(field) {
var data = this.mesh.layerSource.data.dataArray;
var scales = this.mesh.get('scales');
var scale = scales[field];
var scaleController = this.mesh.get('scaleController');
if (!scale) {
scale = scaleController.createScale(field, data);
scales[field] = scale;
}
return scale;
} // 获取属性映射的值
}, {
key: "_getAttrValues",
value: function _getAttrValues(attr, record) {
var scales = attr.scales;
var params = [];
for (var i = 0; i < scales.length; i++) {
var scale = scales[i];
var field = scale.field;
if (scale.type === 'identity') {
params.push(scale.value);
} else {
params.push(record[field]);
}
}
var indexZoom = params.indexOf('zoom');
indexZoom !== -1 ? params[indexZoom] = attr.zoom : null;
var values = attr.mapping.apply(attr, params);
return values;
}
}, {
key: "_mapping",
value: function _mapping() {
var attrs = this.mesh.get('attrs');
var mappedData = [];
var data = this.mesh.layerSource.data.dataArray;
for (var i = 0; i < data.length; i++) {
var record = data[i];
var newRecord = {};
newRecord.id = data[i]._id;
for (var k in attrs) {
if (attrs.hasOwnProperty(k)) {
var attr = attrs[k];
var names = attr.names;
var values = this._getAttrValues(attr, record);
if (names.length > 1) {
// position 之类的生成多个字段的属性
for (var j = 0; j < values.length; j++) {
var val = values[j];
var name = names[j];
newRecord[name] = _util["default"].isArray(val) && val.length === 1 ? val[0] : val; // 只有一个值时返回第一个属性值
}
} else {
newRecord[names[0]] = values.length === 1 ? values[0] : values;
}
}
}
newRecord.coordinates = record.coordinates;
mappedData.push(newRecord);
} // 通过透明度过滤数据
if (attrs.hasOwnProperty('filter')) {
mappedData.forEach(function (item) {
if (item.filter === false) {
item.color[3] = 0;
item.id = -item.id;
}
});
}
this.mesh.layerData = mappedData;
}
/**
* 更新数据maping
* @param {*} layerSource 数据源
* @param {*} layer map
*/
}, {
key: "_updateMaping",
value: function _updateMaping() {
var attrs = this.mesh.get('attrs');
var data = this.mesh.layerSource.data.dataArray;
var layerData = this.mesh.layerData;
for (var i = 0; i < data.length; i++) {
var record = data[i];
for (var attrName in attrs) {
if (attrs.hasOwnProperty(attrName) && attrs[attrName].neadUpdate) {
var attr = attrs[attrName];
var names = attr.names;
var values = this._getAttrValues(attr, record);
if (names.length > 1) {
// position 之类的生成多个字段的属性
for (var j = 0; j < values.length; j++) {
var val = values[j];
var name = names[j];
layerData[i][name] = _util["default"].isArray(val) && val.length === 1 ? val[0] : val; // 只有一个值时返回第一个属性值
}
} else {
layerData[i][names[0]] = values.length === 1 ? values[0] : values;
}
attr.neadUpdate = true;
}
}
}
}
}, {
key: "_initTileAttrs",
value: function _initTileAttrs() {
var attrOptions = this.layer.get('attrOptions');
for (var type in attrOptions) {
if (attrOptions.hasOwnProperty(type)) {
this._updateTileAttr(type);
}
}
}
}, {
key: "_updateTileAttr",
value: function _updateTileAttr(type) {
var self = this;
var attrs = this.mesh.get('attrs');
var attrOptions = this.layer.get('attrOptions');
var option = attrOptions[type];
option.neadUpdate = true;
var className = _util["default"].upperFirst(type);
var fields = this._parseFields(option.field);
var scales = [];
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var scale = self._createScale(field);
if (type === 'color' && _util["default"].isNil(option.values)) {
// 设置 color 的默认色值
option.values = _global["default"].colors;
}
scales.push(scale);
}
option.scales = scales;
var attr = new _index["default"][className](option);
attrs[type] = attr;
}
}, {
key: "_parseFields",
value: function _parseFields(field) {
if (_util["default"].isArray(field)) {
return field;
}
if (_util["default"].isString(field)) {
return field.split('*');
}
return [field];
}
}]);
return Mapping;
}();
exports["default"] = Mapping;

View File

@ -1,105 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
var THREE = _interopRequireWildcard(require("../three"));
var _object3dUtil = require("../../util/object3d-util");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var PickContoller =
/*#__PURE__*/
function () {
function PickContoller(cfg) {
_classCallCheck(this, PickContoller);
_util["default"].assign(this, cfg);
this.pickObject3D = new THREE.Object3D();
this.addToPicking(this.pickObject3D);
}
_createClass(PickContoller, [{
key: "getPickingId",
value: function getPickingId() {
return this.layer.scene._engine._picking.getNextId();
}
}, {
key: "addToPicking",
value: function addToPicking(object) {
object.name = this.layer.layerId;
this.layer.scene._engine._picking.add(object);
}
}, {
key: "removePickingObject",
value: function removePickingObject(object) {
this.layer.scene._engine._picking.remove(object);
}
}, {
key: "removePickingMesh",
value: function removePickingMesh(mesh) {
this.pickObject3D.remove(mesh);
(0, _object3dUtil.destoryObject)(mesh);
}
}, {
key: "removePickMeshByName",
value: function removePickMeshByName(name) {
for (var i = 0; i < this.pickObject3D.children.length; i++) {
if (this.pickObject3D.children[i].name === name) {
this.removePickingMesh(this.pickObject3D.children[i]);
}
}
}
}, {
key: "removeAllMesh",
value: function removeAllMesh() {
var _this = this;
this.pickObject3D.children.forEach(function (element) {
_this.pickObject3D.remove(element);
(0, _object3dUtil.destoryObject)(element);
});
}
}, {
key: "addPickMesh",
value: function addPickMesh(mesh) {
var _this2 = this;
var pickmaterial = mesh.material.clone();
pickmaterial.defines.PICK = true; // pickmaterial.fragmentShader = pickingFragmentShader;
var pickingMesh = new THREE[mesh.type](mesh.geometry, pickmaterial);
pickingMesh.name = mesh.name;
pickingMesh.onBeforeRender = function () {
var zoom = _this2.layer.scene.getZoom();
(0, _object3dUtil.updateObjecteUniform)(pickingMesh, {
u_zoom: zoom
});
};
this.pickObject3D.add(pickingMesh);
}
}]);
return PickContoller;
}();
exports["default"] = PickContoller;

View File

@ -1,163 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
var _global = _interopRequireDefault(require("../../global"));
var _scale = _interopRequireDefault(require("../../scale/"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
var TYPES = {
LINEAR: 'linear',
CAT: 'cat',
TIME: 'time'
};
var ScaleController =
/*#__PURE__*/
function () {
function ScaleController(cfg) {
_classCallCheck(this, ScaleController);
// defs 列定义
this.defs = {};
_util["default"].assign(this, cfg);
}
_createClass(ScaleController, [{
key: "_getDef",
value: function _getDef(field) {
var defs = this.defs;
var def = null;
if (_global["default"].scales[field] || defs[field]) {
def = _util["default"].mix({}, _global["default"].scales[field]); // 处理覆盖属性的问题
_util["default"].each(defs[field], function (v, k) {
if (_util["default"].isNil(v)) {
delete def[k];
} else {
def[k] = v;
}
});
}
return def;
}
}, {
key: "_getDefaultType",
value: function _getDefaultType(field, data) {
var type = TYPES.LINEAR;
var value = _util["default"].Array.firstValue(data, field);
if (_util["default"].isArray(value)) {
value = value[0];
}
if (dateRegex.test(value)) {
type = TYPES.TIME;
} else if (_util["default"].isString(value)) {
type = TYPES.CAT;
}
return type;
}
}, {
key: "_getScaleCfg",
value: function _getScaleCfg(type, field, data) {
var cfg = {
field: field
};
var values = _util["default"].Array.values(data, field);
cfg.values = values;
if (!_scale["default"].isCategory(type) && type !== 'time') {
var range = _util["default"].Array.getRange(values);
cfg.min = range.min;
cfg.max = range.max;
cfg.nice = true;
}
if (type === 'time') {
cfg.nice = false;
}
return cfg;
}
}, {
key: "createScale",
value: function createScale(field, data) {
var self = this;
var def = self._getDef(field);
var scale; // 如果数据为空直接返回常量度量
if (!data || !data.length) {
if (def && def.type) {
scale = _scale["default"][def.type](def);
} else {
scale = _scale["default"].identity({
value: field,
field: field.toString(),
values: [field]
});
}
return scale;
}
var firstValue = _util["default"].Array.firstValue(data, field);
if (_util["default"].isNumber(field) || _util["default"].isNil(firstValue) && !def) {
scale = _scale["default"].identity({
value: field,
field: field.toString(),
values: [field]
});
} else {
// 如果已经定义过这个度量
var type;
if (def) {
type = def.type;
}
type = type || self._getDefaultType(field, data);
var cfg = self._getScaleCfg(type, field, data);
if (def) {
_util["default"].mix(cfg, def);
}
scale = _scale["default"][type](cfg);
}
return scale;
}
}]);
return ScaleController;
}();
var _default = ScaleController;
exports["default"] = _default;

View File

@ -1,292 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
var _global = _interopRequireDefault(require("../../global"));
var _scale = _interopRequireDefault(require("./scale"));
var _base = _interopRequireDefault(require("../base"));
var _index = _interopRequireDefault(require("../../attr/index"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var TileMapping =
/*#__PURE__*/
function (_Base) {
_inherits(TileMapping, _Base);
function TileMapping(source, cfg) {
var _this;
_classCallCheck(this, TileMapping);
_this = _possibleConstructorReturn(this, _getPrototypeOf(TileMapping).call(this, cfg));
_this.source = source;
_this._init();
return _this;
}
_createClass(TileMapping, [{
key: "_init",
value: function _init() {
this._initControllers();
this._initTileAttrs();
this._mapping();
}
}, {
key: "update",
value: function update() {
this.set('scales', {});
this._initTileAttrs();
this._updateMaping();
}
}, {
key: "_initControllers",
value: function _initControllers() {
var scalesOption = this.get('scaleOptions');
var scaleController = new _scale["default"]({
defs: _objectSpread({}, scalesOption)
});
this.set('scaleController', scaleController);
}
}, {
key: "_createScale",
value: function _createScale(field) {
var scales = this.get('scales');
this._initControllers(); // scale更新
var scale = scales[field];
if (!scale) {
scale = this.createScale(field);
scales[field] = scale;
}
return scale;
}
}, {
key: "createScale",
value: function createScale(field) {
var data = this.source.data.dataArray;
var scales = this.get('scales');
var scale = scales[field];
var scaleController = this.get('scaleController');
if (!scale) {
scale = scaleController.createScale(field, data);
scales[field] = scale;
}
return scale;
} // 获取属性映射的值
}, {
key: "_getAttrValues",
value: function _getAttrValues(attr, record) {
var scales = attr.scales;
var params = [];
for (var i = 0; i < scales.length; i++) {
var scale = scales[i];
var field = scale.field;
if (scale.type === 'identity') {
params.push(scale.value);
} else {
params.push(record[field]);
}
}
var indexZoom = params.indexOf('zoom');
indexZoom !== -1 ? params[indexZoom] = attr.zoom : null;
var values = attr.mapping.apply(attr, params);
return values;
}
}, {
key: "_mapping",
value: function _mapping() {
var attrs = this.get('attrs');
var mappedData = [];
var data = this.source.data.dataArray;
for (var i = 0; i < data.length; i++) {
var record = data[i];
var newRecord = {};
newRecord.id = data[i]._id;
for (var k in attrs) {
if (attrs.hasOwnProperty(k)) {
var attr = attrs[k];
var names = attr.names;
var values = this._getAttrValues(attr, record);
if (names.length > 1) {
// position 之类的生成多个字段的属性
for (var j = 0; j < values.length; j++) {
var val = values[j];
var name = names[j];
newRecord[name] = _util["default"].isArray(val) && val.length === 1 ? val[0] : val; // 只有一个值时返回第一个属性值
}
} else {
newRecord[names[0]] = values.length === 1 ? values[0] : values;
}
}
}
newRecord.coordinates = record.coordinates;
mappedData.push(newRecord);
} // 通过透明度过滤数据
if (attrs.hasOwnProperty('filter')) {
mappedData.forEach(function (item) {
if (item.filter === false) {
item.color[3] = 0;
item.id = -item.id;
}
});
}
this.layerData = mappedData;
}
/**
* 更新数据maping
* @param {*} layerSource 数据源
* @param {*} layer map
*/
}, {
key: "_updateMaping",
value: function _updateMaping() {
var attrs = this.get('attrs');
var data = this.source.data.dataArray;
var layerData = this.layerData;
for (var i = 0; i < data.length; i++) {
var record = data[i];
for (var attrName in attrs) {
if (attrs.hasOwnProperty(attrName) && attrs[attrName].neadUpdate) {
var attr = attrs[attrName];
var names = attr.names;
var values = this._getAttrValues(attr, record);
if (names.length > 1) {
// position 之类的生成多个字段的属性
for (var j = 0; j < values.length; j++) {
var val = values[j];
var name = names[j];
layerData[i][name] = _util["default"].isArray(val) && val.length === 1 ? val[0] : val; // 只有一个值时返回第一个属性值
}
} else {
layerData[i][names[0]] = values.length === 1 ? values[0] : values;
}
attr.neadUpdate = true;
}
}
}
}
}, {
key: "_initTileAttrs",
value: function _initTileAttrs() {
var attrOptions = this.get('attrOptions');
for (var type in attrOptions) {
if (attrOptions.hasOwnProperty(type)) {
this._updateTileAttr(type);
}
}
}
}, {
key: "_updateTileAttr",
value: function _updateTileAttr(type) {
var self = this;
var attrs = this.get('attrs');
var attrOptions = this.get('attrOptions');
var option = attrOptions[type];
option.neadUpdate = true;
var className = _util["default"].upperFirst(type);
var fields = this._parseFields(option.field);
var scales = [];
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var scale = self._createScale(field);
if (type === 'color' && _util["default"].isNil(option.values)) {
// 设置 color 的默认色值
option.values = _global["default"].colors;
}
scales.push(scale);
}
option.scales = scales;
var attr = new _index["default"][className](option);
attrs[type] = attr;
}
}, {
key: "_parseFields",
value: function _parseFields(field) {
if (_util["default"].isArray(field)) {
return field;
}
if (_util["default"].isString(field)) {
return field.split('*');
}
return [field];
}
}]);
return TileMapping;
}(_base["default"]);
exports["default"] = TileMapping;

View File

@ -1,43 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Camera =
/*#__PURE__*/
function () {
function Camera(container) {
_classCallCheck(this, Camera);
this.container = container;
var camera = new THREE.PerspectiveCamera(45, 1, 1, 2000000);
this.camera = camera;
this.updateSize();
window.addEventListener('resize', this.updateSize.bind(this));
}
_createClass(Camera, [{
key: "updateSize",
value: function updateSize() {
var container = this.container;
this.camera.aspect = container.clientWidth / container.clientHeight;
this.camera.updateProjectionMatrix();
}
}]);
return Camera;
}();
exports["default"] = Camera;

View File

@ -1,117 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
var _copyShader = _interopRequireDefault(require("./copy-shader"));
var _shaderPass = _interopRequireDefault(require("./shader-pass"));
var _maskPass = _interopRequireWildcard(require("./mask-pass"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
// jscs:disable
/* eslint-disable */
/**
* @author alteredq / http://alteredqualia.com/
*/
var EffectComposer = function EffectComposer(renderer, renderTarget) {
this.renderer = renderer;
if (renderTarget === undefined) {
var pixelRatio = renderer.getPixelRatio();
var width = Math.floor(renderer.context.canvas.width / pixelRatio) || 1;
var height = Math.floor(renderer.context.canvas.height / pixelRatio) || 1;
var parameters = {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBAFormat,
stencilBuffer: false
};
renderTarget = new THREE.WebGLRenderTarget(width, height, parameters);
}
this.renderTarget1 = renderTarget;
this.renderTarget2 = renderTarget.clone();
this.writeBuffer = this.renderTarget1;
this.readBuffer = this.renderTarget2;
this.passes = [];
if (_copyShader["default"] === undefined) console.error("EffectComposer relies on THREE.CopyShader");
this.copyPass = new _shaderPass["default"](_copyShader["default"]);
};
EffectComposer.prototype = {
swapBuffers: function swapBuffers() {
var tmp = this.readBuffer;
this.readBuffer = this.writeBuffer;
this.writeBuffer = tmp;
},
visible: true,
type: 'composer',
addPass: function addPass(pass) {
this.passes.push(pass);
},
insertPass: function insertPass(pass, index) {
this.passes.splice(index, 0, pass);
},
render: function render(delta) {
this.writeBuffer = this.renderTarget1;
this.readBuffer = this.renderTarget2;
var maskActive = false;
var pass,
i,
il = this.passes.length;
for (i = 0; i < il; i++) {
pass = this.passes[i];
if (!pass.enabled) continue;
pass.render(this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive);
if (pass.needsSwap) {
if (maskActive) {
var context = this.renderer.context;
context.stencilFunc(context.NOTEQUAL, 1, 0xffffffff);
this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, delta);
context.stencilFunc(context.EQUAL, 1, 0xffffffff);
}
this.swapBuffers();
}
if (pass instanceof _maskPass["default"]) {
maskActive = true;
} else if (pass instanceof _maskPass.ClearMaskPass) {
maskActive = false;
}
}
},
reset: function reset(renderTarget) {
if (renderTarget === undefined) {
renderTarget = this.renderTarget1.clone();
var pixelRatio = this.renderer.getPixelRatio();
renderTarget.setSize(Math.floor(this.renderer.context.canvas.width / pixelRatio), Math.floor(this.renderer.context.canvas.height / pixelRatio));
}
this.renderTarget1.dispose();
this.renderTarget1 = renderTarget;
this.renderTarget2.dispose();
this.renderTarget2 = renderTarget.clone();
this.writeBuffer = this.renderTarget1;
this.readBuffer = this.renderTarget2;
},
setSize: function setSize(width, height) {
this.renderTarget1.setSize(width, height);
this.renderTarget2.setSize(width, height);
}
};
var _default = EffectComposer;
exports["default"] = _default;

View File

@ -1,36 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
// jscs:disable
/* eslint-disable */
/**
* @author alteredq / http://alteredqualia.com/
*
* Full-screen textured quad shader
*/
var CopyShader = {
uniforms: {
"tDiffuse": {
type: "t",
value: null
},
"opacity": {
type: "f",
value: 1.0
}
},
vertexShader: ["varying vec2 vUv;", "void main() {", "vUv = uv;", "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "}"].join("\n"),
fragmentShader: ["uniform float opacity;", "uniform sampler2D tDiffuse;", "varying vec2 vUv;", "void main() {", "vec4 texel = texture2D( tDiffuse, vUv );", "gl_FragColor = opacity * texel;", "}"].join("\n")
};
var _default = CopyShader;
exports["default"] = _default;

View File

@ -1,27 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = _default;
var _composer = _interopRequireDefault(require("./composer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _default(renderer, container) {
var composer = new _composer["default"](renderer);
var updateSize = function updateSize() {
// TODO: Re-enable this when perf issues can be solved
//
// Rendering double the resolution of the screen can be really slow
// var pixelRatio = window.devicePixelRatio;
var pixelRatio = 1;
composer.setSize(container.clientWidth * pixelRatio, container.clientHeight * pixelRatio);
};
window.addEventListener('resize', updateSize, false);
updateSize();
return composer;
}

View File

@ -1,110 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _wolfy87Eventemitter = _interopRequireDefault(require("wolfy87-eventemitter"));
var THREE = _interopRequireWildcard(require("../three"));
var _scene = _interopRequireDefault(require("./scene"));
var _camera = _interopRequireDefault(require("./camera"));
var _renderer = _interopRequireDefault(require("./renderer"));
var _picking = _interopRequireDefault(require("./picking/picking"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Engine =
/*#__PURE__*/
function (_EventEmitter) {
_inherits(Engine, _EventEmitter);
function Engine(container, world) {
var _this;
_classCallCheck(this, Engine);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Engine).call(this));
_this._scene = _scene["default"];
_this._camera = new _camera["default"](container).camera;
_this._renderer = new _renderer["default"](container).renderer;
_this._world = world; // 地图场景实例
// for MapBox
_this.world = new THREE.Group();
_this._scene.add(_this.world);
_this._picking = (0, _picking["default"])(_this._world, _this._renderer, _this._camera);
_this.clock = new THREE.Clock();
_this.composerLayers = [];
return _this;
}
_createClass(Engine, [{
key: "_initPostProcessing",
value: function _initPostProcessing() {
this.composerLayers.forEach(function (layer) {
layer.visible && layer.render();
});
}
}, {
key: "update",
value: function update() {
this._renderer.clear();
this._renderer.render(this._scene, this._camera);
this._initPostProcessing();
}
}, {
key: "destroy",
value: function destroy() {} // 渲染第三方Scene对象
}, {
key: "renderScene",
value: function renderScene(scene) {
this._renderer.render(scene, this._camera);
}
}, {
key: "run",
value: function run() {
this.update();
this.engineID = requestAnimationFrame(this.run.bind(this));
}
}, {
key: "stop",
value: function stop() {
cancelAnimationFrame(this.engineID);
}
}]);
return Engine;
}(_wolfy87Eventemitter["default"]);
exports["default"] = Engine;

View File

@ -1,74 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ClearMaskPass = exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
// jscs:disable
/* eslint-disable */
/**
* @author alteredq / http://alteredqualia.com/
*/
var MaskPass = function MaskPass(scene, camera) {
this.scene = scene;
this.camera = camera;
this.enabled = true;
this.clear = true;
this.needsSwap = false;
this.inverse = false;
};
MaskPass.prototype = {
render: function render(renderer, writeBuffer, readBuffer, delta) {
var context = renderer.context; // don't update color or depth
context.colorMask(false, false, false, false);
context.depthMask(false); // set up stencil
var writeValue, clearValue;
if (this.inverse) {
writeValue = 0;
clearValue = 1;
} else {
writeValue = 1;
clearValue = 0;
}
context.enable(context.STENCIL_TEST);
context.stencilOp(context.REPLACE, context.REPLACE, context.REPLACE);
context.stencilFunc(context.ALWAYS, writeValue, 0xffffffff);
context.clearStencil(clearValue); // draw into the stencil buffer
renderer.render(this.scene, this.camera, readBuffer, this.clear);
renderer.render(this.scene, this.camera, writeBuffer, this.clear); // re-enable update of color and depth
context.colorMask(true, true, true, true);
context.depthMask(true); // only render where stencil is set to 1
context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
context.stencilOp(context.KEEP, context.KEEP, context.KEEP);
}
};
var ClearMaskPass = function ClearMaskPass() {
this.enabled = true;
};
exports.ClearMaskPass = ClearMaskPass;
ClearMaskPass.prototype = {
render: function render(renderer, writeBuffer, readBuffer, delta) {
var context = renderer.context;
context.disable(context.STENCIL_TEST);
}
};
var _default = MaskPass;
exports["default"] = _default;

View File

@ -1,250 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = _default;
var _pickingScene = _interopRequireDefault(require("./pickingScene"));
var THREE = _interopRequireWildcard(require("../../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var nextId = 1;
var Picking =
/*#__PURE__*/
function () {
function Picking(world, renderer, camera) {
_classCallCheck(this, Picking);
this._world = world;
this._renderer = renderer;
this._camera = camera;
this._pickingScene = _pickingScene["default"];
this.world = new THREE.Group();
this._pickingScene.add(this.world);
var size = this._renderer.getSize();
this._width = size.width;
this._height = size.height;
var parameters = {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBAFormat,
stencilBuffer: false,
depthBuffer: true
};
this._pickingTexture = new THREE.WebGLRenderTarget(this._width, this._height, parameters);
this._nextId = 1;
this._resizeTexture();
this._initEvents();
}
_createClass(Picking, [{
key: "_initEvents",
value: function _initEvents() {
this._resizeHandler = this._resizeTexture.bind(this);
window.addEventListener('resize', this._resizeHandler, false);
}
}, {
key: "pickdata",
value: function pickdata(event) {
var point = {
x: event.offsetX,
y: event.offsetY,
type: event.type
};
var normalisedPoint = {
x: 0,
y: 0
};
normalisedPoint.x = point.x / this._width * 2 - 1;
normalisedPoint.y = -(point.y / this._height) * 2 + 1;
this._pickAllObject(point, normalisedPoint);
}
}, {
key: "_resizeTexture",
value: function _resizeTexture() {
var size = this._renderer.getSize();
this._width = size.width;
this._height = size.height;
this._pickingTexture.setSize(this._width, this._height);
this._pixelBuffer = new Uint8Array(4 * this._width * this._height);
this._needUpdate = true;
}
}, {
key: "_update",
value: function _update(point) {
var texture = this._pickingTexture;
this._renderer.render(this._pickingScene, this._camera, texture);
this.pixelBuffer = new Uint8Array(4);
this._renderer.readRenderTargetPixels(texture, point.x, this._height - point.y, 1, 1, this.pixelBuffer);
}
}, {
key: "_filterObject",
value: function _filterObject(id) {
this.world.children.forEach(function (object, index) {
index === id ? object.visible = true : object.visible = false;
});
}
}, {
key: "_layerIsVisable",
value: function _layerIsVisable(object) {
var layers = this._world.getLayers();
var isVisable = false;
for (var i = 0; i < layers.length; i++) {
var layer = layers[i];
if (object.name === layer.layerId) {
isVisable = layer.get('visible');
break;
}
}
return isVisable;
}
}, {
key: "_pickAllObject",
value: function _pickAllObject(point, normalisedPoint) {
var _this = this;
this.world.children.forEach(function (object, index) {
if (!_this._layerIsVisable(object)) {
return;
}
_this._filterObject(index);
var item = _this._pick(point, normalisedPoint, object.name);
item.type = point.type;
_this._world.emit('pick', item);
_this._world.emit('pick-' + object.name, item);
});
} // _updateRender() {
// this._renderer.render(this._pickingScene, this._camera, this._pickingTexture);
// }
}, {
key: "_pick",
value: function _pick(point, normalisedPoint, layerId) {
this._update(point);
var id = this.pixelBuffer[2] * 255 * 255 + this.pixelBuffer[1] * 255 + this.pixelBuffer[0];
if (id === 16646655 || this.pixelBuffer[3] === 0) {
id = -999; // return;
}
var _point2d = {
x: point.x,
y: point.y
};
var item = {
layerId: layerId,
featureId: id,
point2d: _point2d
};
return item;
} // Add mesh to picking scene
//
// Picking ID should already be added as an attribute
}, {
key: "add",
value: function add(mesh) {
this.world.add(mesh);
this._needUpdate = true;
} // Remove mesh from picking scene
}, {
key: "remove",
value: function remove(mesh) {
this.world.remove(mesh);
this._needUpdate = true;
} // Returns next ID to use for picking
}, {
key: "getNextId",
value: function getNextId() {
return nextId++;
}
}, {
key: "destroy",
value: function destroy() {
var _this2 = this;
// TODO: Find a way to properly remove these listeners as they stay
// active at the moment
window.removeEventListener('resize', this._resizeHandler, false);
this._envents.forEach(function (event) {
_this2._world._container.removeEventListener(event[0], event[1], false);
});
if (this._pickingScene.children) {
// Remove everything else in the layer
var child;
for (var i = this._pickingScene.children.length - 1; i >= 0; i--) {
child = this._pickingScene.children[i];
if (!child) {
continue;
}
this._pickingScene.remove(child);
if (child.material) {
if (child.material.map) {
child.material.map.dispose();
child.material.map = null;
}
child.material.dispose();
child.material = null;
}
}
}
this._pickingScene = null;
this._pickingTexture = null;
this._pixelBuffer = null;
this._world = null;
this._renderer = null;
this._camera = null;
}
}]);
return Picking;
}(); // Initialise without requiring new keyword
function _default(world, renderer, camera, scene) {
return new Picking(world, renderer, camera, scene);
}

View File

@ -1,30 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = PickingMaterial;
var _material = _interopRequireDefault(require("../../../geom/material/material"));
var _picking_frag = _interopRequireDefault(require("./picking_frag.glsl"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// import picking_vert from './picking_vert.glsl';
function PickingMaterial(options) {
var material = new _material["default"]({
uniforms: {
u_zoom: {
value: options.u_zoom || 1
}
},
defines: {
PICK: true
},
vertexShader: options.vs,
fragmentShader: _picking_frag["default"],
transparent: false
});
return material;
}

View File

@ -1,19 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
// This can be imported from anywhere and will still reference the same scene,
// though there is a helper reference in Engine.pickingScene
var _default = function () {
var scene = new THREE.Scene();
return scene;
}();
exports["default"] = _default;

View File

@ -1,52 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
// jscs:disable
/* eslint-disable */
/**
* @author alteredq / http://alteredqualia.com/
*/
var RenderPass = function RenderPass(scene, camera, overrideMaterial, clearColor, clearAlpha) {
this.scene = scene;
this.camera = camera;
this.overrideMaterial = overrideMaterial;
this.clearColor = clearColor;
this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 1;
this.oldClearColor = new THREE.Color();
this.oldClearAlpha = 1;
this.enabled = true;
this.clear = false;
this.needsSwap = false;
};
RenderPass.prototype = {
render: function render(renderer, writeBuffer, readBuffer, delta) {
this.scene.overrideMaterial = this.overrideMaterial;
if (this.clearColor) {
this.oldClearColor.copy(renderer.getClearColor());
this.oldClearAlpha = renderer.getClearAlpha();
renderer.setClearColor(this.clearColor, this.clearAlpha);
}
renderer.render(this.scene, this.camera, readBuffer, this.clear);
if (this.clearColor) {
renderer.setClearColor(this.oldClearColor, this.oldClearAlpha);
}
this.scene.overrideMaterial = null;
}
};
var _default = RenderPass;
exports["default"] = _default;

View File

@ -1,56 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Renderer =
/*#__PURE__*/
function () {
function Renderer(container) {
_classCallCheck(this, Renderer);
this.container = container;
this.initRender();
this.updateSize();
window.addEventListener('resize', this.updateSize.bind(this), false);
}
_createClass(Renderer, [{
key: "initRender",
value: function initRender() {
this.renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
autoClear: false
});
this.renderer.setClearColor(0xff0000, 0.0);
this.pixelRatio = window.devicePixelRatio;
this.renderer.setPixelRatio(this.pixelRatio);
this.renderer.gammaInput = true;
this.renderer.gammaOutput = true;
this.renderer.shadowMap.enabled = false;
this.container.appendChild(this.renderer.domElement);
}
}, {
key: "updateSize",
value: function updateSize() {
this.renderer.setSize(this.container.clientWidth, this.container.clientHeight);
}
}]);
return Renderer;
}();
exports["default"] = Renderer;

View File

@ -1,107 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var THREE = _interopRequireWildcard(require("../three"));
var _util = _interopRequireDefault(require("../../util"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var RenderPass =
/*#__PURE__*/
function () {
function RenderPass(cfg) {
_classCallCheck(this, RenderPass);
var defaultCfg = this._getDefaultCfg();
_util.default.assign(this, defaultCfg, cfg);
this._init();
}
_createClass(RenderPass, [{
key: "_getDefaultCfg",
value: function _getDefaultCfg() {
var defaultRenderCfg = {
minFilter: THREE.NearestFilter,
magFilter: THREE.NearestFilter,
format: THREE.RGBAFormat,
stencilBuffer: false,
depthBuffer: false
};
return {
size: null,
renderCfg: defaultRenderCfg,
clearColor: 0x000000,
clearAlpha: 0.0,
renderToScreen: false,
renderTarget: true
};
}
}, {
key: "_init",
value: function _init() {
this.scene = new THREE.Scene();
if (this.renderTarget) {
var size = this.size ? this.size : this.renderer.getSize();
this.renderTarget = new THREE.WebGLRenderTarget(size.width, size.height, this.renderCfg);
this.texture = this.renderTarget.texture;
}
this.originClearColor = this.renderer.getClearColor();
this.originClearAlpha = this.renderer.getClearAlpha();
}
}, {
key: "setSize",
value: function setSize(width, height) {
this.size = {
width: width,
height: height
};
this.renderTarget && this.renderTarget.setSize(width, height);
}
}, {
key: "add",
value: function add(mesh) {
this.scene.add(mesh);
}
}, {
key: "remove",
value: function remove(mesh) {
this.scene.remove(mesh);
}
}, {
key: "render",
value: function render() {
this.renderer.setClearColor(this.clearColor, this.clearAlpha);
if (this.renderToScreen) {
this.renderer.setRenderTarget(null);
this.renderer.render(this.scene, this.camera);
} else {
this.renderTarget && this.renderer.render(this.scene, this.camera, this.renderTarget, true);
this.renderer.setRenderTarget(null);
}
this.renderer.setClearColor(this.originClearColor, this.originClearAlpha);
}
}]);
return RenderPass;
}();
exports.default = RenderPass;

View File

@ -1,17 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
var _default = function () {
var scene = new THREE.Scene();
return scene;
}();
exports["default"] = _default;

View File

@ -1,64 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("../three"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
// jscs:disable
/* eslint-disable */
/**
* @author alteredq / http://alteredqualia.com/
*/
var ShaderPass = function ShaderPass(shader, textureID) {
this.textureID = textureID !== undefined ? textureID : "tDiffuse";
if (shader instanceof THREE.ShaderMaterial) {
this.uniforms = shader.uniforms;
this.material = shader;
} else if (shader) {
this.uniforms = THREE.UniformsUtils.clone(shader.uniforms);
this.material = new THREE.ShaderMaterial({
defines: shader.defines || {},
uniforms: this.uniforms,
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader
});
}
this.renderToScreen = false;
this.enabled = true;
this.needsSwap = true;
this.clear = true;
this.camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2), null);
this.scene.add(this.quad);
};
ShaderPass.prototype = {
render: function render(renderer, writeBuffer, readBuffer, delta) {
if (this.uniforms[this.textureID]) {
this.uniforms[this.textureID].value = readBuffer.texture;
}
renderer.autoClear = false;
this.quad.material = this.material;
if (this.renderToScreen) {
renderer.render(this.scene, this.camera);
} else {
renderer.render(this.scene, this.camera, writeBuffer, this.clear);
}
renderer.autoClear = true;
}
};
var _default = ShaderPass;
exports["default"] = _default;

View File

@ -1,79 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var THREE = _interopRequireWildcard(require("../three"));
var _renderpass = _interopRequireDefault(require("./renderpass"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ShaderPass =
/*#__PURE__*/
function (_RenderPass) {
_inherits(ShaderPass, _RenderPass);
function ShaderPass(cfg) {
_classCallCheck(this, ShaderPass);
return _possibleConstructorReturn(this, _getPrototypeOf(ShaderPass).call(this, _objectSpread({
size: {
width: 2,
height: 2
}
}, cfg)));
}
_createClass(ShaderPass, [{
key: "_init",
value: function _init(cfg) {
_get(_getPrototypeOf(ShaderPass.prototype), "_init", this).call(this, cfg);
this.camera = new THREE.OrthographicCamera(-this.size.width / 2, this.size.width / 2, this.size.height / 2, -this.size.height / 2, 0, 100);
this.material = new THREE.ShaderMaterial(_objectSpread({
vertexShader: this.vertexShader,
fragmentShader: this.fragmentShader,
uniforms: this.uniforms
}, this.matCfg));
this.quad = new THREE.Mesh(new THREE.PlaneBufferGeometry(this.size.width, this.size.height), this.material);
this.quad.frustumCulled = false; // Avoid getting clipped
this.scene.add(this.quad);
}
}]);
return ShaderPass;
}(_renderpass.default);
exports.default = ShaderPass;

View File

@ -1,50 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DrawMaterial;
var _material = _interopRequireDefault(require("../../../geom/material/material"));
var _draw_vert = _interopRequireDefault(require("./draw_vert.glsl"));
var _draw_frag = _interopRequireDefault(require("./draw_frag.glsl"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function DrawMaterial(options) {
var material = new _material.default({
uniforms: {
u_color_ramp: {
value: options.u_color_ramp
},
u_wind_max: {
value: options.u_wind_max
},
u_particles_res: {
value: options.u_particles_res
},
u_wind_min: {
value: options.u_wind_min
},
u_opacity: {
value: options.u_opacity
},
u_wind: {
value: options.u_wind
},
u_particles: {
value: options.u_particles
},
u_bbox: {
value: options.u_bbox
}
},
vertexShader: _draw_vert.default,
fragmentShader: _draw_frag.default,
transparent: true
}); // material.blending = THREE.AdditiveBlending
return material;
}

View File

@ -1,85 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _r3Base = require("@ali/r3-base");
var _r3Geometry = require("@ali/r3-geometry");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
/**
* 创建点图层几何体
*/
var DrawGeometry =
/*#__PURE__*/
function (_BufferGeometry) {
_inherits(DrawGeometry, _BufferGeometry);
function DrawGeometry(opts) {
var _this;
_classCallCheck(this, DrawGeometry);
_this = _possibleConstructorReturn(this, _getPrototypeOf(DrawGeometry).call(this, opts.name));
_this._index = opts.index;
_this.mode = _r3Base.DrawMode.POINTS;
_this.primitive.indexType = _r3Base.DataType.UNSIGNED_INT;
_this.initialize();
return _this;
}
/**
* 构造多边形数据
* @private
*/
_createClass(DrawGeometry, [{
key: "initialize",
value: function initialize() {
var _this2 = this;
_get(_getPrototypeOf(DrawGeometry.prototype), "initialize", this).call(this, [{
semantic: 'INDEX',
size: 1,
type: _r3Base.DataType.FLOAT,
normalized: false
}], this._index.length);
this._index.forEach(function (vert, j) {
_this2.setVertexValues(j, {
INDEX: [vert]
});
});
}
}]);
return DrawGeometry;
}(_r3Geometry.BufferGeometry);
exports.default = DrawGeometry;

View File

@ -1,137 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var THREE = _interopRequireWildcard(require("./three"));
var _wolfy87Eventemitter = _interopRequireDefault(require("wolfy87-eventemitter"));
var _ajax = require("../util/ajax");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
// 将图片标注绘制在512*512的画布上每个大小 64*64 支持 64种图片
var LoadImage =
/*#__PURE__*/
function (_EventEmitter) {
_inherits(LoadImage, _EventEmitter);
function LoadImage() {
var _this;
_classCallCheck(this, LoadImage);
_this = _possibleConstructorReturn(this, _getPrototypeOf(LoadImage).call(this));
var pixelRatio = window.devicePixelRatio || 1;
_this.imageWidth = 64 * pixelRatio;
_this.canvas = document.createElement('canvas');
_this.canvas.style.cssText += 'height: 512px;width: 512px;';
_this.canvas.width = _this.imageWidth * 8;
_this.canvas.height = _this.imageWidth * 8;
_this.ctx = _this.canvas.getContext('2d');
_this.images = [];
_this.imagesCount = 0;
_this.imagePos = {};
_this.imagesIds = [];
return _this;
}
_createClass(LoadImage, [{
key: "addImage",
value: function addImage(id, opt) {
var _this2 = this;
this.imagesCount++;
this.imagesIds.push(id);
var imageCount = this.imagesCount;
var x = imageCount % 8 * this.imageWidth;
var y = parseInt(imageCount / 8) * this.imageWidth;
this.imagePos[id] = {
x: x / this.canvas.width,
y: y / this.canvas.height
};
this.texture = new THREE.Texture(this.canvas);
if (typeof opt === 'string') {
(0, _ajax.getImage)({
url: opt
}, function (err, img) {
img.id = id;
_this2.images.push(img);
_this2.ctx.drawImage(img, x, y, _this2.imageWidth, _this2.imageWidth);
_this2.texture.magFilter = THREE.LinearFilter;
_this2.texture.minFilter = THREE.LinearFilter;
_this2.texture.needsUpdate = true;
if (_this2.images.length === _this2.imagesCount) {
_this2.emit('imageLoaded');
}
});
} else {
var width = opt.width,
height = opt.height,
channels = opt.channels;
var data = new Uint8Array(width * height * channels);
var image = new Image();
image.width = width;
image.height = height;
image.data = data;
image.id = id;
this.images.push(image);
this.ctx.drawImage(image, x, y, this.imageWidth, this.imageWidth);
this.texture = new THREE.CanvasTexture(this.canvas);
this.imagePos[id] = {
x: x >> 9,
y: y >> 9
};
if (this.images.length === this.imagesCount) {
this.emit('imageLoaded');
}
}
}
}, {
key: "removeImage",
value: function removeImage() {} // todo
// drawAllImages() {
// this.images.forEach((item, index) => {
// const x = parseInt(index / 8) * 64;
// const y = index % 8 * 64;
// this.ctx.drawImage(item, x, y, 64, 64);
// });
// this.texture = new CanvasTexture(this.canvas);
// this.texture.needsUpdate=true;
// }
}]);
return LoadImage;
}(_wolfy87Eventemitter["default"]);
exports["default"] = LoadImage;

File diff suppressed because it is too large Load Diff

View File

@ -1,279 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _engine = _interopRequireDefault(require("./engine"));
var _layer = require("../layer");
var _base = _interopRequireDefault(require("./base"));
var _image = _interopRequireDefault(require("./image"));
var _fontManager = _interopRequireDefault(require("../geom/buffer/point/text/font-manager"));
var _index = require("../map/index");
var _global = _interopRequireDefault(require("../global"));
var _index2 = require("../interaction/index");
var _shader = require("../geom/shader");
var _style = _interopRequireDefault(require("./style"));
var _crsEpsg = require("@antv/geo-coord/lib/geo/crs/crs-epsg3857");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Scene =
/*#__PURE__*/
function (_Base) {
_inherits(Scene, _Base);
_createClass(Scene, [{
key: "getDefaultCfg",
value: function getDefaultCfg() {
return _global["default"].scene;
}
}]);
function Scene(cfg) {
var _this;
_classCallCheck(this, Scene);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Scene).call(this, cfg));
_this._initMap();
_this.crs = _crsEpsg.epsg3857; // this._initAttribution(); // 暂时取消,后面作为组件去加载
_this.addImage();
_this.fontAtlasManager = new _fontManager["default"]();
_this._layers = [];
_this.animateCount = 0;
return _this;
}
_createClass(Scene, [{
key: "_initEngine",
value: function _initEngine(mapContainer) {
this._engine = new _engine["default"](mapContainer, this);
this.registerMapEvent(); // this._engine.run();
(0, _shader.compileBuiltinModules)();
} // 为pickup场景添加 object 对象
}, {
key: "addPickMesh",
value: function addPickMesh(object) {
this._engine._picking.add(object);
}
}, {
key: "_initMap",
value: function _initMap() {
var _this2 = this;
this.mapContainer = this.get('id');
this.mapType = this.get('mapType') || 'amap';
var MapProvider = (0, _index.getMap)(this.mapType);
var Map = new MapProvider(this._attrs);
Map.mixMap(this);
this._container = Map.container;
Map.on('mapLoad', function () {
_this2.map = Map.map;
_this2._initEngine(Map.renderDom);
Map.asyncCamera(_this2._engine);
_this2.initLayer();
_this2._registEvents();
var hash = _this2.get('hash');
if (hash) {
var Ctor = (0, _index2.getInteraction)('hash');
var interaction = new Ctor({
layer: _this2
});
interaction._onHashChange();
}
_this2.style = new _style["default"](_this2, {});
_this2.emit('loaded');
_this2._engine.update();
});
}
}, {
key: "initLayer",
value: function initLayer() {
var _this3 = this;
var _loop = function _loop(key) {
Scene.prototype[key] = function (cfg) {
var layer = new _layer.LAYER_MAP[key](_this3, cfg);
_this3._layers.push(layer);
return layer;
};
};
for (var key in _layer.LAYER_MAP) {
_loop(key);
}
} // 添加 Tile Source
}, {
key: "addTileSource",
value: function addTileSource(id, Sourcecfg) {
this.style.addSource(id, Sourcecfg);
}
}, {
key: "getTileSource",
value: function getTileSource(id) {
return this.style.getSource(id);
}
}, {
key: "on",
value: function on(type, hander) {
if (this.map) {
this.map.on(type, hander);
}
_get(_getPrototypeOf(Scene.prototype), "on", this).call(this, type, hander);
}
}, {
key: "off",
value: function off(type, hander) {
if (this.map) {
this.map.off(type, hander);
}
_get(_getPrototypeOf(Scene.prototype), "off", this).call(this, type, hander);
}
}, {
key: "addImage",
value: function addImage() {
this.image = new _image["default"]();
}
}, {
key: "_initEvent",
value: function _initEvent() {}
}, {
key: "getLayers",
value: function getLayers() {
return this._layers;
}
}, {
key: "_addLayer",
value: function _addLayer() {}
}, {
key: "_registEvents",
value: function _registEvents() {
var _this4 = this;
var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseleave', 'mouseup', 'rightclick', 'click', 'dblclick'];
events.forEach(function (event) {
_this4._container.addEventListener(event, function (e) {
// 要素拾取
e.pixel || (e.pixel = e.point);
requestAnimationFrame(function () {
_this4._engine._picking.pickdata(e);
});
}, false);
});
}
}, {
key: "removeLayer",
value: function removeLayer(layer) {
var layerIndex = this._layers.indexOf(layer);
if (layerIndex > -1) {
this._layers.splice(layerIndex, 1);
}
layer.destroy();
layer = null;
}
}, {
key: "startAnimate",
value: function startAnimate() {
if (this.animateCount === 0) {
this.unRegsterMapEvent();
this._engine.run();
}
this.animateCount++;
}
}, {
key: "stopAnimate",
value: function stopAnimate() {
if (this.animateCount === 1) {
this._engine.stop();
this.registerMapEvent();
}
this.animateCount++;
} // 地图状态变化时更新可视化渲染
}, {
key: "registerMapEvent",
value: function registerMapEvent() {
var _this5 = this;
this._updateRender = function () {
return _this5._engine.update();
};
this.map.on('mousemove', this._updateRender);
this.map.on('mapmove', this._updateRender);
this.map.on('camerachange', this._updateRender);
}
}, {
key: "unRegsterMapEvent",
value: function unRegsterMapEvent() {
this.map.off('mousemove', this._updateRender);
this.map.off('mapmove', this._updateRender);
this.map.off('camerachange', this._updateRender);
}
}]);
return Scene;
}(_base["default"]);
exports["default"] = Scene;

View File

@ -1,274 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("./base"));
var _source = require("../source");
var _cluster = require("../source/transform/cluster");
var _geo = require("../util/geo");
var _util = require("@antv/util");
var _index = require("../map/index");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Source =
/*#__PURE__*/
function (_Base) {
_inherits(Source, _Base);
_createClass(Source, [{
key: "getDefaultCfg",
value: function getDefaultCfg() {
return {
data: null,
defs: {},
parser: {},
transforms: [],
scaledefs: {},
scales: {},
options: {}
};
}
}]);
function Source(cfg) {
var _this;
_classCallCheck(this, Source);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Source).call(this, cfg));
var transform = _this.get('transforms');
_this._transforms = transform || [];
var mapType = _this.get('mapType') || 'AMap';
_this.projectFlat = (0, _index.getMap)(mapType).project; // 数据解析
_this._init();
return _this;
}
_createClass(Source, [{
key: "_init",
value: function _init() {
this._excuteParser();
var isCluster = this.get('isCluster') || false;
isCluster && this._executeCluster(); // 数据转换 统计,聚合,分类
this._executeTrans(); // 坐标转换
if (!this.get('projected')) {
this._projectCoords();
}
}
}, {
key: "setData",
value: function setData(data) {
var cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Object.assign(this._attrs, cfg);
var transform = this.get('transforms');
this._transforms = transform || [];
this.set('data', data);
this._init();
} // 数据更新
}, {
key: "updateTransfrom",
value: function updateTransfrom(cfg) {
var transforms = cfg.transforms;
this._transforms = transforms;
this.data = (0, _util.clone)(this.originData);
this._executeTrans();
this._projectCoords();
}
}, {
key: "_excuteParser",
value: function _excuteParser() {
var parser = this.get('parser');
var _parser$type = parser.type,
type = _parser$type === void 0 ? 'geojson' : _parser$type;
var data = this.get('data');
this.originData = (0, _source.getParser)(type)(data, parser); // this.data = {
// dataArray: clone(this.originData.dataArray)
// }; // TODO 关闭数据备份
this.data = this.originData;
if (this.data !== null && !this.get('projected')) {
this.data.extent = (0, _geo.extent)(this.data.dataArray);
}
}
/**
* 数据统计
*/
}, {
key: "_executeTrans",
value: function _executeTrans() {
var _this2 = this;
var trans = this._transforms;
trans.forEach(function (tran) {
var type = tran.type;
var data = (0, _source.getTransform)(type)(_this2.data, tran);
Object.assign(_this2.data, data);
});
this._transforms = trans;
}
}, {
key: "transform",
value: function transform(option) {
var data = (0, _source.getTransform)(option.type)(this.data, option);
Object.assign(this.data, data);
}
}, {
key: "_executeCluster",
value: function _executeCluster() {
var clusterCfg = this.get('Cluster') || {};
var zoom = this.get('zoom');
clusterCfg.zoom = Math.floor(zoom);
this.set('cluster', clusterCfg);
var clusterData = (0, _cluster.cluster)(this.data, clusterCfg);
this.data = clusterData.data;
this.pointIndex = clusterData.pointIndex;
}
}, {
key: "updateCusterData",
value: function updateCusterData(zoom, bbox) {
var clusterPoint = this.pointIndex.getClusters(bbox, zoom);
this.data.dataArray = (0, _cluster.formatData)(clusterPoint);
var clusterCfg = this.get('Cluster') || {};
clusterCfg.zoom = Math.floor(zoom);
clusterCfg.bbox = bbox;
this.set('cluster', clusterCfg);
this._projectCoords();
}
}, {
key: "_projectCoords",
value: function _projectCoords() {
var _this3 = this;
if (this.data === null) {
return;
}
this.data.dataArray.forEach(function (data) {
// data.coordinates = this._coordProject(data.coordinates);
data.coordinates = (0, _geo.tranfrormCoord)(data.coordinates, _this3._coorConvert.bind(_this3));
});
}
}, {
key: "_getCoord",
value: function _getCoord(geo) {
if (geo.geometry) {
// GeoJSON feature
geo = geo.geometry.coordinates;
} else if (geo.coordinates) {
// GeoJSON geometry
geo = geo.coordinates;
}
return geo;
}
}, {
key: "_coordProject",
value: function _coordProject(geo) {
var _this4 = this;
if (Array.isArray(geo[0][0])) {
return geo.map(function (coor) {
return _this4._coordProject(coor);
});
}
if (!Array.isArray(geo[0])) {
return this._coorConvert(geo);
}
return geo.map(function (coor) {
return _this4._coorConvert(coor);
});
}
}, {
key: "_coorConvert",
value: function _coorConvert(geo) {
var ll = this.projectFlat(geo);
return [ll.x, ll.y, geo[2] || 0];
}
}, {
key: "getSelectFeature",
value: function getSelectFeature(featureId) {
var data = this.get('data'); // 如果是GeoJSON 数据返回原数
// 颜色编码从1开始要素索引从0开始所以颜色转变要素需要减1
var isCluster = this.get('isCluster') || false;
return data.features && !isCluster ? data.features[featureId - 1] : this.data.dataArray[featureId - 1];
}
}, {
key: "getSeletFeatureIndex",
value: function getSeletFeatureIndex(featureId) {
var data = this.get('data');
if (!data.features) {
return featureId - 1;
}
var featureIndex = 0;
for (var i = 0; i < this.data.dataArray.length; i++) {
var item = this.data.dataArray[i];
if (item._id === featureId) {
break;
}
featureIndex++;
}
return featureIndex;
}
}, {
key: "destroy",
value: function destroy() {
this.data = null;
this.originData = null;
}
}]);
return Source;
}(_base["default"]);
exports["default"] = Source;

View File

@ -1,154 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("../core/base"));
var _worker_pool = _interopRequireDefault(require("../worker/worker_pool"));
var _throttle = _interopRequireDefault(require("../util/throttle"));
var _source_cache = _interopRequireDefault(require("../source/source_cache"));
var _worker_controller = _interopRequireDefault(require("../worker/worker_controller"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
// 统一管理所有的Source
// 统一管理地图样式
var Style =
/*#__PURE__*/
function (_Base) {
_inherits(Style, _Base);
function Style(scene, cfg) {
var _this;
_classCallCheck(this, Style);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Style).call(this, cfg));
_this.scene = scene;
_this._sourceCaches = {};
_this.WorkerPool = new _worker_pool["default"]();
_this._tileMap = {};
_this.WorkerController = new _worker_controller["default"](_this.WorkerPool, _assertThisInitialized(_this));
_this.layerStyles = {};
_this.layers = [];
_this.addMapEvent();
return _this;
}
_createClass(Style, [{
key: "addSource",
value: function addSource(id, sourceCfg) {
if (this._sourceCaches[id] !== undefined) {
throw new Error('SourceID 已存在');
}
sourceCfg.sourceID = id;
this._sourceCaches[id] = new _source_cache["default"](this.scene, sourceCfg);
}
}, {
key: "getSource",
value: function getSource(id) {
return this._sourceCaches[id];
}
}, {
key: "addLayer",
value: function addLayer(layer) {
var id = layer.layerId;
this.layers[id] = layer;
} // 设置
}, {
key: "_addTileStyle",
value: function _addTileStyle(layerCfg) {
var layerid = layerCfg.layerId;
this.layerStyles[layerid] = layerCfg;
this._layerStyleGroupBySourceID();
this.WorkerController.broadcast('setLayers', this.layerStyles); // TODO 更新 style
}
}, {
key: "removeTileStyle",
value: function removeTileStyle(id) {
delete this.layerStyles[id];
this._layerStyleGroupBySourceID();
}
}, {
key: "_layerStyleGroupBySourceID",
value: function _layerStyleGroupBySourceID() {
var sourceStyles = []; // 支持VectorLayer
for (var layerId in this.layerStyles) {
var sourceID = this.layerStyles[layerId].sourceOption.id;
var sourcelayer = this.layerStyles[layerId].sourceOption.parser.sourceLayer;
if (!sourceStyles[sourceID]) sourceStyles[sourceID] = {};
if (!sourceStyles[sourceID][sourcelayer]) sourceStyles[sourceID][sourcelayer] = [];
sourceStyles[sourceID][sourcelayer].push(this.layerStyles[layerId]);
}
this.sourceStyles = sourceStyles;
}
}, {
key: "update",
value: function update(parameters) {
this._addTileStyle(parameters);
for (var key in this._sourceCaches) {
this._sourceCaches[key].update(this.layers, this.sourceStyles[key]);
}
}
}, {
key: "addMapEvent",
value: function addMapEvent() {
var _this2 = this;
this.mapEventHander = (0, _throttle["default"])(function () {
requestAnimationFrame(function () {
for (var key in _this2._sourceCaches) {
_this2._sourceCaches[key].update(_this2.layers, _this2.sourceStyles[key]);
}
});
}, 200);
this.scene.map.on('zoomchange', this.mapEventHander);
this.scene.map.on('dragend', this.mapEventHander);
}
}, {
key: "clearMapEvent",
value: function clearMapEvent() {
this.scene.map.off('zoomchange', this.mapEventHander);
this.scene.map.off('dragend', this.mapEventHander);
} // 计算视野内的瓦片坐标
}]);
return Style;
}(_base["default"]);
exports["default"] = Style;

View File

@ -1,362 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
Float32BufferAttribute: true,
Float64BufferAttribute: true,
Uint32BufferAttribute: true,
Int32BufferAttribute: true,
Uint16BufferAttribute: true,
Int16BufferAttribute: true,
Uint8ClampedBufferAttribute: true,
Uint8BufferAttribute: true,
Int8BufferAttribute: true,
BufferAttribute: true,
Scene: true,
WebGLRenderer: true,
CanvasTexture: true,
Object3D: true,
Group: true,
Clock: true,
Points: true,
LineSegments: true,
Mesh: true,
Texture: true,
WebGLRenderTarget: true,
PerspectiveCamera: true,
OrthographicCamera: true,
BufferGeometry: true,
InstancedBufferGeometry: true,
PlaneBufferGeometry: true,
BoxBufferGeometry: true,
Raycaster: true,
UniformsUtils: true,
Matrix4: true,
Matrix3: true,
Line: true,
Vector4: true,
Vector3: true,
Vector2: true,
ShaderMaterial: true,
DataTexture: true,
Color: true,
InstancedBufferAttribute: true
};
exports.Float32BufferAttribute = Float32BufferAttribute;
Object.defineProperty(exports, "Float64BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Float64BufferAttribute;
}
});
Object.defineProperty(exports, "Uint32BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Uint32BufferAttribute;
}
});
Object.defineProperty(exports, "Int32BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Int32BufferAttribute;
}
});
Object.defineProperty(exports, "Uint16BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Uint16BufferAttribute;
}
});
Object.defineProperty(exports, "Int16BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Int16BufferAttribute;
}
});
Object.defineProperty(exports, "Uint8ClampedBufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Uint8ClampedBufferAttribute;
}
});
Object.defineProperty(exports, "Uint8BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Uint8BufferAttribute;
}
});
Object.defineProperty(exports, "Int8BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.Int8BufferAttribute;
}
});
Object.defineProperty(exports, "BufferAttribute", {
enumerable: true,
get: function get() {
return _BufferAttribute.BufferAttribute;
}
});
Object.defineProperty(exports, "Scene", {
enumerable: true,
get: function get() {
return _Scene.Scene;
}
});
Object.defineProperty(exports, "WebGLRenderer", {
enumerable: true,
get: function get() {
return _WebGLRenderer.WebGLRenderer;
}
});
Object.defineProperty(exports, "CanvasTexture", {
enumerable: true,
get: function get() {
return _CanvasTexture.CanvasTexture;
}
});
Object.defineProperty(exports, "Object3D", {
enumerable: true,
get: function get() {
return _Object3D.Object3D;
}
});
Object.defineProperty(exports, "Group", {
enumerable: true,
get: function get() {
return _Group.Group;
}
});
Object.defineProperty(exports, "Clock", {
enumerable: true,
get: function get() {
return _Clock.Clock;
}
});
Object.defineProperty(exports, "Points", {
enumerable: true,
get: function get() {
return _Points.Points;
}
});
Object.defineProperty(exports, "LineSegments", {
enumerable: true,
get: function get() {
return _LineSegments.LineSegments;
}
});
Object.defineProperty(exports, "Mesh", {
enumerable: true,
get: function get() {
return _Mesh.Mesh;
}
});
Object.defineProperty(exports, "Texture", {
enumerable: true,
get: function get() {
return _Texture.Texture;
}
});
Object.defineProperty(exports, "WebGLRenderTarget", {
enumerable: true,
get: function get() {
return _WebGLRenderTarget.WebGLRenderTarget;
}
});
Object.defineProperty(exports, "PerspectiveCamera", {
enumerable: true,
get: function get() {
return _PerspectiveCamera.PerspectiveCamera;
}
});
Object.defineProperty(exports, "OrthographicCamera", {
enumerable: true,
get: function get() {
return _OrthographicCamera.OrthographicCamera;
}
});
Object.defineProperty(exports, "BufferGeometry", {
enumerable: true,
get: function get() {
return _BufferGeometry.BufferGeometry;
}
});
Object.defineProperty(exports, "InstancedBufferGeometry", {
enumerable: true,
get: function get() {
return _InstancedBufferGeometry.InstancedBufferGeometry;
}
});
Object.defineProperty(exports, "PlaneBufferGeometry", {
enumerable: true,
get: function get() {
return _PlaneGeometry.PlaneBufferGeometry;
}
});
Object.defineProperty(exports, "BoxBufferGeometry", {
enumerable: true,
get: function get() {
return _BoxGeometry.BoxBufferGeometry;
}
});
Object.defineProperty(exports, "Raycaster", {
enumerable: true,
get: function get() {
return _Raycaster.Raycaster;
}
});
Object.defineProperty(exports, "UniformsUtils", {
enumerable: true,
get: function get() {
return _UniformsUtils.UniformsUtils;
}
});
Object.defineProperty(exports, "Matrix4", {
enumerable: true,
get: function get() {
return _Matrix.Matrix4;
}
});
Object.defineProperty(exports, "Matrix3", {
enumerable: true,
get: function get() {
return _Matrix2.Matrix3;
}
});
Object.defineProperty(exports, "Line", {
enumerable: true,
get: function get() {
return _Line.Line;
}
});
Object.defineProperty(exports, "Vector4", {
enumerable: true,
get: function get() {
return _Vector.Vector4;
}
});
Object.defineProperty(exports, "Vector3", {
enumerable: true,
get: function get() {
return _Vector2.Vector3;
}
});
Object.defineProperty(exports, "Vector2", {
enumerable: true,
get: function get() {
return _Vector3.Vector2;
}
});
Object.defineProperty(exports, "ShaderMaterial", {
enumerable: true,
get: function get() {
return _ShaderMaterial.ShaderMaterial;
}
});
Object.defineProperty(exports, "DataTexture", {
enumerable: true,
get: function get() {
return _DataTexture.DataTexture;
}
});
Object.defineProperty(exports, "Color", {
enumerable: true,
get: function get() {
return _Color.Color;
}
});
Object.defineProperty(exports, "InstancedBufferAttribute", {
enumerable: true,
get: function get() {
return _InstancedBufferAttribute.InstancedBufferAttribute;
}
});
require("three/src/polyfills.js");
var _BufferAttribute = require("three/src/core/BufferAttribute.js");
var _constants = require("three/src/constants.js");
Object.keys(_constants).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _constants[key];
}
});
});
var _Scene = require("three/src/scenes/Scene.js");
var _WebGLRenderer = require("three/src/renderers/WebGLRenderer.js");
var _CanvasTexture = require("three/src/textures/CanvasTexture.js");
var _Object3D = require("three/src/core/Object3D.js");
var _Group = require("three/src/objects/Group");
var _Clock = require("three/src/core/Clock");
var _Points = require("three/src/objects/Points.js");
var _LineSegments = require("three/src/objects/LineSegments.js");
var _Mesh = require("three/src/objects/Mesh.js");
var _Texture = require("three/src/textures/Texture.js");
var _WebGLRenderTarget = require("three/src/renderers/WebGLRenderTarget.js");
var _PerspectiveCamera = require("three/src/cameras/PerspectiveCamera.js");
var _OrthographicCamera = require("three/src/cameras/OrthographicCamera.js");
var _BufferGeometry = require("three/src/core/BufferGeometry.js");
var _InstancedBufferGeometry = require("three/src/core/InstancedBufferGeometry");
var _PlaneGeometry = require("three/src/geometries/PlaneGeometry.js");
var _BoxGeometry = require("three/src/geometries/BoxGeometry.js");
var _Raycaster = require("three/src/core/Raycaster.js");
var _UniformsUtils = require("three/src/renderers/shaders/UniformsUtils.js");
var _Matrix = require("three/src/math/Matrix4.js");
var _Matrix2 = require("three/src/math/Matrix3.js");
var _Line = require("three/src/objects/Line.js");
var _Vector = require("three/src/math/Vector4.js");
var _Vector2 = require("three/src/math/Vector3.js");
var _Vector3 = require("three/src/math/Vector2.js");
var _ShaderMaterial = require("three/src/materials/ShaderMaterial.js");
var _DataTexture = require("three/src/textures/DataTexture.js");
var _Color = require("three/src/math/Color.js");
var _InstancedBufferAttribute = require("three/src/core/InstancedBufferAttribute");
// export * from '../../build/three.js';
function Float32BufferAttribute(array, itemSize, normalized) {
if (Array.isArray(array)) {
array = new Float32Array(array);
}
_BufferAttribute.BufferAttribute.call(this, array, itemSize, normalized);
}
Float32BufferAttribute.prototype = Object.create(_BufferAttribute.BufferAttribute.prototype);
Float32BufferAttribute.prototype.constructor = Float32BufferAttribute;

View File

@ -1,94 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var WorkerPool =
/*#__PURE__*/
function () {
function WorkerPool(workerCount) {
_classCallCheck(this, WorkerPool);
this.workerCount = workerCount || Math.max(Math.floor(window.navigator.hardwareConcurrency / 2), 1);
this.workers = []; // worker线程池
this.workerQueue = []; // 任务队列
this._initWorker(); // 初始化线程池
}
_createClass(WorkerPool, [{
key: "_initWorker",
value: function _initWorker() {
while (this.workers.length < this.workerCount) {
this.workers.push(new Worker());
}
}
}, {
key: "runTask",
value: function runTask(payload) {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this.workers.length > 0) {
var worker = _this.workers.shift(); // 从线程池取出一个worker
worker.postMessage(payload); // 向线程发送数据
var workerCallback = function workerCallback(e) {
resolve(e.data); // 成功则返回数据
// 移除事件监听
worker.removeEventListener('message', workerCallback); // 重新放回线程池
_this.workers.push(worker); // 如果任务队列的数据还有则从任务队列继续取数据执行任务
if (_this.workerQueue.length > 0) {
var queueData = _this.workerQueue.shift();
_this.runTask(queueData.payload).then(function (data) {
queueData.resolve(data);
});
}
}; // 监听worker事件
worker.addEventListener('message', workerCallback);
worker.addEventListener('error', function (e) {
reject('filename:' + e.filename + '\nmessage:' + e.message + '\nlineno:' + e.lineno);
});
} else {
// 如果线程池都被占用则将数据丢入任务队列并保存对应的resolve和reject
_this.workerQueue.push({
payload: payload,
resolve: resolve,
reject: reject
});
}
});
}
}, {
key: "release",
value: function release() {
this.workers.forEach(function (worker) {
worker.terminate();
});
}
}]);
return WorkerPool;
}();
var _default = WorkerPool;
exports["default"] = _default;

View File

@ -1 +0,0 @@
"use strict";

View File

@ -1 +0,0 @@
"use strict";

View File

@ -1,92 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _rbush = _interopRequireDefault(require("rbush"));
var _bbox = _interopRequireDefault(require("@turf/bbox"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var FeatureIndex =
/*#__PURE__*/
function () {
function FeatureIndex(data) {
var _this = this;
_classCallCheck(this, FeatureIndex);
this.tree = (0, _rbush["default"])();
this.rawData = data;
data.features.forEach(function (feature) {
_this.insert(feature);
});
}
_createClass(FeatureIndex, [{
key: "insert",
value: function insert(feature) {
var bbox = this.toBBox(feature);
bbox.feature = feature;
this.tree.insert(bbox);
}
}, {
key: "search",
value: function search(feature) {
return this.tree.search(this.toBBox(feature));
}
}, {
key: "clear",
value: function clear() {
this.tree.clear();
}
}, {
key: "all",
value: function all() {
return this.tree.all();
}
}, {
key: "toBBox",
value: function toBBox(feature) {
var bbox = feature.type === 'Point' ? this.pointBBox(feature) : (0, _bbox["default"])(feature);
return {
minX: bbox[0],
minY: bbox[1],
maxX: bbox[2],
maxY: bbox[3]
};
}
}, {
key: "pointBBox",
value: function pointBBox(feature) {
var size = 1 / 1000 / 1000; // 1m
var _feature$geometry$coo = _slicedToArray(feature.geometry.coordinates, 2),
x = _feature$geometry$coo[0],
y = _feature$geometry$coo[1];
return [x - size, y - size, x + size, y + size];
}
}]);
return FeatureIndex;
}();
exports["default"] = FeatureIndex;

View File

@ -1 +0,0 @@
"use strict";

View File

@ -1 +0,0 @@
"use strict";

View File

@ -1,55 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.aProjectFlat = aProjectFlat;
exports.unProjectFlat = unProjectFlat;
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function aProjectFlat(lnglat) {
var maxs = 85.0511287798;
var lat = Math.max(Math.min(maxs, lnglat[1]), -maxs);
var scale = 256 << 20;
var d = Math.PI / 180;
var x = lnglat[0] * d;
var y = lat * d;
y = Math.log(Math.tan(Math.PI / 4 + y / 2));
var a = 0.5 / Math.PI,
b = 0.5,
c = -0.5 / Math.PI;
d = 0.5;
x = scale * (a * x + b) - 215440491;
y = scale * (c * y + d) - 106744817;
return {
x: parseInt(x),
y: parseInt(y)
};
}
function unProjectFlat(px) {
var a = 0.5 / Math.PI,
b = 0.5,
c = -0.5 / Math.PI;
var d = 0.5;
var scale = 256 << 20;
var _px = _slicedToArray(px, 2),
x = _px[0],
y = _px[1];
x = ((x + 215440491) / scale - b) / a;
y = ((y + 106744817) / scale - d) / c;
y = (Math.atan(Math.pow(Math.E, y)) - Math.PI / 4) * 2;
d = Math.PI / 180;
var lat = y / d;
var lng = x / d;
return [lng, lat];
}

View File

@ -1,35 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shapeBae = exports.GeomBase = void 0;
var GeomBase = {
color: 'updateDraw',
size: 'repaint',
filter: 'updateDraw',
layer: '',
pickable: true,
setLayer: function setLayer(layer) {
this.layer = layer;
this.style = layer.get('styleOption');
},
getShape: function getShape(type) {
return type;
},
draw: function draw() {
var shape = this.getShape();
this.Mesh = shape.Mesh();
},
// 更新geometry buffer;
updateDraw: function updateDraw() {},
repaint: function repaint() {}
};
exports.GeomBase = GeomBase;
var shapeBae = {
geometryBuffer: function geometryBuffer() {},
geometry: function geometry() {},
material: function material() {},
mesh: function mesh() {}
};
exports.shapeBae = shapeBae;

View File

@ -1,241 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("../../core/base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var BufferBase =
/*#__PURE__*/
function (_Base) {
_inherits(BufferBase, _Base);
function BufferBase(cfg) {
var _this;
_classCallCheck(this, BufferBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(BufferBase).call(this, cfg));
_this.attributes = {};
_this.verticesCount = 0;
_this.indexCount = 0;
_this.indexArray = new Int32Array(0);
_this._init();
return _this;
}
_createClass(BufferBase, [{
key: "_init",
value: function _init() {
this._calculateFeatures();
this._initAttributes();
this._buildFeatures();
}
}, {
key: "_initAttributes",
value: function _initAttributes() {
this.attributes.positions = new Float32Array(this.verticesCount * 3);
this.attributes.colors = new Float32Array(this.verticesCount * 4);
this.attributes.pickingIds = new Float32Array(this.verticesCount);
this.attributes.sizes = new Float32Array(this.verticesCount);
this.attributes.pickingIds = new Float32Array(this.verticesCount);
if (this.get('uv')) {
this.attributes.uv = new Float32Array(this.verticesCount * 2);
}
this.indexArray = new Int32Array(this.indexCount);
}
}, {
key: "addFeature",
value: function addFeature() {} // 更新渲染
}, {
key: "upload",
value: function upload() {}
}, {
key: "destroy",
value: function destroy() {}
}, {
key: "resize",
value: function resize() {}
}, {
key: "checkIsClosed",
value: function checkIsClosed(points) {
var p1 = points[0][0];
var p2 = points[0][points[0].length - 1];
return p1[0] === p2[0] && p1[1] === p2[1];
}
}, {
key: "concat",
value: function concat(arrayType, arrays) {
var totalLength = 0;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = arrays[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var arr = _step.value;
totalLength += arr.length;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var arrayBuffer = new ArrayBuffer(totalLength * arrayType.BYTES_PER_ELEMENT);
var offset = 0;
var result = new arrayType(arrayBuffer);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = arrays[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _arr = _step2.value;
result.set(_arr, offset);
offset += _arr.length;
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return result;
}
}, {
key: "_encodeArray",
value: function _encodeArray(feature, num) {
var color = feature.color,
id = feature.id,
pattern = feature.pattern,
size = feature.size;
var verticesOffset = feature.bufferInfo.verticesOffset;
var imagePos = this.get('imagePos');
var start1 = verticesOffset;
for (var i = 0; i < num; i++) {
if (feature.hasOwnProperty('color')) {
this.attributes.colors[start1 * 4 + i * 4] = color[0];
this.attributes.colors[start1 * 4 + i * 4 + 1] = color[1];
this.attributes.colors[start1 * 4 + i * 4 + 2] = color[2];
this.attributes.colors[start1 * 4 + i * 4 + 3] = color[3];
}
if (feature.hasOwnProperty('id')) {
this.attributes.pickingIds[start1 + i] = id;
}
if (feature.hasOwnProperty('size')) {
var size2 = size;
if (Array.isArray(size) && size.length === 2) {
size2 = [size[0]];
}
if (!Array.isArray(size)) {
size2 = [size];
}
this.attributes.sizes.set(size2, (start1 + i) * size2.length);
}
if (feature.hasOwnProperty('pattern')) {
var patternPos = imagePos[pattern] || {
x: 0,
y: 0
};
this.attributes.patterns[start1 * 2 + i * 2] = patternPos.x;
this.attributes.patterns[start1 * 2 + i * 2 + 1] = patternPos.y;
}
}
}
}, {
key: "_calculateWall",
value: function _calculateWall(feature) {
var size = feature.size;
var _feature$bufferInfo = feature.bufferInfo,
vertices = _feature$bufferInfo.vertices,
indexOffset = _feature$bufferInfo.indexOffset,
verticesOffset = _feature$bufferInfo.verticesOffset,
faceNum = _feature$bufferInfo.faceNum;
this._encodeArray(feature, faceNum * 4);
for (var i = 0; i < faceNum; i++) {
var prePoint = vertices.slice(i * 3, i * 3 + 3);
var nextPoint = vertices.slice(i * 3 + 3, i * 3 + 6);
this._calculateExtrudeFace(prePoint, nextPoint, verticesOffset + i * 4, indexOffset + i * 6, size);
feature.bufferInfo.verticesOffset += 4;
feature.bufferInfo.indexOffset += 6;
}
}
}, {
key: "_calculateExtrudeFace",
value: function _calculateExtrudeFace(prePoint, nextPoint, positionOffset, indexOffset, size) {
this.attributes.positions.set([prePoint[0], prePoint[1], size, nextPoint[0], nextPoint[1], size, prePoint[0], prePoint[1], 0, nextPoint[0], nextPoint[1], 0], positionOffset * 3);
var indexArray = [1, 2, 0, 3, 2, 1].map(function (v) {
return v + positionOffset;
});
if (this.get('uv')) {
this.attributes.uv.set([0.1, 0, 0, 0, 0.1, size / 2000, 0, size / 2000], positionOffset * 2);
}
this.indexArray.set(indexArray, indexOffset);
}
}]);
return BufferBase;
}(_base["default"]);
exports["default"] = BufferBase;

View File

@ -1,431 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _base = _interopRequireDefault(require("../../core/base"));
var THREE = _interopRequireWildcard(require("../../core/three"));
var _normals2 = require("../normals");
var _extrude2 = _interopRequireDefault(require("../extrude"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var BufferBase =
/*#__PURE__*/
function (_Base) {
_inherits(BufferBase, _Base);
function BufferBase(cfg) {
var _this;
_classCallCheck(this, BufferBase);
_this = _possibleConstructorReturn(this, _getPrototypeOf(BufferBase).call(this, cfg));
_this.bufferStruct = {};
_this.geometryBuffer();
return _this;
}
_createClass(BufferBase, [{
key: "geometryBuffer",
value: function geometryBuffer() {}
}, {
key: "_normals",
value: function _normals() {
var _this$bufferStruct = this.bufferStruct,
position = _this$bufferStruct.position,
indices = _this$bufferStruct.indices,
_this$bufferStruct$no = _this$bufferStruct.normals,
normals = _this$bufferStruct$no === void 0 ? [] : _this$bufferStruct$no;
indices.forEach(function (index, i) {
normals.push((0, _normals2.faceNormals)(index, position[i]));
});
this.bufferStruct.normals = normals;
}
}, {
key: "_extrude",
value: function _extrude(coordinate, heightValue) {
var extrudeData = (0, _extrude2["default"])(coordinate, heightValue);
return extrudeData;
}
}, {
key: "_mergeAttributes",
value: function _mergeAttributes(attributes) {
var lengths = {}; // Find array lengths
attributes.forEach(function (_attributes) {
for (var k in _attributes) {
if (!lengths[k]) {
lengths[k] = 0;
}
lengths[k] += _attributes[k].length;
}
});
var mergedAttributes = {}; // Set up arrays to merge into
for (var k in lengths) {
mergedAttributes[k] = new Float32Array(lengths[k]);
}
var lastLengths = {};
attributes.forEach(function (_attributes) {
for (var _k in _attributes) {
if (!lastLengths[_k]) {
lastLengths[_k] = 0;
}
mergedAttributes[_k].set(_attributes[_k], lastLengths[_k]);
lastLengths[_k] += _attributes[_k].length;
}
});
return mergedAttributes;
}
}, {
key: "_toPolygonAttributes",
value: function _toPolygonAttributes(polygon) {
// Three components per vertex per face (3 x 3 = 9)
var style = polygon.style,
indices = polygon.indices,
position = polygon.position,
indexCount = polygon.indexCount;
var vertices = new Float32Array(indexCount * 3);
var normals = new Float32Array(indexCount * 3);
var colors = new Float32Array(indexCount * 4);
var pickingIds = new Float32Array(indexCount);
var pA = new THREE.Vector3();
var pB = new THREE.Vector3();
var pC = new THREE.Vector3();
var cb = new THREE.Vector3();
var ab = new THREE.Vector3();
var lastIndex = 0;
indices.forEach(function (indice, pIndex) {
for (var i = 0; i < indice.length / 3; i++) {
var index = indice[i * 3];
var color = style[pIndex].color;
var _pickingId = style[pIndex].id;
var ax = position[pIndex][index][0];
var ay = position[pIndex][index][1];
var az = position[pIndex][index][2];
index = indice[i * 3 + 1];
var bx = position[pIndex][index][0];
var by = position[pIndex][index][1];
var bz = position[pIndex][index][2];
index = indice[i * 3 + 2];
var cx = position[pIndex][index][0];
var cy = position[pIndex][index][1];
var cz = position[pIndex][index][2];
pA.set(ax, ay, az);
pB.set(bx, by, bz);
pC.set(cx, cy, cz);
cb.subVectors(pC, pB);
ab.subVectors(pA, pB);
cb.cross(ab);
cb.normalize();
var nx = cb.x;
var ny = cb.y;
var nz = cb.z;
vertices[lastIndex * 9 + 0] = ax;
vertices[lastIndex * 9 + 1] = ay;
vertices[lastIndex * 9 + 2] = az;
normals[lastIndex * 9 + 0] = nx;
normals[lastIndex * 9 + 1] = ny;
normals[lastIndex * 9 + 2] = nz;
colors[lastIndex * 12 + 0] = color[0];
colors[lastIndex * 12 + 1] = color[1];
colors[lastIndex * 12 + 2] = color[2];
colors[lastIndex * 12 + 3] = color[3];
vertices[lastIndex * 9 + 3] = bx;
vertices[lastIndex * 9 + 4] = by;
vertices[lastIndex * 9 + 5] = bz;
normals[lastIndex * 9 + 3] = nx;
normals[lastIndex * 9 + 4] = ny;
normals[lastIndex * 9 + 5] = nz;
colors[lastIndex * 12 + 4] = color[0];
colors[lastIndex * 12 + 5] = color[1];
colors[lastIndex * 12 + 6] = color[2];
colors[lastIndex * 12 + 7] = color[3];
vertices[lastIndex * 9 + 6] = cx;
vertices[lastIndex * 9 + 7] = cy;
vertices[lastIndex * 9 + 8] = cz;
normals[lastIndex * 9 + 6] = nx;
normals[lastIndex * 9 + 7] = ny;
normals[lastIndex * 9 + 8] = nz;
colors[lastIndex * 12 + 8] = color[0];
colors[lastIndex * 12 + 9] = color[1];
colors[lastIndex * 12 + 10] = color[2];
colors[lastIndex * 12 + 11] = color[3];
pickingIds[lastIndex * 3 + 0] = _pickingId;
pickingIds[lastIndex * 3 + 1] = _pickingId;
pickingIds[lastIndex * 3 + 2] = _pickingId;
lastIndex++;
}
});
var attributes = {
vertices: vertices,
normals: normals,
colors: colors,
pickingIds: pickingIds,
faceUv: new Float32Array(polygon.faceUv),
sizes: new Float32Array(polygon.sizes)
};
return attributes;
}
}, {
key: "_toPointShapeAttributes",
value: function _toPointShapeAttributes(polygon) {
// Three components per vertex per face (3 x 3 = 9)
var style = polygon.style,
indices = polygon.indices,
position = polygon.position,
indexCount = polygon.indexCount,
shapes = polygon.shapes,
sizes = polygon.sizes;
var vertices = new Float32Array(indexCount * 3);
var shapePositions = new Float32Array(indexCount * 3);
var a_size = new Float32Array(indexCount * 3);
var normals = new Float32Array(indexCount * 3);
var colors = new Float32Array(indexCount * 4);
var pickingIds = new Float32Array(indexCount);
var pA = new THREE.Vector3();
var pB = new THREE.Vector3();
var pC = new THREE.Vector3();
var cb = new THREE.Vector3();
var ab = new THREE.Vector3();
var lastIndex = 0;
indices.forEach(function (indice, pIndex) {
for (var i = 0; i < indice.length / 3; i++) {
var index = indice[i * 3];
var color = style[pIndex].color;
var coor1 = position[pIndex];
var size = sizes[pIndex];
var _pickingId = style[pIndex].id;
var ax = shapes[pIndex][index][0];
var ay = shapes[pIndex][index][1];
var az = shapes[pIndex][index][2];
index = indice[i * 3 + 1];
var bx = shapes[pIndex][index][0];
var by = shapes[pIndex][index][1];
var bz = shapes[pIndex][index][2];
index = indice[i * 3 + 2];
var cx = shapes[pIndex][index][0];
var cy = shapes[pIndex][index][1];
var cz = shapes[pIndex][index][2];
pA.set(ax, ay, az);
pB.set(bx, by, bz);
pC.set(cx, cy, cz);
cb.subVectors(pC, pB);
ab.subVectors(pA, pB);
cb.cross(ab);
cb.normalize();
var nx = cb.x;
var ny = cb.y;
var nz = cb.z;
vertices[lastIndex * 9 + 0] = coor1[0];
vertices[lastIndex * 9 + 1] = coor1[1];
vertices[lastIndex * 9 + 2] = coor1[2];
shapePositions[lastIndex * 9 + 0] = ax;
shapePositions[lastIndex * 9 + 1] = ay;
shapePositions[lastIndex * 9 + 2] = az;
a_size[lastIndex * 9 + 0] = size[0];
a_size[lastIndex * 9 + 1] = size[1];
a_size[lastIndex * 9 + 2] = size[2];
normals[lastIndex * 9 + 0] = nx;
normals[lastIndex * 9 + 1] = ny;
normals[lastIndex * 9 + 2] = nz;
colors[lastIndex * 12 + 0] = color[0];
colors[lastIndex * 12 + 1] = color[1];
colors[lastIndex * 12 + 2] = color[2];
colors[lastIndex * 12 + 3] = color[3];
vertices[lastIndex * 9 + 3] = coor1[0];
vertices[lastIndex * 9 + 4] = coor1[1];
vertices[lastIndex * 9 + 5] = coor1[2];
shapePositions[lastIndex * 9 + 3] = bx;
shapePositions[lastIndex * 9 + 4] = by;
shapePositions[lastIndex * 9 + 5] = bz;
a_size[lastIndex * 9 + 3] = size[0];
a_size[lastIndex * 9 + 4] = size[1];
a_size[lastIndex * 9 + 5] = size[2];
normals[lastIndex * 9 + 3] = nx;
normals[lastIndex * 9 + 4] = ny;
normals[lastIndex * 9 + 5] = nz;
colors[lastIndex * 12 + 4] = color[0];
colors[lastIndex * 12 + 5] = color[1];
colors[lastIndex * 12 + 6] = color[2];
colors[lastIndex * 12 + 7] = color[3];
vertices[lastIndex * 9 + 6] = coor1[0];
vertices[lastIndex * 9 + 7] = coor1[1];
vertices[lastIndex * 9 + 8] = coor1[2];
a_size[lastIndex * 9 + 6] = size[0];
a_size[lastIndex * 9 + 7] = size[1];
a_size[lastIndex * 9 + 8] = size[2];
shapePositions[lastIndex * 9 + 6] = cx;
shapePositions[lastIndex * 9 + 7] = cy;
shapePositions[lastIndex * 9 + 8] = cz;
normals[lastIndex * 9 + 6] = nx;
normals[lastIndex * 9 + 7] = ny;
normals[lastIndex * 9 + 8] = nz;
colors[lastIndex * 12 + 8] = color[0];
colors[lastIndex * 12 + 9] = color[1];
colors[lastIndex * 12 + 10] = color[2];
colors[lastIndex * 12 + 11] = color[3];
pickingIds[lastIndex * 3 + 0] = _pickingId;
pickingIds[lastIndex * 3 + 1] = _pickingId;
pickingIds[lastIndex * 3 + 2] = _pickingId;
lastIndex++;
}
});
var attributes = {
vertices: vertices,
normals: normals,
colors: colors,
pickingIds: pickingIds,
shapePositions: shapePositions,
a_size: a_size,
faceUv: new Float32Array(polygon.faceUv)
};
return attributes;
}
}, {
key: "_toPolygonLineAttributes",
value: function _toPolygonLineAttributes(polygonline) {
var style = polygonline.style,
indices = polygonline.indices,
position = polygonline.position,
indexCount = polygonline.indexCount;
var vertices = new Float32Array(indexCount * 3);
var colors = new Float32Array(indexCount * 4);
var pickingIds = new Float32Array(indexCount);
var lastIndex = 0;
indices.forEach(function (indice, pIndex) {
for (var i = 0; i < indice.length; i++) {
var index = indice[i];
var color = style[pIndex].color;
var _pickingId = style[pIndex].id;
vertices[lastIndex * 3] = position[pIndex][index][0];
vertices[lastIndex * 3 + 1] = position[pIndex][index][1];
vertices[lastIndex * 3 + 2] = position[pIndex][index][2];
colors[lastIndex * 4] = color[0];
colors[lastIndex * 4 + 1] = color[1];
colors[lastIndex * 4 + 2] = color[2];
colors[lastIndex * 4 + 3] = color[3];
pickingIds[lastIndex] = _pickingId;
lastIndex++;
}
});
var attributes = {
vertices: vertices,
colors: colors,
pickingIds: pickingIds
};
return attributes;
}
}, {
key: "_toPointsAttributes",
value: function _toPointsAttributes(point) {
var style = point.style,
position = point.position;
var count = position.length;
var vertices = new Float32Array(count * 3);
var colors = new Float32Array(count * 4);
var sizes = new Float32Array(count);
var shapes = new Float32Array(count);
var pickingIds = new Float32Array(count);
position.forEach(function (pos, index) {
vertices[index * 3] = pos[0];
vertices[index * 3 + 1] = pos[1];
vertices[index * 3 + 2] = pos[2];
colors[index * 4] = style[index].color[0];
colors[index * 4 + 1] = style[index].color[1];
colors[index * 4 + 2] = style[index].color[2];
colors[index * 4 + 3] = style[index].color[3];
pickingIds[index] = style[index].id;
sizes[index] = style[index].size * window.devicePixelRatio;
if (style[index].shape) {
shapes[index] = style[index].shape;
}
});
var attributes = {
vertices: vertices,
colors: colors,
sizes: sizes,
shapes: shapes,
pickingIds: pickingIds
};
return attributes;
}
}, {
key: "_generateTexture",
value: function _generateTexture() {
// build a small canvas 32x64 and paint it in white
var canvas = document.createElement('canvas');
canvas.width = 32;
canvas.height = 64;
var context = canvas.getContext('2d'); // plain it in white
context.fillStyle = '#ffffff';
context.fillRect(0, 0, 32, 64); // draw the window rows - with a small noise to simulate light variations in each room
for (var y = 8; y < 64; y += 8) {
for (var x = 0; x < 32; x += 2) {
var value = Math.floor(Math.random() * 64);
context.fillStyle = 'rgb(' + [value, value, value].join(',') + ')';
context.fillRect(x, y, 2, 4);
}
}
context.fillStyle = '#105CB3';
context.fillRect(0, 60, 32, 64); // build a bigger canvas and copy the small one in it
// This is a trick to upscale the texture without filtering
var canvas2 = document.createElement('canvas');
canvas2.width = 512;
canvas2.height = 1024;
var context2 = canvas2.getContext('2d'); // disable smoothing
context2.imageSmoothingEnabled = false;
context2.webkitImageSmoothingEnabled = false;
context2.mozImageSmoothingEnabled = false; // then draw the image
context2.drawImage(canvas, 0, 0, canvas2.width, canvas2.height); // return the just built canvas2
var texture = new THREE.Texture(canvas2); // texture.anisotropy = renderer.getMaxAnisotropy();
texture.needsUpdate = true;
return texture;
}
}]);
return BufferBase;
}(_base["default"]);
exports["default"] = BufferBase;

View File

@ -1,26 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.registerBuffer = exports.getBuffer = exports.Buffer_MAP = void 0;
var Buffer_MAP = {};
exports.Buffer_MAP = Buffer_MAP;
var getBuffer = function getBuffer(bufferType, shapeType) {
return Buffer_MAP[bufferType.toLowerCase()] && Buffer_MAP[bufferType.toLowerCase()][shapeType.toLowerCase()];
};
exports.getBuffer = getBuffer;
var registerBuffer = function registerBuffer(bufferType, shapeType, render) {
if (getBuffer(bufferType, shapeType)) {
throw new Error("Render shapeType '".concat(shapeType, "' existed."));
} // 存储到 map 中
if (!Buffer_MAP[bufferType.toLowerCase()]) Buffer_MAP[bufferType.toLowerCase()] = {};
Buffer_MAP[bufferType.toLowerCase()][shapeType.toLowerCase()] = render;
};
exports.registerBuffer = registerBuffer;

View File

@ -1,70 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = gridBuffer;
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function gridBuffer(layerData) {
var attribute = {
vertices: [],
miter: [],
colors: [],
pickingIds: []
};
layerData.forEach(function (element) {
var _attribute$colors, _attribute$colors2, _attribute$colors3, _attribute$colors4, _attribute$colors5, _attribute$colors6;
var color = element.color,
id = element.id;
var _element$coordinates = _slicedToArray(element.coordinates, 3),
x = _element$coordinates[0],
y = _element$coordinates[1],
z = _element$coordinates[2];
attribute.vertices.push(x, y, z);
attribute.miter.push(-1, -1);
attribute.vertices.push(x, y, z);
attribute.miter.push(1, 1);
attribute.vertices.push(x, y, z);
attribute.miter.push(-1, 1);
attribute.vertices.push(x, y, z);
attribute.miter.push(-1, -1);
attribute.vertices.push(x, y, z);
attribute.miter.push(1, -1);
attribute.vertices.push(x, y, z);
attribute.miter.push(1, 1);
(_attribute$colors = attribute.colors).push.apply(_attribute$colors, _toConsumableArray(color));
(_attribute$colors2 = attribute.colors).push.apply(_attribute$colors2, _toConsumableArray(color));
(_attribute$colors3 = attribute.colors).push.apply(_attribute$colors3, _toConsumableArray(color));
(_attribute$colors4 = attribute.colors).push.apply(_attribute$colors4, _toConsumableArray(color));
(_attribute$colors5 = attribute.colors).push.apply(_attribute$colors5, _toConsumableArray(color));
(_attribute$colors6 = attribute.colors).push.apply(_attribute$colors6, _toConsumableArray(color));
attribute.pickingIds.push(id, id, id, id, id, id);
});
return attribute;
}

View File

@ -1,177 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _buffer = _interopRequireDefault(require("../buffer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Grid3D =
/*#__PURE__*/
function (_BufferBase) {
_inherits(Grid3D, _BufferBase);
function Grid3D() {
_classCallCheck(this, Grid3D);
return _possibleConstructorReturn(this, _getPrototypeOf(Grid3D).apply(this, arguments));
}
_createClass(Grid3D, [{
key: "_buildFeatures",
value: function _buildFeatures() {
var _this = this;
var layerData = this.get('layerData');
this._offset = 0;
var shapeType = this.get('shapeType');
layerData.forEach(function (feature) {
_this._calculateTop(feature);
if (shapeType === 'squareColumn') {
_this._calculateWall(feature);
}
delete feature.bufferInfo;
});
}
}, {
key: "_initAttributes",
value: function _initAttributes() {
_get(_getPrototypeOf(Grid3D.prototype), "_initAttributes", this).call(this);
this.attributes.miters = new Float32Array(this.verticesCount * 3);
this.attributes.normals = new Float32Array(this.verticesCount * 3);
}
}, {
key: "_calculateFeatures",
value: function _calculateFeatures() {
var layerData = this.get('layerData');
var shapeType = this.get('shapeType');
if (shapeType === 'squareColumn') {
this.verticesCount = layerData.length * 20;
} else {
this.verticesCount = layerData.length * 4;
}
this.indexCount = this.verticesCount * 1.5;
}
}, {
key: "_calculateTop",
value: function _calculateTop(feature) {
var _this2 = this;
var _feature$coordinates = _slicedToArray(feature.coordinates, 2),
x = _feature$coordinates[0],
y = _feature$coordinates[1];
var size = feature.size;
feature.bufferInfo = {
verticesOffset: this._offset
};
var shapeType = this.get('shapeType');
if (shapeType !== 'squareColumn') {
size = 0;
}
this._encodeArray(feature, 4);
this.attributes.positions.set([x, y, size, x, y, size, x, y, size, x, y, size], this._offset * 3);
this.attributes.miters.set([-1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1], this._offset * 3);
this.attributes.normals.set([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], this._offset * 3); // top normal
var indexArray = [0, 2, 1, 2, 3, 1].map(function (v) {
return v + _this2._offset;
});
this.indexArray.set(indexArray, this._offset * 1.5);
this._offset += 4;
}
}, {
key: "_calculateWall",
value: function _calculateWall(feature) {
var size = feature.size;
var _feature$coordinates2 = _slicedToArray(feature.coordinates, 2),
x = _feature$coordinates2[0],
y = _feature$coordinates2[1];
var vertices = [1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1];
feature.bufferInfo = {
verticesOffset: this._offset
};
this._encodeArray(feature, 20); // front left, back right
this.attributes.normals.set([0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, // bottom
-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // left
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // top
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 // right
], this._offset * 3); // top normal
for (var i = 0; i < 4; i++) {
this.attributes.positions.set([x, y, 1, x, y, 1, x, y, 1, x, y, 1], this._offset * 3);
var prePoint = vertices.slice(i * 3, i * 3 + 3);
var nextPoint = vertices.slice(i * 3 + 3, i * 3 + 6);
this._calculateExtrudeFace(prePoint, nextPoint, this._offset, this._offset * 1.5, size);
this._offset += 4;
}
}
}, {
key: "_calculateExtrudeFace",
value: function _calculateExtrudeFace(prePoint, nextPoint, positionOffset, indexOffset, size) {
this.attributes.miters.set([prePoint[0], prePoint[1], size, nextPoint[0], nextPoint[1], size, prePoint[0], prePoint[1], 0, nextPoint[0], nextPoint[1], 0], positionOffset * 3);
var indexArray = [0, 1, 2, 1, 3, 2].map(function (v) {
return v + positionOffset;
});
if (this.get('uv')) {
// temp 点亮城市demo
this.attributes.uv.set([0.1, 0, 0, 0, 0.1, size / 2000, 0, size / 2000], positionOffset * 2);
}
this.indexArray.set(indexArray, indexOffset);
}
}]);
return Grid3D;
}(_buffer["default"]);
exports["default"] = Grid3D;

View File

@ -1,169 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createColorRamp = createColorRamp;
exports["default"] = void 0;
var _colorscales = require("../../../attr/colorscales");
var THREE = _interopRequireWildcard(require("../../../core/three"));
var _base = _interopRequireDefault(require("../../../core/base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var HeatmapBuffer =
/*#__PURE__*/
function (_Base) {
_inherits(HeatmapBuffer, _Base);
function HeatmapBuffer(cfg) {
var _this;
_classCallCheck(this, HeatmapBuffer);
_this = _possibleConstructorReturn(this, _getPrototypeOf(HeatmapBuffer).call(this, cfg));
_this.init();
return _this;
}
_createClass(HeatmapBuffer, [{
key: "init",
value: function init() {
var _this2 = this;
var data = this.get('data');
var positions = [];
var dirs = [];
var weights = []; // const indices = [];
// 组织顶点数据
data.forEach(function (d) {
// const totalIndex = index * 4;
var coord = d.coordinates;
var weight = d.size;
var dir = _this2._addDir(-1, 1);
var dir1 = _this2._addDir(1, 1);
var dir2 = _this2._addDir(-1, -1);
var dir3 = _this2._addDir(1, -1);
positions.push.apply(positions, _toConsumableArray(coord).concat(_toConsumableArray(coord), _toConsumableArray(coord), _toConsumableArray(coord), _toConsumableArray(coord), _toConsumableArray(coord)));
dirs.push.apply(dirs, _toConsumableArray(dir).concat(_toConsumableArray(dir2), _toConsumableArray(dir3), _toConsumableArray(dir1), _toConsumableArray(dir), _toConsumableArray(dir3)));
weights.push(weight, weight, weight, weight, weight, weight); // indices.push(totalIndex, totalIndex + 2, totalIndex + 3, totalIndex, totalIndex + 3, totalIndex + 1);
});
this.attributes = {
vertices: positions,
// indices,
dirs: dirs,
weights: weights
};
}
}, {
key: "_addVertex",
value: function _addVertex(position, dirX, dirY) {
var x = position[0] * 2 + (dirX + 1) / 2;
var y = position[1] * 2 + (dirY + 1) / 2;
var z = position[2];
return [x, y, z];
}
}, {
key: "_addDir",
value: function _addDir(dirX, dirY) {
var x = (dirX + 1) / 2;
var y = (dirY + 1) / 2;
return [x, y];
}
}]);
return HeatmapBuffer;
}(_base["default"]);
exports["default"] = HeatmapBuffer;
function createColorRamp(colors) {
var colorImageData = getColorRamp(colors);
var colorTexture = getTexture(colorImageData);
return colorTexture;
}
function getColorRamp(name) {
var colorscale = name;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = 1;
canvas.height = 256;
var gradient = ctx.createLinearGradient(0, 0, 0, 256);
var data = null;
if (typeof colorscale === 'string') {
colorscale = _colorscales.colorScales[name];
}
if (Object.prototype.toString.call(colorscale) === '[object Object]') {
var min = colorscale.positions[0];
var max = colorscale.positions[colorscale.positions.length - 1];
for (var i = 0; i < colorscale.colors.length; ++i) {
var value = (colorscale.positions[i] - min) / (max - min);
gradient.addColorStop(value, colorscale.colors[i]);
}
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 1, 256);
data = new Uint8ClampedArray(ctx.getImageData(0, 0, 1, 256).data);
}
if (Object.prototype.toString.call(colorscale) === '[object Uint8Array]') {
data = ctx.createImageData(1, 256);
}
return new ImageData(data, 1, 256);
}
function getTexture(image) {
var texture = new THREE.Texture(image);
texture.wrapS = THREE.ClampToEdgeWrapping;
texture.wrapT = THREE.ClampToEdgeWrapping;
texture.magFilter = THREE.NearestFilter;
texture.minFilter = THREE.NearestFilter;
texture.format = THREE.RGBAFormat;
texture.type = THREE.UnsignedByteType;
texture.needsUpdate = true;
return texture;
}

View File

@ -1,44 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = hexagonBuffer;
var _polygon = require("../../shape/polygon");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function hexagonBuffer(layerData) {
var attribute = {
vertices: [],
miter: [],
colors: [],
pickingIds: []
};
var a = Math.cos(Math.PI / 6);
var points = [[0, -1, 0], [-a, -0.5, 0], [-a, 0.5, 0], [0, 1, 0], [a, 0.5, 0], [a, -0.5, 0], [0, -1, 0]]; // const hexgonPoints = polygonPath(6);
var hexgonFill = (0, _polygon.fill)([points]);
var positionsIndex = hexgonFill.positionsIndex,
positions = hexgonFill.positions;
layerData.forEach(function (element) {
positionsIndex.forEach(function (pointIndex) {
var _attribute$vertices, _attribute$colors;
(_attribute$vertices = attribute.vertices).push.apply(_attribute$vertices, _toConsumableArray(element.coordinates));
attribute.miter.push(positions[pointIndex][0], positions[pointIndex][1]);
attribute.pickingIds.push(element.id);
(_attribute$colors = attribute.colors).push.apply(_attribute$colors, _toConsumableArray(element.color));
});
});
return attribute;
}

View File

@ -1,96 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _buffer = _interopRequireDefault(require("../buffer"));
var _extrude = require("../../extrude");
var _global = _interopRequireDefault(require("../../../global"));
var shapePath = _interopRequireWildcard(require("../../shape/path"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Hexagon3D =
/*#__PURE__*/
function (_BufferBase) {
_inherits(Hexagon3D, _BufferBase);
function Hexagon3D() {
_classCallCheck(this, Hexagon3D);
return _possibleConstructorReturn(this, _getPrototypeOf(Hexagon3D).apply(this, arguments));
}
_createClass(Hexagon3D, [{
key: "_buildFeatures",
value: function _buildFeatures() {
var _this = this;
var layerData = this.get('layerData');
this._offset = 0;
layerData.forEach(function (feature) {
_this._calculateFill(feature);
});
}
}, {
key: "_calculateFeatures",
value: function _calculateFeatures() {
var shape = this.get('shapeType');
var hexgonFill = this.getShape(shape);
var layerData = this.get('layerData');
this.verticesCount = layerData.length;
this.indexCount = 0;
this.instanceGeometry = hexgonFill;
}
}, {
key: "_calculateFill",
value: function _calculateFill(feature) {
feature.bufferInfo = {
verticesOffset: this._offset
};
var coordinates = feature.coordinates;
this._encodeArray(feature, 1);
this.attributes.positions.set(coordinates, this._offset * 3);
this._offset++;
}
}, {
key: "getShape",
value: function getShape(shape) {
var pointShape = _global["default"].pointShape;
if (pointShape['3d'].indexOf(shape) !== -1) return (0, _extrude.extrude_Polygon)([shapePath[shape]()]);
if (pointShape['2d'].indexOf(shape) !== -1) return (0, _extrude.fillPolygon)([shapePath[shape]()]);
return (0, _extrude.fillPolygon)([shapePath[shape]()]);
}
}]);
return Hexagon3D;
}(_buffer["default"]);
exports["default"] = Hexagon3D;

View File

@ -1,104 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _util = _interopRequireDefault(require("../../util"));
var THREE = _interopRequireWildcard(require("../../core/three"));
var _base = _interopRequireDefault(require("../../core/base"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ImageBuffer =
/*#__PURE__*/
function (_Base) {
_inherits(ImageBuffer, _Base);
function ImageBuffer(cfg) {
var _this;
_classCallCheck(this, ImageBuffer);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ImageBuffer).call(this, cfg));
_this.init();
return _this;
}
_createClass(ImageBuffer, [{
key: "init",
value: function init() {
var _this2 = this;
var layerData = this.get('layerData');
var coordinates = layerData[0].coordinates;
var images = layerData[0].images;
var positions = [].concat(_toConsumableArray(coordinates[0]), [coordinates[1][0], coordinates[0][1], 0], _toConsumableArray(coordinates[1]), _toConsumableArray(coordinates[0]), _toConsumableArray(coordinates[1]), [coordinates[0][0], coordinates[1][1], 0]);
var image = images;
if (_util["default"].isArray(images)) {
image = images[0];
var textures = images.map(function (img) {
return _this2._getTexture(img);
});
this.u_rasters = textures;
}
var uv = [0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0];
var texture = new THREE.Texture(image);
texture.magFilter = THREE.LinearFilter;
texture.minFilter = THREE.LinearMipMapLinearFilter;
texture.needsUpdate = true;
var attributes = {
vertices: new Float32Array(positions),
uvs: new Float32Array(uv)
};
this.attributes = attributes;
this.texture = texture;
}
}, {
key: "_getTexture",
value: function _getTexture(image) {
var texture = new THREE.Texture(image);
texture.magFilter = THREE.LinearFilter;
texture.minFilter = THREE.LinearFilter;
}
}]);
return ImageBuffer;
}(_base["default"]);
exports["default"] = ImageBuffer;

View File

@ -1,54 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getBuffer", {
enumerable: true,
get: function get() {
return _factory.getBuffer;
}
});
var _fill_buffer = _interopRequireDefault(require("./polygon/fill_buffer"));
var _line_buffer = _interopRequireDefault(require("./polygon/line_buffer"));
var _extrude_buffer = _interopRequireDefault(require("./polygon/extrude_buffer"));
var _fill_buffer2 = _interopRequireDefault(require("./point/fill_buffer2"));
var _meshline = _interopRequireDefault(require("./line/meshline"));
var _arcline = _interopRequireDefault(require("./line/arcline"));
var _hexagon_3d = _interopRequireDefault(require("./heatmap/hexagon_3d"));
var _extrude_buffer2 = _interopRequireDefault(require("./point/extrude_buffer"));
var _factory = require("./factory");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// Polygon
// Point
// Line
// heatmap
// 3D Shape
// Point
(0, _factory.registerBuffer)('point', 'fill', _fill_buffer2["default"]); // polygon
(0, _factory.registerBuffer)('polygon', 'fill', _fill_buffer["default"]);
(0, _factory.registerBuffer)('polygon', 'extrude', _extrude_buffer["default"]);
(0, _factory.registerBuffer)('polygon', 'line', _line_buffer["default"]); // line
(0, _factory.registerBuffer)('line', 'line', _meshline["default"]);
(0, _factory.registerBuffer)('line', 'arc', _arcline["default"]);
(0, _factory.registerBuffer)('line', 'greatCircle', _arcline["default"]); // heatmap
// registerBuffer('heatmap', 'square', Grid3D);
// registerBuffer('heatmap', 'squareColumn', Grid3D);
(0, _factory.registerBuffer)('heatmap', 'shape', _hexagon_3d["default"]);
(0, _factory.registerBuffer)('point', 'shape', _hexagon_3d["default"]); // 3D Shape
(0, _factory.registerBuffer)('shape', 'extrude', _extrude_buffer2["default"]);

View File

@ -1,182 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _bufferBase = _interopRequireDefault(require("./bufferBase"));
var _shape = require("../shape");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var LineBuffer =
/*#__PURE__*/
function (_BufferBase) {
_inherits(LineBuffer, _BufferBase);
function LineBuffer() {
_classCallCheck(this, LineBuffer);
return _possibleConstructorReturn(this, _getPrototypeOf(LineBuffer).apply(this, arguments));
}
_createClass(LineBuffer, [{
key: "geometryBuffer",
value: function geometryBuffer() {
var shapeType = this.shapeType = this.get('shapeType');
if (shapeType === 'line') {
this.attributes = this._getMeshLineAttributes();
return;
} else if (shapeType === 'arc') {
this.attributes = this._getArcLineAttributes();
return;
}
}
}, {
key: "_getShape",
value: function _getShape(geo, props, index) {
if (!this.shapeType) {
return _shape.lineShape.defaultLine(geo, index);
}
var shape = this.shapeType;
if (shape === 'meshLine') {
return _shape.lineShape[shape](geo, props, index);
} else if (shape === 'tubeLine') {
return _shape.lineShape[shape](geo, props, index);
} else if (shape === 'arc') {
return _shape.lineShape[shape](geo, props, index);
}
return _shape.lineShape.Line(geo, props, index);
}
}, {
key: "_getArcLineAttributes",
value: function _getArcLineAttributes() {
var _this = this;
var layerData = this.get('layerData');
var positions = [];
var colors = [];
var indexArray = [];
var sizes = [];
var instances = [];
var pickingIds = [];
layerData.forEach(function (item) {
var props = item;
var positionCount = positions.length / 3;
var attrData = _this._getShape(item.coordinates, props, positionCount);
positions.push.apply(positions, _toConsumableArray(attrData.positions));
colors.push.apply(colors, _toConsumableArray(attrData.colors));
indexArray.push.apply(indexArray, _toConsumableArray(attrData.indexArray));
instances.push.apply(instances, _toConsumableArray(attrData.instances));
sizes.push.apply(sizes, _toConsumableArray(attrData.sizes));
pickingIds.push.apply(pickingIds, _toConsumableArray(attrData.pickingIds));
});
return {
pickingIds: pickingIds,
positions: positions,
colors: colors,
indexArray: indexArray,
sizes: sizes,
instances: instances
};
}
}, {
key: "_getMeshLineAttributes",
value: function _getMeshLineAttributes() {
var layerData = this.get('layerData');
var _this$get = this.get('style'),
dashArray = _this$get.dashArray;
var imagePos = this.get('imagePos');
var positions = [];
var pickingIds = [];
var normal = [];
var miter = [];
var colors = [];
var indexArray = [];
var sizes = [];
var attrDistance = [];
var attrDashArray = [];
var textureCoord = [];
var totalDistance = [];
layerData.forEach(function (item) {
var props = item;
var positionCount = positions.length / 3;
var patternPos = {
x: 0,
y: 0
};
if (item.pattern && imagePos[item.pattern]) {
patternPos = imagePos[item.pattern];
}
var attr = _shape.lineShape.Line(item.coordinates, props, positionCount, dashArray, patternPos);
positions.push.apply(positions, _toConsumableArray(attr.positions));
normal.push.apply(normal, _toConsumableArray(attr.normal));
miter.push.apply(miter, _toConsumableArray(attr.miter));
colors.push.apply(colors, _toConsumableArray(attr.colors));
indexArray.push.apply(indexArray, _toConsumableArray(attr.indexArray));
sizes.push.apply(sizes, _toConsumableArray(attr.sizes));
attrDistance.push.apply(attrDistance, _toConsumableArray(attr.attrDistance));
pickingIds.push.apply(pickingIds, _toConsumableArray(attr.pickingIds));
attrDashArray.push.apply(attrDashArray, _toConsumableArray(attr.dashArray));
textureCoord.push.apply(textureCoord, _toConsumableArray(attr.textureCoordArray));
totalDistance.push.apply(totalDistance, _toConsumableArray(attr.totalDistances));
});
return {
positions: positions,
normal: normal,
miter: miter,
colors: colors,
indexArray: indexArray,
pickingIds: pickingIds,
sizes: sizes,
attrDistance: attrDistance,
attrDashArray: attrDashArray,
textureCoord: textureCoord,
totalDistance: totalDistance
};
}
}]);
return LineBuffer;
}(_bufferBase["default"]);
exports["default"] = LineBuffer;

View File

@ -1,110 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _buffer = _interopRequireDefault(require("../buffer"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ArcLineBuffer =
/*#__PURE__*/
function (_BufferBase) {
_inherits(ArcLineBuffer, _BufferBase);
function ArcLineBuffer() {
_classCallCheck(this, ArcLineBuffer);
return _possibleConstructorReturn(this, _getPrototypeOf(ArcLineBuffer).apply(this, arguments));
}
_createClass(ArcLineBuffer, [{
key: "_buildFeatures",
value: function _buildFeatures() {
var _this = this;
var layerData = this.get('layerData');
layerData.forEach(function (feature, index) {
_this._calculateArc(feature, index);
});
}
}, {
key: "_initAttributes",
value: function _initAttributes() {
_get(_getPrototypeOf(ArcLineBuffer.prototype), "_initAttributes", this).call(this);
this.attributes.instanceArray = new Float32Array(this.verticesCount * 4);
}
}, {
key: "_calculateArc",
value: function _calculateArc(feature, offset) {
var _this2 = this;
var _this$get = this.get('style'),
_this$get$segNum = _this$get.segNum,
segNum = _this$get$segNum === void 0 ? 30 : _this$get$segNum;
var coordinates = feature.coordinates;
var _loop = function _loop(i) {
_this2.attributes.positions.set([i, 1, i, i, -1, i], offset * segNum * 6 + i * 6);
_this2.attributes.instanceArray.set([coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1], coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1]], offset * segNum * 8 + i * 8);
if (i !== segNum - 1) {
var indexArray = [0, 1, 2, 1, 3, 2].map(function (v) {
return offset * segNum * 2 + i * 2 + v;
});
_this2.indexArray.set(indexArray, offset * segNum * 6 + i * 6 - offset * 6);
}
};
for (var i = 0; i < segNum; i++) {
_loop(i);
}
feature.bufferInfo = {
verticesOffset: offset * segNum * 2
};
this._encodeArray(feature, segNum * 2);
}
}, {
key: "_calculateFeatures",
value: function _calculateFeatures() {
var layerData = this.get('layerData');
var segNum = this.get('segNum') || 30;
this.verticesCount = layerData.length * segNum * 2;
this.indexCount = this.verticesCount * 3 - layerData.length * 6;
}
}]);
return ArcLineBuffer;
}(_buffer["default"]);
exports["default"] = ArcLineBuffer;

View File

@ -1,142 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _buffer = _interopRequireDefault(require("../buffer"));
var _polylineNormals = _interopRequireDefault(require("../../../util/polyline-normals"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var MeshLineBuffer =
/*#__PURE__*/
function (_BufferBase) {
_inherits(MeshLineBuffer, _BufferBase);
function MeshLineBuffer() {
_classCallCheck(this, MeshLineBuffer);
return _possibleConstructorReturn(this, _getPrototypeOf(MeshLineBuffer).apply(this, arguments));
}
_createClass(MeshLineBuffer, [{
key: "_buildFeatures",
value: function _buildFeatures() {
var _this = this;
var layerData = this.get('layerData');
layerData.forEach(function (feature) {
_this._calculateLine(feature);
delete feature.bufferInfo;
});
}
}, {
key: "_initAttributes",
value: function _initAttributes() {
_get(_getPrototypeOf(MeshLineBuffer.prototype), "_initAttributes", this).call(this);
this.attributes.dashArray = new Float32Array(this.verticesCount);
this.attributes.attrDistance = new Float32Array(this.verticesCount);
this.attributes.totalDistances = new Float32Array(this.verticesCount);
this.attributes.patterns = new Float32Array(this.verticesCount * 2);
this.attributes.miters = new Float32Array(this.verticesCount);
this.attributes.normals = new Float32Array(this.verticesCount * 3);
}
}, {
key: "_calculateFeatures",
value: function _calculateFeatures() {
var _this2 = this;
var layerData = this.get('layerData'); // 计算长
layerData.forEach(function (feature) {
var bufferInfo = {};
var coordinates = feature.coordinates;
if (Array.isArray(coordinates[0][0])) {
coordinates = coordinates[0];
}
var _getNormals = (0, _polylineNormals["default"])(coordinates, false, _this2.verticesCount),
normals = _getNormals.normals,
attrIndex = _getNormals.attrIndex,
attrPos = _getNormals.attrPos,
attrDistance = _getNormals.attrDistance,
miters = _getNormals.miters;
bufferInfo.normals = normals;
bufferInfo.arrayIndex = attrIndex;
bufferInfo.positions = attrPos;
bufferInfo.attrDistance = attrDistance;
bufferInfo.miters = miters;
bufferInfo.verticesOffset = _this2.verticesCount;
bufferInfo.indexOffset = _this2.indexCount;
_this2.verticesCount += attrPos.length / 3;
_this2.indexCount += attrIndex.length;
feature.bufferInfo = bufferInfo;
});
}
}, {
key: "_calculateLine",
value: function _calculateLine(feature) {
var _feature$bufferInfo = feature.bufferInfo,
normals = _feature$bufferInfo.normals,
arrayIndex = _feature$bufferInfo.arrayIndex,
positions = _feature$bufferInfo.positions,
attrDistance = _feature$bufferInfo.attrDistance,
miters = _feature$bufferInfo.miters,
verticesOffset = _feature$bufferInfo.verticesOffset,
indexOffset = _feature$bufferInfo.indexOffset;
var _this$get = this.get('style'),
_this$get$dashArray = _this$get.dashArray,
dashArray = _this$get$dashArray === void 0 ? 200 : _this$get$dashArray;
this._encodeArray(feature, positions.length / 3);
var totalLength = attrDistance[attrDistance.length - 1]; // 增加长度
var totalDistances = Array(positions.length / 3).fill(totalLength); // 虚线比例
var ratio = dashArray / totalLength;
var dashArrays = Array(positions.length / 3).fill(ratio);
this.attributes.positions.set(positions, verticesOffset * 3);
this.indexArray.set(arrayIndex, indexOffset);
this.attributes.miters.set(miters, verticesOffset);
this.attributes.normals.set(normals, verticesOffset * 3);
this.attributes.attrDistance.set(attrDistance, verticesOffset);
this.attributes.totalDistances.set(totalDistances, verticesOffset);
this.attributes.dashArray.set(dashArrays, verticesOffset);
}
}]);
return MeshLineBuffer;
}(_buffer["default"]);
exports["default"] = MeshLineBuffer;

View File

@ -1,243 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _bufferBase = _interopRequireDefault(require("./bufferBase"));
var _index = require("../shape/index");
var polygonPath = _interopRequireWildcard(require("../shape/path"));
var polygonShape = _interopRequireWildcard(require("../shape/polygon"));
var lineShape = _interopRequireWildcard(require("../shape/line"));
var _global = _interopRequireDefault(require("../../global"));
var _util = _interopRequireDefault(require("../../util"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var pointShape = _global["default"].pointShape;
var PointBuffer =
/*#__PURE__*/
function (_BufferBase) {
_inherits(PointBuffer, _BufferBase);
function PointBuffer() {
_classCallCheck(this, PointBuffer);
return _possibleConstructorReturn(this, _getPrototypeOf(PointBuffer).apply(this, arguments));
}
_createClass(PointBuffer, [{
key: "geometryBuffer",
value: function geometryBuffer() {
var type = this.get('type');
switch (type) {
case 'image':
this._imageBuffer();
break;
case '2d':
this._3dRegularBuffer();
break;
case '3d':
this._3dRegularBuffer();
break;
case 'Model':
this._ModelBuffer();
break;
default:
this._sdfRegularBuffer();
}
}
}, {
key: "_imageBuffer",
value: function _imageBuffer() {
var coordinates = this.get('coordinates');
var properties = this.get('properties');
var imagePos = this.get('imagePos');
var uv = new Float32Array(properties.length * 2);
for (var i = 0; i < properties.length; i++) {
var _imagePos$properties$ = imagePos[properties[i].shape],
x = _imagePos$properties$.x,
y = _imagePos$properties$.y;
uv[i * 2] = x;
uv[i * 2 + 1] = y;
}
this.bufferStruct.position = coordinates;
this.bufferStruct.uv = uv;
this.bufferStruct.style = properties;
this.attributes = this._toPointsAttributes(this.bufferStruct);
this.attributes.uvs = uv;
}
}, {
key: "_sdfRegularBuffer",
value: function _sdfRegularBuffer() {
var coordinates = this.get('coordinates');
var properties = this.get('properties');
this.bufferStruct.position = coordinates;
this.bufferStruct.style = properties;
this.attributes = this._toPointsAttributes(this.bufferStruct);
}
}, {
key: "_3dRegularBuffer",
value: function _3dRegularBuffer() {
var _this = this;
var lineAttribute = {
shapes: [],
normal: [],
miter: [],
indexArray: [],
sizes: [],
positions: []
};
var coordinates = this.get('coordinates');
var properties = this.get('properties');
var style = this.get('style');
var type = this.get('type');
var positions = [];
var shapes = [];
var sizes = [];
var uvs = [];
var positionsIndex = [];
var indexCount = 0;
this.bufferStruct.style = properties;
coordinates.forEach(function (geo, index) {
var _lineAttribute$shapes, _lineAttribute$normal, _lineAttribute$miter, _lineAttribute$indexA;
var _properties$index = properties[index],
size = _properties$index.size,
shape = _properties$index.shape; // let shapeType = '';
if (type === '2d' || type === '3d' && size[2] === 0) {
// let shapeType = 'fill';
_util["default"].isArray(size) || (size = [size, size, 0]);
} else {
_util["default"].isArray(size) || (size = [size, size, size]);
}
if (_index.regularShape[shape] == null) {
uvs.push(0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0);
shape = 'square';
}
properties[index].size = size;
var _this$_getShape = _this._getShape(properties[index], style, lineAttribute.miter.length),
_this$_getShape2 = _slicedToArray(_this$_getShape, 2),
vert = _this$_getShape2[0],
polygonLine = _this$_getShape2[1];
polygonLine.miter.forEach(function () {
var _lineAttribute$positi, _lineAttribute$sizes;
(_lineAttribute$positi = lineAttribute.positions).push.apply(_lineAttribute$positi, _toConsumableArray(geo));
(_lineAttribute$sizes = lineAttribute.sizes).push.apply(_lineAttribute$sizes, _toConsumableArray(size));
});
(_lineAttribute$shapes = lineAttribute.shapes).push.apply(_lineAttribute$shapes, _toConsumableArray(polygonLine.positions));
(_lineAttribute$normal = lineAttribute.normal).push.apply(_lineAttribute$normal, _toConsumableArray(polygonLine.normal));
(_lineAttribute$miter = lineAttribute.miter).push.apply(_lineAttribute$miter, _toConsumableArray(polygonLine.miter));
(_lineAttribute$indexA = lineAttribute.indexArray).push.apply(_lineAttribute$indexA, _toConsumableArray(polygonLine.indexArray));
shapes.push(vert.positions);
positions.push(geo);
sizes.push(size);
positionsIndex.push(vert.positionsIndex);
indexCount += vert.positionsIndex.length;
});
this.bufferStruct.indices = positionsIndex;
this.bufferStruct.position = positions;
this.bufferStruct.indexCount = indexCount;
this.bufferStruct.shapes = shapes;
this.bufferStruct.sizes = sizes;
this.bufferStruct.faceUv = uvs;
this.attributes = this._toPointShapeAttributes(this.bufferStruct);
this.lineAttribute = lineAttribute;
}
}, {
key: "_getShape",
value: function _getShape(props, style, positionsIndex) {
var shape = props.shape;
var stroke = style.stroke,
strokeWidth = style.strokeWidth;
var path = polygonPath[shape]();
var polygon = null;
var polygonLine = null;
if (pointShape['3d'].indexOf(shape) === -1) {
polygon = polygonShape.fill([path]);
polygonLine = lineShape.Line(path, {
size: [strokeWidth, 0],
color: stroke
}, positionsIndex);
} else {
polygon = polygonShape.extrude([path]);
}
return [polygon, polygonLine];
}
}]);
return PointBuffer;
}(_bufferBase["default"]);
exports["default"] = PointBuffer;

View File

@ -1,66 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = circleBuffer;
var _vertexCompress = require("../../../util/vertex-compress");
var _global = _interopRequireDefault(require("../../../global"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var pointShape = _global["default"].pointShape;
var LEFT_SHIFT17 = 131072.0; // const LEFT_SHIFT18 = 262144.0;
// const LEFT_SHIFT19 = 524288.0;
// const LEFT_SHIFT20 = 1048576.0;
var LEFT_SHIFT21 = 2097152.0; // const LEFT_SHIFT22 = 4194304.0;
var LEFT_SHIFT23 = 8388608.0; // const LEFT_SHIFT24 = 16777216.0;
function circleBuffer(layerData) {
var index = [];
var aPosition = [];
var aPackedData = [];
layerData.forEach(function (_ref, i) {
var _ref$size = _ref.size,
size = _ref$size === void 0 ? 0 : _ref$size,
color = _ref.color,
id = _ref.id,
coordinates = _ref.coordinates,
shape = _ref.shape;
var shapeIndex = pointShape['2d'].indexOf(shape) || 0;
if (isNaN(size)) {
size = 0;
} // pack color(vec4) into vec2
var packedColor = [(0, _vertexCompress.packUint8ToFloat)(color[0] * 255, color[1] * 255), (0, _vertexCompress.packUint8ToFloat)(color[2] * 255, color[3] * 255)]; // construct point coords
[[-1, -1], [1, -1], [1, 1], [-1, 1]].forEach(function (extrude) {
// vec4(color, color, (4-bit extrude, 4-bit shape, 16-bit size), id)
aPackedData.push.apply(aPackedData, packedColor.concat([(extrude[0] + 1) * LEFT_SHIFT23 + (extrude[1] + 1) * LEFT_SHIFT21 + shapeIndex * LEFT_SHIFT17 + size, id]));
}); // TODO如果使用相对瓦片坐标还可以进一步压缩
aPosition.push.apply(aPosition, _toConsumableArray(coordinates).concat(_toConsumableArray(coordinates), _toConsumableArray(coordinates), _toConsumableArray(coordinates)));
index.push.apply(index, _toConsumableArray([0, 1, 2, 0, 2, 3].map(function (n) {
return n + i * 4;
})));
});
return {
aPosition: aPosition,
index: index,
aPackedData: aPackedData
};
}

View File

@ -1,174 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _buffer = _interopRequireDefault(require("../buffer"));
var _global = _interopRequireDefault(require("../../../global"));
var _extrude = require("../../extrude");
var shapePath = _interopRequireWildcard(require("../../shape/path"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var ExtrudeBuffer =
/*#__PURE__*/
function (_BufferBase) {
_inherits(ExtrudeBuffer, _BufferBase);
function ExtrudeBuffer() {
_classCallCheck(this, ExtrudeBuffer);
return _possibleConstructorReturn(this, _getPrototypeOf(ExtrudeBuffer).apply(this, arguments));
}
_createClass(ExtrudeBuffer, [{
key: "_buildFeatures",
value: function _buildFeatures() {
var _this = this;
var layerData = this.get('layerData');
this._offset = 0;
this._indexOffset = 0;
layerData.forEach(function (feature) {
_this._calculateFill(feature);
});
}
}, {
key: "_initAttributes",
value: function _initAttributes() {
_get(_getPrototypeOf(ExtrudeBuffer.prototype), "_initAttributes", this).call(this);
this.attributes.miters = new Float32Array(this.verticesCount * 3);
this.attributes.normals = new Float32Array(this.verticesCount * 3);
this.attributes.sizes = new Float32Array(this.verticesCount * 3);
}
}, {
key: "_calculateFeatures",
value: function _calculateFeatures() {
var _this2 = this;
var layerData = this.get('layerData');
this.geometryMap = {};
layerData.forEach(function (feature) {
var shape = feature.shape;
var _this2$getShape = _this2.getShape(shape),
positions = _this2$getShape.positions,
indexArray = _this2$getShape.indexArray;
_this2.verticesCount += positions.length / 3;
_this2.indexCount += indexArray.length;
});
}
}, {
key: "_calcultateGeometry",
value: function _calcultateGeometry() {
var shape = this.get('shapeType');
var hexgonFill = this.getShapeFunction(shape)([this._getPoints(6)]);
this.instanceGeometry = hexgonFill;
}
}, {
key: "_calculateFill",
value: function _calculateFill(feature) {
var _this3 = this;
feature.bufferInfo = {
verticesOffset: this._offset
};
var coordinates = feature.coordinates,
shape = feature.shape;
var instanceGeometry = this.getShape(shape);
var numPoint = instanceGeometry.positions.length / 3;
this._encodeArray(feature, numPoint);
this.attributes.miters.set(instanceGeometry.positions, this._offset * 3);
var indexArray = instanceGeometry.indexArray.map(function (v) {
return v + _this3._offset;
});
this.indexArray.set(indexArray, this._indexOffset);
if (instanceGeometry.normals) {
this.attributes.normals.set(instanceGeometry.normals, this._offset * 3);
}
var position = [];
for (var i = 0; i < numPoint; i++) {
position.push.apply(position, _toConsumableArray(coordinates));
}
this.attributes.positions.set(position, this._offset * 3);
this._offset += numPoint;
this._indexOffset += indexArray.length;
}
}, {
key: "_getPoints",
value: function _getPoints(num) {
return (0, shapePath.polygonPath)(num, 1);
}
}, {
key: "getShape",
value: function getShape(shape) {
var pointShape = _global["default"].pointShape;
if (this.geometryMap[shape]) {
return this.geometryMap[shape];
}
var geometry = null;
if (pointShape['3d'].indexOf(shape) !== -1) {
geometry = (0, _extrude.extrude_Polygon)([shapePath[shape]()]);
} else if (pointShape['2d'].indexOf(shape) !== -1) {
geometry = (0, _extrude.fillPolygon)([shapePath[shape]()]);
} else {
geometry = (0, _extrude.fillPolygon)([shapePath[shape]()]);
}
this.geometryMap[shape] = geometry;
return geometry;
}
}]);
return ExtrudeBuffer;
}(_buffer["default"]);
exports["default"] = ExtrudeBuffer;

View File

@ -1,127 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = fillBuffer;
var _global = _interopRequireDefault(require("../../../global"));
var THREE = _interopRequireWildcard(require("../../../core/three"));
var polygonShape = _interopRequireWildcard(require("../../shape/polygon"));
var polygonPath = _interopRequireWildcard(require("../../shape/path"));
var _util = _interopRequireDefault(require("../../../util"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var pointShape = _global["default"].pointShape;
function fillBuffer(layerData) {
var attribute = {
vertices: [],
normals: [],
colors: [],
pickingIds: [],
shapePositions: [],
a_size: [],
faceUv: []
};
layerData.forEach(function (item) {
var size = item.size,
shape = item.shape,
color = item.color,
id = item.id,
coordinates = item.coordinates;
var polygon = null;
var path = polygonPath[shape]();
if (pointShape['2d'].indexOf(shape) !== -1) {
_util["default"].isArray(size) || (size = [size, size, 0]);
polygon = polygonShape.fill([path]);
} else if (pointShape['3d'].indexOf(shape) !== -1) {
_util["default"].isArray(size) || (size = [size, size, size]);
polygon = polygonShape.extrude([path]);
} else {
throw new Error('Invalid shape type: ' + shape);
}
toPointShapeAttributes(polygon, coordinates, {
size: size,
shape: shape,
color: color,
id: id
}, attribute); // toPointShapeAttributes(polygon, null, {}, attribute);
// instanced attributes
// attribute.vertices.push(...coordinates);
// attribute.a_size.push(...size);
// attribute.colors.push(...color);
// attribute.pickingIds.push(id);
});
return attribute;
}
function toPointShapeAttributes(polygon, geo, style, attribute) {
var positionsIndex = polygon.positionsIndex,
positions = polygon.positions;
var pA = new THREE.Vector3();
var pB = new THREE.Vector3();
var pC = new THREE.Vector3();
var cb = new THREE.Vector3();
var ab = new THREE.Vector3();
for (var i = 0; i < positionsIndex.length / 3; i++) {
var _attribute$vertices, _attribute$a_size, _attribute$colors;
var index = positionsIndex[i * 3];
var color = style.color,
size = style.size,
id = style.id;
var ax = positions[index][0];
var ay = positions[index][1];
var az = positions[index][2];
index = positionsIndex[i * 3 + 1];
var bx = positions[index][0];
var by = positions[index][1];
var bz = positions[index][2];
index = positionsIndex[i * 3 + 2];
var cx = positions[index][0];
var cy = positions[index][1];
var cz = positions[index][2];
pA.set(ax, ay, az);
pB.set(bx, by, bz);
pC.set(cx, cy, cz);
cb.subVectors(pC, pB);
ab.subVectors(pA, pB);
cb.cross(ab);
cb.normalize();
var nx = cb.x;
var ny = cb.y;
var nz = cb.z;
(_attribute$vertices = attribute.vertices).push.apply(_attribute$vertices, _toConsumableArray(geo).concat(_toConsumableArray(geo), _toConsumableArray(geo)));
attribute.shapePositions.push(ax, ay, az, bx, by, bz, cx, cy, cz);
(_attribute$a_size = attribute.a_size).push.apply(_attribute$a_size, _toConsumableArray(size).concat(_toConsumableArray(size), _toConsumableArray(size)));
attribute.normals.push(nx, ny, nz, nx, ny, nz, nx, ny, nz);
(_attribute$colors = attribute.colors).push.apply(_attribute$colors, _toConsumableArray(color).concat(_toConsumableArray(color), _toConsumableArray(color)));
attribute.pickingIds.push(id, id, id); // attribute.shapePositions.push(ax, ay, az, bx, by, bz, cx, cy, cz);
// attribute.normals.push(nx, ny, nz, nx, ny, nz, nx, ny, nz);
}
}

View File

@ -1,74 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = FillBuffer;
var _vertexCompress = require("../../../util/vertex-compress");
var _global = _interopRequireDefault(require("../../../global"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var pointShape = _global["default"].pointShape;
var LEFT_SHIFT17 = 131072.0; // const LEFT_SHIFT18 = 262144.0;
// const LEFT_SHIFT19 = 524288.0;
// const LEFT_SHIFT20 = 1048576.0;
var LEFT_SHIFT21 = 2097152.0; // const LEFT_SHIFT22 = 4194304.0;
var LEFT_SHIFT23 = 8388608.0; // const LEFT_SHIFT24 = 16777216.0;
function FillBuffer(data) {
var index = [];
var aPosition = [];
var aPackedData = [];
var layerData = data.layerData;
layerData.forEach(function (_ref, i) {
var _ref$size = _ref.size,
size = _ref$size === void 0 ? 0 : _ref$size,
color = _ref.color,
id = _ref.id,
coordinates = _ref.coordinates,
shape = _ref.shape;
var shapeIndex = pointShape['2d'].indexOf(shape) || 0;
var newCoord = coordinates;
if (coordinates.length === 1) {
newCoord = coordinates[0][0];
}
if (isNaN(size)) {
size = 0;
} // pack color(vec4) into vec2
var packedColor = [(0, _vertexCompress.packUint8ToFloat)(color[0] * 255, color[1] * 255), (0, _vertexCompress.packUint8ToFloat)(color[2] * 255, color[3] * 255)]; // construct point coords
[[-1, -1], [1, -1], [1, 1], [-1, 1]].forEach(function (extrude) {
// vec4(color, color, (4-bit extrude, 4-bit shape, 16-bit size), id)
aPackedData.push.apply(aPackedData, packedColor.concat([(extrude[0] + 1) * LEFT_SHIFT23 + (extrude[1] + 1) * LEFT_SHIFT21 + shapeIndex * LEFT_SHIFT17 + size, id]));
}); // TODO如果使用相对瓦片坐标还可以进一步压缩
aPosition.push.apply(aPosition, _toConsumableArray(newCoord).concat(_toConsumableArray(newCoord), _toConsumableArray(newCoord), _toConsumableArray(newCoord)));
index.push.apply(index, _toConsumableArray([0, 1, 2, 0, 2, 3].map(function (n) {
return n + i * 4;
})));
});
return {
attributes: {
aPosition: new Float32Array(aPosition),
aPackedData: new Float32Array(aPackedData)
},
indexArray: new Int32Array(index)
};
}

View File

@ -1,168 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _buffer = _interopRequireDefault(require("../buffer"));
var _global = _interopRequireDefault(require("../../../global"));
var _extrude = require("../../extrude");
var shapePath = _interopRequireWildcard(require("../../shape/path"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var pointShape = _global["default"].pointShape;
var PointFillBuffer =
/*#__PURE__*/
function (_BufferBase) {
_inherits(PointFillBuffer, _BufferBase);
function PointFillBuffer() {
_classCallCheck(this, PointFillBuffer);
return _possibleConstructorReturn(this, _getPrototypeOf(PointFillBuffer).apply(this, arguments));
}
_createClass(PointFillBuffer, [{
key: "_buildFeatures",
value: function _buildFeatures() {
var _this = this;
var layerData = this.get('layerData');
this._offset = 0;
this._indexOffset = 0;
layerData.forEach(function (feature) {
_this._calculateFill(feature);
});
}
}, {
key: "_initAttributes",
value: function _initAttributes() {
_get(_getPrototypeOf(PointFillBuffer.prototype), "_initAttributes", this).call(this);
this.attributes.miters = new Float32Array(this.verticesCount * 2);
this.attributes.sizes = new Float32Array(this.verticesCount);
this.attributes.shapes = new Float32Array(this.verticesCount);
}
}, {
key: "_calculateFeatures",
value: function _calculateFeatures() {
var layerData = this.get('layerData');
this.verticesCount = layerData.length * 4;
this.indexCount = layerData.length * 6;
}
}, {
key: "_calcultateGeometry",
value: function _calcultateGeometry() {
var shape = this.get('shapeType');
var hexgonFill = this.getShapeFunction(shape)([this._getPoints(6)]);
this.instanceGeometry = hexgonFill;
}
}, {
key: "_calculateFill",
value: function _calculateFill(feature) {
var _this2 = this;
feature.bufferInfo = {
verticesOffset: this._offset
};
var coordinates = feature.coordinates,
shape = feature.shape;
var shapeIndex = pointShape['2d'].indexOf(shape) || 0;
var newCoord = coordinates;
if (coordinates.length === 1) {
newCoord = coordinates[0][0];
}
feature.bufferInfo = {
verticesOffset: this._offset
};
this._encodeArray(feature, 4);
this.attributes.shapes.set([shapeIndex, shapeIndex, shapeIndex, shapeIndex], this._offset);
this.attributes.miters.set([-1, -1, 1, -1, 1, 1, -1, 1], this._offset * 2);
var indexArray = [0, 1, 2, 0, 2, 3].map(function (n) {
return n + _this2._offset;
});
this.indexArray.set(indexArray, this._offset * 1.5);
var position = [];
for (var i = 0; i < 4; i++) {
position.push.apply(position, _toConsumableArray(newCoord));
}
this.attributes.positions.set(position, this._offset * 3);
this._offset += 4;
}
}, {
key: "_getPoints",
value: function _getPoints(num) {
return (0, shapePath.polygonPath)(num, 1);
}
}, {
key: "getShape",
value: function getShape(shape) {
var pointShape = _global["default"].pointShape;
if (this.geometryMap[shape]) {
return this.geometryMap[shape];
}
var geometry = null;
if (pointShape['3d'].indexOf(shape) !== -1) {
geometry = (0, _extrude.extrude_Polygon)([shapePath[shape]()]);
} else if (pointShape['2d'].indexOf(shape) !== -1) {
geometry = (0, _extrude.fillPolygon)([shapePath[shape]()]);
} else {
geometry = (0, _extrude.fillPolygon)([shapePath[shape]()]);
}
this.geometryMap[shape] = geometry;
return geometry;
}
}]);
return PointFillBuffer;
}(_buffer["default"]);
exports["default"] = PointFillBuffer;

Some files were not shown because too many files have changed in this diff Show More