@antv/l7-renderer
Advanced tools
Comparing version 2.16.1 to 2.16.2
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap; | ||
/** | ||
@@ -6,0 +4,0 @@ * @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射 |
@@ -5,7 +5,4 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
var _dec, _class; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
/** | ||
@@ -15,2 +12,3 @@ * render w/ regl | ||
*/ | ||
import { isMini } from '@antv/l7-utils'; | ||
@@ -26,36 +24,28 @@ import { injectable } from 'inversify'; | ||
import ReglTexture2D from "./ReglTexture2D"; | ||
/** | ||
* regl renderer | ||
*/ | ||
var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () { | ||
function ReglRendererService() { | ||
var _this = this; | ||
_classCallCheck(this, ReglRendererService); | ||
_defineProperty(this, "createModel", function (options) { | ||
return new ReglModel(_this.gl, options); | ||
}); | ||
_defineProperty(this, "createAttribute", function (options) { | ||
return new ReglAttribute(_this.gl, options); | ||
}); | ||
_defineProperty(this, "createBuffer", function (options) { | ||
return new ReglBuffer(_this.gl, options); | ||
}); | ||
_defineProperty(this, "createElements", function (options) { | ||
return new ReglElements(_this.gl, options); | ||
}); | ||
_defineProperty(this, "createTexture2D", function (options) { | ||
return new ReglTexture2D(_this.gl, options); | ||
}); | ||
_defineProperty(this, "createFramebuffer", function (options) { | ||
return new ReglFramebuffer(_this.gl, options); | ||
}); | ||
_defineProperty(this, "useFramebuffer", function (framebuffer, drawCommands) { | ||
@@ -66,12 +56,10 @@ _this.gl({ | ||
}); | ||
_defineProperty(this, "clear", function (options) { | ||
var _this$gl; | ||
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clear-the-draw-buffer | ||
var color = options.color, | ||
depth = options.depth, | ||
stencil = options.stencil, | ||
_options$framebuffer = options.framebuffer, | ||
framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer; | ||
depth = options.depth, | ||
stencil = options.stencil, | ||
_options$framebuffer = options.framebuffer, | ||
framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer; | ||
var reglClearOptions = { | ||
@@ -85,25 +73,20 @@ color: color, | ||
}); | ||
_defineProperty(this, "viewport", function (_ref) { | ||
var x = _ref.x, | ||
y = _ref.y, | ||
width = _ref.width, | ||
height = _ref.height; | ||
y = _ref.y, | ||
width = _ref.width, | ||
height = _ref.height; | ||
// use WebGL context directly | ||
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#unsafe-escape-hatch | ||
_this.gl._gl.viewport(x, y, width, height); | ||
_this.width = width; | ||
_this.height = height; | ||
_this.gl._refresh(); | ||
}); | ||
_defineProperty(this, "readPixels", function (options) { | ||
var framebuffer = options.framebuffer, | ||
x = options.x, | ||
y = options.y, | ||
width = options.width, | ||
height = options.height; | ||
x = options.x, | ||
y = options.y, | ||
width = options.width, | ||
height = options.height; | ||
var readPixelsOptions = { | ||
@@ -115,10 +98,7 @@ x: x, | ||
}; | ||
if (framebuffer) { | ||
readPixelsOptions.framebuffer = framebuffer.get(); | ||
} | ||
return _this.gl.read(readPixelsOptions); | ||
}); | ||
_defineProperty(this, "getViewportSize", function () { | ||
@@ -130,3 +110,2 @@ return { | ||
}); | ||
_defineProperty(this, "getContainer", function () { | ||
@@ -137,7 +116,5 @@ if (isMini) { | ||
var _this$canvas; | ||
return (_this$canvas = _this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.parentElement; | ||
} | ||
}); | ||
_defineProperty(this, "getCanvas", function () { | ||
@@ -147,23 +124,21 @@ // return this.$container?.getElementsByTagName('canvas')[0] || null; | ||
}); | ||
_defineProperty(this, "getGLContext", function () { | ||
return _this.gl._gl; | ||
}); | ||
_defineProperty(this, "destroy", function () { | ||
var _this$gl2, _this$gl2$_gl, _this$gl2$_gl$getExte; | ||
// this.canvas = null 清除对 webgl 实例的引用 | ||
// @ts-ignore | ||
_this.canvas = null; // make sure release webgl context | ||
_this.canvas = null; | ||
(_this$gl2 = _this.gl) === null || _this$gl2 === void 0 ? void 0 : (_this$gl2$_gl = _this$gl2._gl) === null || _this$gl2$_gl === void 0 ? void 0 : (_this$gl2$_gl$getExte = _this$gl2$_gl.getExtension('WEBGL_lose_context')) === null || _this$gl2$_gl$getExte === void 0 ? void 0 : _this$gl2$_gl$getExte.loseContext(); // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up | ||
// make sure release webgl context | ||
(_this$gl2 = _this.gl) === null || _this$gl2 === void 0 ? void 0 : (_this$gl2$_gl = _this$gl2._gl) === null || _this$gl2$_gl === void 0 ? void 0 : (_this$gl2$_gl$getExte = _this$gl2$_gl.getExtension('WEBGL_lose_context')) === null || _this$gl2$_gl$getExte === void 0 ? void 0 : _this$gl2$_gl$getExte.loseContext(); | ||
_this.gl.destroy(); // @ts-ignore | ||
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up | ||
_this.gl.destroy(); | ||
// @ts-ignore | ||
_this.gl = null; | ||
}); | ||
} | ||
_createClass(ReglRendererService, [{ | ||
@@ -174,70 +149,60 @@ key: "init", | ||
var _this2 = this; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
// this.$container = $container; | ||
this.canvas = canvas; | ||
if (!gl) { | ||
_context.next = 5; | ||
break; | ||
} | ||
this.gl = gl; | ||
_context.next = 8; | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
// this.$container = $container; | ||
this.canvas = canvas; | ||
if (!gl) { | ||
_context.next = 5; | ||
break; | ||
} | ||
this.gl = gl; | ||
_context.next = 8; | ||
break; | ||
case 5: | ||
_context.next = 7; | ||
return new Promise(function (resolve, reject) { | ||
regl({ | ||
canvas: _this2.canvas, | ||
attributes: { | ||
alpha: true, | ||
// use TAA instead of MSAA | ||
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1 | ||
antialias: cfg.antialias, | ||
premultipliedAlpha: true, | ||
preserveDrawingBuffer: cfg.preserveDrawingBuffer, | ||
stencil: cfg.stencil | ||
}, | ||
// TODO: use extensions | ||
extensions: ['OES_element_index_uint', 'OES_standard_derivatives', | ||
// wireframe | ||
'ANGLE_instanced_arrays' // VSM shadow map | ||
], | ||
case 5: | ||
_context.next = 7; | ||
return new Promise(function (resolve, reject) { | ||
regl({ | ||
canvas: _this2.canvas, | ||
attributes: { | ||
alpha: true, | ||
// use TAA instead of MSAA | ||
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1 | ||
antialias: cfg.antialias, | ||
premultipliedAlpha: true, | ||
preserveDrawingBuffer: cfg.preserveDrawingBuffer, | ||
stencil: cfg.stencil | ||
}, | ||
// TODO: use extensions | ||
extensions: ['OES_element_index_uint', 'OES_standard_derivatives', // wireframe | ||
'ANGLE_instanced_arrays' // VSM shadow map | ||
], | ||
optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float', 'EXT_texture_filter_anisotropic', 'EXT_blend_minmax', 'WEBGL_depth_texture', 'WEBGL_lose_context'], | ||
profile: true, | ||
onDone: function onDone(err, r) { | ||
if (err || !r) { | ||
reject(err); | ||
} // @ts-ignore | ||
resolve(r); | ||
optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float', 'EXT_texture_filter_anisotropic', 'EXT_blend_minmax', 'WEBGL_depth_texture', 'WEBGL_lose_context'], | ||
profile: true, | ||
onDone: function onDone(err, r) { | ||
if (err || !r) { | ||
reject(err); | ||
} | ||
}); | ||
// @ts-ignore | ||
resolve(r); | ||
} | ||
}); | ||
case 7: | ||
this.gl = _context.sent; | ||
case 8: | ||
this.extensionObject = { | ||
OES_texture_float: this.testExtension('OES_texture_float') | ||
}; | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}); | ||
case 7: | ||
this.gl = _context.sent; | ||
case 8: | ||
this.extensionObject = { | ||
OES_texture_float: this.testExtension('OES_texture_float') | ||
}; | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this); | ||
})); | ||
function init(_x, _x2, _x3) { | ||
return _init.apply(this, arguments); | ||
} | ||
return init; | ||
@@ -258,3 +223,4 @@ }() | ||
key: "setState", | ||
value: // TODO: 临时方法 | ||
value: | ||
// TODO: 临时方法 | ||
function setState() { | ||
@@ -278,3 +244,2 @@ this.gl({ | ||
}); | ||
this.gl._refresh(); | ||
@@ -302,3 +267,2 @@ } | ||
}); | ||
this.gl._refresh(); | ||
@@ -323,5 +287,4 @@ } | ||
}]); | ||
return ReglRendererService; | ||
}()) || _class); | ||
export { ReglRendererService as default }; |
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
/** | ||
@@ -10,9 +9,8 @@ * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#attributes | ||
_classCallCheck(this, ReglAttribute); | ||
var buffer = options.buffer, | ||
offset = options.offset, | ||
stride = options.stride, | ||
normalized = options.normalized, | ||
size = options.size, | ||
divisor = options.divisor; | ||
offset = options.offset, | ||
stride = options.stride, | ||
normalized = options.normalized, | ||
size = options.size, | ||
divisor = options.divisor; | ||
this.buffer = buffer; | ||
@@ -26,3 +24,2 @@ this.attribute = { | ||
}; | ||
if (size) { | ||
@@ -32,3 +29,2 @@ this.attribute.size = size; | ||
} | ||
_createClass(ReglAttribute, [{ | ||
@@ -50,6 +46,4 @@ key: "get", | ||
}]); | ||
return ReglAttribute; | ||
}(); | ||
export { ReglAttribute as default }; |
@@ -5,2 +5,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import { dataTypeMap, usageMap } from "./constants"; | ||
/** | ||
@@ -10,18 +11,15 @@ * adaptor for regl.Buffer | ||
*/ | ||
var ReglBuffer = /*#__PURE__*/function () { | ||
function ReglBuffer(reGl, options) { | ||
_classCallCheck(this, ReglBuffer); | ||
var data = options.data, | ||
usage = options.usage, | ||
type = options.type; | ||
usage = options.usage, | ||
type = options.type; | ||
this.buffer = reGl.buffer({ | ||
data: data, | ||
usage: usageMap[usage || gl.STATIC_DRAW], | ||
type: dataTypeMap[type || gl.UNSIGNED_BYTE] // length: 0, | ||
type: dataTypeMap[type || gl.UNSIGNED_BYTE] | ||
// length: 0, | ||
}); | ||
} | ||
_createClass(ReglBuffer, [{ | ||
@@ -41,10 +39,8 @@ key: "get", | ||
var data = _ref.data, | ||
offset = _ref.offset; | ||
offset = _ref.offset; | ||
this.buffer.subdata(data, offset); | ||
} | ||
}]); | ||
return ReglBuffer; | ||
}(); | ||
export { ReglBuffer as default }; |
@@ -5,14 +5,13 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import { dataTypeMap, usageMap } from "./constants"; | ||
/** | ||
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#elements | ||
*/ | ||
var ReglElements = /*#__PURE__*/function () { | ||
function ReglElements(reGl, options) { | ||
_classCallCheck(this, ReglElements); | ||
var data = options.data, | ||
usage = options.usage, | ||
type = options.type, | ||
count = options.count; | ||
usage = options.usage, | ||
type = options.type, | ||
count = options.count; | ||
this.elements = reGl.elements({ | ||
@@ -25,3 +24,2 @@ data: data, | ||
} | ||
_createClass(ReglElements, [{ | ||
@@ -40,9 +38,8 @@ key: "get", | ||
key: "destroy", | ||
value: function destroy() {// this.elements.destroy(); | ||
value: function destroy() { | ||
// this.elements.destroy(); | ||
} | ||
}]); | ||
return ReglElements; | ||
}(); | ||
export { ReglElements as default }; |
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
/** | ||
@@ -11,7 +10,6 @@ * adaptor for regl.Framebuffer | ||
_classCallCheck(this, ReglFramebuffer); | ||
var width = options.width, | ||
height = options.height, | ||
color = options.color, | ||
colors = options.colors; | ||
height = options.height, | ||
color = options.color, | ||
colors = options.colors; | ||
var framebufferOptions = { | ||
@@ -21,3 +19,2 @@ width: width, | ||
}; | ||
if (Array.isArray(colors)) { | ||
@@ -28,11 +25,10 @@ framebufferOptions.colors = colors.map(function (c) { | ||
} | ||
if (color && typeof color !== 'boolean') { | ||
framebufferOptions.color = color.get(); | ||
} // TODO: depth & stencil | ||
} | ||
// TODO: depth & stencil | ||
this.framebuffer = reGl.framebuffer(framebufferOptions); | ||
} | ||
_createClass(ReglFramebuffer, [{ | ||
@@ -52,10 +48,8 @@ key: "get", | ||
var width = _ref.width, | ||
height = _ref.height; | ||
height = _ref.height; | ||
this.framebuffer.resize(width, height); | ||
} | ||
}]); | ||
return ReglFramebuffer; | ||
}(); | ||
export { ReglFramebuffer as default }; |
@@ -9,3 +9,2 @@ import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import { blendEquationMap, blendFuncMap, cullFaceMap, depthFuncMap, primitiveMap, stencilFuncMap, stencilOpMap } from "./constants"; | ||
/** | ||
@@ -17,21 +16,17 @@ * adaptor for regl.DrawCommand | ||
_classCallCheck(this, ReglModel); | ||
_defineProperty(this, "destroyed", false); | ||
_defineProperty(this, "uniforms", {}); | ||
this.reGl = reGl; | ||
var vs = options.vs, | ||
fs = options.fs, | ||
attributes = options.attributes, | ||
uniforms = options.uniforms, | ||
primitive = options.primitive, | ||
count = options.count, | ||
elements = options.elements, | ||
depth = options.depth, | ||
cull = options.cull, | ||
instances = options.instances; | ||
fs = options.fs, | ||
attributes = options.attributes, | ||
uniforms = options.uniforms, | ||
primitive = options.primitive, | ||
count = options.count, | ||
elements = options.elements, | ||
depth = options.depth, | ||
cull = options.cull, | ||
instances = options.instances; | ||
var reglUniforms = {}; | ||
this.options = options; | ||
if (uniforms) { | ||
@@ -45,3 +40,2 @@ this.uniforms = this.extractUniforms(uniforms); | ||
} | ||
var reglAttributes = {}; | ||
@@ -58,2 +52,3 @@ Object.keys(attributes).forEach(function (name) { | ||
colorMask: reGl.prop('colorMask'), | ||
lineWidth: 1, | ||
blend: { | ||
@@ -83,10 +78,9 @@ // @ts-ignore | ||
}; | ||
if (instances) { | ||
drawParams.instances = instances; | ||
} // Tip: | ||
} | ||
// Tip: | ||
// elements 中可能包含 count,此时不应传入 | ||
// count 和 elements 相比、count 优先 | ||
if (count) { | ||
@@ -97,8 +91,7 @@ drawParams.count = count; | ||
} | ||
this.initDepthDrawParams({ | ||
depth: depth | ||
}, drawParams); // this.initBlendDrawParams({ blend }, drawParams); | ||
}, drawParams); | ||
// this.initBlendDrawParams({ blend }, drawParams); | ||
// this.initStencilDrawParams({ stencil }, drawParams); | ||
this.initCullDrawParams({ | ||
@@ -110,3 +103,2 @@ cull: cull | ||
} | ||
_createClass(ReglModel, [{ | ||
@@ -141,14 +133,11 @@ key: "updateAttributesAndElements", | ||
value: function draw(options, pick) { | ||
// console.log('options', this.drawParams) | ||
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) { | ||
return; | ||
} | ||
var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {})); | ||
var reglDrawProps = {}; | ||
Object.keys(uniforms).forEach(function (uniformName) { | ||
var type = _typeof(uniforms[uniformName]); | ||
if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) || // @ts-ignore | ||
if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) || | ||
// @ts-ignore | ||
uniforms[uniformName].BYTES_PER_ELEMENT) { | ||
@@ -159,5 +148,5 @@ reglDrawProps[uniformName] = uniforms[uniformName]; | ||
} | ||
}); // 更新 blend | ||
}); | ||
// 更新 blend | ||
// @ts-ignore | ||
reglDrawProps.blend = pick // picking 操作不应该使用 blend | ||
@@ -168,9 +157,11 @@ ? this.getBlendDrawParams({ | ||
} | ||
}) : this.getBlendDrawParams(options); // 更新stentil 配置 | ||
}) : this.getBlendDrawParams(options); | ||
// 更新stentil 配置 | ||
// @ts-ignore | ||
reglDrawProps.stencil = this.getStencilDrawParams(options); | ||
// @ts-ignore | ||
reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick); | ||
reglDrawProps.stencil = this.getStencilDrawParams(options); // @ts-ignore | ||
reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick); // 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色 | ||
// 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色 | ||
this.drawCommand(reglDrawProps); | ||
@@ -182,6 +173,4 @@ } | ||
var _this$drawParams, _this$drawParams$elem; | ||
// @ts-ignore | ||
(_this$drawParams = this.drawParams) === null || _this$drawParams === void 0 ? void 0 : (_this$drawParams$elem = _this$drawParams.elements) === null || _this$drawParams$elem === void 0 ? void 0 : _this$drawParams$elem.destroy(); | ||
if (this.options.attributes) { | ||
@@ -193,9 +182,8 @@ Object.values(this.options.attributes).forEach(function (attr) { | ||
} | ||
this.destroyed = true; | ||
} | ||
/** | ||
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer | ||
*/ | ||
}, { | ||
@@ -205,3 +193,2 @@ key: "initDepthDrawParams", | ||
var depth = _ref.depth; | ||
if (depth) { | ||
@@ -220,11 +207,9 @@ drawParams.depth = { | ||
var blend = _ref2.blend; | ||
var _ref3 = blend || {}, | ||
enable = _ref3.enable, | ||
func = _ref3.func, | ||
equation = _ref3.equation, | ||
_ref3$color = _ref3.color, | ||
color = _ref3$color === void 0 ? [0, 0, 0, 0] : _ref3$color; // @ts-ignore | ||
enable = _ref3.enable, | ||
func = _ref3.func, | ||
equation = _ref3.equation, | ||
_ref3$color = _ref3.color, | ||
color = _ref3$color === void 0 ? [0, 0, 0, 0] : _ref3$color; | ||
// @ts-ignore | ||
return { | ||
@@ -248,3 +233,2 @@ enable: !!enable, | ||
*/ | ||
}, { | ||
@@ -254,26 +238,24 @@ key: "getStencilDrawParams", | ||
var stencil = _ref4.stencil; | ||
var _ref5 = stencil || {}, | ||
enable = _ref5.enable, | ||
_ref5$mask = _ref5.mask, | ||
mask = _ref5$mask === void 0 ? -1 : _ref5$mask, | ||
_ref5$func = _ref5.func, | ||
func = _ref5$func === void 0 ? { | ||
cmp: gl.ALWAYS, | ||
ref: 0, | ||
mask: -1 | ||
} : _ref5$func, | ||
_ref5$opFront = _ref5.opFront, | ||
opFront = _ref5$opFront === void 0 ? { | ||
fail: gl.KEEP, | ||
zfail: gl.KEEP, | ||
zpass: gl.KEEP | ||
} : _ref5$opFront, | ||
_ref5$opBack = _ref5.opBack, | ||
opBack = _ref5$opBack === void 0 ? { | ||
fail: gl.KEEP, | ||
zfail: gl.KEEP, | ||
zpass: gl.KEEP | ||
} : _ref5$opBack; | ||
enable = _ref5.enable, | ||
_ref5$mask = _ref5.mask, | ||
mask = _ref5$mask === void 0 ? -1 : _ref5$mask, | ||
_ref5$func = _ref5.func, | ||
func = _ref5$func === void 0 ? { | ||
cmp: gl.ALWAYS, | ||
ref: 0, | ||
mask: -1 | ||
} : _ref5$func, | ||
_ref5$opFront = _ref5.opFront, | ||
opFront = _ref5$opFront === void 0 ? { | ||
fail: gl.KEEP, | ||
zfail: gl.KEEP, | ||
zpass: gl.KEEP | ||
} : _ref5$opFront, | ||
_ref5$opBack = _ref5.opBack, | ||
opBack = _ref5$opBack === void 0 ? { | ||
fail: gl.KEEP, | ||
zfail: gl.KEEP, | ||
zpass: gl.KEEP | ||
} : _ref5$opBack; | ||
return { | ||
@@ -304,9 +286,8 @@ enable: !!enable, | ||
var colorMask = stencil !== null && stencil !== void 0 && stencil.enable && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true]; // 非掩码模式下,颜色通道全部开启 | ||
return colorMask; | ||
} | ||
/** | ||
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling | ||
*/ | ||
}, { | ||
@@ -316,7 +297,6 @@ key: "initCullDrawParams", | ||
var cull = _ref7.cull; | ||
if (cull) { | ||
var enable = cull.enable, | ||
_cull$face = cull.face, | ||
face = _cull$face === void 0 ? gl.BACK : _cull$face; | ||
_cull$face = cull.face, | ||
face = _cull$face === void 0 ? gl.BACK : _cull$face; | ||
drawParams.cull = { | ||
@@ -328,2 +308,3 @@ enable: !!enable, | ||
} | ||
/** | ||
@@ -334,3 +315,2 @@ * 考虑结构体命名, eg: | ||
*/ | ||
}, { | ||
@@ -340,3 +320,2 @@ key: "extractUniforms", | ||
var _this = this; | ||
var extractedUniforms = {}; | ||
@@ -352,7 +331,10 @@ Object.keys(uniforms).forEach(function (uniformName) { | ||
var _this2 = this; | ||
if (uniformValue === null || typeof uniformValue === 'number' || // u_A: 1 | ||
typeof uniformValue === 'boolean' || // u_A: false | ||
Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' || // u_A: [1, 2, 3] | ||
isTypedArray(uniformValue) || // u_A: Float32Array | ||
if (uniformValue === null || typeof uniformValue === 'number' || | ||
// u_A: 1 | ||
typeof uniformValue === 'boolean' || | ||
// u_A: false | ||
Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' || | ||
// u_A: [1, 2, 3] | ||
isTypedArray(uniformValue) || | ||
// u_A: Float32Array | ||
// @ts-ignore | ||
@@ -362,17 +344,19 @@ uniformValue === '' || 'resize' in uniformValue) { | ||
return; | ||
} // u_Struct.a.b.c | ||
} | ||
// u_Struct.a.b.c | ||
if (isPlainObject(uniformValue)) { | ||
Object.keys(uniformValue).forEach(function (childName) { | ||
_this2.extractUniformsRecursively(childName, // @ts-ignore | ||
_this2.extractUniformsRecursively(childName, | ||
// @ts-ignore | ||
uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName)); | ||
}); | ||
} // u_Struct[0].a | ||
} | ||
// u_Struct[0].a | ||
if (Array.isArray(uniformValue)) { | ||
uniformValue.forEach(function (child, idx) { | ||
Object.keys(child).forEach(function (childName) { | ||
_this2.extractUniformsRecursively(childName, // @ts-ignore | ||
_this2.extractUniformsRecursively(childName, | ||
// @ts-ignore | ||
child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]")); | ||
@@ -384,6 +368,4 @@ }); | ||
}]); | ||
return ReglModel; | ||
}(); | ||
export { ReglModel as default }; |
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import { formatMap } from "./constants"; | ||
/** | ||
@@ -8,10 +9,8 @@ * adaptor for regl.Renderbuffer | ||
*/ | ||
var ReglRenderbuffer = /*#__PURE__*/function () { | ||
function ReglRenderbuffer(reGl, options) { | ||
_classCallCheck(this, ReglRenderbuffer); | ||
var width = options.width, | ||
height = options.height, | ||
format = options.format; | ||
height = options.height, | ||
format = options.format; | ||
this.renderbuffer = reGl.renderbuffer({ | ||
@@ -23,3 +22,2 @@ width: width, | ||
} | ||
_createClass(ReglRenderbuffer, [{ | ||
@@ -39,10 +37,8 @@ key: "get", | ||
var width = _ref.width, | ||
height = _ref.height; | ||
height = _ref.height; | ||
this.renderbuffer.resize(width, height); | ||
} | ||
}]); | ||
return ReglRenderbuffer; | ||
}(); | ||
export { ReglRenderbuffer as default }; |
@@ -6,2 +6,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import { colorSpaceMap, dataTypeMap, filterMap, formatMap, mipmapMap, wrapModeMap } from "./constants"; | ||
/** | ||
@@ -11,42 +12,39 @@ * adaptor for regl.Buffer | ||
*/ | ||
var ReglTexture2D = /*#__PURE__*/function () { | ||
function ReglTexture2D(reGl, options) { | ||
_classCallCheck(this, ReglTexture2D); | ||
_defineProperty(this, "isDestroy", false); | ||
var data = options.data, | ||
_options$type = options.type, | ||
type = _options$type === void 0 ? gl.UNSIGNED_BYTE : _options$type, | ||
width = options.width, | ||
height = options.height, | ||
_options$flipY = options.flipY, | ||
flipY = _options$flipY === void 0 ? false : _options$flipY, | ||
_options$format = options.format, | ||
format = _options$format === void 0 ? gl.RGBA : _options$format, | ||
_options$mipmap = options.mipmap, | ||
mipmap = _options$mipmap === void 0 ? false : _options$mipmap, | ||
_options$wrapS = options.wrapS, | ||
wrapS = _options$wrapS === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapS, | ||
_options$wrapT = options.wrapT, | ||
wrapT = _options$wrapT === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapT, | ||
_options$aniso = options.aniso, | ||
aniso = _options$aniso === void 0 ? 0 : _options$aniso, | ||
_options$alignment = options.alignment, | ||
alignment = _options$alignment === void 0 ? 1 : _options$alignment, | ||
_options$premultiplyA = options.premultiplyAlpha, | ||
premultiplyAlpha = _options$premultiplyA === void 0 ? false : _options$premultiplyA, | ||
_options$mag = options.mag, | ||
mag = _options$mag === void 0 ? gl.NEAREST : _options$mag, | ||
_options$min = options.min, | ||
min = _options$min === void 0 ? gl.NEAREST : _options$min, | ||
_options$colorSpace = options.colorSpace, | ||
colorSpace = _options$colorSpace === void 0 ? gl.BROWSER_DEFAULT_WEBGL : _options$colorSpace, | ||
_options$x = options.x, | ||
x = _options$x === void 0 ? 0 : _options$x, | ||
_options$y = options.y, | ||
y = _options$y === void 0 ? 0 : _options$y, | ||
_options$copy = options.copy, | ||
copy = _options$copy === void 0 ? false : _options$copy; | ||
_options$type = options.type, | ||
type = _options$type === void 0 ? gl.UNSIGNED_BYTE : _options$type, | ||
width = options.width, | ||
height = options.height, | ||
_options$flipY = options.flipY, | ||
flipY = _options$flipY === void 0 ? false : _options$flipY, | ||
_options$format = options.format, | ||
format = _options$format === void 0 ? gl.RGBA : _options$format, | ||
_options$mipmap = options.mipmap, | ||
mipmap = _options$mipmap === void 0 ? false : _options$mipmap, | ||
_options$wrapS = options.wrapS, | ||
wrapS = _options$wrapS === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapS, | ||
_options$wrapT = options.wrapT, | ||
wrapT = _options$wrapT === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapT, | ||
_options$aniso = options.aniso, | ||
aniso = _options$aniso === void 0 ? 0 : _options$aniso, | ||
_options$alignment = options.alignment, | ||
alignment = _options$alignment === void 0 ? 1 : _options$alignment, | ||
_options$premultiplyA = options.premultiplyAlpha, | ||
premultiplyAlpha = _options$premultiplyA === void 0 ? false : _options$premultiplyA, | ||
_options$mag = options.mag, | ||
mag = _options$mag === void 0 ? gl.NEAREST : _options$mag, | ||
_options$min = options.min, | ||
min = _options$min === void 0 ? gl.NEAREST : _options$min, | ||
_options$colorSpace = options.colorSpace, | ||
colorSpace = _options$colorSpace === void 0 ? gl.BROWSER_DEFAULT_WEBGL : _options$colorSpace, | ||
_options$x = options.x, | ||
x = _options$x === void 0 ? 0 : _options$x, | ||
_options$y = options.y, | ||
y = _options$y === void 0 ? 0 : _options$y, | ||
_options$copy = options.copy, | ||
copy = _options$copy === void 0 ? false : _options$copy; | ||
this.width = width; | ||
@@ -75,3 +73,2 @@ this.height = height; | ||
}; | ||
if (data) { | ||
@@ -81,3 +78,2 @@ // @ts-ignore | ||
} | ||
if (typeof mipmap === 'number') { | ||
@@ -88,6 +84,4 @@ textureOptions.mipmap = mipmapMap[mipmap]; | ||
} | ||
this.texture = reGl.texture(textureOptions); | ||
} | ||
_createClass(ReglTexture2D, [{ | ||
@@ -114,3 +108,3 @@ key: "get", | ||
var width = _ref.width, | ||
height = _ref.height; | ||
height = _ref.height; | ||
this.texture.resize(width, height); | ||
@@ -130,13 +124,9 @@ this.width = width; | ||
var _this$texture; | ||
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy(); | ||
} | ||
this.isDestroy = true; | ||
} | ||
}]); | ||
return ReglTexture2D; | ||
}(); | ||
export { ReglTexture2D as default }; |
@@ -20,2 +20,6 @@ var __create = Object.create; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
@@ -22,0 +26,0 @@ mod |
@@ -20,2 +20,6 @@ var __create = Object.create; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
@@ -137,2 +141,4 @@ mod | ||
alpha: true, | ||
// use TAA instead of MSAA | ||
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1 | ||
antialias: cfg.antialias, | ||
@@ -143,6 +149,9 @@ premultipliedAlpha: true, | ||
}, | ||
// TODO: use extensions | ||
extensions: [ | ||
"OES_element_index_uint", | ||
"OES_standard_derivatives", | ||
// wireframe | ||
"ANGLE_instanced_arrays" | ||
// VSM shadow map | ||
], | ||
@@ -177,2 +186,3 @@ optionalExtensions: [ | ||
} | ||
// TODO: 临时方法 | ||
setState() { | ||
@@ -232,3 +242,1 @@ this.gl({ | ||
], ReglRendererService); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
@@ -50,3 +50,1 @@ var __defProp = Object.defineProperty; | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
@@ -34,2 +34,3 @@ var __defProp = Object.defineProperty; | ||
type: import_constants.dataTypeMap[type || import_l7_core.gl.UNSIGNED_BYTE] | ||
// length: 0, | ||
}); | ||
@@ -50,3 +51,1 @@ } | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
@@ -48,3 +48,1 @@ var __defProp = Object.defineProperty; | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
@@ -52,3 +52,1 @@ var __defProp = Object.defineProperty; | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
@@ -62,14 +62,25 @@ var __defProp = Object.defineProperty; | ||
vert: vs, | ||
// @ts-ignore | ||
colorMask: reGl.prop("colorMask"), | ||
lineWidth: 1, | ||
blend: { | ||
// @ts-ignore | ||
enable: reGl.prop("blend.enable"), | ||
// @ts-ignore | ||
func: reGl.prop("blend.func"), | ||
// @ts-ignore | ||
equation: reGl.prop("blend.equation"), | ||
// @ts-ignore | ||
color: reGl.prop("blend.color") | ||
}, | ||
stencil: { | ||
// @ts-ignore | ||
enable: reGl.prop("stencil.enable"), | ||
// @ts-ignore | ||
mask: reGl.prop("stencil.mask"), | ||
// @ts-ignore | ||
func: reGl.prop("stencil.func"), | ||
// @ts-ignore | ||
opFront: reGl.prop("stencil.opFront"), | ||
// @ts-ignore | ||
opBack: reGl.prop("stencil.opBack") | ||
@@ -126,3 +137,4 @@ }, | ||
const type = typeof uniforms[uniformName]; | ||
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || uniforms[uniformName].BYTES_PER_ELEMENT) { | ||
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || // @ts-ignore | ||
uniforms[uniformName].BYTES_PER_ELEMENT) { | ||
reglDrawProps[uniformName] = uniforms[uniformName]; | ||
@@ -150,2 +162,5 @@ } else { | ||
} | ||
/** | ||
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer | ||
*/ | ||
initDepthDrawParams({ depth }, drawParams) { | ||
@@ -180,2 +195,5 @@ if (depth) { | ||
} | ||
/** | ||
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil | ||
*/ | ||
getStencilDrawParams({ | ||
@@ -226,2 +244,5 @@ stencil | ||
} | ||
/** | ||
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling | ||
*/ | ||
initCullDrawParams({ cull }, drawParams) { | ||
@@ -236,2 +257,7 @@ if (cull) { | ||
} | ||
/** | ||
* 考虑结构体命名, eg: | ||
* a: { b: 1 } -> 'a.b' | ||
* a: [ { b: 1 } ] -> 'a[0].b' | ||
*/ | ||
extractUniforms(uniforms) { | ||
@@ -250,3 +276,8 @@ const extractedUniforms = {}; | ||
extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) { | ||
if (uniformValue === null || typeof uniformValue === "number" || typeof uniformValue === "boolean" || Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || (0, import_lodash.isTypedArray)(uniformValue) || uniformValue === "" || "resize" in uniformValue) { | ||
if (uniformValue === null || typeof uniformValue === "number" || // u_A: 1 | ||
typeof uniformValue === "boolean" || // u_A: false | ||
Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || // u_A: [1, 2, 3] | ||
(0, import_lodash.isTypedArray)(uniformValue) || // u_A: Float32Array | ||
// @ts-ignore | ||
uniformValue === "" || "resize" in uniformValue) { | ||
uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue; | ||
@@ -259,2 +290,3 @@ return; | ||
childName, | ||
// @ts-ignore | ||
uniformValue[childName], | ||
@@ -271,2 +303,3 @@ uniforms, | ||
childName, | ||
// @ts-ignore | ||
child[childName], | ||
@@ -281,3 +314,1 @@ uniforms, | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
@@ -45,3 +45,1 @@ var __defProp = Object.defineProperty; | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
@@ -55,2 +55,3 @@ var __defProp = Object.defineProperty; | ||
height, | ||
// @ts-ignore | ||
type: import_constants.dataTypeMap[type], | ||
@@ -60,2 +61,3 @@ format: import_constants.formatMap[format], | ||
wrapT: import_constants.wrapModeMap[wrapT], | ||
// @ts-ignore | ||
mag: import_constants.filterMap[mag], | ||
@@ -68,2 +70,3 @@ min: import_constants.filterMap[min], | ||
aniso, | ||
// copy pixels from current bind framebuffer | ||
x, | ||
@@ -108,3 +111,1 @@ y, | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
{ | ||
"name": "@antv/l7-renderer", | ||
"version": "2.16.1", | ||
"version": "2.16.2", | ||
"description": "", | ||
@@ -28,8 +28,8 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@antv/l7-test-utils": "2.16.1", | ||
"@antv/l7-test-utils": "2.16.2", | ||
"gl": "^5.0.3" | ||
}, | ||
"dependencies": { | ||
"@antv/l7-core": "2.16.1", | ||
"@antv/l7-utils": "2.16.1", | ||
"@antv/l7-core": "2.16.2", | ||
"@antv/l7-utils": "2.16.2", | ||
"@babel/runtime": "^7.7.7", | ||
@@ -41,3 +41,3 @@ "inversify": "^5.0.1", | ||
}, | ||
"gitHead": "0976422540e1c3e23563239847110b40c6cb852a", | ||
"gitHead": "93b6d071e7d9c07c8bafcf1e6ce37b5f21185905", | ||
"publishConfig": { | ||
@@ -44,0 +44,0 @@ "access": "public" |
96626
2313
+ Added@antv/l7-core@2.16.2(transitive)
+ Added@antv/l7-utils@2.16.2(transitive)
- Removed@antv/l7-core@2.16.1(transitive)
- Removed@antv/l7-utils@2.16.1(transitive)
Updated@antv/l7-core@2.16.2
Updated@antv/l7-utils@2.16.2