mirror of https://gitee.com/antv-l7/antv-l7
fix blending
This commit is contained in:
parent
8f30dab6e2
commit
4f781b2657
|
@ -29,7 +29,7 @@ const scene = new L7.Scene({
|
||||||
window.scene = scene;
|
window.scene = scene;
|
||||||
scene.on('loaded', () => {
|
scene.on('loaded', () => {
|
||||||
// ./data/mUQPWCYaxOfiSznuANvG.txt
|
// ./data/mUQPWCYaxOfiSznuANvG.txt
|
||||||
$.get('./data/00.csv', data => {
|
$.get('https://gw.alipayobjects.com/os/rmsportal/BElVQFEFvpAKzddxFZxJ.txt', data => {
|
||||||
scene.PointLayer({
|
scene.PointLayer({
|
||||||
zIndex: 2
|
zIndex: 2
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,7 +33,8 @@ scene.on('loaded', () => {
|
||||||
$.get('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt', data => {
|
$.get('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt', data => {
|
||||||
|
|
||||||
scene.LineLayer({
|
scene.LineLayer({
|
||||||
zIndex: 2
|
zIndex: 2,
|
||||||
|
blending:'additive'
|
||||||
})
|
})
|
||||||
.source(data, {
|
.source(data, {
|
||||||
parser:{
|
parser:{
|
||||||
|
@ -50,6 +51,7 @@ scene.on('loaded', () => {
|
||||||
.color('rgb(13,64,140)')
|
.color('rgb(13,64,140)')
|
||||||
.style({
|
.style({
|
||||||
opacity:1.,
|
opacity:1.,
|
||||||
|
blending:'additive'
|
||||||
})
|
})
|
||||||
.animate({
|
.animate({
|
||||||
enable: true,
|
enable: true,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7",
|
"name": "@antv/l7",
|
||||||
"version": "1.3.5-beta.1",
|
"version": "1.3.5-beta.2",
|
||||||
"description": "Large-scale WebGL-powered Geospatial Data Visualization",
|
"description": "Large-scale WebGL-powered Geospatial Data Visualization",
|
||||||
"main": "build/L7.js",
|
"main": "build/L7.js",
|
||||||
"homepage": "https://github.com/antvis/l7",
|
"homepage": "https://github.com/antvis/l7",
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
|
|
||||||
import * as THREE from '../../core/three';
|
import * as THREE from '../../core/three';
|
||||||
|
|
||||||
|
|
||||||
export default class Material extends THREE.ShaderMaterial {
|
export default class Material extends THREE.ShaderMaterial {
|
||||||
static blendingEnum = {
|
|
||||||
normal: 'NormalBlending',
|
|
||||||
additive: 'AdditiveBlending',
|
|
||||||
subtractive: 'SubtractiveBlending'
|
|
||||||
}
|
|
||||||
setUniformsValue(name, value) {
|
setUniformsValue(name, value) {
|
||||||
if (!this.uniforms[name]) { return; }
|
if (!this.uniforms[name]) { return; }
|
||||||
this.uniforms[name].value = value;
|
this.uniforms[name].value = value;
|
||||||
|
@ -34,6 +27,12 @@ export default class Material extends THREE.ShaderMaterial {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setBending(type) {
|
setBending(type) {
|
||||||
this.blending = THREE[this.blendingEnum[type]] || THREE.NormalBlending;
|
this.blending = THREE[Material.blendingEnum[type]] || THREE.NormalBlending;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Material.blendingEnum = {
|
||||||
|
normal: 'NormalBlending',
|
||||||
|
additive: 'AdditiveBlending',
|
||||||
|
subtractive: 'SubtractiveBlending'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ export default class PointMaterial extends Material {
|
||||||
this.vertexShader = vs;
|
this.vertexShader = vs;
|
||||||
this.fragmentShader = fs;
|
this.fragmentShader = fs;
|
||||||
this.transparent = true;
|
this.transparent = true;
|
||||||
|
if (_uniforms) {
|
||||||
this.blending = THREE.AdditiveBlending;
|
this.blending = THREE[Material.blendingEnum[_uniforms.blending]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ export default class PointMaterial extends Material {
|
||||||
this.vertexShader = vs;
|
this.vertexShader = vs;
|
||||||
this.fragmentShader = fs;
|
this.fragmentShader = fs;
|
||||||
this.transparent = true;
|
this.transparent = true;
|
||||||
|
this.blending = THREE[Material.blendingEnum[_uniforms.blending]];
|
||||||
if (!this.uniforms.shape) { this.blending = THREE.AdditiveBlending; }
|
if (!this.uniforms.shape) { this.blending = THREE.AdditiveBlending; }
|
||||||
if (this.uniforms.u_texture) {
|
if (this.uniforms.u_texture) {
|
||||||
this.defines.TEXCOORD_0 = true;
|
this.defines.TEXCOORD_0 = true;
|
||||||
|
|
|
@ -26,11 +26,11 @@ export default function DrawArcLine(layerData, layer, buffer) {
|
||||||
u_opacity: style.opacity,
|
u_opacity: style.opacity,
|
||||||
u_zoom: layer.scene.getZoom(),
|
u_zoom: layer.scene.getZoom(),
|
||||||
activeColor: activeOption.fill,
|
activeColor: activeOption.fill,
|
||||||
shapeType: layer.shapeType
|
shapeType: layer.shapeType,
|
||||||
|
blending: style.blending
|
||||||
}, {
|
}, {
|
||||||
SHAPE: false
|
SHAPE: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const animateOptions = layer.get('animateOptions');
|
const animateOptions = layer.get('animateOptions');
|
||||||
if (animateOptions.enable) {
|
if (animateOptions.enable) {
|
||||||
layer.scene.startAnimate();
|
layer.scene.startAnimate();
|
||||||
|
|
|
@ -40,15 +40,14 @@ export default function DrawLine(layerData, layer, buffer) {
|
||||||
u_dash_ratio: style.dashRatio,
|
u_dash_ratio: style.dashRatio,
|
||||||
activeColor: activeOption.fill,
|
activeColor: activeOption.fill,
|
||||||
u_pattern_spacing: style.patternSpacing || 0,
|
u_pattern_spacing: style.patternSpacing || 0,
|
||||||
u_texture: hasPattern ? layer.scene.image.texture : null
|
u_texture: hasPattern ? layer.scene.image.texture : null,
|
||||||
|
blending: style.blending
|
||||||
}, {
|
}, {
|
||||||
SHAPE: false,
|
SHAPE: false,
|
||||||
ANIMATE: false,
|
ANIMATE: false,
|
||||||
DASHLINE: style.lineType === 'dash',
|
DASHLINE: style.lineType === 'dash',
|
||||||
TEXTURE: hasPattern
|
TEXTURE: hasPattern
|
||||||
});
|
});
|
||||||
lineMaterial.setBending(style.blending);
|
|
||||||
|
|
||||||
const lineMesh = new THREE.Mesh(geometry, lineMaterial);
|
const lineMesh = new THREE.Mesh(geometry, lineMaterial);
|
||||||
if (animateOptions.enable) {
|
if (animateOptions.enable) {
|
||||||
layer.scene.startAnimate();
|
layer.scene.startAnimate();
|
||||||
|
|
|
@ -26,6 +26,7 @@ export default function DrawFill(layerData, layer) {
|
||||||
u_opacity: style.opacity,
|
u_opacity: style.opacity,
|
||||||
u_activeColor: activeOption.fill,
|
u_activeColor: activeOption.fill,
|
||||||
u_zoom: layer.scene.getZoom(),
|
u_zoom: layer.scene.getZoom(),
|
||||||
|
blending: style.blending,
|
||||||
...generateLightingUniforms(style.lights)
|
...generateLightingUniforms(style.lights)
|
||||||
}, {
|
}, {
|
||||||
SHAPE: true,
|
SHAPE: true,
|
||||||
|
|
|
@ -17,7 +17,8 @@ export default function DrawNormal(layerData, layer) {
|
||||||
geometry.addAttribute('a_size', new THREE.Float32BufferAttribute(attributes.sizes, 1));
|
geometry.addAttribute('a_size', new THREE.Float32BufferAttribute(attributes.sizes, 1));
|
||||||
const material = new PointMaterial({
|
const material = new PointMaterial({
|
||||||
u_opacity: opacity,
|
u_opacity: opacity,
|
||||||
u_activeColor: activeOption.fill
|
u_activeColor: activeOption.fill,
|
||||||
|
blending: style.blending
|
||||||
}, {
|
}, {
|
||||||
}, style);
|
}, style);
|
||||||
const strokeMesh = new THREE.Points(geometry, material);
|
const strokeMesh = new THREE.Points(geometry, material);
|
||||||
|
|
Loading…
Reference in New Issue