@antv/g-webgpu 1.1.4 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="@webgpu/types" />
|
|
1
|
+
import type { CanvasLike } from '@antv/g';
|
|
3
2
|
import { ContextService } from '@antv/g';
|
|
4
3
|
export declare class WebGLContextService implements ContextService<WebGLRenderingContext> {
|
|
5
4
|
private $container;
|
|
@@ -8,7 +7,7 @@ export declare class WebGLContextService implements ContextService<WebGLRenderin
|
|
|
8
7
|
private context;
|
|
9
8
|
private canvasConfig;
|
|
10
9
|
init(): void;
|
|
11
|
-
getDomElement():
|
|
10
|
+
getDomElement(): CanvasLike;
|
|
12
11
|
getContext(): WebGLRenderingContext;
|
|
13
12
|
getBoundingClientRect(): DOMRect;
|
|
14
13
|
destroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGLContextService.d.ts","sourceRoot":"","sources":["../src/WebGLContextService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebGLContextService.d.ts","sourceRoot":"","sources":["../src/WebGLContextService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAgB,cAAc,EAAmC,MAAM,SAAS,CAAC;AAGxF,qBACa,mBAAoB,YAAW,cAAc,CAAC,qBAAqB,CAAC;IAC/E,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,OAAO,CAA+B;IAG9C,OAAO,CAAC,YAAY,CAAe;IAEnC,IAAI;IAgCJ,aAAa;IAIb,UAAU;IAIV,qBAAqB;IAMrB,OAAO;IAQP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAapC,MAAM;IAIN,gBAAgB,CAAC,MAAM,EAAE,MAAM;CAKhC"}
|
package/dist/index.umd.js
CHANGED
|
@@ -435,7 +435,6 @@
|
|
|
435
435
|
var _class;
|
|
436
436
|
|
|
437
437
|
var DOMInteractionPlugin_1;
|
|
438
|
-
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
439
438
|
/**
|
|
440
439
|
* listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
|
|
441
440
|
*/
|
|
@@ -451,8 +450,7 @@
|
|
|
451
450
|
_proto.apply = function apply(renderingService) {
|
|
452
451
|
var _this = this;
|
|
453
452
|
|
|
454
|
-
var canvas = this.renderingContext.root.ownerDocument.defaultView;
|
|
455
|
-
var SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
453
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
456
454
|
|
|
457
455
|
var onPointerMove = function onPointerMove(ev) {
|
|
458
456
|
renderingService.hooks.pointerMove.call(ev);
|
|
@@ -9093,12 +9091,6 @@
|
|
|
9093
9091
|
frontFace: frontFace,
|
|
9094
9092
|
polygonOffset: polygonOffset,
|
|
9095
9093
|
attachmentsState: attachmentsState,
|
|
9096
|
-
blendEquation: BlendMode.Add,
|
|
9097
|
-
blendEquationAlpha: BlendMode.Add,
|
|
9098
|
-
blendSrc: BlendFactor.SrcAlpha,
|
|
9099
|
-
blendDst: BlendFactor.OneMinusSrcAlpha,
|
|
9100
|
-
blendSrcAlpha: BlendFactor.Zero,
|
|
9101
|
-
blendDstAlpha: BlendFactor.One,
|
|
9102
9094
|
dithering: false,
|
|
9103
9095
|
wireframe: false,
|
|
9104
9096
|
wireframeColor: 'black',
|
|
@@ -9214,6 +9206,14 @@
|
|
|
9214
9206
|
* Blending state
|
|
9215
9207
|
*/
|
|
9216
9208
|
|
|
9209
|
+
}, {
|
|
9210
|
+
key: "blendConstant",
|
|
9211
|
+
get: function get() {
|
|
9212
|
+
return this.props.blendConstant;
|
|
9213
|
+
},
|
|
9214
|
+
set: function set(value) {
|
|
9215
|
+
this.props.blendConstant = value;
|
|
9216
|
+
}
|
|
9217
9217
|
}, {
|
|
9218
9218
|
key: "blendEquation",
|
|
9219
9219
|
get: function get() {
|
|
@@ -9443,6 +9443,14 @@
|
|
|
9443
9443
|
});
|
|
9444
9444
|
}
|
|
9445
9445
|
|
|
9446
|
+
var definedProps = function definedProps(obj) {
|
|
9447
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_ref) {
|
|
9448
|
+
var k = _ref[0],
|
|
9449
|
+
v = _ref[1];
|
|
9450
|
+
return v !== undefined;
|
|
9451
|
+
}));
|
|
9452
|
+
};
|
|
9453
|
+
|
|
9446
9454
|
var counter$1 = 1;
|
|
9447
9455
|
var FILL_TEXTURE_MAPPING = 'FillTextureMapping';
|
|
9448
9456
|
/**
|
|
@@ -10183,29 +10191,15 @@
|
|
|
10183
10191
|
cullMode = material.cullMode,
|
|
10184
10192
|
frontFace = material.frontFace,
|
|
10185
10193
|
polygonOffset = material.polygonOffset,
|
|
10194
|
+
blendConstant = material.blendConstant,
|
|
10186
10195
|
blendEquation = material.blendEquation,
|
|
10187
10196
|
blendEquationAlpha = material.blendEquationAlpha,
|
|
10188
10197
|
blendSrc = material.blendSrc,
|
|
10189
10198
|
blendDst = material.blendDst,
|
|
10190
10199
|
blendSrcAlpha = material.blendSrcAlpha,
|
|
10191
10200
|
blendDstAlpha = material.blendDstAlpha;
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
// should not affect color buffer when drawing stencil
|
|
10195
|
-
channelWriteMask: this.material.stencilWrite ? ChannelWriteMask.None : ChannelWriteMask.AllChannels,
|
|
10196
|
-
// channelWriteMask: ChannelWriteMask.AllChannels,
|
|
10197
|
-
rgbBlendState: {
|
|
10198
|
-
blendMode: blendEquation,
|
|
10199
|
-
blendSrcFactor: blendSrc,
|
|
10200
|
-
blendDstFactor: blendDst
|
|
10201
|
-
},
|
|
10202
|
-
alphaBlendState: {
|
|
10203
|
-
blendMode: blendEquationAlpha,
|
|
10204
|
-
blendSrcFactor: blendSrcAlpha,
|
|
10205
|
-
blendDstFactor: blendDstAlpha
|
|
10206
|
-
}
|
|
10207
|
-
}],
|
|
10208
|
-
// blendConstant: Color;
|
|
10201
|
+
var materialMegaState = definedProps({
|
|
10202
|
+
blendConstant: blendConstant,
|
|
10209
10203
|
depthCompare: depthCompare,
|
|
10210
10204
|
depthWrite: depthWrite,
|
|
10211
10205
|
stencilCompare: stencilCompare,
|
|
@@ -10216,6 +10210,24 @@
|
|
|
10216
10210
|
frontFace: frontFace,
|
|
10217
10211
|
polygonOffset: polygonOffset
|
|
10218
10212
|
});
|
|
10213
|
+
var currentAttachmentsState = renderInst.getMegaStateFlags().attachmentsState[0];
|
|
10214
|
+
renderInst.setMegaStateFlags(_extends({
|
|
10215
|
+
attachmentsState: [{
|
|
10216
|
+
// should not affect color buffer when drawing stencil
|
|
10217
|
+
channelWriteMask: this.material.stencilWrite ? ChannelWriteMask.None : ChannelWriteMask.AllChannels,
|
|
10218
|
+
// channelWriteMask: ChannelWriteMask.AllChannels,
|
|
10219
|
+
rgbBlendState: _extends({}, currentAttachmentsState.rgbBlendState, definedProps({
|
|
10220
|
+
blendMode: blendEquation,
|
|
10221
|
+
blendSrcFactor: blendSrc,
|
|
10222
|
+
blendDstFactor: blendDst
|
|
10223
|
+
})),
|
|
10224
|
+
alphaBlendState: _extends({}, currentAttachmentsState.alphaBlendState, definedProps({
|
|
10225
|
+
blendMode: blendEquationAlpha,
|
|
10226
|
+
blendSrcFactor: blendSrcAlpha,
|
|
10227
|
+
blendDstFactor: blendDstAlpha
|
|
10228
|
+
}))
|
|
10229
|
+
}]
|
|
10230
|
+
}, materialMegaState));
|
|
10219
10231
|
renderInst.setBindingLayouts([{
|
|
10220
10232
|
numUniformBuffers: numUniformBuffers,
|
|
10221
10233
|
numSamplers: this.textureMappings.length,
|
|
@@ -10322,9 +10334,9 @@
|
|
|
10322
10334
|
__decorate([manaSyringe.inject(LightPool), __metadata("design:type", LightPool)], Instanced.prototype, "lightPool", void 0);
|
|
10323
10335
|
|
|
10324
10336
|
Instanced = __decorate([manaSyringe.injectable()], Instanced);
|
|
10325
|
-
var
|
|
10337
|
+
var frag = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Data;\nin vec2 v_Radius;\nin vec4 v_StylePacked3;\n\nout vec4 outputColor;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\nvoid main() {\n int shape = int(floor(v_Data.w + 0.5));\n float epsilon = 0.000001;\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n float antialiasblur = v_Data.z;\n float antialiased_blur = -max(0.0, antialiasblur);\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius;\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data.xy, 1.0);\n inner_df = sdCircle(v_Data.xy, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data.xy, vec2(1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n // vec2 imagecoord = mod(v_Uv, 0.1);\n // vec4 texel = texture(SAMPLER_2D(u_Map), imagecoord);\n // u_Color = texel;\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}"; // eslint-disable-line
|
|
10326
10338
|
|
|
10327
|
-
var
|
|
10339
|
+
var vert = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n mat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n float antialiasblur = 1.0 / (a_Size.x + strokeWidth);\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * radius;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\n v_StylePacked3 = a_StylePacked3;\n}"; // eslint-disable-line
|
|
10328
10340
|
|
|
10329
10341
|
var SDFVertexAttributeBufferIndex;
|
|
10330
10342
|
|
|
@@ -10361,7 +10373,7 @@
|
|
|
10361
10373
|
return false;
|
|
10362
10374
|
}
|
|
10363
10375
|
|
|
10364
|
-
if (this.needDrawStrokeSeparately(object) || this.needDrawStrokeSeparately(this.instance)) {
|
|
10376
|
+
if (this.needDrawStrokeSeparately(object.parsedStyle) || this.needDrawStrokeSeparately(this.instance.parsedStyle)) {
|
|
10365
10377
|
return false;
|
|
10366
10378
|
}
|
|
10367
10379
|
|
|
@@ -10480,24 +10492,29 @@
|
|
|
10480
10492
|
return size;
|
|
10481
10493
|
};
|
|
10482
10494
|
|
|
10483
|
-
_proto.shouldOmitStroke = function shouldOmitStroke(
|
|
10484
|
-
var lineDash =
|
|
10485
|
-
stroke =
|
|
10486
|
-
strokeOpacity =
|
|
10487
|
-
|
|
10495
|
+
_proto.shouldOmitStroke = function shouldOmitStroke(parsedStyle) {
|
|
10496
|
+
var lineDash = parsedStyle.lineDash,
|
|
10497
|
+
stroke = parsedStyle.stroke,
|
|
10498
|
+
strokeOpacity = parsedStyle.strokeOpacity;
|
|
10499
|
+
var hasStroke = stroke && !stroke.isNone;
|
|
10500
|
+
var hasLineDash = lineDash && lineDash.length && lineDash.every(function (item) {
|
|
10488
10501
|
return item.value !== 0;
|
|
10489
|
-
})
|
|
10502
|
+
});
|
|
10503
|
+
var hasStrokeOpacity = strokeOpacity.value < 1;
|
|
10504
|
+
return !hasStroke || hasStroke && (hasLineDash || hasStrokeOpacity);
|
|
10490
10505
|
};
|
|
10491
10506
|
|
|
10492
|
-
_proto.needDrawStrokeSeparately = function needDrawStrokeSeparately(
|
|
10493
|
-
var
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10507
|
+
_proto.needDrawStrokeSeparately = function needDrawStrokeSeparately(parsedStyle) {
|
|
10508
|
+
var stroke = parsedStyle.stroke,
|
|
10509
|
+
lineDash = parsedStyle.lineDash,
|
|
10510
|
+
lineWidth = parsedStyle.lineWidth,
|
|
10511
|
+
strokeOpacity = parsedStyle.strokeOpacity;
|
|
10512
|
+
var hasStroke = stroke && !stroke.isNone;
|
|
10513
|
+
var hasLineDash = lineDash && lineDash.length && lineDash.every(function (item) {
|
|
10499
10514
|
return item.value !== 0;
|
|
10500
|
-
})
|
|
10515
|
+
});
|
|
10516
|
+
var hasStrokeOpacity = strokeOpacity.value < 1;
|
|
10517
|
+
return hasStroke && lineWidth.value > 0 && (hasLineDash || hasStrokeOpacity);
|
|
10501
10518
|
};
|
|
10502
10519
|
|
|
10503
10520
|
return SDFMesh;
|
|
@@ -11109,10 +11126,10 @@
|
|
|
11109
11126
|
return piMod(Math.atan2(dy, dx));
|
|
11110
11127
|
}
|
|
11111
11128
|
};
|
|
11112
|
-
var vert$2 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvoid main() {\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n //TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n}"; // eslint-disable-line
|
|
11113
|
-
|
|
11114
11129
|
var frag$2 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * 0.5 + u_DashOffset, u_Dash + u_Gap) - (u_Gap * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n }\n}"; // eslint-disable-line
|
|
11115
11130
|
|
|
11131
|
+
var vert$2 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvoid main() {\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n //TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n}"; // eslint-disable-line
|
|
11132
|
+
|
|
11116
11133
|
var JOINT_TYPE;
|
|
11117
11134
|
|
|
11118
11135
|
(function (JOINT_TYPE) {
|
|
@@ -11533,7 +11550,11 @@
|
|
|
11533
11550
|
} else if (command === 'Z' && (object.nodeName === g.Shape.PATH || object.nodeName === g.Shape.RECT)) {
|
|
11534
11551
|
var _points2;
|
|
11535
11552
|
|
|
11536
|
-
|
|
11553
|
+
var epsilon = 0.0001; // skip if already closed
|
|
11554
|
+
|
|
11555
|
+
if (Math.abs(points[points.length - 2] - points[startPointIndex]) > epsilon || Math.abs(points[points.length - 1] - points[startPointIndex + 1]) > epsilon) {
|
|
11556
|
+
points.push(points[startPointIndex], points[startPointIndex + 1]);
|
|
11557
|
+
}
|
|
11537
11558
|
|
|
11538
11559
|
(_points2 = points).push.apply(_points2, addTailSegment(points[startPointIndex], points[startPointIndex + 1], points[startPointIndex + 2], points[startPointIndex + 3]));
|
|
11539
11560
|
}
|
|
@@ -13179,6 +13200,7 @@
|
|
|
13179
13200
|
named: g.Shape.MESH
|
|
13180
13201
|
}]
|
|
13181
13202
|
})], MeshRenderer);
|
|
13203
|
+
var DeviceContribution = manaSyringe.Syringe.defineToken('DeviceContribution');
|
|
13182
13204
|
var _excluded = ["style"];
|
|
13183
13205
|
|
|
13184
13206
|
var Light = /*#__PURE__*/function (_DisplayObject) {
|
|
@@ -13235,7 +13257,6 @@
|
|
|
13235
13257
|
}(g.DisplayObject);
|
|
13236
13258
|
|
|
13237
13259
|
Fog.tag = 'fog';
|
|
13238
|
-
var DeviceContribution = manaSyringe.Syringe.defineToken('DeviceContribution');
|
|
13239
13260
|
|
|
13240
13261
|
var _class$1;
|
|
13241
13262
|
|
|
@@ -13392,7 +13413,7 @@
|
|
|
13392
13413
|
|
|
13393
13414
|
_this.swapChain.configureSwapChain($canvas.width, $canvas.height);
|
|
13394
13415
|
|
|
13395
|
-
_this.renderingContext.root.ownerDocument.defaultView.
|
|
13416
|
+
_this.renderingContext.root.ownerDocument.defaultView.addEventListener(g.CanvasEvent.RESIZE, function () {
|
|
13396
13417
|
_this.swapChain.configureSwapChain($canvas.width, $canvas.height);
|
|
13397
13418
|
});
|
|
13398
13419
|
|
|
@@ -13427,7 +13448,9 @@
|
|
|
13427
13448
|
_this.builder = _this.renderHelper.renderGraph.newGraphBuilder(); // use canvas.background
|
|
13428
13449
|
|
|
13429
13450
|
var backgroundColor = g.parseColor(_this.canvasConfig.background);
|
|
13430
|
-
var clearColor = _this.canvasConfig.background ?
|
|
13451
|
+
var clearColor = _this.canvasConfig.background ? // use premultipliedAlpha
|
|
13452
|
+
// @see https://canvatechblog.com/alpha-blending-and-webgl-99feb392779e
|
|
13453
|
+
colorNewFromRGBA(Number(backgroundColor.r) / 255 * Number(backgroundColor.alpha), Number(backgroundColor.g) / 255 * Number(backgroundColor.alpha), Number(backgroundColor.b) / 255 * Number(backgroundColor.alpha), Number(backgroundColor.alpha)) : TransparentBlack; // retrieve at each frame since canvas may resize
|
|
13431
13454
|
|
|
13432
13455
|
var renderInput = {
|
|
13433
13456
|
backbufferWidth: canvas.width,
|
|
@@ -13472,14 +13495,15 @@
|
|
|
13472
13495
|
numSamplers: 0
|
|
13473
13496
|
}]);
|
|
13474
13497
|
template.setMegaStateFlags(setAttachmentStateSimple({
|
|
13475
|
-
depthWrite: true
|
|
13498
|
+
depthWrite: true,
|
|
13499
|
+
blendConstant: TransparentBlack
|
|
13476
13500
|
}, {
|
|
13477
13501
|
rgbBlendMode: BlendMode.Add,
|
|
13478
13502
|
alphaBlendMode: BlendMode.Add,
|
|
13479
13503
|
rgbBlendSrcFactor: BlendFactor.SrcAlpha,
|
|
13480
|
-
alphaBlendSrcFactor: BlendFactor.
|
|
13504
|
+
alphaBlendSrcFactor: BlendFactor.One,
|
|
13481
13505
|
rgbBlendDstFactor: BlendFactor.OneMinusSrcAlpha,
|
|
13482
|
-
alphaBlendDstFactor: BlendFactor.
|
|
13506
|
+
alphaBlendDstFactor: BlendFactor.OneMinusSrcAlpha
|
|
13483
13507
|
})); // Update Scene Params
|
|
13484
13508
|
|
|
13485
13509
|
var _this$canvasConfig2 = _this.canvasConfig,
|
|
@@ -13750,7 +13774,7 @@
|
|
|
13750
13774
|
var renderLists = this.renderGraphPlugin.getRenderLists();
|
|
13751
13775
|
var renderInstManager = this.renderHelper.renderInstManager;
|
|
13752
13776
|
var builder = this.renderHelper.renderGraph.newGraphBuilder();
|
|
13753
|
-
var clearColor =
|
|
13777
|
+
var clearColor = TransparentBlack; // retrieve at each frame since canvas may resize
|
|
13754
13778
|
|
|
13755
13779
|
var x = rect.x,
|
|
13756
13780
|
y = rect.y,
|
|
@@ -14364,6 +14388,7 @@
|
|
|
14364
14388
|
copyMegaState: copyMegaState,
|
|
14365
14389
|
defaultBindingLayoutSamplerDescriptor: defaultBindingLayoutSamplerDescriptor,
|
|
14366
14390
|
defaultMegaState: defaultMegaState,
|
|
14391
|
+
definedProps: definedProps,
|
|
14367
14392
|
enumToObject: enumToObject,
|
|
14368
14393
|
fallbackUndefined: fallbackUndefined,
|
|
14369
14394
|
fillArray: fillArray,
|
|
@@ -17908,6 +17933,7 @@
|
|
|
17908
17933
|
function HTMLRenderingPlugin() {
|
|
17909
17934
|
this.contextService = void 0;
|
|
17910
17935
|
this.renderingContext = void 0;
|
|
17936
|
+
this.canvasConfig = void 0;
|
|
17911
17937
|
this.$camera = void 0;
|
|
17912
17938
|
}
|
|
17913
17939
|
|
|
@@ -17993,6 +18019,7 @@
|
|
|
17993
18019
|
};
|
|
17994
18020
|
|
|
17995
18021
|
_proto.getOrCreateEl = function getOrCreateEl(object) {
|
|
18022
|
+
var doc = this.canvasConfig.document;
|
|
17996
18023
|
var existedId = this.getId(object);
|
|
17997
18024
|
var $container = this.contextService.getDomElement().parentNode;
|
|
17998
18025
|
|
|
@@ -18000,7 +18027,7 @@
|
|
|
18000
18027
|
var $existedElement = $container.querySelector('#' + existedId);
|
|
18001
18028
|
|
|
18002
18029
|
if (!$existedElement) {
|
|
18003
|
-
$existedElement = document.createElement('div');
|
|
18030
|
+
$existedElement = (doc || document).createElement('div');
|
|
18004
18031
|
object.parsedStyle.$el = $existedElement;
|
|
18005
18032
|
$existedElement.id = existedId;
|
|
18006
18033
|
|
|
@@ -18131,6 +18158,8 @@
|
|
|
18131
18158
|
|
|
18132
18159
|
__decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "renderingContext", void 0);
|
|
18133
18160
|
|
|
18161
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "canvasConfig", void 0);
|
|
18162
|
+
|
|
18134
18163
|
HTMLRenderingPlugin = HTMLRenderingPlugin_1 = __decorate([manaSyringe.singleton({
|
|
18135
18164
|
contrib: g.RenderingPluginContribution
|
|
18136
18165
|
})], HTMLRenderingPlugin);
|