figureone 1.7.1 → 1.9.0

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.
package/index.js CHANGED
@@ -7167,6 +7167,18 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
7167
7167
  * @group Misc Figure Element
7168
7168
  */
7169
7169
  var GLObject = /*#__PURE__*/function (_DrawingObject) {
7170
+ // Optional mask textures used by the `textureMap` color mode (one or more).
7171
+ // They share the base texture's coordinates (`a_texcoord`/`v_texcoord`), so
7172
+ // each needs no buffer or mapping of its own - just an id/src and a load
7173
+ // color. Mask i is bound to the shader's u_mask{i} sampler (its uniform name
7174
+ // is precomputed so the draw loop allocates nothing). A mask with an empty
7175
+ // src is a transparent placeholder - an index-preserving no-op slot.
7176
+
7177
+ // The webgl texture id this object currently holds a base-texture reference to
7178
+ // (acquired by initTexture, or adopted from a shared atlas via
7179
+ // setBaseTextureRef). resetTextureBuffer releases exactly this id, so the
7180
+ // release can never be unbalanced with the acquire. null = no reference held.
7181
+
7170
7182
  function GLObject(webgl) {
7171
7183
  var _this;
7172
7184
  var vertexShader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
@@ -7196,6 +7208,8 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7196
7208
  _this.numVertices = 0;
7197
7209
  _this.uniforms = {};
7198
7210
  _this.texture = null;
7211
+ _this.acquiredBaseTextureId = null;
7212
+ _this.maskTextures = [];
7199
7213
  // this.selectorProgramIndex = this.webgl.getProgram(selectorVertexShader, selectorFragShader);
7200
7214
  _this.initProgram();
7201
7215
  return _this;
@@ -7393,6 +7407,31 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7393
7407
  }
7394
7408
  this.onLoad = onLoad;
7395
7409
  }
7410
+
7411
+ /**
7412
+ * Buffer a mask texture for the `textureMap` color mode. Each call appends a
7413
+ * mask, bound to the next u_mask{i} sampler. Masks share the base texture's
7414
+ * coordinates, so only a source and load color are needed. The default load
7415
+ * color is fully transparent so that, until the mask loads, no region is
7416
+ * recolored and the base texture shows through unchanged.
7417
+ *
7418
+ * An empty `location` registers a transparent placeholder, which keeps the
7419
+ * u_mask{i} indexing aligned with the tint blocks when a caller supplies an
7420
+ * invalid/missing mask in a positional list (the slot becomes a no-op).
7421
+ */
7422
+ }, {
7423
+ key: "addMaskTexture",
7424
+ value: function addMaskTexture() {
7425
+ var location = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
7426
+ var loadColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0, 0];
7427
+ var isPlaceholder = location == null || location === '';
7428
+ this.maskTextures.push({
7429
+ id: isPlaceholder ? '__figureOneEmptyMask' : location,
7430
+ src: isPlaceholder ? '' : location,
7431
+ loadColor: isPlaceholder ? [0, 0, 0, 0] : loadColor,
7432
+ uniformName: "u_mask".concat(this.maskTextures.length)
7433
+ });
7434
+ }
7396
7435
  }, {
7397
7436
  key: "updateTexture",
7398
7437
  value: function updateTexture(data) {
@@ -7406,6 +7445,7 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7406
7445
  }, {
7407
7446
  key: "initTexture",
7408
7447
  value: function initTexture() {
7448
+ var _this4 = this;
7409
7449
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
7410
7450
  var texture = this.texture,
7411
7451
  webgl = this.webgl;
@@ -7429,7 +7469,20 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7429
7469
  // gl.STATIC_DRAW,
7430
7470
  // );
7431
7471
  webgl.addTexture(id, data || src, loadColor, repeat, this.executeOnLoad.bind(this), force);
7472
+ // addTexture took/holds a reference to this id; record it so
7473
+ // resetTextureBuffer releases exactly what was acquired. (For a forced
7474
+ // update the id is unchanged, so this is idempotent.)
7475
+ this.acquiredBaseTextureId = id;
7432
7476
  this.state = webgl.textures[texture.id].state;
7477
+
7478
+ // Register the optional mask textures (textureMap color mode). Each loads
7479
+ // onto its own texture unit and reuses the base texture's coordinates. A
7480
+ // placeholder (empty src) is registered directly from its load color as a
7481
+ // 1x1 transparent texture, with no image to load.
7482
+ this.maskTextures.forEach(function (maskTexture) {
7483
+ var data = maskTexture.src !== '' ? maskTexture.src : maskTexture.loadColor;
7484
+ webgl.addTexture(maskTexture.id, data, maskTexture.loadColor, false, _this4.executeOnLoad.bind(_this4), force);
7485
+ });
7433
7486
  // if (
7434
7487
  // !(texture.id in webgl.textures)
7435
7488
  // || (
@@ -7484,6 +7537,30 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7484
7537
  // }
7485
7538
  }
7486
7539
 
7540
+ /**
7541
+ * Adopt a base-texture reference to an already-registered texture (e.g. a
7542
+ * shared font atlas uploaded by the Atlas, whose id this object renders with
7543
+ * but does not upload itself).
7544
+ *
7545
+ * Releases any previously-held base reference first (so a font/atlas change
7546
+ * rebalances correctly) and is idempotent when the id is unchanged. If the
7547
+ * texture isn't registered yet, no reference is taken and acquiredBaseTextureId
7548
+ * is cleared, so the later resetTextureBuffer release stays balanced (it only
7549
+ * releases a reference that was actually acquired).
7550
+ */
7551
+ }, {
7552
+ key: "setBaseTextureRef",
7553
+ value: function setBaseTextureRef(id) {
7554
+ if (this.acquiredBaseTextureId === id) {
7555
+ return;
7556
+ }
7557
+ var webgl = this.webgl;
7558
+ if (this.acquiredBaseTextureId != null) {
7559
+ webgl.deleteTexture(this.acquiredBaseTextureId);
7560
+ }
7561
+ this.acquiredBaseTextureId = webgl.acquireTexture(id) ? id : null;
7562
+ }
7563
+
7487
7564
  // A texture map is a texture coords point that lines up with the texture
7488
7565
  // vertex point. So, if the vertex shape is rectangular, centered at the
7489
7566
  // origin and wants to incorporate the entire texture, then the map would
@@ -7661,16 +7738,25 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7661
7738
  value: function resetTextureBuffer() {
7662
7739
  var deleteTexture = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7663
7740
  var texture = this.texture,
7741
+ maskTextures = this.maskTextures,
7664
7742
  webgl = this.webgl,
7665
7743
  gl = this.gl;
7666
- if (texture) {
7667
- if (deleteTexture && webgl.textures[texture.id] != null) {
7668
- webgl.deleteTexture(texture.id);
7669
- }
7670
- if (texture.buffer != null) {
7671
- gl.deleteBuffer(texture.buffer);
7672
- texture.buffer = null;
7673
- }
7744
+ if (deleteTexture && this.acquiredBaseTextureId != null) {
7745
+ // Release exactly the base reference this object acquired, so a failed
7746
+ // acquire (e.g. an atlas not registered yet) can never over-release.
7747
+ webgl.deleteTexture(this.acquiredBaseTextureId);
7748
+ this.acquiredBaseTextureId = null;
7749
+ }
7750
+ if (texture && texture.buffer != null) {
7751
+ gl.deleteBuffer(texture.buffer);
7752
+ texture.buffer = null;
7753
+ }
7754
+ if (deleteTexture) {
7755
+ maskTextures.forEach(function (maskTexture) {
7756
+ if (webgl.textures[maskTexture.id] != null) {
7757
+ webgl.deleteTexture(maskTexture.id);
7758
+ }
7759
+ });
7674
7760
  }
7675
7761
  }
7676
7762
  }, {
@@ -7682,14 +7768,14 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7682
7768
  }, {
7683
7769
  key: "resetBuffers",
7684
7770
  value: function resetBuffers() {
7685
- var _this4 = this;
7771
+ var _this5 = this;
7686
7772
  var deleteTexture = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7687
7773
  var gl = this.gl;
7688
7774
  Object.keys(this.attributes).forEach(function (attributeName) {
7689
- if (_this4.attributes[attributeName].buffer != null) {
7690
- gl.deleteBuffer(_this4.attributes[attributeName].buffer);
7775
+ if (_this5.attributes[attributeName].buffer != null) {
7776
+ gl.deleteBuffer(_this5.attributes[attributeName].buffer);
7691
7777
  }
7692
- _this4.attributes[attributeName].buffer = null;
7778
+ _this5.attributes[attributeName].buffer = null;
7693
7779
  });
7694
7780
  this.attributes = {};
7695
7781
  this.resetTextureBuffer(deleteTexture);
@@ -7869,7 +7955,7 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7869
7955
  }, {
7870
7956
  key: "drawWithTransformMatrix",
7871
7957
  value: function drawWithTransformMatrix(scene, worldMatrix, color) {
7872
- var _this5 = this;
7958
+ var _this6 = this;
7873
7959
  var numDrawVertices = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.numVertices;
7874
7960
  var targetTexture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
7875
7961
  // if (targetTexture) {
@@ -7899,13 +7985,13 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7899
7985
  if (targetTexture && attributeName !== 'a_vertex') {
7900
7986
  return;
7901
7987
  }
7902
- var _this5$attributes$att = _this5.attributes[attributeName],
7903
- buffer = _this5$attributes$att.buffer,
7904
- size = _this5$attributes$att.size,
7905
- type = _this5$attributes$att.type,
7906
- stride = _this5$attributes$att.stride,
7907
- offset = _this5$attributes$att.offset,
7908
- normalize = _this5$attributes$att.normalize;
7988
+ var _this6$attributes$att = _this6.attributes[attributeName],
7989
+ buffer = _this6$attributes$att.buffer,
7990
+ size = _this6$attributes$att.size,
7991
+ type = _this6$attributes$att.type,
7992
+ stride = _this6$attributes$att.stride,
7993
+ offset = _this6$attributes$att.offset,
7994
+ normalize = _this6$attributes$att.normalize;
7909
7995
  gl.enableVertexAttribArray(locations[attributeName]);
7910
7996
  // Bind it to ARRAY_BUFFER (think of it as ARRAY_BUFFER = positionBuffer)
7911
7997
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
@@ -7937,12 +8023,15 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7937
8023
  gl.uniformMatrix4fv(locations.u_viewMatrix, false, _tools_m3__WEBPACK_IMPORTED_MODULE_0__.transpose(scene.viewMatrix));
7938
8024
  }
7939
8025
  Object.keys(this.uniforms).forEach(function (uniformName) {
7940
- var method = _this5.uniforms[uniformName].method;
8026
+ var method = _this6.uniforms[uniformName].method;
7941
8027
  method(locations[uniformName], uniformName);
7942
8028
  });
7943
8029
  gl.uniform1f(locations.u_z, this.z);
7944
8030
  gl.uniform4f(locations.u_color, color[0], color[1], color[2], color[3]);
7945
8031
  var texture = this.texture;
8032
+ // Set when a textured object's base texture can't be bound, so we skip the
8033
+ // draw rather than sampling a stale/wrong texture (see below).
8034
+ var skipDraw = false;
7946
8035
  if (texture != null && targetTexture === false) {
7947
8036
  // Tell the position attribute how to get data out of positionBuffer (ARRAY_BUFFER)
7948
8037
  var texSize = 2; // 2 components per iteration
@@ -7956,13 +8045,49 @@ var GLObject = /*#__PURE__*/function (_DrawingObject) {
7956
8045
  gl.enableVertexAttribArray(locations.a_texcoord);
7957
8046
  gl.bindBuffer(gl.ARRAY_BUFFER, texture.buffer);
7958
8047
  gl.vertexAttribPointer(locations.a_texcoord, texSize, texType, texNormalize, texStride, texOffset);
7959
- gl.uniform1i(locations.u_use_texture, 1);
7960
- var index = webglInstance.textures[texture.id].index;
7961
- gl.uniform1i(locations.u_texture, index);
8048
+ // Assign content texture units for this draw from the shared pool. Unit 0
8049
+ // is reserved for the target/selector framebuffer texture, so content
8050
+ // starts at unit 1: the base texture, then each mask texture in turn.
8051
+ // bindTextureToUnit only issues a bindTexture when the unit isn't already
8052
+ // pointing at that texture, so runs of draws sharing a texture (e.g. text
8053
+ // sharing a font atlas) issue no bind calls.
8054
+ var textureUnit = 1;
8055
+ if (webglInstance.bindTextureToUnit(texture.id, textureUnit)) {
8056
+ gl.uniform1i(locations.u_use_texture, 1);
8057
+ gl.uniform1i(locations.u_texture, textureUnit);
8058
+ textureUnit += 1;
8059
+
8060
+ // Bind the mask textures (textureMap color mode), each to its own
8061
+ // texture unit and precomputed u_mask{i} sampler. They reuse the
8062
+ // a_texcoord / v_texcoord bound above, so no extra attribute is needed.
8063
+ // Only assign the sampler if the bind succeeds — otherwise the uniform
8064
+ // would default to sampler 0 (the reserved target texture) and recolor
8065
+ // with garbage. Uses an indexed loop with precomputed uniform names to
8066
+ // avoid per-frame allocation.
8067
+ var maskTextures = this.maskTextures;
8068
+ for (var i = 0; i < maskTextures.length; i += 1) {
8069
+ var maskTexture = maskTextures[i];
8070
+ var maskLocation = locations[maskTexture.uniformName];
8071
+ if (maskLocation != null && webglInstance.bindTextureToUnit(maskTexture.id, textureUnit)) {
8072
+ gl.uniform1i(maskLocation, textureUnit);
8073
+ textureUnit += 1;
8074
+ }
8075
+ }
8076
+ } else {
8077
+ // The base texture isn't available (e.g. a shared texture was deleted by
8078
+ // another element's cleanup while this one still references it). The
8079
+ // composed texture shaders sample u_texture unconditionally, so there is
8080
+ // no safe in-shader fallback — skip this object's draw this frame rather
8081
+ // than sampling whatever stale texture occupies the unit.
8082
+ gl.uniform1i(locations.u_use_texture, 0);
8083
+ skipDraw = true;
8084
+ }
7962
8085
  } else {
7963
8086
  gl.uniform1i(locations.u_use_texture, 0);
7964
8087
  }
7965
- gl.drawArrays(this.glPrimitive, 0, numDrawVertices);
8088
+ if (!skipDraw) {
8089
+ gl.drawArrays(this.glPrimitive, 0, numDrawVertices);
8090
+ }
7966
8091
  if (texture) {
7967
8092
  gl.disableVertexAttribArray(locations.a_texcoord);
7968
8093
  }
@@ -52823,11 +52948,20 @@ var FigureElementPrimitiveGLText = /*#__PURE__*/function (_FigureElementPrimiti)
52823
52948
  scene: scene,
52824
52949
  font: this.font
52825
52950
  });
52951
+ var textureID = this.atlas.font.getTextureID();
52826
52952
  if (this.drawingObject.texture == null) {
52827
- this.drawingObject.addTexture(this.atlas.font.getTextureID());
52953
+ this.drawingObject.addTexture(textureID);
52828
52954
  } else {
52829
- this.drawingObject.texture.id = this.atlas.font.getTextureID();
52830
- }
52955
+ this.drawingObject.texture.id = textureID;
52956
+ }
52957
+ // Take a webgl reference to the shared atlas texture so it survives other
52958
+ // elements' cleanup. The Atlas registers/uploads the texture; this element
52959
+ // only adopts its id (GLObject.addTexture above doesn't touch webgl), so
52960
+ // without this its resetTextureBuffer release would be unbalanced and the
52961
+ // first element's cleanup would free the atlas for the others.
52962
+ // setBaseTextureRef releases any previously-held id (createAtlas re-runs on
52963
+ // font changes) and is idempotent when the id is unchanged.
52964
+ this.drawingObject.setBaseTextureRef(textureID);
52831
52965
  // console.log(this.atlas)
52832
52966
  this.setText(this.text);
52833
52967
  this.atlasNotificationsID = this.atlas.notifications.add('updated', this.loaded.bind(this));
@@ -54522,27 +54656,28 @@ __webpack_require__.r(__webpack_exports__);
54522
54656
  /* harmony import */ var _tools_g2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../tools/g2 */ "./src/js/tools/g2.ts");
54523
54657
  /* harmony import */ var _tools_htmlGenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../tools/htmlGenerator */ "./src/js/tools/htmlGenerator.ts");
54524
54658
  /* harmony import */ var _Element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Element */ "./src/js/figure/Element.ts");
54525
- /* harmony import */ var _tools_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../tools/math */ "./src/js/tools/math.ts");
54526
- /* harmony import */ var _tools_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../tools/tools */ "./src/js/tools/tools.ts");
54527
- /* harmony import */ var _DrawingObjects_GLObject_GLObject__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../DrawingObjects/GLObject/GLObject */ "./src/js/figure/DrawingObjects/GLObject/GLObject.ts");
54528
- /* harmony import */ var _Animation_Animation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animation/Animation */ "./src/js/figure/Animation/Animation.ts");
54529
- /* harmony import */ var _FigureElementPrimitiveMorph__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./FigureElementPrimitiveMorph */ "./src/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.ts");
54530
- /* harmony import */ var _FigureElementPrimitive2DText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./FigureElementPrimitive2DText */ "./src/js/figure/FigurePrimitives/FigureElementPrimitive2DText.ts");
54531
- /* harmony import */ var _FigureElementPrimitiveGLText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./FigureElementPrimitiveGLText */ "./src/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.ts");
54532
- /* harmony import */ var _Text__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Text */ "./src/js/figure/FigurePrimitives/Text.ts");
54533
- /* harmony import */ var _DrawingObjects_HTMLObject_HTMLObject__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../DrawingObjects/HTMLObject/HTMLObject */ "./src/js/figure/DrawingObjects/HTMLObject/HTMLObject.ts");
54534
- /* harmony import */ var _geometries_lines_lines__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../geometries/lines/lines */ "./src/js/figure/geometries/lines/lines.ts");
54535
- /* harmony import */ var _geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../geometries/polygon/polygon */ "./src/js/figure/geometries/polygon/polygon.ts");
54536
- /* harmony import */ var _geometries_rectangle__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../geometries/rectangle */ "./src/js/figure/geometries/rectangle.ts");
54537
- /* harmony import */ var _geometries_ellipse__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../geometries/ellipse */ "./src/js/figure/geometries/ellipse.ts");
54538
- /* harmony import */ var _geometries_arc__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../geometries/arc */ "./src/js/figure/geometries/arc.ts");
54539
- /* harmony import */ var _geometries_triangle__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../geometries/triangle */ "./src/js/figure/geometries/triangle.ts");
54540
- /* harmony import */ var _geometries_arrow__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../geometries/arrow */ "./src/js/figure/geometries/arrow.ts");
54541
- /* harmony import */ var _geometries_line__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../geometries/line */ "./src/js/figure/geometries/line.ts");
54542
- /* harmony import */ var _geometries_copy_copy__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../geometries/copy/copy */ "./src/js/figure/geometries/copy/copy.ts");
54543
- /* harmony import */ var _geometries_buffer__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../geometries/buffer */ "./src/js/figure/geometries/buffer.ts");
54544
- /* harmony import */ var _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../tools/geometry/scene */ "./src/js/tools/geometry/scene.ts");
54545
- /* harmony import */ var _FigureElementPrimitiveGesture__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./FigureElementPrimitiveGesture */ "./src/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.ts");
54659
+ /* harmony import */ var _webgl_shaders__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../webgl/shaders */ "./src/js/figure/webgl/shaders.ts");
54660
+ /* harmony import */ var _tools_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../tools/math */ "./src/js/tools/math.ts");
54661
+ /* harmony import */ var _tools_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../tools/tools */ "./src/js/tools/tools.ts");
54662
+ /* harmony import */ var _DrawingObjects_GLObject_GLObject__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../DrawingObjects/GLObject/GLObject */ "./src/js/figure/DrawingObjects/GLObject/GLObject.ts");
54663
+ /* harmony import */ var _Animation_Animation__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Animation/Animation */ "./src/js/figure/Animation/Animation.ts");
54664
+ /* harmony import */ var _FigureElementPrimitiveMorph__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./FigureElementPrimitiveMorph */ "./src/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.ts");
54665
+ /* harmony import */ var _FigureElementPrimitive2DText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./FigureElementPrimitive2DText */ "./src/js/figure/FigurePrimitives/FigureElementPrimitive2DText.ts");
54666
+ /* harmony import */ var _FigureElementPrimitiveGLText__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./FigureElementPrimitiveGLText */ "./src/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.ts");
54667
+ /* harmony import */ var _Text__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Text */ "./src/js/figure/FigurePrimitives/Text.ts");
54668
+ /* harmony import */ var _DrawingObjects_HTMLObject_HTMLObject__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../DrawingObjects/HTMLObject/HTMLObject */ "./src/js/figure/DrawingObjects/HTMLObject/HTMLObject.ts");
54669
+ /* harmony import */ var _geometries_lines_lines__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../geometries/lines/lines */ "./src/js/figure/geometries/lines/lines.ts");
54670
+ /* harmony import */ var _geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../geometries/polygon/polygon */ "./src/js/figure/geometries/polygon/polygon.ts");
54671
+ /* harmony import */ var _geometries_rectangle__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../geometries/rectangle */ "./src/js/figure/geometries/rectangle.ts");
54672
+ /* harmony import */ var _geometries_ellipse__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../geometries/ellipse */ "./src/js/figure/geometries/ellipse.ts");
54673
+ /* harmony import */ var _geometries_arc__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../geometries/arc */ "./src/js/figure/geometries/arc.ts");
54674
+ /* harmony import */ var _geometries_triangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../geometries/triangle */ "./src/js/figure/geometries/triangle.ts");
54675
+ /* harmony import */ var _geometries_arrow__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../geometries/arrow */ "./src/js/figure/geometries/arrow.ts");
54676
+ /* harmony import */ var _geometries_line__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../geometries/line */ "./src/js/figure/geometries/line.ts");
54677
+ /* harmony import */ var _geometries_copy_copy__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../geometries/copy/copy */ "./src/js/figure/geometries/copy/copy.ts");
54678
+ /* harmony import */ var _geometries_buffer__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../geometries/buffer */ "./src/js/figure/geometries/buffer.ts");
54679
+ /* harmony import */ var _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../tools/geometry/scene */ "./src/js/tools/geometry/scene.ts");
54680
+ /* harmony import */ var _FigureElementPrimitiveGesture__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./FigureElementPrimitiveGesture */ "./src/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.ts");
54546
54681
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
54547
54682
  function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
54548
54683
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
@@ -54573,6 +54708,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
54573
54708
 
54574
54709
 
54575
54710
 
54711
+
54576
54712
  // eslint-disable-next-line import/no-cycle
54577
54713
  // eslint-disable-next-line import/no-cycle
54578
54714
 
@@ -54668,7 +54804,7 @@ function setupPulse(element, options) {
54668
54804
  element.pulseDefault.scale = options.pulse;
54669
54805
  } else {
54670
54806
  // eslint-disable-next-line no-param-reassign
54671
- element.pulseDefault = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, element.pulseDefault, options.pulse);
54807
+ element.pulseDefault = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, element.pulseDefault, options.pulse);
54672
54808
  }
54673
54809
  }
54674
54810
  }
@@ -54742,7 +54878,45 @@ var FigurePrimitives = /*#__PURE__*/function () {
54742
54878
  optionsIn[_key] = arguments[_key];
54743
54879
  }
54744
54880
  // Setup the default options
54745
- var oIn = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn));
54881
+ var oIn = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn));
54882
+ // The mask recolor (textureMap) path supports one or more mask textures,
54883
+ // supplied as `mask` (single) or `masks` (array). Normalize the input: a
54884
+ // non-array `masks` is coerced to an array, and an empty/absent `masks`
54885
+ // falls back to the singular `mask`. `masks` takes precedence when both are
54886
+ // given and `masks` is non-empty.
54887
+ var rawMasks;
54888
+ if (oIn.masks != null) {
54889
+ rawMasks = Array.isArray(oIn.masks) ? oIn.masks : [oIn.masks];
54890
+ } else {
54891
+ rawMasks = [];
54892
+ }
54893
+ if (rawMasks.length === 0 && oIn.mask != null) {
54894
+ rawMasks = [oIn.mask];
54895
+ }
54896
+ var isValidMask = function isValidMask(m) {
54897
+ return m != null && m.src != null && m.src !== '';
54898
+ };
54899
+ // Masks are positional: each slot owns its own u_mask{i} sampler and tint
54900
+ // block (tints[CHANNELS_PER_MASK * i ...]). Invalid/missing slots are kept
54901
+ // as transparent no-ops rather than dropped, so a conditionally-built list
54902
+ // never shifts later masks onto the wrong tints. The textureMap path is only
54903
+ // selected when at least one slot is a valid mask.
54904
+ var hasMask = rawMasks.some(isValidMask);
54905
+ var maskList = hasMask ? rawMasks : [];
54906
+ var numMasks = maskList.length;
54907
+ var NUM_TINTS = numMasks * _webgl_shaders__WEBPACK_IMPORTED_MODULE_3__.CHANNELS_PER_MASK;
54908
+ // Guard the per-element mask count against the device's texture units (one
54909
+ // is reserved for the base texture). This catches an excessive count with a
54910
+ // clear error instead of an opaque GL failure. Note: a figure with many
54911
+ // other textures can still exhaust units - that global limit is pre-existing
54912
+ // and not checked here.
54913
+ if (hasMask) {
54914
+ var _gl = this.webgl[0].gl;
54915
+ var maxUnits = _gl.getParameter(_gl.MAX_TEXTURE_IMAGE_UNITS);
54916
+ if (typeof maxUnits === 'number' && maxUnits > 0 && numMasks + 1 > maxUnits) {
54917
+ throw new Error("FigureOne gl: ".concat(numMasks, " mask textures (plus the base texture) exceed this device's ").concat(maxUnits, " texture units. Use fewer masks."));
54918
+ }
54919
+ }
54746
54920
  var defaultOptions = {
54747
54921
  glPrimitive: 'TRIANGLES',
54748
54922
  vertexShader: {
@@ -54762,7 +54936,8 @@ var FigurePrimitives = /*#__PURE__*/function () {
54762
54936
  coords: [],
54763
54937
  loadColor: [0, 0, 1, 0.5]
54764
54938
  },
54765
- name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.generateUniqueId)('primitive_'),
54939
+ tints: [],
54940
+ name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.generateUniqueId)('primitive_'),
54766
54941
  color: this.defaultColor,
54767
54942
  drawNumber: 0,
54768
54943
  transform: [['s', 1], ['r', 0, 0, 0, 1], ['t', 0, 0, 0]],
@@ -54773,6 +54948,16 @@ var FigurePrimitives = /*#__PURE__*/function () {
54773
54948
  defaultOptions.vertexShader.color = 'texture';
54774
54949
  defaultOptions.fragmentShader.color = 'texture';
54775
54950
  }
54951
+ // A mask recolors regions of the base texture, so it uses the textureMap
54952
+ // color mode (which also samples the base texture). It therefore takes
54953
+ // precedence over the plain 'texture' mode set above. The fragment shader is
54954
+ // composed for the exact number of masks, so a single mask generates the
54955
+ // same shader (and cost) as before.
54956
+ if (hasMask) {
54957
+ defaultOptions.vertexShader.color = 'textureMap';
54958
+ defaultOptions.fragmentShader.color = 'textureMap';
54959
+ defaultOptions.fragmentShader.masks = numMasks;
54960
+ }
54776
54961
  if (oIn.dimension != null) {
54777
54962
  defaultOptions.vertexShader.dimension = oIn.dimension;
54778
54963
  }
@@ -54790,7 +54975,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
54790
54975
  }
54791
54976
 
54792
54977
  // Combine default and input options
54793
- var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultOptions, oIn);
54978
+ var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultOptions, oIn);
54794
54979
  options.transform = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getTransform)(options.transform);
54795
54980
  if (options.position != null) {
54796
54981
  options.position = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getPoint)(options.position);
@@ -54798,7 +54983,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
54798
54983
  }
54799
54984
 
54800
54985
  // User shaders to create a gl drawing object
54801
- var glObject = new _DrawingObjects_GLObject_GLObject__WEBPACK_IMPORTED_MODULE_5__["default"](this.webgl[0], options.vertexShader, options.fragmentShader);
54986
+ var glObject = new _DrawingObjects_GLObject_GLObject__WEBPACK_IMPORTED_MODULE_6__["default"](this.webgl[0], options.vertexShader, options.fragmentShader);
54802
54987
 
54803
54988
  // Set the glPrimitive
54804
54989
  glObject.setPrimitive(options.glPrimitive.toUpperCase());
@@ -54879,7 +55064,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
54879
55064
  usage: 'STATIC',
54880
55065
  size: 2
54881
55066
  };
54882
- var b = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultAttribute, buffer);
55067
+ var b = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultAttribute, buffer);
54883
55068
  glObject.addAttribute(b.name, b.size, b.data, b.type, b.normalize, b.stride, b.offset, b.usageIn);
54884
55069
  });
54885
55070
  glObject.initAttributes();
@@ -54892,18 +55077,58 @@ var FigurePrimitives = /*#__PURE__*/function () {
54892
55077
  type: 'FLOAT',
54893
55078
  length: 1
54894
55079
  };
54895
- var u = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultUniform, uniform);
55080
+ var u = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultUniform, uniform);
54896
55081
  glObject.addUniform(u.name, u.length, u.type, u.value);
54897
55082
  });
54898
55083
  }
54899
55084
 
55085
+ // Normalize a tint color to a 4-component [r, g, b, a] array. A missing
55086
+ // tint becomes fully transparent (alpha 0), which leaves the base texture
55087
+ // unchanged. A 3-component color defaults to alpha 1 (fully recolored).
55088
+ var toTint = function toTint(c) {
55089
+ if (c == null) {
55090
+ return [0, 0, 0, 0];
55091
+ }
55092
+ if (c.length < 4) {
55093
+ return [c[0] || 0, c[1] || 0, c[2] || 0, 1];
55094
+ }
55095
+ return [c[0], c[1], c[2], c[3]];
55096
+ };
55097
+
54900
55098
  // Add a texture - use mapFrom and mapTo if texture coords is not defined
54901
55099
  if (options.texture.src !== '') {
54902
55100
  var t = options.texture;
54903
55101
  glObject.addTexture(t.src, (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getRect)(t.mapFrom), (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getRect)(t.mapTo), t.mapToAttribute, t.coords || [], t.repeat, t.onLoad, t.loadColor);
55102
+ // A mask recolors regions of the base texture (textureMap color mode).
55103
+ // Each mask is bound to u_mask{i} and shares the base texture coordinates.
55104
+ // Invalid slots register a transparent placeholder so masks stay
55105
+ // positional (later masks keep their tint block).
55106
+ maskList.forEach(function (m) {
55107
+ if (isValidMask(m)) {
55108
+ glObject.addMaskTexture(m.src, m.loadColor);
55109
+ } else {
55110
+ glObject.addMaskTexture('');
55111
+ }
55112
+ });
54904
55113
  glObject.initTexture();
54905
55114
  }
54906
55115
 
55116
+ // Seed the textureMap tint uniforms (u_tint0..u_tint{4*numMasks-1}). Each
55117
+ // corresponds to a mask channel (r, g, b, a). Any tints beyond the available
55118
+ // mask channels are ignored. The values are mirrored into customState so
55119
+ // they survive state save/restore and recordings.
55120
+ var tintColors = [];
55121
+ if (hasMask) {
55122
+ tintColors = Array.from({
55123
+ length: NUM_TINTS
55124
+ }, function (_, i) {
55125
+ return toTint(options.tints[i]);
55126
+ });
55127
+ tintColors.forEach(function (tint, i) {
55128
+ glObject.addUniform("u_tint".concat(i), 4, 'FLOAT', tint);
55129
+ });
55130
+ }
55131
+
54907
55132
  // Create th figure element primitive with the gl drawing object
54908
55133
  var element;
54909
55134
  if (options.figureElementPrimitiveCallback != null) {
@@ -54920,6 +55145,49 @@ var FigurePrimitives = /*#__PURE__*/function () {
54920
55145
  element.custom.getUniform = element.drawingObject.getUniform.bind(element.drawingObject);
54921
55146
  element.dimColor = this.defaultDimColor.slice();
54922
55147
 
55148
+ // textureMap tints: expose setters and mirror the current values in
55149
+ // customState so they are captured by state save/restore and recordings.
55150
+ if (hasMask) {
55151
+ element.customState.tints = tintColors.map(function (t) {
55152
+ return t.slice();
55153
+ });
55154
+ // Set a single region's tint. Indices outside the available tints
55155
+ // (4 * numMasks) are ignored rather than throwing - an out-of-range index
55156
+ // would otherwise reference a nonexistent u_tint uniform and corrupt
55157
+ // customState, which would then re-throw on every later state restore.
55158
+ element.custom.setTint = function (index, color) {
55159
+ if (index < 0 || index >= NUM_TINTS) {
55160
+ return;
55161
+ }
55162
+ var tint = toTint(color);
55163
+ element.customState.tints[index] = tint;
55164
+ element.drawingObject.updateUniform("u_tint".concat(index), tint);
55165
+ };
55166
+ // Replace all region tints. Missing or null entries reset that region to
55167
+ // transparent (no recolor), so setTints always defines the full set.
55168
+ element.custom.setTints = function (colors) {
55169
+ for (var index = 0; index < NUM_TINTS; index += 1) {
55170
+ element.custom.setTint(index, colors[index] == null ? null : colors[index]);
55171
+ }
55172
+ };
55173
+ // Custom uniforms are not part of drawing object state, so after a state
55174
+ // restore (including Recorder playback and seek) the tint values are
55175
+ // merged back into customState but not re-applied to the GPU. Re-push them
55176
+ // to the u_tint uniforms whenever state is set. Only the valid tints are
55177
+ // applied so a malformed customState can never throw here.
55178
+ element.notifications.add('setState', function () {
55179
+ var tints = element.customState.tints;
55180
+ if (tints == null) {
55181
+ return;
55182
+ }
55183
+ for (var index = 0; index < NUM_TINTS; index += 1) {
55184
+ if (tints[index] != null) {
55185
+ element.drawingObject.updateUniform("u_tint".concat(index), tints[index]);
55186
+ }
55187
+ }
55188
+ });
55189
+ }
55190
+
54923
55191
  // Setup move, touch, scenarios, dim and default colors if defined in
54924
55192
  // options
54925
55193
  if (options.move != null && options.move !== false) {
@@ -54940,7 +55208,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
54940
55208
  element.scenarios = options.scenarios;
54941
55209
  }
54942
55210
  if (options.scene != null) {
54943
- if (options.scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"]) {
55211
+ if (options.scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"]) {
54944
55212
  element.scene = options.scene;
54945
55213
  } else {
54946
55214
  element.setScene(options.scene);
@@ -54966,13 +55234,13 @@ var FigurePrimitives = /*#__PURE__*/function () {
54966
55234
  for (var _len2 = arguments.length, optionsIn = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
54967
55235
  optionsIn[_key2] = arguments[_key2];
54968
55236
  }
54969
- var oIn = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn));
55237
+ var oIn = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn));
54970
55238
  var defaultOptions = {
54971
55239
  dimension: 3,
54972
55240
  light: oIn.lines ? null : 'directional',
54973
55241
  usage: 'STATIC'
54974
55242
  };
54975
- var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultOptions, oIn);
55243
+ var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultOptions, oIn);
54976
55244
  var dim = options.dimension;
54977
55245
  var processOptions = function processOptions(o, u) {
54978
55246
  if (o.usage == null) {
@@ -54985,13 +55253,13 @@ var FigurePrimitives = /*#__PURE__*/function () {
54985
55253
  // and colors
54986
55254
  if (o.copy != null) {
54987
55255
  if (o.vertices != null) {
54988
- o.vertices = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_20__.copyPoints)(o.vertices, o.copy, 'points');
55256
+ o.vertices = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_21__.copyPoints)(o.vertices, o.copy, 'points');
54989
55257
  }
54990
55258
  if (o.normals != null) {
54991
- o.normals = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_20__.copyPoints)(o.normals, o.copy, 'normals');
55259
+ o.normals = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_21__.copyPoints)(o.normals, o.copy, 'normals');
54992
55260
  }
54993
55261
  if (o.colors != null) {
54994
- var count = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_20__.getCopyCount)(o.copy);
55262
+ var count = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_21__.getCopyCount)(o.copy);
54995
55263
  var out = [];
54996
55264
  for (var i = 0; i < count; i += 1) {
54997
55265
  out.push.apply(out, _toConsumableArray(o.colors.map(function (c) {
@@ -55001,7 +55269,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55001
55269
  o.colors = out;
55002
55270
  }
55003
55271
  if (o.texture != null && o.texture.coords != null) {
55004
- var _count = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_20__.getCopyCount)(o.copy);
55272
+ var _count = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_21__.getCopyCount)(o.copy);
55005
55273
  var _out = [];
55006
55274
  for (var _i = 0; _i < _count; _i += 1) {
55007
55275
  _out.push.apply(_out, _toConsumableArray(o.texture.coords.slice()));
@@ -55072,8 +55340,8 @@ var FigurePrimitives = /*#__PURE__*/function () {
55072
55340
  }, {
55073
55341
  key: "generic3DBase",
55074
55342
  value: function generic3DBase(defaultOptions, optionsIn, getPointsFn) {
55075
- var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultOptions, optionsIn);
55076
- var element = this.generic3((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, options, {
55343
+ var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultOptions, optionsIn);
55344
+ var element = this.generic3((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, options, {
55077
55345
  points: [],
55078
55346
  normals: options.lines ? null : [],
55079
55347
  glPrimitive: options.lines ? 'LINES' : undefined
@@ -55085,7 +55353,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55085
55353
  element.custom.options = options;
55086
55354
  element.custom.getPoints = getPointsFn;
55087
55355
  element.custom.updatePoints = function (updateOptions) {
55088
- var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, element.custom.options, {
55356
+ var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, element.custom.options, {
55089
55357
  transform: [],
55090
55358
  position: [0, 0]
55091
55359
  }, updateOptions);
@@ -55098,12 +55366,12 @@ var FigurePrimitives = /*#__PURE__*/function () {
55098
55366
  points = _element$custom$getPo2[0],
55099
55367
  normals = _element$custom$getPo2[1];
55100
55368
  if (o.lines == null || o.lines === false) {
55101
- element.custom.updateGeneric3((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
55369
+ element.custom.updateGeneric3((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
55102
55370
  points: points,
55103
55371
  normals: normals
55104
55372
  }));
55105
55373
  } else {
55106
- element.custom.updateGeneric3((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
55374
+ element.custom.updateGeneric3((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
55107
55375
  points: points,
55108
55376
  normals: null
55109
55377
  }));
@@ -55123,7 +55391,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55123
55391
  sides: 10,
55124
55392
  normals: 'flat',
55125
55393
  center: [0, 0, 0]
55126
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55394
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55127
55395
  return (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.sphere)(o);
55128
55396
  });
55129
55397
  }
@@ -55135,7 +55403,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55135
55403
  }
55136
55404
  return this.generic3DBase({
55137
55405
  side: this.defaultLength
55138
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55406
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55139
55407
  return (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.cube)(o);
55140
55408
  });
55141
55409
  }
@@ -55147,7 +55415,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55147
55415
  }
55148
55416
  return this.generic3DBase({
55149
55417
  length: this.defaultLength / 3
55150
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55418
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55151
55419
  return (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.prism)(o);
55152
55420
  });
55153
55421
  }
@@ -55161,7 +55429,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55161
55429
  radius: this.defaultLength / 20,
55162
55430
  sides: 10,
55163
55431
  normals: 'flat'
55164
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55432
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55165
55433
  return (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.cylinder)(o);
55166
55434
  });
55167
55435
  }
@@ -55176,7 +55444,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55176
55444
  sides: 10,
55177
55445
  normals: 'flat',
55178
55446
  length: 1
55179
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55447
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55180
55448
  return (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.cone)(o);
55181
55449
  });
55182
55450
  }
@@ -55190,7 +55458,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55190
55458
  width: this.defaultLength / 40,
55191
55459
  sides: 10,
55192
55460
  normals: 'curve'
55193
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55461
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55194
55462
  return (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.line3)(o);
55195
55463
  });
55196
55464
  }
@@ -55203,7 +55471,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55203
55471
  return this.generic3DBase({
55204
55472
  sides: 10,
55205
55473
  normals: 'flat'
55206
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55474
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55207
55475
  return (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.revolve)(o);
55208
55476
  });
55209
55477
  }
@@ -55216,7 +55484,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55216
55484
  return this.generic3DBase({
55217
55485
  normals: 'flat',
55218
55486
  lines: false
55219
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55487
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)), function (o) {
55220
55488
  return _tools_g2__WEBPACK_IMPORTED_MODULE_0__.surface.surface(o);
55221
55489
  });
55222
55490
  }
@@ -55244,7 +55512,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55244
55512
  value: function morph() {
55245
55513
  var _this = this;
55246
55514
  var defaultOptions = {
55247
- name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.generateUniqueId)('primitive_'),
55515
+ name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.generateUniqueId)('primitive_'),
55248
55516
  color: this.defaultColor,
55249
55517
  points: [],
55250
55518
  glPrimitive: 'TRIANGLES',
@@ -55254,7 +55522,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55254
55522
  for (var _len1 = arguments.length, optionsIn = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
55255
55523
  optionsIn[_key1] = arguments[_key1];
55256
55524
  }
55257
- var options = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
55525
+ var options = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
55258
55526
  options.transform = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getTransform)(options.transform);
55259
55527
  if (options.position != null) {
55260
55528
  options.position = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getPoint)(options.position);
@@ -55266,7 +55534,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55266
55534
  colorVertex = true;
55267
55535
  fragmentShader = 'vertexColor';
55268
55536
  }
55269
- var glObject = new _DrawingObjects_GLObject_GLObject__WEBPACK_IMPORTED_MODULE_5__["default"](this.webgl[0], ['morpher', options.points.length, colorVertex], fragmentShader);
55537
+ var glObject = new _DrawingObjects_GLObject_GLObject__WEBPACK_IMPORTED_MODULE_6__["default"](this.webgl[0], ['morpher', options.points.length, colorVertex], fragmentShader);
55270
55538
  glObject.setPrimitive(options.glPrimitive.toUpperCase());
55271
55539
  var shapeNameMap = {};
55272
55540
  if (options.names != null) {
@@ -55285,7 +55553,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55285
55553
  usage: 'STATIC',
55286
55554
  size: 2
55287
55555
  };
55288
- var b = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultBuffer);
55556
+ var b = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultBuffer);
55289
55557
  glObject.addAttribute(attribute, b.size, points, b.type, b.normalize, b.stride, b.offset, b.usageIn);
55290
55558
  });
55291
55559
  if (colorVertex) {
@@ -55310,7 +55578,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55310
55578
  usage: 'STATIC',
55311
55579
  size: 4
55312
55580
  };
55313
- var b = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultBuffer);
55581
+ var b = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultBuffer);
55314
55582
  glObject.addAttribute(attribute, b.size, colors, b.type, b.normalize, b.stride, b.offset, b.usageIn);
55315
55583
  });
55316
55584
  options.color = this.defaultColor;
@@ -55318,7 +55586,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55318
55586
  glObject.addUniform('u_from', 1, 'INT');
55319
55587
  glObject.addUniform('u_to', 1, 'INT');
55320
55588
  glObject.addUniform('u_percent', 1, 'FLOAT');
55321
- var element = new _FigureElementPrimitiveMorph__WEBPACK_IMPORTED_MODULE_7__["default"](glObject, options.transform, options.color, null, options.name);
55589
+ var element = new _FigureElementPrimitiveMorph__WEBPACK_IMPORTED_MODULE_8__["default"](glObject, options.transform, options.color, null, options.name);
55322
55590
  element.shapeNameMap = shapeNameMap;
55323
55591
  element.setPoints(0);
55324
55592
  element.fnMap.add('_morphCallback', function (percentage, customProperties) {
@@ -55330,7 +55598,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55330
55598
  for (var _len10 = arguments.length, opt = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
55331
55599
  opt[_key10] = arguments[_key10];
55332
55600
  }
55333
- var o = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}, {
55601
+ var o = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}, {
55334
55602
  progression: 'easeinout',
55335
55603
  element: element
55336
55604
  }].concat(opt));
@@ -55340,7 +55608,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55340
55608
  };
55341
55609
  o.callback = '_morphCallback';
55342
55610
  o.timeKeeper = _this.timeKeeper;
55343
- return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_6__.CustomAnimationStep(o);
55611
+ return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_7__.CustomAnimationStep(o);
55344
55612
  };
55345
55613
  element.animations.customSteps.push({
55346
55614
  step: element.animations.morph.bind(this),
@@ -55458,7 +55726,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55458
55726
  for (var _len11 = arguments.length, optionsIn = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
55459
55727
  optionsIn[_key11] = arguments[_key11];
55460
55728
  }
55461
- var oIn = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn));
55729
+ var oIn = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn));
55462
55730
  var element = this.generic3.apply(this, [{
55463
55731
  dimension: 2,
55464
55732
  light: null,
@@ -55546,7 +55814,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55546
55814
  drawBorderBuffer: 0,
55547
55815
  simple: false
55548
55816
  };
55549
- var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultOptions, optionsIn);
55817
+ var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultOptions, optionsIn);
55550
55818
  if (o.linePrimitives === false) {
55551
55819
  o.lineNum = 2;
55552
55820
  }
@@ -55555,19 +55823,19 @@ var FigurePrimitives = /*#__PURE__*/function () {
55555
55823
  var drawBorder;
55556
55824
  var drawBorderBuffer;
55557
55825
  if (o.simple) {
55558
- var _makeFastPolyLine = (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_12__.makeFastPolyLine)(o.points, o.width, o.close);
55826
+ var _makeFastPolyLine = (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_13__.makeFastPolyLine)(o.points, o.width, o.close);
55559
55827
  var _makeFastPolyLine2 = _slicedToArray(_makeFastPolyLine, 3);
55560
55828
  points = _makeFastPolyLine2[0];
55561
55829
  drawBorder = _makeFastPolyLine2[1];
55562
55830
  drawBorderBuffer = _makeFastPolyLine2[2];
55563
55831
  } else if (o.cornersOnly) {
55564
- var _makePolyLineCorners = (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_12__.makePolyLineCorners)(o.points, o.width, o.close, o.cornerLength, o.widthIs, o.cornerStyle, o.cornerSize, o.cornerSides, o.minAutoCornerAngle, o.linePrimitives, o.lineNum, o.drawBorderBuffer);
55832
+ var _makePolyLineCorners = (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_13__.makePolyLineCorners)(o.points, o.width, o.close, o.cornerLength, o.widthIs, o.cornerStyle, o.cornerSize, o.cornerSides, o.minAutoCornerAngle, o.linePrimitives, o.lineNum, o.drawBorderBuffer);
55565
55833
  var _makePolyLineCorners2 = _slicedToArray(_makePolyLineCorners, 3);
55566
55834
  points = _makePolyLineCorners2[0];
55567
55835
  drawBorder = _makePolyLineCorners2[1];
55568
55836
  drawBorderBuffer = _makePolyLineCorners2[2];
55569
55837
  } else {
55570
- var _makePolyLine = (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_12__.makePolyLine)(o.points, o.width, o.close, o.widthIs, o.cornerStyle, o.cornerSize, o.cornerSides, o.minAutoCornerAngle, o.dash, o.linePrimitives, o.lineNum, o.drawBorder, o.drawBorderBuffer, o.arrow);
55838
+ var _makePolyLine = (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_13__.makePolyLine)(o.points, o.width, o.close, o.widthIs, o.cornerStyle, o.cornerSize, o.cornerSides, o.minAutoCornerAngle, o.dash, o.linePrimitives, o.lineNum, o.drawBorder, o.drawBorderBuffer, o.arrow);
55571
55839
  var _makePolyLine2 = _slicedToArray(_makePolyLine, 3);
55572
55840
  points = _makePolyLine2[0];
55573
55841
  drawBorder = _makePolyLine2[1];
@@ -55603,7 +55871,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55603
55871
  for (var _len12 = arguments.length, optionsIn = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
55604
55872
  optionsIn[_key12] = arguments[_key12];
55605
55873
  }
55606
- var options = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn));
55874
+ var options = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn));
55607
55875
  var element = this.generic.apply(this, [{
55608
55876
  transform: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Transform().scale(1).rotate(0).translate(),
55609
55877
  border: 'draw',
@@ -55628,7 +55896,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55628
55896
  drawBorderBuffer: 0
55629
55897
  };
55630
55898
  element.custom.updatePoints = function (updateOptions) {
55631
- var _this2$getPolylineTri = _this2.getPolylineTris((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, element.custom.options, updateOptions)),
55899
+ var _this2$getPolylineTri = _this2.getPolylineTris((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, element.custom.options, updateOptions)),
55632
55900
  _this2$getPolylineTri2 = _slicedToArray(_this2$getPolylineTri, 5),
55633
55901
  o = _this2$getPolylineTri2[0],
55634
55902
  points = _this2$getPolylineTri2[1],
@@ -55636,7 +55904,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55636
55904
  drawBorderBuffer = _this2$getPolylineTri2[3],
55637
55905
  drawType = _this2$getPolylineTri2[4];
55638
55906
  element.custom.options = o;
55639
- element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
55907
+ element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
55640
55908
  points: points,
55641
55909
  drawBorder: drawBorder,
55642
55910
  drawBorderBuffer: drawBorderBuffer,
@@ -55663,12 +55931,12 @@ var FigurePrimitives = /*#__PURE__*/function () {
55663
55931
  if (o.sidesToDraw > o.sides) {
55664
55932
  o.sidesToDraw = o.sides;
55665
55933
  }
55666
- var points = (0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_13__.getPolygonPoints)(o);
55934
+ var points = (0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_14__.getPolygonPoints)(o);
55667
55935
  // let { drawBorderBuffer } = o;
55668
55936
  var drawBorderOffset = 0;
55669
55937
  var drawBorder;
55670
55938
  if (o.line != null) {
55671
- o.line = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, {
55939
+ o.line = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, {
55672
55940
  width: this.defaultLineWidth,
55673
55941
  widthIs: 'mid'
55674
55942
  }, o.line);
@@ -55706,7 +55974,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55706
55974
  if (drawBorderOffset === 0) {
55707
55975
  drawBorder = [points];
55708
55976
  } else {
55709
- drawBorder = [(0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_13__.getPolygonPoints)((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
55977
+ drawBorder = [(0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_14__.getPolygonPoints)((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
55710
55978
  radius: o.radius + drawBorderOffset
55711
55979
  }))];
55712
55980
  }
@@ -55739,7 +56007,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55739
56007
  return [];
55740
56008
  };
55741
56009
  element.custom.updatePoints = function (updateOptions) {
55742
- var borderOptions = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, element.custom.options, updateOptions);
56010
+ var borderOptions = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, element.custom.options, updateOptions);
55743
56011
  var _element$custom$getBo = element.custom.getBorder(borderOptions),
55744
56012
  _element$custom$getBo2 = _slicedToArray(_element$custom$getBo, 2),
55745
56013
  o = _element$custom$getBo2[0],
@@ -55750,10 +56018,10 @@ var FigurePrimitives = /*#__PURE__*/function () {
55750
56018
  points = _element$custom$getFi2[0],
55751
56019
  drawType = _element$custom$getFi2[1];
55752
56020
  element.custom.options = o;
55753
- element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
56021
+ element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
55754
56022
  points: points,
55755
56023
  drawBorder: border,
55756
- drawBorderBuffer: (0,_geometries_buffer__WEBPACK_IMPORTED_MODULE_21__.getBufferBorder)([border], o.drawBorderBuffer, element.custom.skipConcave, element.custom.bufferOffset),
56024
+ drawBorderBuffer: (0,_geometries_buffer__WEBPACK_IMPORTED_MODULE_22__.getBufferBorder)([border], o.drawBorderBuffer, element.custom.skipConcave, element.custom.bufferOffset),
55757
56025
  drawType: drawType
55758
56026
  }));
55759
56027
  } else {
@@ -55768,7 +56036,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55768
56036
  o.line.drawBorder = 'positive';
55769
56037
  bufferOffsetToUse = 'positive';
55770
56038
  }
55771
- var _element$custom$getLi = element.custom.getLine((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o.line, {
56039
+ var _element$custom$getLi = element.custom.getLine((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o.line, {
55772
56040
  points: border
55773
56041
  })),
55774
56042
  _element$custom$getLi2 = _slicedToArray(_element$custom$getLi, 5),
@@ -55781,8 +56049,8 @@ var FigurePrimitives = /*#__PURE__*/function () {
55781
56049
  if (element.custom.bufferOffset === 'positive') {
55782
56050
  drawBorder.reverse();
55783
56051
  }
55784
- var drawBorderBuffer = (0,_geometries_buffer__WEBPACK_IMPORTED_MODULE_21__.getBufferBorder)(drawBorder, o.drawBorderBuffer, element.custom.skipConcave, bufferOffsetToUse);
55785
- element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
56052
+ var drawBorderBuffer = (0,_geometries_buffer__WEBPACK_IMPORTED_MODULE_22__.getBufferBorder)(drawBorder, o.drawBorderBuffer, element.custom.skipConcave, bufferOffsetToUse);
56053
+ element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
55786
56054
  points: _points,
55787
56055
  drawBorder: drawBorder,
55788
56056
  drawBorderBuffer: drawBorderBuffer,
@@ -55810,7 +56078,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55810
56078
  direction: 1,
55811
56079
  rotation: 0,
55812
56080
  offset: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0)
55813
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56081
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
55814
56082
  element.custom.getBorder = function (o) {
55815
56083
  var border = _this4.getPolygonBorder(o);
55816
56084
  if (o.sidesToDraw !== o.sides) {
@@ -55827,13 +56095,13 @@ var FigurePrimitives = /*#__PURE__*/function () {
55827
56095
  return border;
55828
56096
  };
55829
56097
  element.custom.getFill = function (border, fillOptions) {
55830
- return [(0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_13__.getTrisFillPolygon)(fillOptions.offset, border, fillOptions.sides, fillOptions.sidesToDraw), 'TRIANGLES'];
56098
+ return [(0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_14__.getTrisFillPolygon)(fillOptions.offset, border, fillOptions.sides, fillOptions.sidesToDraw), 'TRIANGLES'];
55831
56099
  };
55832
56100
  // element.custom.getLine = (o: OBJ_PolyLineTris) => this.getPolylineTris(o);
55833
56101
 
55834
56102
  element.drawingObject.getPointCountForAngle = function (angle) {
55835
56103
  var optionsToUse = element.custom.options;
55836
- var sidesToDraw = Math.floor(_tools_math__WEBPACK_IMPORTED_MODULE_3__.round(angle, 8) / _tools_math__WEBPACK_IMPORTED_MODULE_3__.round(Math.PI * 2, 8) * optionsToUse.sides);
56104
+ var sidesToDraw = Math.floor(_tools_math__WEBPACK_IMPORTED_MODULE_4__.round(angle, 8) / _tools_math__WEBPACK_IMPORTED_MODULE_4__.round(Math.PI * 2, 8) * optionsToUse.sides);
55837
56105
  if (optionsToUse.line == null) {
55838
56106
  return sidesToDraw * 3;
55839
56107
  }
@@ -55842,7 +56110,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55842
56110
  }
55843
56111
  return sidesToDraw * 6;
55844
56112
  };
55845
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56113
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
55846
56114
  return element;
55847
56115
  }
55848
56116
 
@@ -55863,7 +56131,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55863
56131
  direction: 1,
55864
56132
  rotation: 0,
55865
56133
  offset: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0)
55866
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56134
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
55867
56135
  element.custom.getBorder = function (o) {
55868
56136
  if (o.innerRadius == null) {
55869
56137
  o.innerRadius = o.radius / 3;
@@ -55875,9 +56143,9 @@ var FigurePrimitives = /*#__PURE__*/function () {
55875
56143
  return result;
55876
56144
  };
55877
56145
  element.custom.getFill = function (border, fillOptions) {
55878
- return [(0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_13__.getTrisFillPolygon)(fillOptions.offset, border, fillOptions.sides, fillOptions.sidesToDraw), 'TRIANGLES'];
56146
+ return [(0,_geometries_polygon_polygon__WEBPACK_IMPORTED_MODULE_14__.getTrisFillPolygon)(fillOptions.offset, border, fillOptions.sides, fillOptions.sidesToDraw), 'TRIANGLES'];
55879
56147
  };
55880
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56148
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
55881
56149
  return element;
55882
56150
  }
55883
56151
 
@@ -55901,7 +56169,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55901
56169
  sides: 1
55902
56170
  },
55903
56171
  offset: [0, 0]
55904
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56172
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
55905
56173
  element.custom.getBorder = function (o) {
55906
56174
  if (o.line != null && o.line.widthIs === 'inside') {
55907
56175
  o.line.widthIs = 'positive';
@@ -55912,13 +56180,13 @@ var FigurePrimitives = /*#__PURE__*/function () {
55912
56180
  if (o.offset != null) {
55913
56181
  o.offset = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getPoint)(o.offset);
55914
56182
  }
55915
- return [o, (0,_geometries_rectangle__WEBPACK_IMPORTED_MODULE_14__.getRectangleBorder)(o)];
56183
+ return [o, (0,_geometries_rectangle__WEBPACK_IMPORTED_MODULE_15__.getRectangleBorder)(o)];
55916
56184
  };
55917
56185
  element.custom.getFill = function (border) {
55918
- return [(0,_geometries_rectangle__WEBPACK_IMPORTED_MODULE_14__.rectangleBorderToTris)(border), 'TRIANGLES'];
56186
+ return [(0,_geometries_rectangle__WEBPACK_IMPORTED_MODULE_15__.rectangleBorderToTris)(border), 'TRIANGLES'];
55919
56187
  };
55920
56188
  // element.custom.getLine = (o: OBJ_PolyLineTris) => this.getPolylineTris(o);
55921
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56189
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
55922
56190
  return element;
55923
56191
  }
55924
56192
  }, {
@@ -55937,7 +56205,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
55937
56205
  yAlign: 'baseline',
55938
56206
  transform: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Transform().scale(1).rotate(0).translate(0, 0),
55939
56207
  // color: this.defaultColor,
55940
- name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.generateUniqueId)('primitive_'),
56208
+ name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.generateUniqueId)('primitive_'),
55941
56209
  vertexShader: {
55942
56210
  dimension: 2,
55943
56211
  color: 'texture'
@@ -56004,7 +56272,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56004
56272
  yAlign: 'baseline',
56005
56273
  transform: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Transform().scale(1).rotate(0).translate(0, 0),
56006
56274
  color: this.defaultColor,
56007
- name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.generateUniqueId)('primitive_'),
56275
+ name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.generateUniqueId)('primitive_'),
56008
56276
  vertexShader: {
56009
56277
  dimension: 2,
56010
56278
  color: 'texture'
@@ -56029,7 +56297,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56029
56297
  for (var _len18 = arguments.length, fo = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
56030
56298
  fo[_key18] = arguments[_key18];
56031
56299
  }
56032
- return _construct(_FigureElementPrimitiveGLText__WEBPACK_IMPORTED_MODULE_9__["default"], fo);
56300
+ return _construct(_FigureElementPrimitiveGLText__WEBPACK_IMPORTED_MODULE_10__["default"], fo);
56033
56301
  };
56034
56302
  var element = this.gl(o);
56035
56303
  element.setup(o);
@@ -56060,7 +56328,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56060
56328
  element.scenarios = options.scenarios;
56061
56329
  }
56062
56330
  if (options.scene != null) {
56063
- if (options.scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"]) {
56331
+ if (options.scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"]) {
56064
56332
  element.scene = options.scene;
56065
56333
  } else {
56066
56334
  element.setScene(options.scene);
@@ -56084,7 +56352,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56084
56352
  yAlign: 'baseline',
56085
56353
  transform: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Transform().scale(1).rotate(0).translate(0, 0),
56086
56354
  color: this.defaultColor,
56087
- name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.generateUniqueId)('primitive_'),
56355
+ name: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.generateUniqueId)('primitive_'),
56088
56356
  adjustments: {
56089
56357
  width: 0,
56090
56358
  ascent: 0,
@@ -56101,14 +56369,14 @@ var FigurePrimitives = /*#__PURE__*/function () {
56101
56369
  for (var _len20 = arguments.length, fo = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
56102
56370
  fo[_key20] = arguments[_key20];
56103
56371
  }
56104
- return _construct(_FigureElementPrimitiveGLText__WEBPACK_IMPORTED_MODULE_9__["default"], fo);
56372
+ return _construct(_FigureElementPrimitiveGLText__WEBPACK_IMPORTED_MODULE_10__["default"], fo);
56105
56373
  };
56106
56374
  o.transform = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getTransform)(o.transform);
56107
56375
  if (o.position != null) {
56108
56376
  o.position = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getPoint)(o.position);
56109
56377
  o.transform.updateTranslation(o.position);
56110
56378
  }
56111
- var element = new _FigureElementPrimitive2DText__WEBPACK_IMPORTED_MODULE_8__["default"](this.draw2D[0], o);
56379
+ var element = new _FigureElementPrimitive2DText__WEBPACK_IMPORTED_MODULE_9__["default"](this.draw2D[0], o);
56112
56380
  return this.elementSetup(element, o);
56113
56381
  }
56114
56382
  }, {
@@ -56128,15 +56396,15 @@ var FigurePrimitives = /*#__PURE__*/function () {
56128
56396
  for (var _len21 = arguments.length, options = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
56129
56397
  options[_key21] = arguments[_key21];
56130
56398
  }
56131
- var combinedOptions = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options));
56399
+ var combinedOptions = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options));
56132
56400
  for (var i = options.length - 1; i >= 0; i -= 1) {
56133
- if (options[i].scene != null && options[i].scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"]) {
56401
+ if (options[i].scene != null && options[i].scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"]) {
56134
56402
  combinedOptions.scene = options[i].scene;
56135
56403
  break;
56136
56404
  }
56137
56405
  }
56138
56406
  for (var _i2 = options.length - 1; _i2 >= 0; _i2 -= 1) {
56139
- if (options[_i2].changeScene != null && options[_i2].changeScene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"]) {
56407
+ if (options[_i2].changeScene != null && options[_i2].changeScene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"]) {
56140
56408
  combinedOptions.changeScene = options[_i2].changeScene;
56141
56409
  break;
56142
56410
  }
@@ -56145,16 +56413,16 @@ var FigurePrimitives = /*#__PURE__*/function () {
56145
56413
  scene = combinedOptions.scene;
56146
56414
  if (scene == null) {
56147
56415
  scene = this.scene;
56148
- } else if (!(scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"])) {
56149
- scene = new _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"](scene);
56416
+ } else if (!(scene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"])) {
56417
+ scene = new _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"](scene);
56150
56418
  }
56151
- if (changeScene != null && !(changeScene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"])) {
56152
- changeScene = new _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"](changeScene);
56419
+ if (changeScene != null && !(changeScene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"])) {
56420
+ changeScene = new _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"](changeScene);
56153
56421
  }
56154
56422
  defaultOptions.width = scene.right - scene.left;
56155
56423
  defaultOptions.height = scene.top - scene.bottom;
56156
56424
  defaultOptions.position = [scene.left + defaultOptions.width / 2, scene.bottom + defaultOptions.height / 2];
56157
- var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjectsWithOptions)({}, defaultOptions, combinedOptions);
56425
+ var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjectsWithOptions)({}, defaultOptions, combinedOptions);
56158
56426
  var element = this.rectangle({
56159
56427
  width: o.width,
56160
56428
  height: o.height,
@@ -56166,7 +56434,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56166
56434
  for (var _len22 = arguments.length, fo = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
56167
56435
  fo[_key22] = arguments[_key22];
56168
56436
  }
56169
- return _construct(_FigureElementPrimitiveGesture__WEBPACK_IMPORTED_MODULE_23__["default"], fo);
56437
+ return _construct(_FigureElementPrimitiveGesture__WEBPACK_IMPORTED_MODULE_24__["default"], fo);
56170
56438
  }
56171
56439
  });
56172
56440
  element.setup(o);
@@ -56186,7 +56454,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56186
56454
  for (var _len23 = arguments.length, options = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
56187
56455
  options[_key23] = arguments[_key23];
56188
56456
  }
56189
- var o = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjectsWithOptions.apply(void 0, [{
56457
+ var o = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjectsWithOptions.apply(void 0, [{
56190
56458
  except: 'controlScene'
56191
56459
  }, {}, {
56192
56460
  left: 0,
@@ -56218,7 +56486,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56218
56486
  }
56219
56487
  for (var i = options.length - 1; i >= 0; i -= 1) {
56220
56488
  if (options[i].controlScene != null) {
56221
- if (options[i].controlScene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"]) {
56489
+ if (options[i].controlScene instanceof _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"]) {
56222
56490
  element.custom.sceneToChange = options[i].controlScene;
56223
56491
  i = -1;
56224
56492
  } else if (typeof options[i].controlScene === 'string') {
@@ -56227,7 +56495,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56227
56495
  }
56228
56496
  }
56229
56497
  }
56230
- element.scene = new _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_22__["default"]({
56498
+ element.scene = new _tools_geometry_scene__WEBPACK_IMPORTED_MODULE_23__["default"]({
56231
56499
  style: '2D',
56232
56500
  left: 0,
56233
56501
  right: 1,
@@ -56286,7 +56554,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56286
56554
  }
56287
56555
  if (deltaEl > 0 && angleToLock > Math.PI / 2) {
56288
56556
  angleToLock = Math.PI - angleToLock;
56289
- deltaEl = _tools_math__WEBPACK_IMPORTED_MODULE_3__.round(Math.min(angleToLock - deltaAngle, deltaEl), 4);
56557
+ deltaEl = _tools_math__WEBPACK_IMPORTED_MODULE_4__.round(Math.min(angleToLock - deltaAngle, deltaEl), 4);
56290
56558
  }
56291
56559
  var t = [['r', deltaEl].concat(_toConsumableArray(tiltAxis.toArray())), ['r', deltaAz].concat(_toConsumableArray(panAxis.toArray()))];
56292
56560
  var matrix = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getTransform)(t).matrix();
@@ -56316,7 +56584,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56316
56584
  xAlign: 'center',
56317
56585
  yAlign: 'middle',
56318
56586
  sides: 20
56319
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56587
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56320
56588
  element.custom.getBorder = function (o) {
56321
56589
  if (o.line != null && o.line.widthIs === 'inside') {
56322
56590
  o.line.widthIs = 'positive';
@@ -56324,13 +56592,13 @@ var FigurePrimitives = /*#__PURE__*/function () {
56324
56592
  if (o.line != null && o.line.widthIs === 'outside') {
56325
56593
  o.line.widthIs = 'negative';
56326
56594
  }
56327
- return [o, (0,_geometries_ellipse__WEBPACK_IMPORTED_MODULE_15__.getEllipseBorder)(o)];
56595
+ return [o, (0,_geometries_ellipse__WEBPACK_IMPORTED_MODULE_16__.getEllipseBorder)(o)];
56328
56596
  };
56329
56597
  element.custom.getFill = function (border) {
56330
- return [(0,_geometries_ellipse__WEBPACK_IMPORTED_MODULE_15__.ellipseBorderToTris)(border), 'TRIANGLES'];
56598
+ return [(0,_geometries_ellipse__WEBPACK_IMPORTED_MODULE_16__.ellipseBorderToTris)(border), 'TRIANGLES'];
56331
56599
  };
56332
56600
  // element.custom.getLine = (o: OBJ_PolyLineTris) => this.getPolylineTris(o);
56333
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56601
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56334
56602
  return element;
56335
56603
  }
56336
56604
 
@@ -56351,7 +56619,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56351
56619
  angle: 1,
56352
56620
  offset: [0, 0],
56353
56621
  fillCenter: false
56354
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56622
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56355
56623
  element.custom.getBorder = function (o) {
56356
56624
  if (o.line != null && o.line.widthIs === 'inside') {
56357
56625
  o.line.widthIs = 'positive';
@@ -56363,13 +56631,13 @@ var FigurePrimitives = /*#__PURE__*/function () {
56363
56631
  o.offset = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getPoint)(o.offset);
56364
56632
  }
56365
56633
  element.custom.close = false;
56366
- return [o, (0,_geometries_arc__WEBPACK_IMPORTED_MODULE_16__.getArcBorder)(o)];
56634
+ return [o, (0,_geometries_arc__WEBPACK_IMPORTED_MODULE_17__.getArcBorder)(o)];
56367
56635
  };
56368
56636
  element.custom.getFill = function (border) {
56369
- return [(0,_geometries_arc__WEBPACK_IMPORTED_MODULE_16__.arcBorderToTris)(border), 'TRIANGLES'];
56637
+ return [(0,_geometries_arc__WEBPACK_IMPORTED_MODULE_17__.arcBorderToTris)(border), 'TRIANGLES'];
56370
56638
  };
56371
56639
  // element.custom.getLine = (o: OBJ_PolyLineTris) => this.getPolylineTris(o);
56372
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56640
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56373
56641
  return element;
56374
56642
  }
56375
56643
 
@@ -56391,7 +56659,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56391
56659
  top: 'center',
56392
56660
  direction: 1,
56393
56661
  rotation: 0
56394
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56662
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56395
56663
  element.custom.getBorder = function (o) {
56396
56664
  if (o.xAlign == null) {
56397
56665
  if (o.points != null) {
@@ -56418,8 +56686,8 @@ var FigurePrimitives = /*#__PURE__*/function () {
56418
56686
  // } else {
56419
56687
  // element.custom.bufferOffset = 'negative';
56420
56688
  // }
56421
- var border = (0,_geometries_triangle__WEBPACK_IMPORTED_MODULE_17__.getTriangleBorder)(o);
56422
- if (o.direction === -1 || (0,_geometries_triangle__WEBPACK_IMPORTED_MODULE_17__.getTriangleDirection)(border) === -1) {
56689
+ var border = (0,_geometries_triangle__WEBPACK_IMPORTED_MODULE_18__.getTriangleBorder)(o);
56690
+ if (o.direction === -1 || (0,_geometries_triangle__WEBPACK_IMPORTED_MODULE_18__.getTriangleDirection)(border) === -1) {
56423
56691
  border.reverse();
56424
56692
  }
56425
56693
  return [o, border];
@@ -56431,7 +56699,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56431
56699
  element.custom.getFill = function (border) {
56432
56700
  return [border, 'TRIANGLES'];
56433
56701
  };
56434
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56702
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56435
56703
  return element;
56436
56704
  }
56437
56705
 
@@ -56456,7 +56724,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56456
56724
  tail: false,
56457
56725
  drawPosition: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0)
56458
56726
  // barb: this.defaultLength / 8,
56459
- }, _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56727
+ }, _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56460
56728
  element.custom.getBorder = function (o) {
56461
56729
  if (o.line != null && o.line.widthIs === 'inside') {
56462
56730
  o.line.widthIs = 'positive';
@@ -56464,17 +56732,17 @@ var FigurePrimitives = /*#__PURE__*/function () {
56464
56732
  if (o.line != null && o.line.widthIs === 'outside') {
56465
56733
  o.line.widthIs = 'negative';
56466
56734
  }
56467
- var optionsWithDefaultArrow = (0,_geometries_arrow__WEBPACK_IMPORTED_MODULE_18__.defaultArrowOptions)(o);
56468
- var _getArrow = (0,_geometries_arrow__WEBPACK_IMPORTED_MODULE_18__.getArrow)(optionsWithDefaultArrow),
56735
+ var optionsWithDefaultArrow = (0,_geometries_arrow__WEBPACK_IMPORTED_MODULE_19__.defaultArrowOptions)(o);
56736
+ var _getArrow = (0,_geometries_arrow__WEBPACK_IMPORTED_MODULE_19__.getArrow)(optionsWithDefaultArrow),
56469
56737
  _getArrow2 = _slicedToArray(_getArrow, 2),
56470
56738
  border = _getArrow2[0],
56471
56739
  borderBuffer = _getArrow2[1];
56472
56740
  return [optionsWithDefaultArrow, border, borderBuffer];
56473
56741
  };
56474
56742
  element.custom.getFill = function (border, o) {
56475
- return [(0,_geometries_arrow__WEBPACK_IMPORTED_MODULE_18__.getArrowTris)(border, o), 'TRIANGLES'];
56743
+ return [(0,_geometries_arrow__WEBPACK_IMPORTED_MODULE_19__.getArrowTris)(border, o), 'TRIANGLES'];
56476
56744
  };
56477
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options)));
56745
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options)));
56478
56746
  return element;
56479
56747
  }
56480
56748
 
@@ -56503,7 +56771,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56503
56771
  }
56504
56772
  };
56505
56773
  var getTris = function getTris(points) {
56506
- return (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_12__.makePolyLine)(points, element.custom.options.line.width, false, 'mid', 'auto',
56774
+ return (0,_geometries_lines_lines__WEBPACK_IMPORTED_MODULE_13__.makePolyLine)(points, element.custom.options.line.width, false, 'mid', 'auto',
56507
56775
  // cornerStyle doesn't matter
56508
56776
  0.1,
56509
56777
  // cornerSize doesn't matter
@@ -56514,7 +56782,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56514
56782
  element.custom.options.line.dash, element.custom.options.line.linePrimitives, element.custom.options.line.lineNum, [[]], 0);
56515
56783
  };
56516
56784
  element.custom.updatePoints = function (updateOptions) {
56517
- var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, element.custom.options, updateOptions);
56785
+ var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, element.custom.options, updateOptions);
56518
56786
  element.custom.options = o;
56519
56787
  // Prioritize Num over Step. Only define Num from Step if Num is undefined.
56520
56788
  var bounds = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getRect)(o.bounds);
@@ -56567,7 +56835,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56567
56835
  var _getTris = getTris([yLineStart, yLineStop]),
56568
56836
  _getTris2 = _slicedToArray(_getTris, 1),
56569
56837
  yLine = _getTris2[0];
56570
- yTris = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_20__.copyPoints)(yLine, [{
56838
+ yTris = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_21__.copyPoints)(yLine, [{
56571
56839
  along: 'x',
56572
56840
  num: xNum - 1,
56573
56841
  step: xStep
@@ -56577,7 +56845,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56577
56845
  var _getTris3 = getTris([xLineStart, xLineStop]),
56578
56846
  _getTris4 = _slicedToArray(_getTris3, 1),
56579
56847
  xLine = _getTris4[0];
56580
- xTris = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_20__.copyPoints)(xLine, [{
56848
+ xTris = (0,_geometries_copy_copy__WEBPACK_IMPORTED_MODULE_21__.copyPoints)(xLine, [{
56581
56849
  along: 'y',
56582
56850
  num: yNum - 1,
56583
56851
  step: yStep
@@ -56598,14 +56866,14 @@ var FigurePrimitives = /*#__PURE__*/function () {
56598
56866
  drawBorderBuffer = [[border[0].add(-buf, -buf), border[1].add(buf, -buf), border[2].add(buf, buf), border[3].add(-buf, buf)]];
56599
56867
  }
56600
56868
  }
56601
- element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
56869
+ element.custom.updateGeneric((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
56602
56870
  points: [].concat(_toConsumableArray(xTris), _toConsumableArray(yTris)),
56603
56871
  drawBorder: drawBorder,
56604
56872
  drawBorderBuffer: drawBorderBuffer,
56605
56873
  drawType: o.line.linePrimitives ? 'LINES' : 'TRIANGLES'
56606
56874
  }));
56607
56875
  };
56608
- element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(optionsIn)));
56876
+ element.custom.updatePoints(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(optionsIn)));
56609
56877
  return element;
56610
56878
  }
56611
56879
 
@@ -56619,15 +56887,15 @@ var FigurePrimitives = /*#__PURE__*/function () {
56619
56887
  for (var _len29 = arguments.length, options = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
56620
56888
  options[_key29] = arguments[_key29];
56621
56889
  }
56622
- var element = this.polyline(_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}, {
56890
+ var element = this.polyline(_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}, {
56623
56891
  transform: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Transform().scale(1).rotate(0).translate()
56624
56892
  }].concat(options, [{
56625
56893
  points: [[0, 0], [0, 1]],
56626
56894
  dash: [],
56627
56895
  arrow: null
56628
56896
  }])));
56629
- var joinedOptions = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}].concat(options));
56630
- element.custom.options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, element.custom.options, {
56897
+ var joinedOptions = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}].concat(options));
56898
+ element.custom.options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, element.custom.options, {
56631
56899
  p1: [0, 0],
56632
56900
  angle: 0,
56633
56901
  length: this.defaultLength,
@@ -56665,14 +56933,14 @@ var FigurePrimitives = /*#__PURE__*/function () {
56665
56933
 
56666
56934
  element.custom.updatePolyline = element.custom.updatePoints;
56667
56935
  element.custom.updatePoints = function (updateOptions) {
56668
- var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, element.custom.options, updateOptions);
56669
- var _getLine = (0,_geometries_line__WEBPACK_IMPORTED_MODULE_19__["default"])(o),
56936
+ var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, element.custom.options, updateOptions);
56937
+ var _getLine = (0,_geometries_line__WEBPACK_IMPORTED_MODULE_20__["default"])(o),
56670
56938
  _getLine2 = _slicedToArray(_getLine, 3),
56671
56939
  updatedPoints = _getLine2[0],
56672
56940
  updatedBorder = _getLine2[1],
56673
56941
  updatedTouchBorder = _getLine2[2];
56674
56942
  // element.custom.setupLine(updatedPoints, o);
56675
- element.custom.updatePolyline((0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, o, {
56943
+ element.custom.updatePolyline((0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, o, {
56676
56944
  points: updatedPoints,
56677
56945
  border: updatedBorder,
56678
56946
  touchBorder: updatedTouchBorder
@@ -56700,7 +56968,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56700
56968
  }, {
56701
56969
  key: "textGL",
56702
56970
  value: function textGL(options) {
56703
- return (0,_Text__WEBPACK_IMPORTED_MODULE_10__["default"])(this.webgl[0], options);
56971
+ return (0,_Text__WEBPACK_IMPORTED_MODULE_11__["default"])(this.webgl[0], options);
56704
56972
  }
56705
56973
 
56706
56974
  /*
@@ -56734,7 +57002,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56734
57002
  for (var _len30 = arguments.length, optionsIn = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
56735
57003
  optionsIn[_key30] = arguments[_key30];
56736
57004
  }
56737
- var options = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
57005
+ var options = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
56738
57006
  for (var i = 0; i < optionsIn.length; i += 1) {
56739
57007
  if (optionsIn[i].font != null) {
56740
57008
  if (optionsIn[i].font.src) {
@@ -56955,7 +57223,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56955
57223
  wrap: true,
56956
57224
  id: "id__temp_".concat(Math.round(Math.random() * 10000))
56957
57225
  };
56958
- var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects)({}, defaultOptions, optionsIn);
57226
+ var options = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects)({}, defaultOptions, optionsIn);
56959
57227
  options.element = optionsIn.element;
56960
57228
  var element;
56961
57229
  var parent;
@@ -56984,7 +57252,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
56984
57252
  if (parent == null) {
56985
57253
  parent = this.htmlCanvas;
56986
57254
  }
56987
- var hT = new _DrawingObjects_HTMLObject_HTMLObject__WEBPACK_IMPORTED_MODULE_11__["default"](parent, options.id, new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0), options.yAlign, options.xAlign, options.element);
57255
+ var hT = new _DrawingObjects_HTMLObject_HTMLObject__WEBPACK_IMPORTED_MODULE_12__["default"](parent, options.id, new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0), options.yAlign, options.xAlign, options.element);
56988
57256
  var p = (0,_tools_g2__WEBPACK_IMPORTED_MODULE_0__.getPoint)(options.position);
56989
57257
  var figureElement = new _Element__WEBPACK_IMPORTED_MODULE_2__.FigureElementPrimitive(hT, new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Transform().scale(1, 1).translate(p.x, p.y), [1, 1, 1, 1]);
56990
57258
  figureElement.timeKeeper = this.timeKeeper;
@@ -57016,7 +57284,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
57016
57284
  element.style.position = 'absolute';
57017
57285
  element.setAttribute('id', id);
57018
57286
  this.htmlCanvas.appendChild(element);
57019
- var hT = new _DrawingObjects_HTMLObject_HTMLObject__WEBPACK_IMPORTED_MODULE_11__["default"](this.htmlCanvas, id, new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0), yAlign, xAlign, elementToAdd);
57287
+ var hT = new _DrawingObjects_HTMLObject_HTMLObject__WEBPACK_IMPORTED_MODULE_12__["default"](this.htmlCanvas, id, new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0), yAlign, xAlign, elementToAdd);
57020
57288
  var figureElement = new _Element__WEBPACK_IMPORTED_MODULE_2__.FigureElementPrimitive(hT, new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Transform().scale(1, 1).translate(location.x, location.y), [1, 1, 1, 1]);
57021
57289
  figureElement.timeKeeper = this.timeKeeper;
57022
57290
  figureElement.recorder = this.recorder;
@@ -57026,7 +57294,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
57026
57294
  key: "htmlImage",
57027
57295
  value: function htmlImage() {
57028
57296
  var defaultOptions = {
57029
- id: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.generateUniqueId)('id__html_image_'),
57297
+ id: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.generateUniqueId)('id__html_image_'),
57030
57298
  classes: '',
57031
57299
  position: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0),
57032
57300
  yAlign: 'middle',
@@ -57036,7 +57304,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
57036
57304
  for (var _len31 = arguments.length, optionsIn = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
57037
57305
  optionsIn[_key31] = arguments[_key31];
57038
57306
  }
57039
- var options = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
57307
+ var options = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
57040
57308
  var image = document.createElement('img');
57041
57309
  image.src = options.src;
57042
57310
  var id = options.id,
@@ -57056,7 +57324,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
57056
57324
  value: function htmlText() {
57057
57325
  var defaultOptions = {
57058
57326
  text: '',
57059
- id: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_4__.generateUniqueId)('id__html_text_'),
57327
+ id: (0,_tools_tools__WEBPACK_IMPORTED_MODULE_5__.generateUniqueId)('id__html_text_'),
57060
57328
  classes: '',
57061
57329
  position: new _tools_g2__WEBPACK_IMPORTED_MODULE_0__.Point(0, 0),
57062
57330
  yAlign: 'middle',
@@ -57066,7 +57334,7 @@ var FigurePrimitives = /*#__PURE__*/function () {
57066
57334
  for (var _len32 = arguments.length, optionsIn = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
57067
57335
  optionsIn[_key32] = arguments[_key32];
57068
57336
  }
57069
- var options = _tools_tools__WEBPACK_IMPORTED_MODULE_4__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
57337
+ var options = _tools_tools__WEBPACK_IMPORTED_MODULE_5__.joinObjects.apply(void 0, [{}, defaultOptions].concat(optionsIn));
57070
57338
  var inside = document.createElement('div');
57071
57339
  (0,_tools_htmlGenerator__WEBPACK_IMPORTED_MODULE_1__.setHTML)(inside, options.text, options.modifiers);
57072
57340
  var id = options.id,
@@ -66072,6 +66340,7 @@ var Atlas = /*#__PURE__*/function () {
66072
66340
 
66073
66341
  __webpack_require__.r(__webpack_exports__);
66074
66342
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
66343
+ /* harmony export */ CHANNELS_PER_MASK: () => (/* binding */ CHANNELS_PER_MASK),
66075
66344
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
66076
66345
  /* harmony export */ });
66077
66346
  /* harmony import */ var _tools_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../tools/tools */ "./src/js/tools/tools.ts");
@@ -66088,6 +66357,14 @@ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(
66088
66357
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
66089
66358
 
66090
66359
 
66360
+ /**
66361
+ * Number of recolorable regions a single mask texture provides in the
66362
+ * `textureMap` color mode - one per channel (r, g, b, a). N masks therefore
66363
+ * define `CHANNELS_PER_MASK * N` tints.
66364
+ * @group Shaders
66365
+ */
66366
+ var CHANNELS_PER_MASK = 4;
66367
+
66091
66368
  /**
66092
66369
  * Options used to compose vertex shader source code.
66093
66370
  *
@@ -66143,7 +66420,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
66143
66420
  * to fragment shader used when `light = 'point'`
66144
66421
  *
66145
66422
  * @property {2 | 3} [dimension] (`2`)
66146
- * @property {'vertex' | 'uniform' | 'texture'} [color] (`uniform`)
66423
+ * @property {'vertex' | 'uniform' | 'texture' | 'textureMap'} [color] (`uniform`)
66147
66424
  * @property {'point' | 'directional' | null} [light] (`null`)
66148
66425
  * @interface
66149
66426
  * @group Shaders
@@ -66176,7 +66453,16 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
66176
66453
  * - `vec4 u_color`: global color for all vertices used all times. When
66177
66454
  * `color = 'texture'` or `color = 'vertex'`, only the alpha channel of
66178
66455
  * `u_color` is used.
66179
- * - `sampler2D u_texture`: texture used when `color = 'texture'`.
66456
+ * - `sampler2D u_texture`: texture used when `color = 'texture'`,
66457
+ * `color = 'textureAlpha'` or `color = 'textureMap'`.
66458
+ * - `sampler2D u_mask0`, `u_mask1`, ...: mask textures used when
66459
+ * `color = 'textureMap'` (one per mask, set by the `masks` count). Each mask's
66460
+ * `r`, `g`, `b` and `a` channels select four regions of `u_texture` to
66461
+ * recolor. Mask `m`'s four channels map to tints `u_tint{4m+0..3}`.
66462
+ * - `vec4 u_tint0`, `u_tint1`, ...: region tint colors used when
66463
+ * `color = 'textureMap'` (four per mask). The `rgb` channels are the tint
66464
+ * color and the `a` channel is the tint strength (`0` leaves the base texture
66465
+ * unchanged).
66180
66466
  * - `vec3 u_directionalLight`: world space position of directional light
66181
66467
  * source used when `light = 'directional'`
66182
66468
  * - `float u_ambientLight`: ambient light used when `light = 'directional'` or
@@ -66196,7 +66482,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
66196
66482
  * from vertex shader used when `light = 'point'`
66197
66483
  *
66198
66484
  * @property {2 | 3} [dimension] (`2`)
66199
- * @property {'vertex' | 'uniform' | 'texture'} [color] (`uniform`)
66485
+ * @property {'vertex' | 'uniform' | 'texture' | 'textureMap'} [color] (`uniform`)
66200
66486
  * @property {'point' | 'directional' | null} [light] (`null`)
66201
66487
  * @interface
66202
66488
  * @group Shaders
@@ -66235,7 +66521,7 @@ function composeVertexShader() {
66235
66521
  src += 'attribute vec4 a_vertex;\n';
66236
66522
  vars.push('a_vertex');
66237
66523
  }
66238
- if (color === 'texture') {
66524
+ if (color === 'texture' || color === 'textureMap') {
66239
66525
  src += 'attribute vec2 a_texcoord;\n';
66240
66526
  src += 'varying vec2 v_texcoord;\n';
66241
66527
  vars.push('a_texcoord');
@@ -66270,7 +66556,7 @@ function composeVertexShader() {
66270
66556
  } else {
66271
66557
  src += ' gl_Position = u_worldViewProjectionMatrix * a_vertex;\n';
66272
66558
  }
66273
- if (color === 'texture') {
66559
+ if (color === 'texture' || color === 'textureMap') {
66274
66560
  src += ' v_texcoord = a_texcoord;\n';
66275
66561
  } else if (color === 'vertex') {
66276
66562
  src += ' v_color = a_color;\n';
@@ -66289,11 +66575,18 @@ function composeFragShader() {
66289
66575
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66290
66576
  var defaultOptions = {
66291
66577
  color: 'uniform',
66292
- light: null
66578
+ light: null,
66579
+ masks: 1
66293
66580
  };
66294
66581
  var _joinObjects2 = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_0__.joinObjects)(defaultOptions, options),
66295
66582
  light = _joinObjects2.light,
66296
- color = _joinObjects2.color;
66583
+ color = _joinObjects2.color,
66584
+ masks = _joinObjects2.masks;
66585
+ // textureMap recolors the base texture using one or more mask textures. Each
66586
+ // mask contributes CHANNELS_PER_MASK regions (its r, g, b, a channels), so
66587
+ // numMasks masks define CHANNELS_PER_MASK * numMasks tints.
66588
+ var numMasks = color === 'textureMap' ? Math.max(1, masks) : 0;
66589
+ var channels = ['r', 'g', 'b', 'a'];
66297
66590
  var src = '\nprecision mediump float;\n';
66298
66591
  src += 'uniform vec4 u_color;\n';
66299
66592
  var vars = ['u_color'];
@@ -66304,6 +66597,18 @@ function composeFragShader() {
66304
66597
  src += 'uniform sampler2D u_texture;\n';
66305
66598
  src += 'varying vec2 v_texcoord;\n';
66306
66599
  vars.push('u_texture');
66600
+ } else if (color === 'textureMap') {
66601
+ src += 'uniform sampler2D u_texture;\n';
66602
+ vars.push('u_texture');
66603
+ for (var m = 0; m < numMasks; m += 1) {
66604
+ src += "uniform sampler2D u_mask".concat(m, ";\n");
66605
+ vars.push("u_mask".concat(m));
66606
+ }
66607
+ for (var t = 0; t < numMasks * CHANNELS_PER_MASK; t += 1) {
66608
+ src += "uniform vec4 u_tint".concat(t, ";\n");
66609
+ vars.push("u_tint".concat(t));
66610
+ }
66611
+ src += 'varying vec2 v_texcoord;\n';
66307
66612
  }
66308
66613
  if (light === 'directional') {
66309
66614
  src += 'varying vec3 v_normal;\n';
@@ -66338,6 +66643,23 @@ function composeFragShader() {
66338
66643
  // src += ' gl_FragColor.rgb *= gl_FragColor.a * texture2D(u_texture, v_texcoord).a;\n';
66339
66644
  // src += ' gl_FragColor = texture2D(u_texture, v_texcoord).a * u_color;\n';
66340
66645
  src += ' gl_FragColor.rgb *= gl_FragColor.a;\n';
66646
+ } else if (color === 'textureMap') {
66647
+ // Base texture color, with each mask texture retinting up to four regions.
66648
+ // Each mask channel (r, g, b, a) selects a region, and the matching u_tint's
66649
+ // alpha controls how strongly that region is recolored (0 = leave the base
66650
+ // color unchanged). With one mask this is exactly four mixes and one extra
66651
+ // texture fetch; each additional mask adds one fetch and four mixes.
66652
+ src += ' vec4 base = texture2D(u_texture, v_texcoord);\n';
66653
+ src += ' vec3 col = base.rgb;\n';
66654
+ for (var _m = 0; _m < numMasks; _m += 1) {
66655
+ src += " vec4 mask".concat(_m, " = texture2D(u_mask").concat(_m, ", v_texcoord);\n");
66656
+ for (var c = 0; c < CHANNELS_PER_MASK; c += 1) {
66657
+ var _t = _m * CHANNELS_PER_MASK + c;
66658
+ src += " col = mix(col, u_tint".concat(_t, ".rgb, mask").concat(_m, ".").concat(channels[c], " * u_tint").concat(_t, ".a);\n");
66659
+ }
66660
+ }
66661
+ src += ' gl_FragColor = vec4(col, base.a * u_color.a);\n';
66662
+ src += ' gl_FragColor.rgb *= gl_FragColor.a;\n';
66341
66663
  }
66342
66664
 
66343
66665
  // src += ' gl_FragColor.rgb *= gl_FragColor.a;\n';
@@ -66912,6 +67234,20 @@ var WebGLInstance = /*#__PURE__*/function () {
66912
67234
  value:
66913
67235
  // locations: Object;
66914
67236
 
67237
+ // Content texture units are a small shared pool reused across draws. Unit 0 is
67238
+ // reserved for the target/selector framebuffer texture, so content starts at
67239
+ // unit 1. boundUnits[u] tracks which texture id is currently bound to GL unit
67240
+ // u, so bindTextureToUnit can skip redundant binds (bind-on-change).
67241
+
67242
+ // Monotonic source for texture handles (never reused, so deleting a texture
67243
+ // can never cause a later texture to collide with a live one).
67244
+
67245
+ // gl.MAX_TEXTURE_IMAGE_UNITS (the fragment-shader sampler limit), queried once
67246
+ // for a diagnostic warning. Matches the per-object mask guard in
67247
+ // FigurePrimitives.gl().
67248
+
67249
+ // Set once the unit-budget warning has fired, so it isn't logged every frame.
67250
+
66915
67251
  /*
66916
67252
  Add, or update a texture. If the texture already exists, then do nothing.
66917
67253
  A texture is referenced with a unique id, and defined by either a url (string), Image or html canvas element.
@@ -66927,45 +67263,52 @@ var WebGLInstance = /*#__PURE__*/function () {
66927
67263
  var onLoad = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
66928
67264
  var force = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
66929
67265
  /*
66930
- If the texture already exits, then return its index. If the texture is
66931
- still loading, then add the onLoad callback to the list of callbacks to
66932
- be called once the texture loads.
67266
+ A texture id can be shared by multiple owners (e.g. several GLText elements
67267
+ using the same font atlas, plus the Atlas itself). Each addTexture call
67268
+ that isn't a forced content update acquires one reference; deleteTexture
67269
+ releases one, and the GL texture is freed only when the last owner releases
67270
+ it. This lets one element's cleanup() drop its reference without pulling a
67271
+ still-shared texture out from under the survivors.
67272
+ If the texture already exists and is still loading, the onLoad callback is
67273
+ added to the list to be called once the texture loads.
66933
67274
  */
66934
67275
  if (!force && this.textures[id] != null) {
66935
- if (this.textures[id].state === 'loaded') {
66936
- if (onLoad != null) {
66937
- this.textures[id].onLoad.push(onLoad);
66938
- }
67276
+ // Another owner (or the same owner re-acquiring) references an existing
67277
+ // texture: take a reference and (re)register the load callback.
67278
+ var existingTexture = this.textures[id];
67279
+ existingTexture.refCount += 1;
67280
+ if (onLoad != null) {
67281
+ existingTexture.onLoad.push(onLoad);
67282
+ }
67283
+ if (existingTexture.state === 'loaded') {
66939
67284
  this.onLoad(id);
66940
- return this.textures[id].index;
66941
67285
  }
66942
- // Otherwise loading
67286
+ return existingTexture.handle;
67287
+ }
67288
+ var gl = this.gl;
67289
+ if (this.textures[id] != null) {
67290
+ // Forced content update of an existing texture: keep its identity AND
67291
+ // reference count so other owners survive the update. setTextureData
67292
+ // (below) frees and replaces the old glTexture, so the entry — including
67293
+ // its glTexture pointer — is preserved here rather than recreated.
67294
+ // Append (don't replace) onLoad so pending callbacks other owners
67295
+ // registered while the texture was still loading aren't silently dropped.
67296
+ this.textures[id].state = 'loading';
66943
67297
  if (onLoad != null) {
66944
67298
  this.textures[id].onLoad.push(onLoad);
66945
67299
  }
66946
- return this.textures[id].index;
66947
- // removed by dead control flow
66948
-
66949
- }
66950
- var index = 0;
66951
- if (this.textures[id] != null) {
66952
- index = this.textures[id].index;
66953
67300
  } else {
66954
- index = Object.keys(this.textures).length + 1;
67301
+ // Brand new texture: the first owner holds the only reference.
67302
+ this.textures[id] = {
67303
+ id: id,
67304
+ state: 'loading',
67305
+ onLoad: onLoad != null ? [onLoad] : [],
67306
+ handle: this.nextTextureHandle,
67307
+ refCount: 1
67308
+ };
67309
+ this.nextTextureHandle += 1;
66955
67310
  }
66956
- // If a texture already exists, then unload it
66957
- this.deleteTexture(id);
66958
- var gl = this.gl;
66959
- this.textures[id] = {
66960
- id: id,
66961
- state: 'loading',
66962
- onLoad: [],
66963
- index: index
66964
- };
66965
67311
  var texture = this.textures[id];
66966
- if (onLoad != null) {
66967
- texture.onLoad.push(onLoad);
66968
- }
66969
67312
  // If the data is a url string, then load the data into an image
66970
67313
  if (typeof data === 'string') {
66971
67314
  this.setTextureData(id, loadColor);
@@ -66984,7 +67327,7 @@ var WebGLInstance = /*#__PURE__*/function () {
66984
67327
  this.onLoad(id);
66985
67328
  texture.state = 'loaded';
66986
67329
  }
66987
- return this.textures[id].index;
67330
+ return this.textures[id].handle;
66988
67331
  }
66989
67332
  }, {
66990
67333
  key: "getAtlas",
@@ -67020,6 +67363,27 @@ var WebGLInstance = /*#__PURE__*/function () {
67020
67363
  throw errors[0];
67021
67364
  }
67022
67365
  }
67366
+
67367
+ // Take an additional reference to an already-registered texture, without
67368
+ // re-uploading it or touching its load callbacks. Used when an element adopts
67369
+ // a texture another owner created and uploaded (e.g. a GLText element sharing
67370
+ // a font atlas registered by the Atlas). Returns false if the texture isn't
67371
+ // registered yet, in which case no reference was taken. Release with
67372
+ // deleteTexture.
67373
+ }, {
67374
+ key: "acquireTexture",
67375
+ value: function acquireTexture(id) {
67376
+ var texture = this.textures[id];
67377
+ if (texture == null) {
67378
+ return false;
67379
+ }
67380
+ texture.refCount += 1;
67381
+ return true;
67382
+ }
67383
+
67384
+ // Release one reference to a texture. The GL texture is freed only once the
67385
+ // last owner releases it, so one element's cleanup can't delete a texture
67386
+ // another element still shares (see addTexture for the rationale).
67023
67387
  }, {
67024
67388
  key: "deleteTexture",
67025
67389
  value: function deleteTexture(id) {
@@ -67027,13 +67391,27 @@ var WebGLInstance = /*#__PURE__*/function () {
67027
67391
  if (texture == null) {
67028
67392
  return;
67029
67393
  }
67030
- var gl = this.gl;
67394
+ texture.refCount -= 1;
67395
+ if (texture.refCount <= 0) {
67396
+ this.freeTexture(id);
67397
+ }
67398
+ }
67031
67399
 
67032
- // If texture exists, then delete it
67400
+ // Unconditionally free a texture regardless of reference count. Used for
67401
+ // teardown (cleanup), where every owner is going away at once.
67402
+ }, {
67403
+ key: "freeTexture",
67404
+ value: function freeTexture(id) {
67405
+ var texture = this.textures[id];
67406
+ if (texture == null) {
67407
+ return;
67408
+ }
67409
+ var gl = this.gl;
67410
+ // gl.deleteTexture unbinds it from any unit it was bound to, so we just drop
67411
+ // the stale cache entries.
67033
67412
  if (texture.glTexture != null) {
67034
- gl.activeTexture(gl.TEXTURE0 + texture.index);
67035
- gl.bindTexture(gl.TEXTURE_2D, null);
67036
67413
  gl.deleteTexture(texture.glTexture);
67414
+ this.clearBoundUnits(id);
67037
67415
  }
67038
67416
  this.cancel(id);
67039
67417
  delete this.textures[id];
@@ -67045,6 +67423,53 @@ var WebGLInstance = /*#__PURE__*/function () {
67045
67423
  Object.keys(this.textures).forEach(function (id) {
67046
67424
  _this3.textures[id].glTexture = null;
67047
67425
  });
67426
+ // The new context starts with nothing bound, so the bind cache is stale.
67427
+ this.boundUnits = [];
67428
+ }
67429
+
67430
+ // Drop any working-unit cache entries that point at this texture id, so a
67431
+ // future draw re-binds rather than trusting a stale/deleted glTexture.
67432
+ }, {
67433
+ key: "clearBoundUnits",
67434
+ value: function clearBoundUnits(id) {
67435
+ for (var u = 0; u < this.boundUnits.length; u += 1) {
67436
+ if (this.boundUnits[u] === id) {
67437
+ this.boundUnits[u] = null;
67438
+ }
67439
+ }
67440
+ }
67441
+
67442
+ /*
67443
+ Bind a registered texture to a content texture unit for the current draw.
67444
+ Content units are a small shared pool (unit 0 is reserved for the
67445
+ target/selector framebuffer texture). bindTexture is only issued when the
67446
+ unit is not already pointing at this texture, so runs of draws that share a
67447
+ texture (e.g. text sharing a font atlas) issue zero bind calls.
67448
+ */
67449
+ }, {
67450
+ key: "bindTextureToUnit",
67451
+ value: function bindTextureToUnit(id, unit) {
67452
+ var texture = this.textures[id];
67453
+ if (texture == null || texture.glTexture == null) {
67454
+ return false;
67455
+ }
67456
+ if (unit >= this.maxTextureUnits) {
67457
+ // Out of unit budget: warn once (not every frame) and don't issue an
67458
+ // out-of-range bind. The caller treats false as "not bound".
67459
+ if (!this.warnedUnitOverflow) {
67460
+ (0,_tools_tools__WEBPACK_IMPORTED_MODULE_2__.Console)("FigureOne WebGL warning: texture unit ".concat(unit, " exceeds this device's ") + "MAX_TEXTURE_IMAGE_UNITS (".concat(this.maxTextureUnits, "). Reduce the ") + 'number of simultaneous textures/masks.');
67461
+ this.warnedUnitOverflow = true;
67462
+ }
67463
+ return false;
67464
+ }
67465
+ if (this.boundUnits[unit] === id) {
67466
+ return true;
67467
+ }
67468
+ var gl = this.gl;
67469
+ gl.activeTexture(gl.TEXTURE0 + unit);
67470
+ gl.bindTexture(gl.TEXTURE_2D, texture.glTexture);
67471
+ this.boundUnits[unit] = id;
67472
+ return true;
67048
67473
  }
67049
67474
  }, {
67050
67475
  key: "cleanup",
@@ -67058,9 +67483,10 @@ var WebGLInstance = /*#__PURE__*/function () {
67058
67483
  }
67059
67484
  });
67060
67485
  this.programs = [];
67061
- // Delete all textures
67486
+ // Free all textures outright, ignoring reference counts — every owner is
67487
+ // going away in this teardown.
67062
67488
  Object.keys(this.textures).forEach(function (id) {
67063
- _this4.deleteTexture(id);
67489
+ _this4.freeTexture(id);
67064
67490
  });
67065
67491
  this.textures = {};
67066
67492
  // Clean up atlases
@@ -67081,20 +67507,27 @@ var WebGLInstance = /*#__PURE__*/function () {
67081
67507
  return (value & value - 1) === 0;
67082
67508
  }
67083
67509
  var texture = this.textures[id];
67084
- var index = texture.index;
67085
67510
  var gl = this.gl;
67511
+ // Upload happens on the first content unit as scratch. Any cache entry for
67512
+ // this id refers to the old glTexture we're about to replace, so invalidate
67513
+ // them all before binding the new one.
67514
+ var uploadUnit = 1;
67515
+ this.clearBoundUnits(id);
67086
67516
 
67087
67517
  // If texture exists, then delete it
67088
67518
  if (texture.glTexture != null) {
67089
- gl.activeTexture(gl.TEXTURE0 + index);
67519
+ gl.activeTexture(gl.TEXTURE0 + uploadUnit);
67090
67520
  gl.bindTexture(gl.TEXTURE_2D, null);
67091
67521
  gl.deleteTexture(texture.glTexture);
67092
67522
  }
67093
67523
  // Create a texture
67094
67524
  var glTexture = gl.createTexture();
67095
67525
  texture.glTexture = glTexture;
67096
- gl.activeTexture(gl.TEXTURE0 + index);
67526
+ gl.activeTexture(gl.TEXTURE0 + uploadUnit);
67097
67527
  gl.bindTexture(gl.TEXTURE_2D, glTexture);
67528
+ // The new glTexture is now bound to the upload unit; record it so a draw
67529
+ // that needs it on this unit can skip a redundant bind.
67530
+ this.boundUnits[uploadUnit] = id;
67098
67531
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
67099
67532
 
67100
67533
  // If image is a color, then create s ingle pixel image of that color
@@ -67158,7 +67591,7 @@ var WebGLInstance = /*#__PURE__*/function () {
67158
67591
  value: function onLoad(id) {
67159
67592
  var _this5 = this;
67160
67593
  this.textures[id].onLoad.forEach(function (f) {
67161
- return _this5.fnMap.exec(f, true, _this5.textures[id].index);
67594
+ return _this5.fnMap.exec(f, true, _this5.textures[id].handle);
67162
67595
  });
67163
67596
  this.textures[id].onLoad = [];
67164
67597
  }
@@ -67167,7 +67600,7 @@ var WebGLInstance = /*#__PURE__*/function () {
67167
67600
  value: function cancel(id) {
67168
67601
  var _this6 = this;
67169
67602
  this.textures[id].onLoad.forEach(function (f) {
67170
- return _this6.fnMap.exec(f, false, _this6.textures[id].index);
67603
+ return _this6.fnMap.exec(f, false, _this6.textures[id].handle);
67171
67604
  });
67172
67605
  this.textures[id].onLoad = [];
67173
67606
  }
@@ -67232,6 +67665,11 @@ var WebGLInstance = /*#__PURE__*/function () {
67232
67665
  value: function init(gl) {
67233
67666
  this.gl = gl;
67234
67667
  this.textures = {};
67668
+ this.boundUnits = [];
67669
+ this.nextTextureHandle = 1;
67670
+ this.warnedUnitOverflow = false;
67671
+ var maxUnits = gl.getParameter ? gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS) : 0;
67672
+ this.maxTextureUnits = maxUnits || 8;
67235
67673
  this.programs = [];
67236
67674
  this.targetTexture = null;
67237
67675
  this.lastUsedProgram = null;
@@ -81845,8 +82283,8 @@ var tools = {
81845
82283
  */
81846
82284
 
81847
82285
  var Fig = {
81848
- version: "1.7.1",
81849
- gitHash: "501b3a1fb",
82286
+ version: "1.9.0",
82287
+ gitHash: "2e042f98b",
81850
82288
  tools: tools,
81851
82289
  Figure: _js_figure_Figure__WEBPACK_IMPORTED_MODULE_5__["default"],
81852
82290
  Recorder: _js_figure_Recorder_Recorder__WEBPACK_IMPORTED_MODULE_7__.Recorder,