Merge pull request #745 from antvis/shihui_dev

Shihui dev
This commit is contained in:
YiQianYao 2021-08-16 14:04:35 +08:00 committed by GitHub
commit 07601a27c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 121 additions and 44 deletions

7
.gitignore vendored
View File

@ -81,4 +81,9 @@ packages/l7/package_bak.json
stories/Test stories/Test
packages/draw/node_modules/@turf packages/draw/node_modules/@turf
packages/district/src/data packages/district/src/data
yarn.lock yarn.lock
# npm command lines
publish.sh
latest.sh
beta.sh

22
beta.sh
View File

@ -1,11 +1,11 @@
npm dist-tag add @antv/l7-component@2.5.4 beta npm dist-tag add @antv/l7-component@2.5.5 beta
npm dist-tag add @antv/l7-core@2.5.4 beta npm dist-tag add @antv/l7-core@2.5.5 beta
npm dist-tag add @antv/l7@2.5.4 beta npm dist-tag add @antv/l7@2.5.5 beta
npm dist-tag add @antv/l7-layers@2.5.4 beta npm dist-tag add @antv/l7-layers@2.5.5 beta
npm dist-tag add @antv/l7-map@2.5.4 beta npm dist-tag add @antv/l7-map@2.5.5 beta
npm dist-tag add @antv/l7-maps@2.5.4 beta npm dist-tag add @antv/l7-maps@2.5.5 beta
npm dist-tag add @antv/l7-renderer@2.5.4 beta npm dist-tag add @antv/l7-renderer@2.5.5 beta
npm dist-tag add @antv/l7-scene@2.5.4 beta npm dist-tag add @antv/l7-scene@2.5.5 beta
npm dist-tag add @antv/l7-source@2.5.4 beta npm dist-tag add @antv/l7-source@2.5.5 beta
npm dist-tag add @antv/l7-three@2.5.4 beta npm dist-tag add @antv/l7-three@2.5.5 beta
npm dist-tag add @antv/l7-utils@2.5.4 beta npm dist-tag add @antv/l7-utils@2.5.5 beta

View File

@ -1,11 +1,11 @@
npm dist-tag add @antv/l7-component@2.4.4 latest npm dist-tag add @antv/l7-component@2.5.5 latest
npm dist-tag add @antv/l7-core@2.4.4 latest npm dist-tag add @antv/l7-core@2.5.5 latest
npm dist-tag add @antv/l7@2.4.4 latest npm dist-tag add @antv/l7@2.5.5 latest
npm dist-tag add @antv/l7-layers@2.4.4 latest npm dist-tag add @antv/l7-layers@2.5.5 latest
npm dist-tag add @antv/l7-map@2.4.4 latest npm dist-tag add @antv/l7-map@2.5.5 latest
npm dist-tag add @antv/l7-maps@2.4.4 latest npm dist-tag add @antv/l7-maps@2.5.5 latest
npm dist-tag add @antv/l7-renderer@2.4.4 latest npm dist-tag add @antv/l7-renderer@2.5.5 latest
npm dist-tag add @antv/l7-scene@2.4.4 latest npm dist-tag add @antv/l7-scene@2.5.5 latest
npm dist-tag add @antv/l7-source@2.4.4 latest npm dist-tag add @antv/l7-source@2.5.5 latest
npm dist-tag add @antv/l7-three@2.4.4 latest npm dist-tag add @antv/l7-three@2.5.5 latest
npm dist-tag add @antv/l7-utils@2.4.4 latest npm dist-tag add @antv/l7-utils@2.5.5 latest

View File

@ -172,6 +172,7 @@ export interface ILayer {
get(name: string): number; get(name: string): number;
setBlend(type: keyof typeof BlendType): void; setBlend(type: keyof typeof BlendType): void;
// animate(field: string, option: any): ILayer; // animate(field: string, option: any): ILayer;
renderLayers(): void;
render(): ILayer; render(): ILayer;
clear(): void; clear(): void;
clearModels(): void; clearModels(): void;

View File

@ -70,6 +70,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
public pickedFeatureID: number | null = null; public pickedFeatureID: number | null = null;
public selectedFeatureID: number | null = null; public selectedFeatureID: number | null = null;
public styleNeedUpdate: boolean = false; public styleNeedUpdate: boolean = false;
public rendering: boolean;
public dataState: IDataState = { public dataState: IDataState = {
dataSourceNeedUpdate: false, dataSourceNeedUpdate: false,
@ -508,6 +509,17 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
return this; return this;
} }
/**
*
*/
public renderLayers(): void {
this.rendering = true;
this.layerService.renderLayers();
this.rendering = false;
}
public render(): ILayer { public render(): ILayer {
// if ( // if (
// this.needPick() && // this.needPick() &&

View File

@ -166,7 +166,9 @@ export default class ImageModel extends BaseModel {
this.texture.update({ this.texture.update({
data: this.iconService.getCanvas(), data: this.iconService.getCanvas(),
}); });
this.layer.render(); // this.layer.render();
// TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层
this.layer.renderLayers();
return; return;
} }
this.texture = createTexture2D({ this.texture = createTexture2D({

View File

@ -329,6 +329,7 @@ class HandlerManager {
public triggerRenderFrame() { public triggerRenderFrame() {
if (this.frameId === undefined) { if (this.frameId === undefined) {
this.frameId = this.map.requestRenderFrame((timeStamp: number) => { this.frameId = this.map.requestRenderFrame((timeStamp: number) => {
// @ts-ignore
delete this.frameId; delete this.frameId;
this.handleEvent(new RenderFrameEvent('renderFrame', { timeStamp })); this.handleEvent(new RenderFrameEvent('renderFrame', { timeStamp }));
this.applyChanges(); this.applyChanges();

View File

@ -64,6 +64,7 @@ export const raf =
window.requestAnimationFrame || window.requestAnimationFrame ||
// @ts-ignore // @ts-ignore
window.mozRequestAnimationFrame || window.mozRequestAnimationFrame ||
// @ts-ignore
window.webkitRequestAnimationFrame || window.webkitRequestAnimationFrame ||
// @ts-ignore // @ts-ignore
window.msRequestAnimationFrame; window.msRequestAnimationFrame;
@ -72,6 +73,7 @@ export const cancel =
window.cancelAnimationFrame || window.cancelAnimationFrame ||
// @ts-ignore // @ts-ignore
window.mozCancelAnimationFrame || window.mozCancelAnimationFrame ||
// @ts-ignore
window.webkitCancelAnimationFrame || window.webkitCancelAnimationFrame ||
// @ts-ignore // @ts-ignore
window.msCancelAnimationFrame; window.msCancelAnimationFrame;

View File

@ -31,7 +31,7 @@
"inversify": "^5.0.1", "inversify": "^5.0.1",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"regl": "^1.6.1" "l7regl": "^0.0.10"
}, },
"gitHead": "7eb8382ede52d803fae13a85fe6af074400260ee", "gitHead": "7eb8382ede52d803fae13a85fe6af074400260ee",
"publishConfig": { "publishConfig": {

View File

@ -3,7 +3,7 @@ import {
IAttributeInitializationOptions, IAttributeInitializationOptions,
IBuffer, IBuffer,
} from '@antv/l7-core'; } from '@antv/l7-core';
import regl from 'regl'; import regl from 'l7regl';
import ReglBuffer from './ReglBuffer'; import ReglBuffer from './ReglBuffer';
/** /**

View File

@ -1,5 +1,5 @@
import { gl, IBuffer, IBufferInitializationOptions } from '@antv/l7-core'; import { gl, IBuffer, IBufferInitializationOptions } from '@antv/l7-core';
import regl from 'regl'; import regl from 'l7regl';
import { dataTypeMap, usageMap } from './constants'; import { dataTypeMap, usageMap } from './constants';
/** /**

View File

@ -1,5 +1,5 @@
import { gl, IElements, IElementsInitializationOptions } from '@antv/l7-core'; import { gl, IElements, IElementsInitializationOptions } from '@antv/l7-core';
import regl from 'regl'; import regl from 'l7regl';
import { dataTypeMap, usageMap } from './constants'; import { dataTypeMap, usageMap } from './constants';
/** /**

View File

@ -5,7 +5,7 @@ import {
IRenderbuffer, IRenderbuffer,
ITexture2D, ITexture2D,
} from '@antv/l7-core'; } from '@antv/l7-core';
import regl from 'regl'; import regl from 'l7regl';
import ReglTexture2D from './ReglTexture2D'; import ReglTexture2D from './ReglTexture2D';
/** /**

View File

@ -6,8 +6,8 @@ import {
IModelInitializationOptions, IModelInitializationOptions,
IUniform, IUniform,
} from '@antv/l7-core'; } from '@antv/l7-core';
import regl from 'l7regl';
import { isPlainObject, isTypedArray } from 'lodash'; import { isPlainObject, isTypedArray } from 'lodash';
import regl from 'regl';
import { import {
blendEquationMap, blendEquationMap,
blendFuncMap, blendFuncMap,

View File

@ -2,7 +2,7 @@ import {
IRenderbuffer, IRenderbuffer,
IRenderbufferInitializationOptions, IRenderbufferInitializationOptions,
} from '@antv/l7-core'; } from '@antv/l7-core';
import regl from 'regl'; import regl from 'l7regl';
import { formatMap } from './constants'; import { formatMap } from './constants';
/** /**

View File

@ -1,5 +1,5 @@
import { gl, ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core'; import { gl, ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
import regl from 'regl'; import regl from 'l7regl';
import { import {
colorSpaceMap, colorSpaceMap,
dataTypeMap, dataTypeMap,

View File

@ -1,6 +1,6 @@
import { gl } from '@antv/l7-core'; import { gl } from '@antv/l7-core';
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import quad from '../../../../core/src/shaders/post-processing/quad.glsl'; import quad from '../../../../core/src/shaders/post-processing/quad.glsl';
import ReglAttribute from '../ReglAttribute'; import ReglAttribute from '../ReglAttribute';
import ReglBuffer from '../ReglBuffer'; import ReglBuffer from '../ReglBuffer';

View File

@ -1,6 +1,6 @@
import { gl } from '@antv/l7-core'; import { gl } from '@antv/l7-core';
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import quad from '../../../../core/src/shaders/post-processing/quad.glsl'; import quad from '../../../../core/src/shaders/post-processing/quad.glsl';
import ReglAttribute from '../ReglAttribute'; import ReglAttribute from '../ReglAttribute';
import ReglBuffer from '../ReglBuffer'; import ReglBuffer from '../ReglBuffer';

View File

@ -1,6 +1,6 @@
import { gl } from '@antv/l7-core'; import { gl } from '@antv/l7-core';
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import quad from '../../../../core/src/shaders/post-processing/quad.glsl'; import quad from '../../../../core/src/shaders/post-processing/quad.glsl';
import ReglAttribute from '../ReglAttribute'; import ReglAttribute from '../ReglAttribute';
import ReglBuffer from '../ReglBuffer'; import ReglBuffer from '../ReglBuffer';

View File

@ -1,6 +1,6 @@
import { gl } from '@antv/l7-core'; import { gl } from '@antv/l7-core';
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import quad from '../../../../core/src/shaders/post-processing/quad.glsl'; import quad from '../../../../core/src/shaders/post-processing/quad.glsl';
import ReglAttribute from '../ReglAttribute'; import ReglAttribute from '../ReglAttribute';
import ReglBuffer from '../ReglBuffer'; import ReglBuffer from '../ReglBuffer';

View File

@ -1,5 +1,5 @@
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import ReglModel from '../ReglModel'; import ReglModel from '../ReglModel';
import createContext from './utils/create-context'; import createContext from './utils/create-context';

View File

@ -1,5 +1,5 @@
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import ReglFramebuffer from '../ReglFramebuffer'; import ReglFramebuffer from '../ReglFramebuffer';
import ReglModel from '../ReglModel'; import ReglModel from '../ReglModel';
import ReglTexture2D from '../ReglTexture2D'; import ReglTexture2D from '../ReglTexture2D';
@ -182,6 +182,7 @@ describe('uniforms in ReglModel', () => {
}, },
// @ts-ignore // @ts-ignore
u_5: [ u_5: [
// @ts-ignore
{ {
c: 100, // 只修改第一个 c: 100, // 只修改第一个
}, },

View File

@ -1,6 +1,6 @@
import { gl } from '@antv/l7-core'; import { gl } from '@antv/l7-core';
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import copy from '../../../../core/src/shaders/post-processing/copy.glsl'; import copy from '../../../../core/src/shaders/post-processing/copy.glsl';
import quad from '../../../../core/src/shaders/post-processing/quad.glsl'; import quad from '../../../../core/src/shaders/post-processing/quad.glsl';
import { ReglRendererService } from '../../index'; import { ReglRendererService } from '../../index';

View File

@ -1,6 +1,6 @@
import { gl } from '@antv/l7-core'; import { gl } from '@antv/l7-core';
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import copy from '../../../../core/src/shaders/post-processing/copy.glsl'; import copy from '../../../../core/src/shaders/post-processing/copy.glsl';
import quad from '../../../../core/src/shaders/post-processing/quad.glsl'; import quad from '../../../../core/src/shaders/post-processing/quad.glsl';
import ReglAttribute from '../ReglAttribute'; import ReglAttribute from '../ReglAttribute';

View File

@ -1,4 +1,4 @@
import regl from 'regl'; import regl from 'l7regl';
// borrow from https://github.com/regl-project/regl/blob/gh-pages/test/attributes.js#L303-L311 // borrow from https://github.com/regl-project/regl/blob/gh-pages/test/attributes.js#L303-L311
export default function checkPixels( export default function checkPixels(

View File

@ -2,7 +2,7 @@
* @desc regl 使 WebGL * @desc regl 使 WebGL
*/ */
import { gl } from '@antv/l7-core'; import { gl } from '@antv/l7-core';
import regl from 'regl'; import regl from 'l7regl';
// @see https://github.com/regl-project/regl/blob/gh-pages/lib/constants/primitives.json // @see https://github.com/regl-project/regl/blob/gh-pages/lib/constants/primitives.json
export const primitiveMap: { export const primitiveMap: {

View File

@ -22,8 +22,8 @@ import {
ITexture2DInitializationOptions, ITexture2DInitializationOptions,
} from '@antv/l7-core'; } from '@antv/l7-core';
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import regl from 'l7regl';
import 'reflect-metadata'; import 'reflect-metadata';
import regl from 'regl';
import ReglAttribute from './ReglAttribute'; import ReglAttribute from './ReglAttribute';
import ReglBuffer from './ReglBuffer'; import ReglBuffer from './ReglBuffer';
import ReglElements from './ReglElements'; import ReglElements from './ReglElements';
@ -80,6 +80,7 @@ export default class ReglRendererService implements IRendererService {
if (err || !r) { if (err || !r) {
reject(err); reject(err);
} }
// @ts-ignore
resolve(r); resolve(r);
}, },
}); });

View File

@ -109,6 +109,7 @@ export function getClass(el: ELType) {
// Check if the element is an SVGElementInstance and use the correspondingElement instead // Check if the element is an SVGElementInstance and use the correspondingElement instead
// (Required for linked SVG elements in IE11.) // (Required for linked SVG elements in IE11.)
if (el instanceof SVGElement) { if (el instanceof SVGElement) {
// @ts-ignore
el = el.correspondingElement; el = el.correspondingElement;
} }
return el.className.baseVal === undefined return el.className.baseVal === undefined

View File

@ -6,14 +6,30 @@ import * as React from 'react';
export default class ScaleComponent extends React.Component { export default class ScaleComponent extends React.Component {
private scene: Scene; private scene: Scene;
private el: HTMLCanvasElement;
public componentWillUnmount() { public componentWillUnmount() {
this.scene.destroy(); this.scene.destroy();
} }
public setCanvas() {
this.el.width = 400;
this.el.height = 300;
this.el.style.width = '300px';
this.el.style.height = '150px';
this.el.style.zIndex = '10';
this.el.style.position = 'absolute';
this.el.style.top = '0';
this.el.style.left = '0';
this.el.style.border = '1px solid';
}
public async componentDidMount() { public async componentDidMount() {
this.setCanvas();
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
// canvas: this.el,
map: new Map({ map: new Map({
hash: true, hash: true,
center: [110.19382669582967, 30.258134], center: [110.19382669582967, 30.258134],
@ -21,6 +37,35 @@ export default class ScaleComponent extends React.Component {
zoom: 2, zoom: 2,
}), }),
}); });
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
);
let imageLayer = new PointLayer({
blend: 'normal',
zIndex: 2,
})
.source(
[
{
id: '5011000000404',
name: '铁路新村(华池路)',
longitude: 121.4216962,
latitude: 31.26082325,
unit_price: 71469.4,
count: 2,
},
],
{
parser: {
type: 'json',
x: 'longitude',
y: 'latitude',
},
},
)
.shape('name', ['00'])
.size(20);
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json', 'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
) )
@ -81,6 +126,10 @@ export default class ScaleComponent extends React.Component {
}); });
scene.addLayer(layer); scene.addLayer(layer);
}); });
scene.on('loaded', () => {
scene.addLayer(imageLayer);
});
} }
public render() { public render() {
@ -94,7 +143,9 @@ export default class ScaleComponent extends React.Component {
right: 0, right: 0,
bottom: 0, bottom: 0,
}} }}
/> >
<canvas ref={(el) => (this.el = el as HTMLCanvasElement)}></canvas>
</div>
); );
} }
} }